+
+
+#include "llimits.h"
+#include "lua.h"
+
+
+/*
+** Extra tags for non-values
+*/
+#define LUA_TPROTO LUA_NUMTAGS
+#define LUA_TUPVAL (LUA_NUMTAGS+1)
+#define LUA_TDEADKEY (LUA_NUMTAGS+2)
+
+/*
+** number of all possible tags (including LUA_TNONE but excluding DEADKEY)
+*/
+#define LUA_TOTALTAGS (LUA_TUPVAL+2)
+
+
+/*
+** tags for Tagged Values have the following use of bits:
+** bits 0-3: actual tag (a LUA_T* value)
+** bits 4-5: variant bits
+** bit 6: whether value is collectable
+*/
+
+#define VARBITS (3 << 4)
+
+
+/*
+** LUA_TFUNCTION variants:
+** 0 - Lua function
+** 1 - light C function
+** 2 - regular C function (closure)
+*/
+
+/* Variant tags for functions */
+#define LUA_TLCL (LUA_TFUNCTION | (0 << 4)) /* Lua closure */
+#define LUA_TLCF (LUA_TFUNCTION | (1 << 4)) /* light C function */
+#define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */
+
+
+/* Variant tags for strings */
+#define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */
+#define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */
+
+
+/* Bit mark for collectable types */
+#define BIT_ISCOLLECTABLE (1 << 6)
+
+/* mark a tag as collectable */
+#define ctb(t) ((t) | BIT_ISCOLLECTABLE)
+
+
+/*
+** Union of all collectable objects
+*/
+typedef union GCObject GCObject;
+
+
+/*
+** Common Header for all collectable objects (in macro form, to be
+** included in other objects)
+*/
+#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
+
+
+/*
+** Common header in struct form
+*/
+typedef struct GCheader {
+ CommonHeader;
+} GCheader;
+
+
+
+/*
+** Union of all Lua values
+*/
+typedef union Value Value;
+
+
+#define numfield lua_Number n; /* numbers */
+
+
+
+/*
+** Tagged Values. This is the basic representation of values in Lua,
+** an actual value plus a tag with its type.
+*/
+
+#define TValuefields Value value_; int tt_
+
+typedef struct lua_TValue TValue;
+
+
+/* macro defining a nil value */
+#define NILCONSTANT {NULL}, LUA_TNIL
+
+
+#define val_(o) ((o)->value_)
+#define num_(o) (val_(o).n)
+
+
+/* raw type tag of a TValue */
+#define rttype(o) ((o)->tt_)
+
+/* tag with no variants (bits 0-3) */
+#define novariant(x) ((x) & 0x0F)
+
+/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */
+#define ttype(o) (rttype(o) & 0x3F)
+
+/* type tag of a TValue with no variants (bits 0-3) */
+#define ttypenv(o) (novariant(rttype(o)))
+
+
+/* Macros to test type */
+#define checktag(o,t) (rttype(o) == (t))
+#define checktype(o,t) (ttypenv(o) == (t))
+#define ttisnumber(o) checktag((o), LUA_TNUMBER)
+#define ttisnil(o) checktag((o), LUA_TNIL)
+#define ttisboolean(o) checktag((o), LUA_TBOOLEAN)
+#define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA)
+#define ttisstring(o) checktype((o), LUA_TSTRING)
+#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR))
+#define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR))
+#define ttistable(o) checktag((o), ctb(LUA_TTABLE))
+#define ttisfunction(o) checktype(o, LUA_TFUNCTION)
+#define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION)
+#define ttisCclosure(o) checktag((o), ctb(LUA_TCCL))
+#define ttisLclosure(o) checktag((o), ctb(LUA_TLCL))
+#define ttislcf(o) checktag((o), LUA_TLCF)
+#define ttisuserdata(o) checktag((o), ctb(LUA_TUSERDATA))
+#define ttisthread(o) checktag((o), ctb(LUA_TTHREAD))
+#define ttisdeadkey(o) checktag((o), LUA_TDEADKEY)
+
+#define ttisequal(o1,o2) (rttype(o1) == rttype(o2))
+
+/* Macros to access values */
+#define nvalue(o) check_exp(ttisnumber(o), num_(o))
+#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc)
+#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p)
+#define rawtsvalue(o) check_exp(ttisstring(o), &val_(o).gc->ts)
+#define tsvalue(o) (&rawtsvalue(o)->tsv)
+#define rawuvalue(o) check_exp(ttisuserdata(o), &val_(o).gc->u)
+#define uvalue(o) (&rawuvalue(o)->uv)
+#define clvalue(o) check_exp(ttisclosure(o), &val_(o).gc->cl)
+#define clLvalue(o) check_exp(ttisLclosure(o), &val_(o).gc->cl.l)
+#define clCvalue(o) check_exp(ttisCclosure(o), &val_(o).gc->cl.c)
+#define fvalue(o) check_exp(ttislcf(o), val_(o).f)
+#define hvalue(o) check_exp(ttistable(o), &val_(o).gc->h)
+#define bvalue(o) check_exp(ttisboolean(o), val_(o).b)
+#define thvalue(o) check_exp(ttisthread(o), &val_(o).gc->th)
+/* a dead value may get the 'gc' field, but cannot access its contents */
+#define deadvalue(o) check_exp(ttisdeadkey(o), cast(void *, val_(o).gc))
+
+#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
+
+
+#define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE)
+
+
+/* Macros for internal tests */
+#define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt)
+
+#define checkliveness(g,obj) \
+ lua_longassert(!iscollectable(obj) || \
+ (righttt(obj) && !isdead(g,gcvalue(obj))))
+
+
+/* Macros to set values */
+#define settt_(o,t) ((o)->tt_=(t))
+
+#define setnvalue(obj,x) \
+ { TValue *io=(obj); num_(io)=(x); settt_(io, LUA_TNUMBER); }
+
+#define setnilvalue(obj) settt_(obj, LUA_TNIL)
+
+#define setfvalue(obj,x) \
+ { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); }
+
+#define setpvalue(obj,x) \
+ { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); }
+
+#define setbvalue(obj,x) \
+ { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); }
+
+#define setgcovalue(L,obj,x) \
+ { TValue *io=(obj); GCObject *i_g=(x); \
+ val_(io).gc=i_g; settt_(io, ctb(gch(i_g)->tt)); }
+
+#define setsvalue(L,obj,x) \
+ { TValue *io=(obj); \
+ TString *x_ = (x); \
+ val_(io).gc=cast(GCObject *, x_); settt_(io, ctb(x_->tsv.tt)); \
+ checkliveness(G(L),io); }
+
+#define setuvalue(L,obj,x) \
+ { TValue *io=(obj); \
+ val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TUSERDATA)); \
+ checkliveness(G(L),io); }
+
+#define setthvalue(L,obj,x) \
+ { TValue *io=(obj); \
+ val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTHREAD)); \
+ checkliveness(G(L),io); }
+
+#define setclLvalue(L,obj,x) \
+ { TValue *io=(obj); \
+ val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TLCL)); \
+ checkliveness(G(L),io); }
+
+#define setclCvalue(L,obj,x) \
+ { TValue *io=(obj); \
+ val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TCCL)); \
+ checkliveness(G(L),io); }
+
+#define sethvalue(L,obj,x) \
+ { TValue *io=(obj); \
+ val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTABLE)); \
+ checkliveness(G(L),io); }
+
+#define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY)
+
+
+
+#define setobj(L,obj1,obj2) \
+ { const TValue *io2=(obj2); TValue *io1=(obj1); \
+ io1->value_ = io2->value_; io1->tt_ = io2->tt_; \
+ checkliveness(G(L),io1); }
+
+
+/*
+** different types of assignments, according to destination
+*/
+
+/* from stack to (same) stack */
+#define setobjs2s setobj
+/* to stack (not from same stack) */
+#define setobj2s setobj
+#define setsvalue2s setsvalue
+#define sethvalue2s sethvalue
+#define setptvalue2s setptvalue
+/* from table to same table */
+#define setobjt2t setobj
+/* to table */
+#define setobj2t setobj
+/* to new object */
+#define setobj2n setobj
+#define setsvalue2n setsvalue
+
+
+/* check whether a number is valid (useful only for NaN trick) */
+#define luai_checknum(L,o,c) { /* empty */ }
+
+
+/*
+** {======================================================
+** NaN Trick
+** =======================================================
+*/
+#if defined(LUA_NANTRICK)
+
+/*
+** numbers are represented in the 'd_' field. All other values have the
+** value (NNMARK | tag) in 'tt__'. A number with such pattern would be
+** a "signaled NaN", which is never generated by regular operations by
+** the CPU (nor by 'strtod')
+*/
+
+/* allows for external implementation for part of the trick */
+#if !defined(NNMARK) /* { */
+
+
+#if !defined(LUA_IEEEENDIAN)
+#error option 'LUA_NANTRICK' needs 'LUA_IEEEENDIAN'
+#endif
+
+
+#define NNMARK 0x7FF7A500
+#define NNMASK 0x7FFFFF00
+
+#undef TValuefields
+#undef NILCONSTANT
+
+#if (LUA_IEEEENDIAN == 0) /* { */
+
+/* little endian */
+#define TValuefields \
+ union { struct { Value v__; int tt__; } i; double d__; } u
+#define NILCONSTANT {{{NULL}, tag2tt(LUA_TNIL)}}
+/* field-access macros */
+#define v_(o) ((o)->u.i.v__)
+#define d_(o) ((o)->u.d__)
+#define tt_(o) ((o)->u.i.tt__)
+
+#else /* }{ */
+
+/* big endian */
+#define TValuefields \
+ union { struct { int tt__; Value v__; } i; double d__; } u
+#define NILCONSTANT {{tag2tt(LUA_TNIL), {NULL}}}
+/* field-access macros */
+#define v_(o) ((o)->u.i.v__)
+#define d_(o) ((o)->u.d__)
+#define tt_(o) ((o)->u.i.tt__)
+
+#endif /* } */
+
+#endif /* } */
+
+
+/* correspondence with standard representation */
+#undef val_
+#define val_(o) v_(o)
+#undef num_
+#define num_(o) d_(o)
+
+
+#undef numfield
+#define numfield /* no such field; numbers are the entire struct */
+
+/* basic check to distinguish numbers from non-numbers */
+#undef ttisnumber
+#define ttisnumber(o) ((tt_(o) & NNMASK) != NNMARK)
+
+#define tag2tt(t) (NNMARK | (t))
+
+#undef rttype
+#define rttype(o) (ttisnumber(o) ? LUA_TNUMBER : tt_(o) & 0xff)
+
+#undef settt_
+#define settt_(o,t) (tt_(o) = tag2tt(t))
+
+#undef setnvalue
+#define setnvalue(obj,x) \
+ { TValue *io_=(obj); num_(io_)=(x); lua_assert(ttisnumber(io_)); }
+
+#undef setobj
+#define setobj(L,obj1,obj2) \
+ { const TValue *o2_=(obj2); TValue *o1_=(obj1); \
+ o1_->u = o2_->u; \
+ checkliveness(G(L),o1_); }
+
+
+/*
+** these redefinitions are not mandatory, but these forms are more efficient
+*/
+
+#undef checktag
+#undef checktype
+#define checktag(o,t) (tt_(o) == tag2tt(t))
+#define checktype(o,t) (ctb(tt_(o) | VARBITS) == ctb(tag2tt(t) | VARBITS))
+
+#undef ttisequal
+#define ttisequal(o1,o2) \
+ (ttisnumber(o1) ? ttisnumber(o2) : (tt_(o1) == tt_(o2)))
+
+
+#undef luai_checknum
+#define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; }
+
+#endif
+/* }====================================================== */
+
+
+
+/*
+** {======================================================
+** types and prototypes
+** =======================================================
+*/
+
+
+union Value {
+ GCObject *gc; /* collectable objects */
+ void *p; /* light userdata */
+ int b; /* booleans */
+ lua_CFunction f; /* light C functions */
+ numfield /* numbers */
+};
+
+
+struct lua_TValue {
+ TValuefields;
+};
+
+
+typedef TValue *StkId; /* index to stack elements */
+
+
+
+
+/*
+** Header for string value; string bytes follow the end of this structure
+*/
+typedef union TString {
+ L_Umaxalign dummy; /* ensures maximum alignment for strings */
+ struct {
+ CommonHeader;
+ lu_byte extra; /* reserved words for short strings; "has hash" for longs */
+ unsigned int hash;
+ size_t len; /* number of characters in string */
+ } tsv;
+} TString;
+
+
+/* get the actual string (array of bytes) from a TString */
+#define getstr(ts) cast(const char *, (ts) + 1)
+
+/* get the actual string (array of bytes) from a Lua value */
+#define svalue(o) getstr(rawtsvalue(o))
+
+
+/*
+** Header for userdata; memory area follows the end of this structure
+*/
+typedef union Udata {
+ L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
+ struct {
+ CommonHeader;
+ struct Table *metatable;
+ struct Table *env;
+ size_t len; /* number of bytes */
+ } uv;
+} Udata;
+
+
+
+/*
+** Description of an upvalue for function prototypes
+*/
+typedef struct Upvaldesc {
+ TString *name; /* upvalue name (for debug information) */
+ lu_byte instack; /* whether it is in stack */
+ lu_byte idx; /* index of upvalue (in stack or in outer function's list) */
+} Upvaldesc;
+
+
+/*
+** Description of a local variable for function prototypes
+** (used for debug information)
+*/
+typedef struct LocVar {
+ TString *varname;
+ int startpc; /* first point where variable is active */
+ int endpc; /* first point where variable is dead */
+} LocVar;
+
+
+/*
+** Function Prototypes
+*/
+typedef struct Proto {
+ CommonHeader;
+ TValue *k; /* constants used by the function */
+ Instruction *code;
+ struct Proto **p; /* functions defined inside the function */
+ int *lineinfo; /* map from opcodes to source lines (debug information) */
+ LocVar *locvars; /* information about local variables (debug information) */
+ Upvaldesc *upvalues; /* upvalue information */
+ union Closure *cache; /* last created closure with this prototype */
+ TString *source; /* used for debug information */
+ int sizeupvalues; /* size of 'upvalues' */
+ int sizek; /* size of `k' */
+ int sizecode;
+ int sizelineinfo;
+ int sizep; /* size of `p' */
+ int sizelocvars;
+ int linedefined;
+ int lastlinedefined;
+ GCObject *gclist;
+ lu_byte numparams; /* number of fixed parameters */
+ lu_byte is_vararg;
+ lu_byte maxstacksize; /* maximum stack used by this function */
+} Proto;
+
+
+
+/*
+** Lua Upvalues
+*/
+typedef struct UpVal {
+ CommonHeader;
+ TValue *v; /* points to stack or to its own value */
+ union {
+ TValue value; /* the value (when closed) */
+ struct { /* double linked list (when open) */
+ struct UpVal *prev;
+ struct UpVal *next;
+ } l;
+ } u;
+} UpVal;
+
+
+/*
+** Closures
+*/
+
+#define ClosureHeader \
+ CommonHeader; lu_byte nupvalues; GCObject *gclist
+
+typedef struct CClosure {
+ ClosureHeader;
+ lua_CFunction f;
+ TValue upvalue[1]; /* list of upvalues */
+} CClosure;
+
+
+typedef struct LClosure {
+ ClosureHeader;
+ struct Proto *p;
+ UpVal *upvals[1]; /* list of upvalues */
+} LClosure;
+
+
+typedef union Closure {
+ CClosure c;
+ LClosure l;
+} Closure;
+
+
+#define isLfunction(o) ttisLclosure(o)
+
+#define getproto(o) (clLvalue(o)->p)
+
+
+/*
+** Tables
+*/
+
+typedef union TKey {
+ struct {
+ TValuefields;
+ struct Node *next; /* for chaining */
+ } nk;
+ TValue tvk;
+} TKey;
+
+
+typedef struct Node {
+ TValue i_val;
+ TKey i_key;
+} Node;
+
+
+typedef struct Table {
+ CommonHeader;
+ lu_byte flags; /* 1<lsizenode))
+
+
+/*
+** (address of) a fixed nil value
+*/
+#define luaO_nilobject (&luaO_nilobject_)
+
+
+LUAI_DDEC const TValue luaO_nilobject_;
+
+
+LUAI_FUNC int luaO_int2fb (unsigned int x);
+LUAI_FUNC int luaO_fb2int (int x);
+LUAI_FUNC int luaO_ceillog2 (unsigned int x);
+LUAI_FUNC lua_Number luaO_arith (int op, lua_Number v1, lua_Number v2);
+LUAI_FUNC int luaO_str2d (const char *s, size_t len, lua_Number *result);
+LUAI_FUNC int luaO_hexavalue (int c);
+LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
+ va_list argp);
+LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
+LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
+
+
+#endif
+
diff --git a/ext/lua/include/lopcodes.h b/ext/lua/include/lopcodes.h
new file mode 100644
index 0000000000..51f5791545
--- /dev/null
+++ b/ext/lua/include/lopcodes.h
@@ -0,0 +1,288 @@
+/*
+** $Id: lopcodes.h,v 1.142.1.1 2013/04/12 18:48:47 roberto Exp $
+** Opcodes for Lua virtual machine
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lopcodes_h
+#define lopcodes_h
+
+#include "llimits.h"
+
+
+/*===========================================================================
+ We assume that instructions are unsigned numbers.
+ All instructions have an opcode in the first 6 bits.
+ Instructions can have the following fields:
+ `A' : 8 bits
+ `B' : 9 bits
+ `C' : 9 bits
+ 'Ax' : 26 bits ('A', 'B', and 'C' together)
+ `Bx' : 18 bits (`B' and `C' together)
+ `sBx' : signed Bx
+
+ A signed argument is represented in excess K; that is, the number
+ value is the unsigned value minus K. K is exactly the maximum value
+ for that argument (so that -max is represented by 0, and +max is
+ represented by 2*max), which is half the maximum for the corresponding
+ unsigned argument.
+===========================================================================*/
+
+
+enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */
+
+
+/*
+** size and position of opcode arguments.
+*/
+#define SIZE_C 9
+#define SIZE_B 9
+#define SIZE_Bx (SIZE_C + SIZE_B)
+#define SIZE_A 8
+#define SIZE_Ax (SIZE_C + SIZE_B + SIZE_A)
+
+#define SIZE_OP 6
+
+#define POS_OP 0
+#define POS_A (POS_OP + SIZE_OP)
+#define POS_C (POS_A + SIZE_A)
+#define POS_B (POS_C + SIZE_C)
+#define POS_Bx POS_C
+#define POS_Ax POS_A
+
+
+/*
+** limits for opcode arguments.
+** we use (signed) int to manipulate most arguments,
+** so they must fit in LUAI_BITSINT-1 bits (-1 for sign)
+*/
+#if SIZE_Bx < LUAI_BITSINT-1
+#define MAXARG_Bx ((1<>1) /* `sBx' is signed */
+#else
+#define MAXARG_Bx MAX_INT
+#define MAXARG_sBx MAX_INT
+#endif
+
+#if SIZE_Ax < LUAI_BITSINT-1
+#define MAXARG_Ax ((1<>POS_OP) & MASK1(SIZE_OP,0)))
+#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
+ ((cast(Instruction, o)<>pos) & MASK1(size,0)))
+#define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \
+ ((cast(Instruction, v)<= R(A) + 1 */
+OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
+OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
+OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
+
+OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
+OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
+
+OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
+OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
+OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */
+
+OP_FORLOOP,/* A sBx R(A)+=R(A+2);
+ if R(A) = R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
+OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */
+
+OP_TFORCALL,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); */
+OP_TFORLOOP,/* A sBx if R(A+1) ~= nil then { R(A)=R(A+1); pc += sBx }*/
+
+OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
+
+OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */
+
+OP_VARARG,/* A B R(A), R(A+1), ..., R(A+B-2) = vararg */
+
+OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
+} OpCode;
+
+
+#define NUM_OPCODES (cast(int, OP_EXTRAARG) + 1)
+
+
+
+/*===========================================================================
+ Notes:
+ (*) In OP_CALL, if (B == 0) then B = top. If (C == 0), then `top' is
+ set to last_result+1, so next open instruction (OP_CALL, OP_RETURN,
+ OP_SETLIST) may use `top'.
+
+ (*) In OP_VARARG, if (B == 0) then use actual number of varargs and
+ set top (like in OP_CALL with C == 0).
+
+ (*) In OP_RETURN, if (B == 0) then return up to `top'.
+
+ (*) In OP_SETLIST, if (B == 0) then B = `top'; if (C == 0) then next
+ 'instruction' is EXTRAARG(real C).
+
+ (*) In OP_LOADKX, the next 'instruction' is always EXTRAARG.
+
+ (*) For comparisons, A specifies what condition the test should accept
+ (true or false).
+
+ (*) All `skips' (pc++) assume that next instruction is a jump.
+
+===========================================================================*/
+
+
+/*
+** masks for instruction properties. The format is:
+** bits 0-1: op mode
+** bits 2-3: C arg mode
+** bits 4-5: B arg mode
+** bit 6: instruction set register A
+** bit 7: operator is a test (next instruction must be a jump)
+*/
+
+enum OpArgMask {
+ OpArgN, /* argument is not used */
+ OpArgU, /* argument is used */
+ OpArgR, /* argument is a register or a jump offset */
+ OpArgK /* argument is a constant or register/constant */
+};
+
+LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES];
+
+#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3))
+#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
+#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
+#define testAMode(m) (luaP_opmodes[m] & (1 << 6))
+#define testTMode(m) (luaP_opmodes[m] & (1 << 7))
+
+
+LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */
+
+
+/* number of list items to accumulate before a SETLIST instruction */
+#define LFIELDS_PER_FLUSH 50
+
+
+#endif
diff --git a/ext/lua/include/lparser.h b/ext/lua/include/lparser.h
new file mode 100644
index 0000000000..0346e3c41a
--- /dev/null
+++ b/ext/lua/include/lparser.h
@@ -0,0 +1,119 @@
+/*
+** $Id: lparser.h,v 1.70.1.1 2013/04/12 18:48:47 roberto Exp $
+** Lua Parser
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lparser_h
+#define lparser_h
+
+#include "llimits.h"
+#include "lobject.h"
+#include "lzio.h"
+
+
+/*
+** Expression descriptor
+*/
+
+typedef enum {
+ VVOID, /* no value */
+ VNIL,
+ VTRUE,
+ VFALSE,
+ VK, /* info = index of constant in `k' */
+ VKNUM, /* nval = numerical value */
+ VNONRELOC, /* info = result register */
+ VLOCAL, /* info = local register */
+ VUPVAL, /* info = index of upvalue in 'upvalues' */
+ VINDEXED, /* t = table register/upvalue; idx = index R/K */
+ VJMP, /* info = instruction pc */
+ VRELOCABLE, /* info = instruction pc */
+ VCALL, /* info = instruction pc */
+ VVARARG /* info = instruction pc */
+} expkind;
+
+
+#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED)
+#define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL)
+
+typedef struct expdesc {
+ expkind k;
+ union {
+ struct { /* for indexed variables (VINDEXED) */
+ short idx; /* index (R/K) */
+ lu_byte t; /* table (register or upvalue) */
+ lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */
+ } ind;
+ int info; /* for generic use */
+ lua_Number nval; /* for VKNUM */
+ } u;
+ int t; /* patch list of `exit when true' */
+ int f; /* patch list of `exit when false' */
+} expdesc;
+
+
+/* description of active local variable */
+typedef struct Vardesc {
+ short idx; /* variable index in stack */
+} Vardesc;
+
+
+/* description of pending goto statements and label statements */
+typedef struct Labeldesc {
+ TString *name; /* label identifier */
+ int pc; /* position in code */
+ int line; /* line where it appeared */
+ lu_byte nactvar; /* local level where it appears in current block */
+} Labeldesc;
+
+
+/* list of labels or gotos */
+typedef struct Labellist {
+ Labeldesc *arr; /* array */
+ int n; /* number of entries in use */
+ int size; /* array size */
+} Labellist;
+
+
+/* dynamic structures used by the parser */
+typedef struct Dyndata {
+ struct { /* list of active local variables */
+ Vardesc *arr;
+ int n;
+ int size;
+ } actvar;
+ Labellist gt; /* list of pending gotos */
+ Labellist label; /* list of active labels */
+} Dyndata;
+
+
+/* control of blocks */
+struct BlockCnt; /* defined in lparser.c */
+
+
+/* state needed to generate code for a given function */
+typedef struct FuncState {
+ Proto *f; /* current function header */
+ Table *h; /* table to find (and reuse) elements in `k' */
+ struct FuncState *prev; /* enclosing function */
+ struct LexState *ls; /* lexical state */
+ struct BlockCnt *bl; /* chain of current blocks */
+ int pc; /* next position to code (equivalent to `ncode') */
+ int lasttarget; /* 'label' of last 'jump label' */
+ int jpc; /* list of pending jumps to `pc' */
+ int nk; /* number of elements in `k' */
+ int np; /* number of elements in `p' */
+ int firstlocal; /* index of first local var (in Dyndata array) */
+ short nlocvars; /* number of elements in 'f->locvars' */
+ lu_byte nactvar; /* number of active local variables */
+ lu_byte nups; /* number of upvalues */
+ lu_byte freereg; /* first free register */
+} FuncState;
+
+
+LUAI_FUNC Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
+ Dyndata *dyd, const char *name, int firstchar);
+
+
+#endif
diff --git a/ext/lua/include/lstate.h b/ext/lua/include/lstate.h
new file mode 100644
index 0000000000..daffd9aacf
--- /dev/null
+++ b/ext/lua/include/lstate.h
@@ -0,0 +1,228 @@
+/*
+** $Id: lstate.h,v 2.82.1.1 2013/04/12 18:48:47 roberto Exp $
+** Global State
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lstate_h
+#define lstate_h
+
+#include "lua.h"
+
+#include "lobject.h"
+#include "ltm.h"
+#include "lzio.h"
+
+
+/*
+
+** Some notes about garbage-collected objects: All objects in Lua must
+** be kept somehow accessible until being freed.
+**
+** Lua keeps most objects linked in list g->allgc. The link uses field
+** 'next' of the CommonHeader.
+**
+** Strings are kept in several lists headed by the array g->strt.hash.
+**
+** Open upvalues are not subject to independent garbage collection. They
+** are collected together with their respective threads. Lua keeps a
+** double-linked list with all open upvalues (g->uvhead) so that it can
+** mark objects referred by them. (They are always gray, so they must
+** be remarked in the atomic step. Usually their contents would be marked
+** when traversing the respective threads, but the thread may already be
+** dead, while the upvalue is still accessible through closures.)
+**
+** Objects with finalizers are kept in the list g->finobj.
+**
+** The list g->tobefnz links all objects being finalized.
+
+*/
+
+
+struct lua_longjmp; /* defined in ldo.c */
+
+
+
+/* extra stack space to handle TM calls and some other extras */
+#define EXTRA_STACK 5
+
+
+#define BASIC_STACK_SIZE (2*LUA_MINSTACK)
+
+
+/* kinds of Garbage Collection */
+#define KGC_NORMAL 0
+#define KGC_EMERGENCY 1 /* gc was forced by an allocation failure */
+#define KGC_GEN 2 /* generational collection */
+
+
+typedef struct stringtable {
+ GCObject **hash;
+ lu_int32 nuse; /* number of elements */
+ int size;
+} stringtable;
+
+
+/*
+** information about a call
+*/
+typedef struct CallInfo {
+ StkId func; /* function index in the stack */
+ StkId top; /* top for this function */
+ struct CallInfo *previous, *next; /* dynamic call link */
+ short nresults; /* expected number of results from this function */
+ lu_byte callstatus;
+ ptrdiff_t extra;
+ union {
+ struct { /* only for Lua functions */
+ StkId base; /* base for this function */
+ const Instruction *savedpc;
+ } l;
+ struct { /* only for C functions */
+ int ctx; /* context info. in case of yields */
+ lua_CFunction k; /* continuation in case of yields */
+ ptrdiff_t old_errfunc;
+ lu_byte old_allowhook;
+ lu_byte status;
+ } c;
+ } u;
+} CallInfo;
+
+
+/*
+** Bits in CallInfo status
+*/
+#define CIST_LUA (1<<0) /* call is running a Lua function */
+#define CIST_HOOKED (1<<1) /* call is running a debug hook */
+#define CIST_REENTRY (1<<2) /* call is running on same invocation of
+ luaV_execute of previous call */
+#define CIST_YIELDED (1<<3) /* call reentered after suspension */
+#define CIST_YPCALL (1<<4) /* call is a yieldable protected call */
+#define CIST_STAT (1<<5) /* call has an error status (pcall) */
+#define CIST_TAIL (1<<6) /* call was tail called */
+#define CIST_HOOKYIELD (1<<7) /* last hook called yielded */
+
+
+#define isLua(ci) ((ci)->callstatus & CIST_LUA)
+
+
+/*
+** `global state', shared by all threads of this state
+*/
+typedef struct global_State {
+ lua_Alloc frealloc; /* function to reallocate memory */
+ void *ud; /* auxiliary data to `frealloc' */
+ lu_mem totalbytes; /* number of bytes currently allocated - GCdebt */
+ l_mem GCdebt; /* bytes allocated not yet compensated by the collector */
+ lu_mem GCmemtrav; /* memory traversed by the GC */
+ lu_mem GCestimate; /* an estimate of the non-garbage memory in use */
+ stringtable strt; /* hash table for strings */
+ TValue l_registry;
+ unsigned int seed; /* randomized seed for hashes */
+ lu_byte currentwhite;
+ lu_byte gcstate; /* state of garbage collector */
+ lu_byte gckind; /* kind of GC running */
+ lu_byte gcrunning; /* true if GC is running */
+ int sweepstrgc; /* position of sweep in `strt' */
+ GCObject *allgc; /* list of all collectable objects */
+ GCObject *finobj; /* list of collectable objects with finalizers */
+ GCObject **sweepgc; /* current position of sweep in list 'allgc' */
+ GCObject **sweepfin; /* current position of sweep in list 'finobj' */
+ GCObject *gray; /* list of gray objects */
+ GCObject *grayagain; /* list of objects to be traversed atomically */
+ GCObject *weak; /* list of tables with weak values */
+ GCObject *ephemeron; /* list of ephemeron tables (weak keys) */
+ GCObject *allweak; /* list of all-weak tables */
+ GCObject *tobefnz; /* list of userdata to be GC */
+ UpVal uvhead; /* head of double-linked list of all open upvalues */
+ Mbuffer buff; /* temporary buffer for string concatenation */
+ int gcpause; /* size of pause between successive GCs */
+ int gcmajorinc; /* pause between major collections (only in gen. mode) */
+ int gcstepmul; /* GC `granularity' */
+ lua_CFunction panic; /* to be called in unprotected errors */
+ struct lua_State *mainthread;
+ const lua_Number *version; /* pointer to version number */
+ TString *memerrmsg; /* memory-error message */
+ TString *tmname[TM_N]; /* array with tag-method names */
+ struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */
+} global_State;
+
+
+/*
+** `per thread' state
+*/
+struct lua_State {
+ CommonHeader;
+ lu_byte status;
+ StkId top; /* first free slot in the stack */
+ global_State *l_G;
+ CallInfo *ci; /* call info for current function */
+ const Instruction *oldpc; /* last pc traced */
+ StkId stack_last; /* last free slot in the stack */
+ StkId stack; /* stack base */
+ int stacksize;
+ unsigned short nny; /* number of non-yieldable calls in stack */
+ unsigned short nCcalls; /* number of nested C calls */
+ lu_byte hookmask;
+ lu_byte allowhook;
+ int basehookcount;
+ int hookcount;
+ lua_Hook hook;
+ GCObject *openupval; /* list of open upvalues in this stack */
+ GCObject *gclist;
+ struct lua_longjmp *errorJmp; /* current error recover point */
+ ptrdiff_t errfunc; /* current error handling function (stack index) */
+ CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
+};
+
+
+#define G(L) (L->l_G)
+
+
+/*
+** Union of all collectable objects
+*/
+union GCObject {
+ GCheader gch; /* common header */
+ union TString ts;
+ union Udata u;
+ union Closure cl;
+ struct Table h;
+ struct Proto p;
+ struct UpVal uv;
+ struct lua_State th; /* thread */
+};
+
+
+#define gch(o) (&(o)->gch)
+
+/* macros to convert a GCObject into a specific value */
+#define rawgco2ts(o) \
+ check_exp(novariant((o)->gch.tt) == LUA_TSTRING, &((o)->ts))
+#define gco2ts(o) (&rawgco2ts(o)->tsv)
+#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
+#define gco2u(o) (&rawgco2u(o)->uv)
+#define gco2lcl(o) check_exp((o)->gch.tt == LUA_TLCL, &((o)->cl.l))
+#define gco2ccl(o) check_exp((o)->gch.tt == LUA_TCCL, &((o)->cl.c))
+#define gco2cl(o) \
+ check_exp(novariant((o)->gch.tt) == LUA_TFUNCTION, &((o)->cl))
+#define gco2t(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
+#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
+#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
+#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
+
+/* macro to convert any Lua object into a GCObject */
+#define obj2gco(v) (cast(GCObject *, (v)))
+
+
+/* actual number of total bytes allocated */
+#define gettotalbytes(g) ((g)->totalbytes + (g)->GCdebt)
+
+LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt);
+LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
+LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L);
+LUAI_FUNC void luaE_freeCI (lua_State *L);
+
+
+#endif
+
diff --git a/ext/lua/include/lstring.h b/ext/lua/include/lstring.h
new file mode 100644
index 0000000000..260e7f169b
--- /dev/null
+++ b/ext/lua/include/lstring.h
@@ -0,0 +1,46 @@
+/*
+** $Id: lstring.h,v 1.49.1.1 2013/04/12 18:48:47 roberto Exp $
+** String table (keep all strings handled by Lua)
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lstring_h
+#define lstring_h
+
+#include "lgc.h"
+#include "lobject.h"
+#include "lstate.h"
+
+
+#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char))
+
+#define sizeudata(u) (sizeof(union Udata)+(u)->len)
+
+#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
+ (sizeof(s)/sizeof(char))-1))
+
+#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT)
+
+
+/*
+** test whether a string is a reserved word
+*/
+#define isreserved(s) ((s)->tsv.tt == LUA_TSHRSTR && (s)->tsv.extra > 0)
+
+
+/*
+** equality for short strings, which are always internalized
+*/
+#define eqshrstr(a,b) check_exp((a)->tsv.tt == LUA_TSHRSTR, (a) == (b))
+
+
+LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed);
+LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b);
+LUAI_FUNC int luaS_eqstr (TString *a, TString *b);
+LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
+LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
+LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
+LUAI_FUNC TString *luaS_new (lua_State *L, const char *str);
+
+
+#endif
diff --git a/ext/lua/include/ltable.h b/ext/lua/include/ltable.h
new file mode 100644
index 0000000000..d69449b2b8
--- /dev/null
+++ b/ext/lua/include/ltable.h
@@ -0,0 +1,45 @@
+/*
+** $Id: ltable.h,v 2.16.1.2 2013/08/30 15:49:41 roberto Exp $
+** Lua tables (hash)
+** See Copyright Notice in lua.h
+*/
+
+#ifndef ltable_h
+#define ltable_h
+
+#include "lobject.h"
+
+
+#define gnode(t,i) (&(t)->node[i])
+#define gkey(n) (&(n)->i_key.tvk)
+#define gval(n) (&(n)->i_val)
+#define gnext(n) ((n)->i_key.nk.next)
+
+#define invalidateTMcache(t) ((t)->flags = 0)
+
+/* returns the key, given the value of a table entry */
+#define keyfromval(v) \
+ (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val))))
+
+
+LUAI_FUNC const TValue *luaH_getint (Table *t, int key);
+LUAI_FUNC void luaH_setint (lua_State *L, Table *t, int key, TValue *value);
+LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
+LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
+LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key);
+LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
+LUAI_FUNC Table *luaH_new (lua_State *L);
+LUAI_FUNC void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize);
+LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize);
+LUAI_FUNC void luaH_free (lua_State *L, Table *t);
+LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
+LUAI_FUNC int luaH_getn (Table *t);
+
+
+#if defined(LUA_DEBUG)
+LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
+LUAI_FUNC int luaH_isdummy (Node *n);
+#endif
+
+
+#endif
diff --git a/ext/lua/include/ltm.h b/ext/lua/include/ltm.h
new file mode 100644
index 0000000000..7f89c841f9
--- /dev/null
+++ b/ext/lua/include/ltm.h
@@ -0,0 +1,57 @@
+/*
+** $Id: ltm.h,v 2.11.1.1 2013/04/12 18:48:47 roberto Exp $
+** Tag methods
+** See Copyright Notice in lua.h
+*/
+
+#ifndef ltm_h
+#define ltm_h
+
+
+#include "lobject.h"
+
+
+/*
+* WARNING: if you change the order of this enumeration,
+* grep "ORDER TM"
+*/
+typedef enum {
+ TM_INDEX,
+ TM_NEWINDEX,
+ TM_GC,
+ TM_MODE,
+ TM_LEN,
+ TM_EQ, /* last tag method with `fast' access */
+ TM_ADD,
+ TM_SUB,
+ TM_MUL,
+ TM_DIV,
+ TM_MOD,
+ TM_POW,
+ TM_UNM,
+ TM_LT,
+ TM_LE,
+ TM_CONCAT,
+ TM_CALL,
+ TM_N /* number of elements in the enum */
+} TMS;
+
+
+
+#define gfasttm(g,et,e) ((et) == NULL ? NULL : \
+ ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
+
+#define fasttm(l,et,e) gfasttm(G(l), et, e)
+
+#define ttypename(x) luaT_typenames_[(x) + 1]
+#define objtypename(x) ttypename(ttypenv(x))
+
+LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS];
+
+
+LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
+LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
+ TMS event);
+LUAI_FUNC void luaT_init (lua_State *L);
+
+#endif
diff --git a/ext/lua/include/lua.h b/ext/lua/include/lua.h
new file mode 100644
index 0000000000..149a2c37bc
--- /dev/null
+++ b/ext/lua/include/lua.h
@@ -0,0 +1,444 @@
+/*
+** $Id: lua.h,v 1.285.1.2 2013/11/11 12:09:16 roberto Exp $
+** Lua - A Scripting Language
+** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
+** See Copyright Notice at the end of this file
+*/
+
+
+#ifndef lua_h
+#define lua_h
+
+#include
+#include
+
+
+#include "luaconf.h"
+
+
+#define LUA_VERSION_MAJOR "5"
+#define LUA_VERSION_MINOR "2"
+#define LUA_VERSION_NUM 502
+#define LUA_VERSION_RELEASE "3"
+
+#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
+#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2013 Lua.org, PUC-Rio"
+#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
+
+
+/* mark for precompiled code ('Lua') */
+#define LUA_SIGNATURE "\033Lua"
+
+/* option for multiple returns in 'lua_pcall' and 'lua_call' */
+#define LUA_MULTRET (-1)
+
+
+/*
+** pseudo-indices
+*/
+#define LUA_REGISTRYINDEX LUAI_FIRSTPSEUDOIDX
+#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i))
+
+
+/* thread status */
+#define LUA_OK 0
+#define LUA_YIELD 1
+#define LUA_ERRRUN 2
+#define LUA_ERRSYNTAX 3
+#define LUA_ERRMEM 4
+#define LUA_ERRGCMM 5
+#define LUA_ERRERR 6
+
+
+typedef struct lua_State lua_State;
+
+typedef int (*lua_CFunction) (lua_State *L);
+
+
+/*
+** functions that read/write blocks when loading/dumping Lua chunks
+*/
+typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
+
+typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
+
+
+/*
+** prototype for memory-allocation functions
+*/
+typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
+
+
+/*
+** basic types
+*/
+#define LUA_TNONE (-1)
+
+#define LUA_TNIL 0
+#define LUA_TBOOLEAN 1
+#define LUA_TLIGHTUSERDATA 2
+#define LUA_TNUMBER 3
+#define LUA_TSTRING 4
+#define LUA_TTABLE 5
+#define LUA_TFUNCTION 6
+#define LUA_TUSERDATA 7
+#define LUA_TTHREAD 8
+
+#define LUA_NUMTAGS 9
+
+
+
+/* minimum Lua stack available to a C function */
+#define LUA_MINSTACK 20
+
+
+/* predefined values in the registry */
+#define LUA_RIDX_MAINTHREAD 1
+#define LUA_RIDX_GLOBALS 2
+#define LUA_RIDX_LAST LUA_RIDX_GLOBALS
+
+
+/* type of numbers in Lua */
+typedef LUA_NUMBER lua_Number;
+
+
+/* type for integer functions */
+typedef LUA_INTEGER lua_Integer;
+
+/* unsigned integer type */
+typedef LUA_UNSIGNED lua_Unsigned;
+
+
+
+/*
+** generic extra include file
+*/
+#if defined(LUA_USER_H)
+#include LUA_USER_H
+#endif
+
+
+/*
+** RCS ident string
+*/
+extern const char lua_ident[];
+
+
+/*
+** state manipulation
+*/
+LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
+LUA_API void (lua_close) (lua_State *L);
+LUA_API lua_State *(lua_newthread) (lua_State *L);
+
+LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
+
+
+LUA_API const lua_Number *(lua_version) (lua_State *L);
+
+
+/*
+** basic stack manipulation
+*/
+LUA_API int (lua_absindex) (lua_State *L, int idx);
+LUA_API int (lua_gettop) (lua_State *L);
+LUA_API void (lua_settop) (lua_State *L, int idx);
+LUA_API void (lua_pushvalue) (lua_State *L, int idx);
+LUA_API void (lua_remove) (lua_State *L, int idx);
+LUA_API void (lua_insert) (lua_State *L, int idx);
+LUA_API void (lua_replace) (lua_State *L, int idx);
+LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx);
+LUA_API int (lua_checkstack) (lua_State *L, int sz);
+
+LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
+
+
+/*
+** access functions (stack -> C)
+*/
+
+LUA_API int (lua_isnumber) (lua_State *L, int idx);
+LUA_API int (lua_isstring) (lua_State *L, int idx);
+LUA_API int (lua_iscfunction) (lua_State *L, int idx);
+LUA_API int (lua_isuserdata) (lua_State *L, int idx);
+LUA_API int (lua_type) (lua_State *L, int idx);
+LUA_API const char *(lua_typename) (lua_State *L, int tp);
+
+LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum);
+LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum);
+LUA_API lua_Unsigned (lua_tounsignedx) (lua_State *L, int idx, int *isnum);
+LUA_API int (lua_toboolean) (lua_State *L, int idx);
+LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
+LUA_API size_t (lua_rawlen) (lua_State *L, int idx);
+LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
+LUA_API void *(lua_touserdata) (lua_State *L, int idx);
+LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
+LUA_API const void *(lua_topointer) (lua_State *L, int idx);
+
+
+/*
+** Comparison and arithmetic functions
+*/
+
+#define LUA_OPADD 0 /* ORDER TM */
+#define LUA_OPSUB 1
+#define LUA_OPMUL 2
+#define LUA_OPDIV 3
+#define LUA_OPMOD 4
+#define LUA_OPPOW 5
+#define LUA_OPUNM 6
+
+LUA_API void (lua_arith) (lua_State *L, int op);
+
+#define LUA_OPEQ 0
+#define LUA_OPLT 1
+#define LUA_OPLE 2
+
+LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
+LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op);
+
+
+/*
+** push functions (C -> stack)
+*/
+LUA_API void (lua_pushnil) (lua_State *L);
+LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
+LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
+LUA_API void (lua_pushunsigned) (lua_State *L, lua_Unsigned n);
+LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
+LUA_API const char *(lua_pushstring) (lua_State *L, const char *s);
+LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
+ va_list argp);
+LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
+LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
+LUA_API void (lua_pushboolean) (lua_State *L, int b);
+LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
+LUA_API int (lua_pushthread) (lua_State *L);
+
+
+/*
+** get functions (Lua -> stack)
+*/
+LUA_API void (lua_getglobal) (lua_State *L, const char *var);
+LUA_API void (lua_gettable) (lua_State *L, int idx);
+LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k);
+LUA_API void (lua_rawget) (lua_State *L, int idx);
+LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n);
+LUA_API void (lua_rawgetp) (lua_State *L, int idx, const void *p);
+LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
+LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
+LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
+LUA_API void (lua_getuservalue) (lua_State *L, int idx);
+
+
+/*
+** set functions (stack -> Lua)
+*/
+LUA_API void (lua_setglobal) (lua_State *L, const char *var);
+LUA_API void (lua_settable) (lua_State *L, int idx);
+LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);
+LUA_API void (lua_rawset) (lua_State *L, int idx);
+LUA_API void (lua_rawseti) (lua_State *L, int idx, int n);
+LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p);
+LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
+LUA_API void (lua_setuservalue) (lua_State *L, int idx);
+
+
+/*
+** 'load' and 'call' functions (load and run Lua code)
+*/
+LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, int ctx,
+ lua_CFunction k);
+#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL)
+
+LUA_API int (lua_getctx) (lua_State *L, int *ctx);
+
+LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
+ int ctx, lua_CFunction k);
+#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL)
+
+LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
+ const char *chunkname,
+ const char *mode);
+
+LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
+
+
+/*
+** coroutine functions
+*/
+LUA_API int (lua_yieldk) (lua_State *L, int nresults, int ctx,
+ lua_CFunction k);
+#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL)
+LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg);
+LUA_API int (lua_status) (lua_State *L);
+
+/*
+** garbage-collection function and options
+*/
+
+#define LUA_GCSTOP 0
+#define LUA_GCRESTART 1
+#define LUA_GCCOLLECT 2
+#define LUA_GCCOUNT 3
+#define LUA_GCCOUNTB 4
+#define LUA_GCSTEP 5
+#define LUA_GCSETPAUSE 6
+#define LUA_GCSETSTEPMUL 7
+#define LUA_GCSETMAJORINC 8
+#define LUA_GCISRUNNING 9
+#define LUA_GCGEN 10
+#define LUA_GCINC 11
+
+LUA_API int (lua_gc) (lua_State *L, int what, int data);
+
+
+/*
+** miscellaneous functions
+*/
+
+LUA_API int (lua_error) (lua_State *L);
+
+LUA_API int (lua_next) (lua_State *L, int idx);
+
+LUA_API void (lua_concat) (lua_State *L, int n);
+LUA_API void (lua_len) (lua_State *L, int idx);
+
+LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
+LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
+
+
+
+/*
+** ===============================================================
+** some useful macros
+** ===============================================================
+*/
+
+#define lua_tonumber(L,i) lua_tonumberx(L,i,NULL)
+#define lua_tointeger(L,i) lua_tointegerx(L,i,NULL)
+#define lua_tounsigned(L,i) lua_tounsignedx(L,i,NULL)
+
+#define lua_pop(L,n) lua_settop(L, -(n)-1)
+
+#define lua_newtable(L) lua_createtable(L, 0, 0)
+
+#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
+
+#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
+
+#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
+#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
+#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
+#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
+#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
+#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
+#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
+#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
+
+#define lua_pushliteral(L, s) \
+ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
+
+#define lua_pushglobaltable(L) \
+ lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)
+
+#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
+
+
+
+/*
+** {======================================================================
+** Debug API
+** =======================================================================
+*/
+
+
+/*
+** Event codes
+*/
+#define LUA_HOOKCALL 0
+#define LUA_HOOKRET 1
+#define LUA_HOOKLINE 2
+#define LUA_HOOKCOUNT 3
+#define LUA_HOOKTAILCALL 4
+
+
+/*
+** Event masks
+*/
+#define LUA_MASKCALL (1 << LUA_HOOKCALL)
+#define LUA_MASKRET (1 << LUA_HOOKRET)
+#define LUA_MASKLINE (1 << LUA_HOOKLINE)
+#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
+
+typedef struct lua_Debug lua_Debug; /* activation record */
+
+
+/* Functions to be called by the debugger in specific events */
+typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
+
+
+LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar);
+LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar);
+LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n);
+LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n);
+
+LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n);
+LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1,
+ int fidx2, int n2);
+
+LUA_API int (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count);
+LUA_API lua_Hook (lua_gethook) (lua_State *L);
+LUA_API int (lua_gethookmask) (lua_State *L);
+LUA_API int (lua_gethookcount) (lua_State *L);
+
+
+struct lua_Debug {
+ int event;
+ const char *name; /* (n) */
+ const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */
+ const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */
+ const char *source; /* (S) */
+ int currentline; /* (l) */
+ int linedefined; /* (S) */
+ int lastlinedefined; /* (S) */
+ unsigned char nups; /* (u) number of upvalues */
+ unsigned char nparams;/* (u) number of parameters */
+ char isvararg; /* (u) */
+ char istailcall; /* (t) */
+ char short_src[LUA_IDSIZE]; /* (S) */
+ /* private part */
+ struct CallInfo *i_ci; /* active function */
+};
+
+/* }====================================================================== */
+
+
+/******************************************************************************
+* Copyright (C) 1994-2013 Lua.org, PUC-Rio.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to deal in the Software without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to
+* permit persons to whom the Software is furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+******************************************************************************/
+
+
+#endif
diff --git a/ext/lua/include/lua.hpp b/ext/lua/include/lua.hpp
new file mode 100644
index 0000000000..ec417f5946
--- /dev/null
+++ b/ext/lua/include/lua.hpp
@@ -0,0 +1,9 @@
+// lua.hpp
+// Lua header files for C++
+// <> not supplied automatically because Lua also compiles as C++
+
+extern "C" {
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+}
diff --git a/ext/lua/include/luaconf.h b/ext/lua/include/luaconf.h
new file mode 100644
index 0000000000..18be9a9e43
--- /dev/null
+++ b/ext/lua/include/luaconf.h
@@ -0,0 +1,551 @@
+/*
+** $Id: luaconf.h,v 1.176.1.1 2013/04/12 18:48:47 roberto Exp $
+** Configuration file for Lua
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lconfig_h
+#define lconfig_h
+
+#include
+#include
+
+
+/*
+** ==================================================================
+** Search for "@@" to find all configurable definitions.
+** ===================================================================
+*/
+
+
+/*
+@@ LUA_ANSI controls the use of non-ansi features.
+** CHANGE it (define it) if you want Lua to avoid the use of any
+** non-ansi feature or library.
+*/
+#if !defined(LUA_ANSI) && defined(__STRICT_ANSI__)
+#define LUA_ANSI
+#endif
+
+
+#if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE)
+#define LUA_WIN /* enable goodies for regular Windows platforms */
+#endif
+
+#if defined(LUA_WIN)
+#define LUA_DL_DLL
+#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
+#endif
+
+
+
+#if defined(LUA_USE_LINUX)
+#define LUA_USE_POSIX
+#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
+#define LUA_USE_READLINE /* needs some extra libraries */
+#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
+#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
+#define LUA_USE_LONGLONG /* assume support for long long */
+#endif
+
+#if defined(LUA_USE_MACOSX)
+#define LUA_USE_POSIX
+#define LUA_USE_DLOPEN /* does not need -ldl */
+#define LUA_USE_READLINE /* needs an extra library: -lreadline */
+#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
+#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
+#define LUA_USE_LONGLONG /* assume support for long long */
+#endif
+
+
+
+/*
+@@ LUA_USE_POSIX includes all functionality listed as X/Open System
+@* Interfaces Extension (XSI).
+** CHANGE it (define it) if your system is XSI compatible.
+*/
+#if defined(LUA_USE_POSIX)
+#define LUA_USE_MKSTEMP
+#define LUA_USE_ISATTY
+#define LUA_USE_POPEN
+#define LUA_USE_ULONGJMP
+#define LUA_USE_GMTIME_R
+#endif
+
+
+
+/*
+@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
+@* Lua libraries.
+@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
+@* C libraries.
+** CHANGE them if your machine has a non-conventional directory
+** hierarchy or if you want to install your libraries in
+** non-conventional directories.
+*/
+#if defined(_WIN32) /* { */
+/*
+** In Windows, any exclamation mark ('!') in the path is replaced by the
+** path of the directory of the executable file of the current process.
+*/
+#define LUA_LDIR "!\\lua\\"
+#define LUA_CDIR "!\\"
+#define LUA_PATH_DEFAULT \
+ LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
+ LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua"
+#define LUA_CPATH_DEFAULT \
+ LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll"
+
+#else /* }{ */
+
+#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/"
+#define LUA_ROOT "/usr/local/"
+#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR
+#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR
+#define LUA_PATH_DEFAULT \
+ LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
+ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua"
+#define LUA_CPATH_DEFAULT \
+ LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
+#endif /* } */
+
+
+/*
+@@ LUA_DIRSEP is the directory separator (for submodules).
+** CHANGE it if your machine does not use "/" as the directory separator
+** and is not Windows. (On Windows Lua automatically uses "\".)
+*/
+#if defined(_WIN32)
+#define LUA_DIRSEP "\\"
+#else
+#define LUA_DIRSEP "/"
+#endif
+
+
+/*
+@@ LUA_ENV is the name of the variable that holds the current
+@@ environment, used to access global names.
+** CHANGE it if you do not like this name.
+*/
+#define LUA_ENV "_ENV"
+
+
+/*
+@@ LUA_API is a mark for all core API functions.
+@@ LUALIB_API is a mark for all auxiliary library functions.
+@@ LUAMOD_API is a mark for all standard library opening functions.
+** CHANGE them if you need to define those functions in some special way.
+** For instance, if you want to create one Windows DLL with the core and
+** the libraries, you may want to use the following definition (define
+** LUA_BUILD_AS_DLL to get it).
+*/
+#if defined(LUA_BUILD_AS_DLL) /* { */
+
+#if defined(LUA_CORE) || defined(LUA_LIB) /* { */
+#define LUA_API __declspec(dllexport)
+#else /* }{ */
+#define LUA_API __declspec(dllimport)
+#endif /* } */
+
+#else /* }{ */
+
+#define LUA_API extern
+
+#endif /* } */
+
+
+/* more often than not the libs go together with the core */
+#define LUALIB_API LUA_API
+#define LUAMOD_API LUALIB_API
+
+
+/*
+@@ LUAI_FUNC is a mark for all extern functions that are not to be
+@* exported to outside modules.
+@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
+@* that are not to be exported to outside modules (LUAI_DDEF for
+@* definitions and LUAI_DDEC for declarations).
+** CHANGE them if you need to mark them in some special way. Elf/gcc
+** (versions 3.2 and later) mark them as "hidden" to optimize access
+** when Lua is compiled as a shared library. Not all elf targets support
+** this attribute. Unfortunately, gcc does not offer a way to check
+** whether the target offers that support, and those without support
+** give a warning about it. To avoid these warnings, change to the
+** default definition.
+*/
+#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
+ defined(__ELF__) /* { */
+#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
+#define LUAI_DDEC LUAI_FUNC
+#define LUAI_DDEF /* empty */
+
+#else /* }{ */
+#define LUAI_FUNC extern
+#define LUAI_DDEC extern
+#define LUAI_DDEF /* empty */
+#endif /* } */
+
+
+
+/*
+@@ LUA_QL describes how error messages quote program elements.
+** CHANGE it if you want a different appearance.
+*/
+#define LUA_QL(x) "'" x "'"
+#define LUA_QS LUA_QL("%s")
+
+
+/*
+@@ LUA_IDSIZE gives the maximum size for the description of the source
+@* of a function in debug information.
+** CHANGE it if you want a different size.
+*/
+#define LUA_IDSIZE 60
+
+
+/*
+@@ luai_writestring/luai_writeline define how 'print' prints its results.
+** They are only used in libraries and the stand-alone program. (The #if
+** avoids including 'stdio.h' everywhere.)
+*/
+#if defined(LUA_LIB) || defined(lua_c)
+#include
+#define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
+#define luai_writeline() (luai_writestring("\n", 1), fflush(stdout))
+#endif
+
+/*
+@@ luai_writestringerror defines how to print error messages.
+** (A format string with one argument is enough for Lua...)
+*/
+#define luai_writestringerror(s,p) \
+ (fprintf(stderr, (s), (p)), fflush(stderr))
+
+
+/*
+@@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is,
+** strings that are internalized. (Cannot be smaller than reserved words
+** or tags for metamethods, as these strings must be internalized;
+** #("function") = 8, #("__newindex") = 10.)
+*/
+#define LUAI_MAXSHORTLEN 40
+
+
+
+/*
+** {==================================================================
+** Compatibility with previous versions
+** ===================================================================
+*/
+
+/*
+@@ LUA_COMPAT_ALL controls all compatibility options.
+** You can define it to get all options, or change specific options
+** to fit your specific needs.
+*/
+#if defined(LUA_COMPAT_ALL) /* { */
+
+/*
+@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
+** You can replace it with 'table.unpack'.
+*/
+#define LUA_COMPAT_UNPACK
+
+/*
+@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
+** You can replace it with 'package.searchers'.
+*/
+#define LUA_COMPAT_LOADERS
+
+/*
+@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
+** You can call your C function directly (with light C functions).
+*/
+#define lua_cpcall(L,f,u) \
+ (lua_pushcfunction(L, (f)), \
+ lua_pushlightuserdata(L,(u)), \
+ lua_pcall(L,1,0,0))
+
+
+/*
+@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
+** You can rewrite 'log10(x)' as 'log(x, 10)'.
+*/
+#define LUA_COMPAT_LOG10
+
+/*
+@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
+** library. You can rewrite 'loadstring(s)' as 'load(s)'.
+*/
+#define LUA_COMPAT_LOADSTRING
+
+/*
+@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
+*/
+#define LUA_COMPAT_MAXN
+
+/*
+@@ The following macros supply trivial compatibility for some
+** changes in the API. The macros themselves document how to
+** change your code to avoid using them.
+*/
+#define lua_strlen(L,i) lua_rawlen(L, (i))
+
+#define lua_objlen(L,i) lua_rawlen(L, (i))
+
+#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
+#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
+
+/*
+@@ LUA_COMPAT_MODULE controls compatibility with previous
+** module functions 'module' (Lua) and 'luaL_register' (C).
+*/
+#define LUA_COMPAT_MODULE
+
+#endif /* } */
+
+/* }================================================================== */
+
+
+
+/*
+@@ LUAI_BITSINT defines the number of bits in an int.
+** CHANGE here if Lua cannot automatically detect the number of bits of
+** your machine. Probably you do not need to change this.
+*/
+/* avoid overflows in comparison */
+#if INT_MAX-20 < 32760 /* { */
+#define LUAI_BITSINT 16
+#elif INT_MAX > 2147483640L /* }{ */
+/* int has at least 32 bits */
+#define LUAI_BITSINT 32
+#else /* }{ */
+#error "you must define LUA_BITSINT with number of bits in an integer"
+#endif /* } */
+
+
+/*
+@@ LUA_INT32 is an signed integer with exactly 32 bits.
+@@ LUAI_UMEM is an unsigned integer big enough to count the total
+@* memory used by Lua.
+@@ LUAI_MEM is a signed integer big enough to count the total memory
+@* used by Lua.
+** CHANGE here if for some weird reason the default definitions are not
+** good enough for your machine. Probably you do not need to change
+** this.
+*/
+#if LUAI_BITSINT >= 32 /* { */
+#define LUA_INT32 int
+#define LUAI_UMEM size_t
+#define LUAI_MEM ptrdiff_t
+#else /* }{ */
+/* 16-bit ints */
+#define LUA_INT32 long
+#define LUAI_UMEM unsigned long
+#define LUAI_MEM long
+#endif /* } */
+
+
+/*
+@@ LUAI_MAXSTACK limits the size of the Lua stack.
+** CHANGE it if you need a different limit. This limit is arbitrary;
+** its only purpose is to stop Lua to consume unlimited stack
+** space (and to reserve some numbers for pseudo-indices).
+*/
+#if LUAI_BITSINT >= 32
+#define LUAI_MAXSTACK 1000000
+#else
+#define LUAI_MAXSTACK 15000
+#endif
+
+/* reserve some space for error handling */
+#define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000)
+
+
+
+
+/*
+@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
+** CHANGE it if it uses too much C-stack space.
+*/
+#define LUAL_BUFFERSIZE BUFSIZ
+
+
+
+
+/*
+** {==================================================================
+@@ LUA_NUMBER is the type of numbers in Lua.
+** CHANGE the following definitions only if you want to build Lua
+** with a number type different from double. You may also need to
+** change lua_number2int & lua_number2integer.
+** ===================================================================
+*/
+
+#define LUA_NUMBER_DOUBLE
+#define LUA_NUMBER double
+
+/*
+@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
+@* over a number.
+*/
+#define LUAI_UACNUMBER double
+
+
+/*
+@@ LUA_NUMBER_SCAN is the format for reading numbers.
+@@ LUA_NUMBER_FMT is the format for writing numbers.
+@@ lua_number2str converts a number to a string.
+@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
+*/
+#define LUA_NUMBER_SCAN "%lf"
+#define LUA_NUMBER_FMT "%.14g"
+#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
+#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
+
+
+/*
+@@ l_mathop allows the addition of an 'l' or 'f' to all math operations
+*/
+#define l_mathop(x) (x)
+
+
+/*
+@@ lua_str2number converts a decimal numeric string to a number.
+@@ lua_strx2number converts an hexadecimal numeric string to a number.
+** In C99, 'strtod' does both conversions. C89, however, has no function
+** to convert floating hexadecimal strings to numbers. For these
+** systems, you can leave 'lua_strx2number' undefined and Lua will
+** provide its own implementation.
+*/
+#define lua_str2number(s,p) strtod((s), (p))
+
+#if defined(LUA_USE_STRTODHEX)
+#define lua_strx2number(s,p) strtod((s), (p))
+#endif
+
+
+/*
+@@ The luai_num* macros define the primitive operations over numbers.
+*/
+
+/* the following operations need the math library */
+#if defined(lobject_c) || defined(lvm_c)
+#include
+#define luai_nummod(L,a,b) ((a) - l_mathop(floor)((a)/(b))*(b))
+#define luai_numpow(L,a,b) (l_mathop(pow)(a,b))
+#endif
+
+/* these are quite standard operations */
+#if defined(LUA_CORE)
+#define luai_numadd(L,a,b) ((a)+(b))
+#define luai_numsub(L,a,b) ((a)-(b))
+#define luai_nummul(L,a,b) ((a)*(b))
+#define luai_numdiv(L,a,b) ((a)/(b))
+#define luai_numunm(L,a) (-(a))
+#define luai_numeq(a,b) ((a)==(b))
+#define luai_numlt(L,a,b) ((a)<(b))
+#define luai_numle(L,a,b) ((a)<=(b))
+#define luai_numisnan(L,a) (!luai_numeq((a), (a)))
+#endif
+
+
+
+/*
+@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
+** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
+** machines, ptrdiff_t gives a good choice between int or long.)
+*/
+#define LUA_INTEGER ptrdiff_t
+
+/*
+@@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
+** It must have at least 32 bits.
+*/
+#define LUA_UNSIGNED unsigned LUA_INT32
+
+
+
+/*
+** Some tricks with doubles
+*/
+
+#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */
+/*
+** The next definitions activate some tricks to speed up the
+** conversion from doubles to integer types, mainly to LUA_UNSIGNED.
+**
+@@ LUA_MSASMTRICK uses Microsoft assembler to avoid clashes with a
+** DirectX idiosyncrasy.
+**
+@@ LUA_IEEE754TRICK uses a trick that should work on any machine
+** using IEEE754 with a 32-bit integer type.
+**
+@@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be
+** defined when LUA_INTEGER is a 32-bit integer.
+**
+@@ LUA_IEEEENDIAN is the endianness of doubles in your machine
+** (0 for little endian, 1 for big endian); if not defined, Lua will
+** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK).
+**
+@@ LUA_NANTRICK controls the use of a trick to pack all types into
+** a single double value, using NaN values to represent non-number
+** values. The trick only works on 32-bit machines (ints and pointers
+** are 32-bit values) with numbers represented as IEEE 754-2008 doubles
+** with conventional endianess (12345678 or 87654321), in CPUs that do
+** not produce signaling NaN values (all NaNs are quiet).
+*/
+
+/* Microsoft compiler on a Pentium (32 bit) ? */
+#if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */
+
+#define LUA_MSASMTRICK
+#define LUA_IEEEENDIAN 0
+#define LUA_NANTRICK
+
+
+/* pentium 32 bits? */
+#elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */
+
+#define LUA_IEEE754TRICK
+#define LUA_IEEELL
+#define LUA_IEEEENDIAN 0
+#define LUA_NANTRICK
+
+/* pentium 64 bits? */
+#elif defined(__x86_64) /* }{ */
+
+#define LUA_IEEE754TRICK
+#define LUA_IEEEENDIAN 0
+
+#elif defined(__POWERPC__) || defined(__ppc__) /* }{ */
+
+#define LUA_IEEE754TRICK
+#define LUA_IEEEENDIAN 1
+
+#else /* }{ */
+
+/* assume IEEE754 and a 32-bit integer type */
+#define LUA_IEEE754TRICK
+
+#endif /* } */
+
+#endif /* } */
+
+/* }================================================================== */
+
+
+
+
+/* =================================================================== */
+
+/*
+** Local configuration. You can use this space to add your redefinitions
+** without modifying the main part of the file.
+*/
+
+
+
+#endif
+
diff --git a/ext/lua/include/lualib.h b/ext/lua/include/lualib.h
new file mode 100644
index 0000000000..da82005c9d
--- /dev/null
+++ b/ext/lua/include/lualib.h
@@ -0,0 +1,55 @@
+/*
+** $Id: lualib.h,v 1.43.1.1 2013/04/12 18:48:47 roberto Exp $
+** Lua standard libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lualib_h
+#define lualib_h
+
+#include "lua.h"
+
+
+
+LUAMOD_API int (luaopen_base) (lua_State *L);
+
+#define LUA_COLIBNAME "coroutine"
+LUAMOD_API int (luaopen_coroutine) (lua_State *L);
+
+#define LUA_TABLIBNAME "table"
+LUAMOD_API int (luaopen_table) (lua_State *L);
+
+#define LUA_IOLIBNAME "io"
+LUAMOD_API int (luaopen_io) (lua_State *L);
+
+#define LUA_OSLIBNAME "os"
+LUAMOD_API int (luaopen_os) (lua_State *L);
+
+#define LUA_STRLIBNAME "string"
+LUAMOD_API int (luaopen_string) (lua_State *L);
+
+#define LUA_BITLIBNAME "bit32"
+LUAMOD_API int (luaopen_bit32) (lua_State *L);
+
+#define LUA_MATHLIBNAME "math"
+LUAMOD_API int (luaopen_math) (lua_State *L);
+
+#define LUA_DBLIBNAME "debug"
+LUAMOD_API int (luaopen_debug) (lua_State *L);
+
+#define LUA_LOADLIBNAME "package"
+LUAMOD_API int (luaopen_package) (lua_State *L);
+
+
+/* open all previous libraries */
+LUALIB_API void (luaL_openlibs) (lua_State *L);
+
+
+
+#if !defined(lua_assert)
+#define lua_assert(x) ((void)0)
+#endif
+
+
+#endif
diff --git a/ext/lua/include/lundump.h b/ext/lua/include/lundump.h
new file mode 100644
index 0000000000..5255db259d
--- /dev/null
+++ b/ext/lua/include/lundump.h
@@ -0,0 +1,28 @@
+/*
+** $Id: lundump.h,v 1.39.1.1 2013/04/12 18:48:47 roberto Exp $
+** load precompiled Lua chunks
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lundump_h
+#define lundump_h
+
+#include "lobject.h"
+#include "lzio.h"
+
+/* load one chunk; from lundump.c */
+LUAI_FUNC Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
+
+/* make header; from lundump.c */
+LUAI_FUNC void luaU_header (lu_byte* h);
+
+/* dump one chunk; from ldump.c */
+LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
+
+/* data to catch conversion errors */
+#define LUAC_TAIL "\x19\x93\r\n\x1a\n"
+
+/* size in bytes of header of binary files */
+#define LUAC_HEADERSIZE (sizeof(LUA_SIGNATURE)-sizeof(char)+2+6+sizeof(LUAC_TAIL)-sizeof(char))
+
+#endif
diff --git a/ext/lua/include/lvm.h b/ext/lua/include/lvm.h
new file mode 100644
index 0000000000..5380270da6
--- /dev/null
+++ b/ext/lua/include/lvm.h
@@ -0,0 +1,44 @@
+/*
+** $Id: lvm.h,v 2.18.1.1 2013/04/12 18:48:47 roberto Exp $
+** Lua virtual machine
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lvm_h
+#define lvm_h
+
+
+#include "ldo.h"
+#include "lobject.h"
+#include "ltm.h"
+
+
+#define tostring(L,o) (ttisstring(o) || (luaV_tostring(L, o)))
+
+#define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL))
+
+#define equalobj(L,o1,o2) (ttisequal(o1, o2) && luaV_equalobj_(L, o1, o2))
+
+#define luaV_rawequalobj(o1,o2) equalobj(NULL,o1,o2)
+
+
+/* not to called directly */
+LUAI_FUNC int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2);
+
+
+LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
+LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r);
+LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
+LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
+LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
+ StkId val);
+LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
+ StkId val);
+LUAI_FUNC void luaV_finishOp (lua_State *L);
+LUAI_FUNC void luaV_execute (lua_State *L);
+LUAI_FUNC void luaV_concat (lua_State *L, int total);
+LUAI_FUNC void luaV_arith (lua_State *L, StkId ra, const TValue *rb,
+ const TValue *rc, TMS op);
+LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb);
+
+#endif
diff --git a/ext/lua/include/lzio.h b/ext/lua/include/lzio.h
new file mode 100644
index 0000000000..441f7479cb
--- /dev/null
+++ b/ext/lua/include/lzio.h
@@ -0,0 +1,65 @@
+/*
+** $Id: lzio.h,v 1.26.1.1 2013/04/12 18:48:47 roberto Exp $
+** Buffered streams
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lzio_h
+#define lzio_h
+
+#include "lua.h"
+
+#include "lmem.h"
+
+
+#define EOZ (-1) /* end of stream */
+
+typedef struct Zio ZIO;
+
+#define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z))
+
+
+typedef struct Mbuffer {
+ char *buffer;
+ size_t n;
+ size_t buffsize;
+} Mbuffer;
+
+#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
+
+#define luaZ_buffer(buff) ((buff)->buffer)
+#define luaZ_sizebuffer(buff) ((buff)->buffsize)
+#define luaZ_bufflen(buff) ((buff)->n)
+
+#define luaZ_resetbuffer(buff) ((buff)->n = 0)
+
+
+#define luaZ_resizebuffer(L, buff, size) \
+ (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
+ (buff)->buffsize = size)
+
+#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
+
+
+LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
+LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
+ void *data);
+LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
+
+
+
+/* --------- Private Part ------------------ */
+
+struct Zio {
+ size_t n; /* bytes still unread */
+ const char *p; /* current position in buffer */
+ lua_Reader reader; /* reader function */
+ void* data; /* additional data */
+ lua_State *L; /* Lua state (for reader) */
+};
+
+
+LUAI_FUNC int luaZ_fill (ZIO *z);
+
+#endif
diff --git a/ext/lua/src/lapi.c b/ext/lua/src/lapi.c
new file mode 100644
index 0000000000..d011431ead
--- /dev/null
+++ b/ext/lua/src/lapi.c
@@ -0,0 +1,1284 @@
+/*
+** $Id: lapi.c,v 2.171.1.1 2013/04/12 18:48:47 roberto Exp $
+** Lua API
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+#include
+
+#define lapi_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lapi.h"
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lgc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+#include "lundump.h"
+#include "lvm.h"
+
+
+
+const char lua_ident[] =
+ "$LuaVersion: " LUA_COPYRIGHT " $"
+ "$LuaAuthors: " LUA_AUTHORS " $";
+
+
+/* value at a non-valid index */
+#define NONVALIDVALUE cast(TValue *, luaO_nilobject)
+
+/* corresponding test */
+#define isvalid(o) ((o) != luaO_nilobject)
+
+/* test for pseudo index */
+#define ispseudo(i) ((i) <= LUA_REGISTRYINDEX)
+
+/* test for valid but not pseudo index */
+#define isstackindex(i, o) (isvalid(o) && !ispseudo(i))
+
+#define api_checkvalidindex(L, o) api_check(L, isvalid(o), "invalid index")
+
+#define api_checkstackindex(L, i, o) \
+ api_check(L, isstackindex(i, o), "index not in the stack")
+
+
+static TValue *index2addr (lua_State *L, int idx) {
+ CallInfo *ci = L->ci;
+ if (idx > 0) {
+ TValue *o = ci->func + idx;
+ api_check(L, idx <= ci->top - (ci->func + 1), "unacceptable index");
+ if (o >= L->top) return NONVALIDVALUE;
+ else return o;
+ }
+ else if (!ispseudo(idx)) { /* negative index */
+ api_check(L, idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index");
+ return L->top + idx;
+ }
+ else if (idx == LUA_REGISTRYINDEX)
+ return &G(L)->l_registry;
+ else { /* upvalues */
+ idx = LUA_REGISTRYINDEX - idx;
+ api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large");
+ if (ttislcf(ci->func)) /* light C function? */
+ return NONVALIDVALUE; /* it has no upvalues */
+ else {
+ CClosure *func = clCvalue(ci->func);
+ return (idx <= func->nupvalues) ? &func->upvalue[idx-1] : NONVALIDVALUE;
+ }
+ }
+}
+
+
+/*
+** to be called by 'lua_checkstack' in protected mode, to grow stack
+** capturing memory errors
+*/
+static void growstack (lua_State *L, void *ud) {
+ int size = *(int *)ud;
+ luaD_growstack(L, size);
+}
+
+
+LUA_API int lua_checkstack (lua_State *L, int size) {
+ int res;
+ CallInfo *ci = L->ci;
+ lua_lock(L);
+ if (L->stack_last - L->top > size) /* stack large enough? */
+ res = 1; /* yes; check is OK */
+ else { /* no; need to grow stack */
+ int inuse = cast_int(L->top - L->stack) + EXTRA_STACK;
+ if (inuse > LUAI_MAXSTACK - size) /* can grow without overflow? */
+ res = 0; /* no */
+ else /* try to grow stack */
+ res = (luaD_rawrunprotected(L, &growstack, &size) == LUA_OK);
+ }
+ if (res && ci->top < L->top + size)
+ ci->top = L->top + size; /* adjust frame top */
+ lua_unlock(L);
+ return res;
+}
+
+
+LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
+ int i;
+ if (from == to) return;
+ lua_lock(to);
+ api_checknelems(from, n);
+ api_check(from, G(from) == G(to), "moving among independent states");
+ api_check(from, to->ci->top - to->top >= n, "not enough elements to move");
+ from->top -= n;
+ for (i = 0; i < n; i++) {
+ setobj2s(to, to->top++, from->top + i);
+ }
+ lua_unlock(to);
+}
+
+
+LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
+ lua_CFunction old;
+ lua_lock(L);
+ old = G(L)->panic;
+ G(L)->panic = panicf;
+ lua_unlock(L);
+ return old;
+}
+
+
+LUA_API const lua_Number *lua_version (lua_State *L) {
+ static const lua_Number version = LUA_VERSION_NUM;
+ if (L == NULL) return &version;
+ else return G(L)->version;
+}
+
+
+
+/*
+** basic stack manipulation
+*/
+
+
+/*
+** convert an acceptable stack index into an absolute index
+*/
+LUA_API int lua_absindex (lua_State *L, int idx) {
+ return (idx > 0 || ispseudo(idx))
+ ? idx
+ : cast_int(L->top - L->ci->func + idx);
+}
+
+
+LUA_API int lua_gettop (lua_State *L) {
+ return cast_int(L->top - (L->ci->func + 1));
+}
+
+
+LUA_API void lua_settop (lua_State *L, int idx) {
+ StkId func = L->ci->func;
+ lua_lock(L);
+ if (idx >= 0) {
+ api_check(L, idx <= L->stack_last - (func + 1), "new top too large");
+ while (L->top < (func + 1) + idx)
+ setnilvalue(L->top++);
+ L->top = (func + 1) + idx;
+ }
+ else {
+ api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top");
+ L->top += idx+1; /* `subtract' index (index is negative) */
+ }
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_remove (lua_State *L, int idx) {
+ StkId p;
+ lua_lock(L);
+ p = index2addr(L, idx);
+ api_checkstackindex(L, idx, p);
+ while (++p < L->top) setobjs2s(L, p-1, p);
+ L->top--;
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_insert (lua_State *L, int idx) {
+ StkId p;
+ StkId q;
+ lua_lock(L);
+ p = index2addr(L, idx);
+ api_checkstackindex(L, idx, p);
+ for (q = L->top; q > p; q--) /* use L->top as a temporary */
+ setobjs2s(L, q, q - 1);
+ setobjs2s(L, p, L->top);
+ lua_unlock(L);
+}
+
+
+static void moveto (lua_State *L, TValue *fr, int idx) {
+ TValue *to = index2addr(L, idx);
+ api_checkvalidindex(L, to);
+ setobj(L, to, fr);
+ if (idx < LUA_REGISTRYINDEX) /* function upvalue? */
+ luaC_barrier(L, clCvalue(L->ci->func), fr);
+ /* LUA_REGISTRYINDEX does not need gc barrier
+ (collector revisits it before finishing collection) */
+}
+
+
+LUA_API void lua_replace (lua_State *L, int idx) {
+ lua_lock(L);
+ api_checknelems(L, 1);
+ moveto(L, L->top - 1, idx);
+ L->top--;
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) {
+ TValue *fr;
+ lua_lock(L);
+ fr = index2addr(L, fromidx);
+ moveto(L, fr, toidx);
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_pushvalue (lua_State *L, int idx) {
+ lua_lock(L);
+ setobj2s(L, L->top, index2addr(L, idx));
+ api_incr_top(L);
+ lua_unlock(L);
+}
+
+
+
+/*
+** access functions (stack -> C)
+*/
+
+
+LUA_API int lua_type (lua_State *L, int idx) {
+ StkId o = index2addr(L, idx);
+ return (isvalid(o) ? ttypenv(o) : LUA_TNONE);
+}
+
+
+LUA_API const char *lua_typename (lua_State *L, int t) {
+ UNUSED(L);
+ return ttypename(t);
+}
+
+
+LUA_API int lua_iscfunction (lua_State *L, int idx) {
+ StkId o = index2addr(L, idx);
+ return (ttislcf(o) || (ttisCclosure(o)));
+}
+
+
+LUA_API int lua_isnumber (lua_State *L, int idx) {
+ TValue n;
+ const TValue *o = index2addr(L, idx);
+ return tonumber(o, &n);
+}
+
+
+LUA_API int lua_isstring (lua_State *L, int idx) {
+ int t = lua_type(L, idx);
+ return (t == LUA_TSTRING || t == LUA_TNUMBER);
+}
+
+
+LUA_API int lua_isuserdata (lua_State *L, int idx) {
+ const TValue *o = index2addr(L, idx);
+ return (ttisuserdata(o) || ttislightuserdata(o));
+}
+
+
+LUA_API int lua_rawequal (lua_State *L, int index1, int index2) {
+ StkId o1 = index2addr(L, index1);
+ StkId o2 = index2addr(L, index2);
+ return (isvalid(o1) && isvalid(o2)) ? luaV_rawequalobj(o1, o2) : 0;
+}
+
+
+LUA_API void lua_arith (lua_State *L, int op) {
+ StkId o1; /* 1st operand */
+ StkId o2; /* 2nd operand */
+ lua_lock(L);
+ if (op != LUA_OPUNM) /* all other operations expect two operands */
+ api_checknelems(L, 2);
+ else { /* for unary minus, add fake 2nd operand */
+ api_checknelems(L, 1);
+ setobjs2s(L, L->top, L->top - 1);
+ L->top++;
+ }
+ o1 = L->top - 2;
+ o2 = L->top - 1;
+ if (ttisnumber(o1) && ttisnumber(o2)) {
+ setnvalue(o1, luaO_arith(op, nvalue(o1), nvalue(o2)));
+ }
+ else
+ luaV_arith(L, o1, o1, o2, cast(TMS, op - LUA_OPADD + TM_ADD));
+ L->top--;
+ lua_unlock(L);
+}
+
+
+LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
+ StkId o1, o2;
+ int i = 0;
+ lua_lock(L); /* may call tag method */
+ o1 = index2addr(L, index1);
+ o2 = index2addr(L, index2);
+ if (isvalid(o1) && isvalid(o2)) {
+ switch (op) {
+ case LUA_OPEQ: i = equalobj(L, o1, o2); break;
+ case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break;
+ case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break;
+ default: api_check(L, 0, "invalid option");
+ }
+ }
+ lua_unlock(L);
+ return i;
+}
+
+
+LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *isnum) {
+ TValue n;
+ const TValue *o = index2addr(L, idx);
+ if (tonumber(o, &n)) {
+ if (isnum) *isnum = 1;
+ return nvalue(o);
+ }
+ else {
+ if (isnum) *isnum = 0;
+ return 0;
+ }
+}
+
+
+LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *isnum) {
+ TValue n;
+ const TValue *o = index2addr(L, idx);
+ if (tonumber(o, &n)) {
+ lua_Integer res;
+ lua_Number num = nvalue(o);
+ lua_number2integer(res, num);
+ if (isnum) *isnum = 1;
+ return res;
+ }
+ else {
+ if (isnum) *isnum = 0;
+ return 0;
+ }
+}
+
+
+LUA_API lua_Unsigned lua_tounsignedx (lua_State *L, int idx, int *isnum) {
+ TValue n;
+ const TValue *o = index2addr(L, idx);
+ if (tonumber(o, &n)) {
+ lua_Unsigned res;
+ lua_Number num = nvalue(o);
+ lua_number2unsigned(res, num);
+ if (isnum) *isnum = 1;
+ return res;
+ }
+ else {
+ if (isnum) *isnum = 0;
+ return 0;
+ }
+}
+
+
+LUA_API int lua_toboolean (lua_State *L, int idx) {
+ const TValue *o = index2addr(L, idx);
+ return !l_isfalse(o);
+}
+
+
+LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
+ StkId o = index2addr(L, idx);
+ if (!ttisstring(o)) {
+ lua_lock(L); /* `luaV_tostring' may create a new string */
+ if (!luaV_tostring(L, o)) { /* conversion failed? */
+ if (len != NULL) *len = 0;
+ lua_unlock(L);
+ return NULL;
+ }
+ luaC_checkGC(L);
+ o = index2addr(L, idx); /* previous call may reallocate the stack */
+ lua_unlock(L);
+ }
+ if (len != NULL) *len = tsvalue(o)->len;
+ return svalue(o);
+}
+
+
+LUA_API size_t lua_rawlen (lua_State *L, int idx) {
+ StkId o = index2addr(L, idx);
+ switch (ttypenv(o)) {
+ case LUA_TSTRING: return tsvalue(o)->len;
+ case LUA_TUSERDATA: return uvalue(o)->len;
+ case LUA_TTABLE: return luaH_getn(hvalue(o));
+ default: return 0;
+ }
+}
+
+
+LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
+ StkId o = index2addr(L, idx);
+ if (ttislcf(o)) return fvalue(o);
+ else if (ttisCclosure(o))
+ return clCvalue(o)->f;
+ else return NULL; /* not a C function */
+}
+
+
+LUA_API void *lua_touserdata (lua_State *L, int idx) {
+ StkId o = index2addr(L, idx);
+ switch (ttypenv(o)) {
+ case LUA_TUSERDATA: return (rawuvalue(o) + 1);
+ case LUA_TLIGHTUSERDATA: return pvalue(o);
+ default: return NULL;
+ }
+}
+
+
+LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
+ StkId o = index2addr(L, idx);
+ return (!ttisthread(o)) ? NULL : thvalue(o);
+}
+
+
+LUA_API const void *lua_topointer (lua_State *L, int idx) {
+ StkId o = index2addr(L, idx);
+ switch (ttype(o)) {
+ case LUA_TTABLE: return hvalue(o);
+ case LUA_TLCL: return clLvalue(o);
+ case LUA_TCCL: return clCvalue(o);
+ case LUA_TLCF: return cast(void *, cast(size_t, fvalue(o)));
+ case LUA_TTHREAD: return thvalue(o);
+ case LUA_TUSERDATA:
+ case LUA_TLIGHTUSERDATA:
+ return lua_touserdata(L, idx);
+ default: return NULL;
+ }
+}
+
+
+
+/*
+** push functions (C -> stack)
+*/
+
+
+LUA_API void lua_pushnil (lua_State *L) {
+ lua_lock(L);
+ setnilvalue(L->top);
+ api_incr_top(L);
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
+ lua_lock(L);
+ setnvalue(L->top, n);
+ luai_checknum(L, L->top,
+ luaG_runerror(L, "C API - attempt to push a signaling NaN"));
+ api_incr_top(L);
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
+ lua_lock(L);
+ setnvalue(L->top, cast_num(n));
+ api_incr_top(L);
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_pushunsigned (lua_State *L, lua_Unsigned u) {
+ lua_Number n;
+ lua_lock(L);
+ n = lua_unsigned2number(u);
+ setnvalue(L->top, n);
+ api_incr_top(L);
+ lua_unlock(L);
+}
+
+
+LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) {
+ TString *ts;
+ lua_lock(L);
+ luaC_checkGC(L);
+ ts = luaS_newlstr(L, s, len);
+ setsvalue2s(L, L->top, ts);
+ api_incr_top(L);
+ lua_unlock(L);
+ return getstr(ts);
+}
+
+
+LUA_API const char *lua_pushstring (lua_State *L, const char *s) {
+ if (s == NULL) {
+ lua_pushnil(L);
+ return NULL;
+ }
+ else {
+ TString *ts;
+ lua_lock(L);
+ luaC_checkGC(L);
+ ts = luaS_new(L, s);
+ setsvalue2s(L, L->top, ts);
+ api_incr_top(L);
+ lua_unlock(L);
+ return getstr(ts);
+ }
+}
+
+
+LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
+ va_list argp) {
+ const char *ret;
+ lua_lock(L);
+ luaC_checkGC(L);
+ ret = luaO_pushvfstring(L, fmt, argp);
+ lua_unlock(L);
+ return ret;
+}
+
+
+LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
+ const char *ret;
+ va_list argp;
+ lua_lock(L);
+ luaC_checkGC(L);
+ va_start(argp, fmt);
+ ret = luaO_pushvfstring(L, fmt, argp);
+ va_end(argp);
+ lua_unlock(L);
+ return ret;
+}
+
+
+LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
+ lua_lock(L);
+ if (n == 0) {
+ setfvalue(L->top, fn);
+ }
+ else {
+ Closure *cl;
+ api_checknelems(L, n);
+ api_check(L, n <= MAXUPVAL, "upvalue index too large");
+ luaC_checkGC(L);
+ cl = luaF_newCclosure(L, n);
+ cl->c.f = fn;
+ L->top -= n;
+ while (n--)
+ setobj2n(L, &cl->c.upvalue[n], L->top + n);
+ setclCvalue(L, L->top, cl);
+ }
+ api_incr_top(L);
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_pushboolean (lua_State *L, int b) {
+ lua_lock(L);
+ setbvalue(L->top, (b != 0)); /* ensure that true is 1 */
+ api_incr_top(L);
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
+ lua_lock(L);
+ setpvalue(L->top, p);
+ api_incr_top(L);
+ lua_unlock(L);
+}
+
+
+LUA_API int lua_pushthread (lua_State *L) {
+ lua_lock(L);
+ setthvalue(L, L->top, L);
+ api_incr_top(L);
+ lua_unlock(L);
+ return (G(L)->mainthread == L);
+}
+
+
+
+/*
+** get functions (Lua -> stack)
+*/
+
+
+LUA_API void lua_getglobal (lua_State *L, const char *var) {
+ Table *reg = hvalue(&G(L)->l_registry);
+ const TValue *gt; /* global table */
+ lua_lock(L);
+ gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
+ setsvalue2s(L, L->top++, luaS_new(L, var));
+ luaV_gettable(L, gt, L->top - 1, L->top - 1);
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_gettable (lua_State *L, int idx) {
+ StkId t;
+ lua_lock(L);
+ t = index2addr(L, idx);
+ luaV_gettable(L, t, L->top - 1, L->top - 1);
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
+ StkId t;
+ lua_lock(L);
+ t = index2addr(L, idx);
+ setsvalue2s(L, L->top, luaS_new(L, k));
+ api_incr_top(L);
+ luaV_gettable(L, t, L->top - 1, L->top - 1);
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_rawget (lua_State *L, int idx) {
+ StkId t;
+ lua_lock(L);
+ t = index2addr(L, idx);
+ api_check(L, ttistable(t), "table expected");
+ setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1));
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
+ StkId t;
+ lua_lock(L);
+ t = index2addr(L, idx);
+ api_check(L, ttistable(t), "table expected");
+ setobj2s(L, L->top, luaH_getint(hvalue(t), n));
+ api_incr_top(L);
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_rawgetp (lua_State *L, int idx, const void *p) {
+ StkId t;
+ TValue k;
+ lua_lock(L);
+ t = index2addr(L, idx);
+ api_check(L, ttistable(t), "table expected");
+ setpvalue(&k, cast(void *, p));
+ setobj2s(L, L->top, luaH_get(hvalue(t), &k));
+ api_incr_top(L);
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
+ Table *t;
+ lua_lock(L);
+ luaC_checkGC(L);
+ t = luaH_new(L);
+ sethvalue(L, L->top, t);
+ api_incr_top(L);
+ if (narray > 0 || nrec > 0)
+ luaH_resize(L, t, narray, nrec);
+ lua_unlock(L);
+}
+
+
+LUA_API int lua_getmetatable (lua_State *L, int objindex) {
+ const TValue *obj;
+ Table *mt = NULL;
+ int res;
+ lua_lock(L);
+ obj = index2addr(L, objindex);
+ switch (ttypenv(obj)) {
+ case LUA_TTABLE:
+ mt = hvalue(obj)->metatable;
+ break;
+ case LUA_TUSERDATA:
+ mt = uvalue(obj)->metatable;
+ break;
+ default:
+ mt = G(L)->mt[ttypenv(obj)];
+ break;
+ }
+ if (mt == NULL)
+ res = 0;
+ else {
+ sethvalue(L, L->top, mt);
+ api_incr_top(L);
+ res = 1;
+ }
+ lua_unlock(L);
+ return res;
+}
+
+
+LUA_API void lua_getuservalue (lua_State *L, int idx) {
+ StkId o;
+ lua_lock(L);
+ o = index2addr(L, idx);
+ api_check(L, ttisuserdata(o), "userdata expected");
+ if (uvalue(o)->env) {
+ sethvalue(L, L->top, uvalue(o)->env);
+ } else
+ setnilvalue(L->top);
+ api_incr_top(L);
+ lua_unlock(L);
+}
+
+
+/*
+** set functions (stack -> Lua)
+*/
+
+
+LUA_API void lua_setglobal (lua_State *L, const char *var) {
+ Table *reg = hvalue(&G(L)->l_registry);
+ const TValue *gt; /* global table */
+ lua_lock(L);
+ api_checknelems(L, 1);
+ gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
+ setsvalue2s(L, L->top++, luaS_new(L, var));
+ luaV_settable(L, gt, L->top - 1, L->top - 2);
+ L->top -= 2; /* pop value and key */
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_settable (lua_State *L, int idx) {
+ StkId t;
+ lua_lock(L);
+ api_checknelems(L, 2);
+ t = index2addr(L, idx);
+ luaV_settable(L, t, L->top - 2, L->top - 1);
+ L->top -= 2; /* pop index and value */
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
+ StkId t;
+ lua_lock(L);
+ api_checknelems(L, 1);
+ t = index2addr(L, idx);
+ setsvalue2s(L, L->top++, luaS_new(L, k));
+ luaV_settable(L, t, L->top - 1, L->top - 2);
+ L->top -= 2; /* pop value and key */
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_rawset (lua_State *L, int idx) {
+ StkId t;
+ lua_lock(L);
+ api_checknelems(L, 2);
+ t = index2addr(L, idx);
+ api_check(L, ttistable(t), "table expected");
+ setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1);
+ invalidateTMcache(hvalue(t));
+ luaC_barrierback(L, gcvalue(t), L->top-1);
+ L->top -= 2;
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
+ StkId t;
+ lua_lock(L);
+ api_checknelems(L, 1);
+ t = index2addr(L, idx);
+ api_check(L, ttistable(t), "table expected");
+ luaH_setint(L, hvalue(t), n, L->top - 1);
+ luaC_barrierback(L, gcvalue(t), L->top-1);
+ L->top--;
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) {
+ StkId t;
+ TValue k;
+ lua_lock(L);
+ api_checknelems(L, 1);
+ t = index2addr(L, idx);
+ api_check(L, ttistable(t), "table expected");
+ setpvalue(&k, cast(void *, p));
+ setobj2t(L, luaH_set(L, hvalue(t), &k), L->top - 1);
+ luaC_barrierback(L, gcvalue(t), L->top - 1);
+ L->top--;
+ lua_unlock(L);
+}
+
+
+LUA_API int lua_setmetatable (lua_State *L, int objindex) {
+ TValue *obj;
+ Table *mt;
+ lua_lock(L);
+ api_checknelems(L, 1);
+ obj = index2addr(L, objindex);
+ if (ttisnil(L->top - 1))
+ mt = NULL;
+ else {
+ api_check(L, ttistable(L->top - 1), "table expected");
+ mt = hvalue(L->top - 1);
+ }
+ switch (ttypenv(obj)) {
+ case LUA_TTABLE: {
+ hvalue(obj)->metatable = mt;
+ if (mt) {
+ luaC_objbarrierback(L, gcvalue(obj), mt);
+ luaC_checkfinalizer(L, gcvalue(obj), mt);
+ }
+ break;
+ }
+ case LUA_TUSERDATA: {
+ uvalue(obj)->metatable = mt;
+ if (mt) {
+ luaC_objbarrier(L, rawuvalue(obj), mt);
+ luaC_checkfinalizer(L, gcvalue(obj), mt);
+ }
+ break;
+ }
+ default: {
+ G(L)->mt[ttypenv(obj)] = mt;
+ break;
+ }
+ }
+ L->top--;
+ lua_unlock(L);
+ return 1;
+}
+
+
+LUA_API void lua_setuservalue (lua_State *L, int idx) {
+ StkId o;
+ lua_lock(L);
+ api_checknelems(L, 1);
+ o = index2addr(L, idx);
+ api_check(L, ttisuserdata(o), "userdata expected");
+ if (ttisnil(L->top - 1))
+ uvalue(o)->env = NULL;
+ else {
+ api_check(L, ttistable(L->top - 1), "table expected");
+ uvalue(o)->env = hvalue(L->top - 1);
+ luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
+ }
+ L->top--;
+ lua_unlock(L);
+}
+
+
+/*
+** `load' and `call' functions (run Lua code)
+*/
+
+
+#define checkresults(L,na,nr) \
+ api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \
+ "results from function overflow current stack size")
+
+
+LUA_API int lua_getctx (lua_State *L, int *ctx) {
+ if (L->ci->callstatus & CIST_YIELDED) {
+ if (ctx) *ctx = L->ci->u.c.ctx;
+ return L->ci->u.c.status;
+ }
+ else return LUA_OK;
+}
+
+
+LUA_API void lua_callk (lua_State *L, int nargs, int nresults, int ctx,
+ lua_CFunction k) {
+ StkId func;
+ lua_lock(L);
+ api_check(L, k == NULL || !isLua(L->ci),
+ "cannot use continuations inside hooks");
+ api_checknelems(L, nargs+1);
+ api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread");
+ checkresults(L, nargs, nresults);
+ func = L->top - (nargs+1);
+ if (k != NULL && L->nny == 0) { /* need to prepare continuation? */
+ L->ci->u.c.k = k; /* save continuation */
+ L->ci->u.c.ctx = ctx; /* save context */
+ luaD_call(L, func, nresults, 1); /* do the call */
+ }
+ else /* no continuation or no yieldable */
+ luaD_call(L, func, nresults, 0); /* just do the call */
+ adjustresults(L, nresults);
+ lua_unlock(L);
+}
+
+
+
+/*
+** Execute a protected call.
+*/
+struct CallS { /* data to `f_call' */
+ StkId func;
+ int nresults;
+};
+
+
+static void f_call (lua_State *L, void *ud) {
+ struct CallS *c = cast(struct CallS *, ud);
+ luaD_call(L, c->func, c->nresults, 0);
+}
+
+
+
+LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc,
+ int ctx, lua_CFunction k) {
+ struct CallS c;
+ int status;
+ ptrdiff_t func;
+ lua_lock(L);
+ api_check(L, k == NULL || !isLua(L->ci),
+ "cannot use continuations inside hooks");
+ api_checknelems(L, nargs+1);
+ api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread");
+ checkresults(L, nargs, nresults);
+ if (errfunc == 0)
+ func = 0;
+ else {
+ StkId o = index2addr(L, errfunc);
+ api_checkstackindex(L, errfunc, o);
+ func = savestack(L, o);
+ }
+ c.func = L->top - (nargs+1); /* function to be called */
+ if (k == NULL || L->nny > 0) { /* no continuation or no yieldable? */
+ c.nresults = nresults; /* do a 'conventional' protected call */
+ status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func);
+ }
+ else { /* prepare continuation (call is already protected by 'resume') */
+ CallInfo *ci = L->ci;
+ ci->u.c.k = k; /* save continuation */
+ ci->u.c.ctx = ctx; /* save context */
+ /* save information for error recovery */
+ ci->extra = savestack(L, c.func);
+ ci->u.c.old_allowhook = L->allowhook;
+ ci->u.c.old_errfunc = L->errfunc;
+ L->errfunc = func;
+ /* mark that function may do error recovery */
+ ci->callstatus |= CIST_YPCALL;
+ luaD_call(L, c.func, nresults, 1); /* do the call */
+ ci->callstatus &= ~CIST_YPCALL;
+ L->errfunc = ci->u.c.old_errfunc;
+ status = LUA_OK; /* if it is here, there were no errors */
+ }
+ adjustresults(L, nresults);
+ lua_unlock(L);
+ return status;
+}
+
+
+LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
+ const char *chunkname, const char *mode) {
+ ZIO z;
+ int status;
+ lua_lock(L);
+ if (!chunkname) chunkname = "?";
+ luaZ_init(L, &z, reader, data);
+ status = luaD_protectedparser(L, &z, chunkname, mode);
+ if (status == LUA_OK) { /* no errors? */
+ LClosure *f = clLvalue(L->top - 1); /* get newly created function */
+ if (f->nupvalues == 1) { /* does it have one upvalue? */
+ /* get global table from registry */
+ Table *reg = hvalue(&G(L)->l_registry);
+ const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
+ /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */
+ setobj(L, f->upvals[0]->v, gt);
+ luaC_barrier(L, f->upvals[0], gt);
+ }
+ }
+ lua_unlock(L);
+ return status;
+}
+
+
+LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
+ int status;
+ TValue *o;
+ lua_lock(L);
+ api_checknelems(L, 1);
+ o = L->top - 1;
+ if (isLfunction(o))
+ status = luaU_dump(L, getproto(o), writer, data, 0);
+ else
+ status = 1;
+ lua_unlock(L);
+ return status;
+}
+
+
+LUA_API int lua_status (lua_State *L) {
+ return L->status;
+}
+
+
+/*
+** Garbage-collection function
+*/
+
+LUA_API int lua_gc (lua_State *L, int what, int data) {
+ int res = 0;
+ global_State *g;
+ lua_lock(L);
+ g = G(L);
+ switch (what) {
+ case LUA_GCSTOP: {
+ g->gcrunning = 0;
+ break;
+ }
+ case LUA_GCRESTART: {
+ luaE_setdebt(g, 0);
+ g->gcrunning = 1;
+ break;
+ }
+ case LUA_GCCOLLECT: {
+ luaC_fullgc(L, 0);
+ break;
+ }
+ case LUA_GCCOUNT: {
+ /* GC values are expressed in Kbytes: #bytes/2^10 */
+ res = cast_int(gettotalbytes(g) >> 10);
+ break;
+ }
+ case LUA_GCCOUNTB: {
+ res = cast_int(gettotalbytes(g) & 0x3ff);
+ break;
+ }
+ case LUA_GCSTEP: {
+ if (g->gckind == KGC_GEN) { /* generational mode? */
+ res = (g->GCestimate == 0); /* true if it will do major collection */
+ luaC_forcestep(L); /* do a single step */
+ }
+ else {
+ lu_mem debt = cast(lu_mem, data) * 1024 - GCSTEPSIZE;
+ if (g->gcrunning)
+ debt += g->GCdebt; /* include current debt */
+ luaE_setdebt(g, debt);
+ luaC_forcestep(L);
+ if (g->gcstate == GCSpause) /* end of cycle? */
+ res = 1; /* signal it */
+ }
+ break;
+ }
+ case LUA_GCSETPAUSE: {
+ res = g->gcpause;
+ g->gcpause = data;
+ break;
+ }
+ case LUA_GCSETMAJORINC: {
+ res = g->gcmajorinc;
+ g->gcmajorinc = data;
+ break;
+ }
+ case LUA_GCSETSTEPMUL: {
+ res = g->gcstepmul;
+ g->gcstepmul = data;
+ break;
+ }
+ case LUA_GCISRUNNING: {
+ res = g->gcrunning;
+ break;
+ }
+ case LUA_GCGEN: { /* change collector to generational mode */
+ luaC_changemode(L, KGC_GEN);
+ break;
+ }
+ case LUA_GCINC: { /* change collector to incremental mode */
+ luaC_changemode(L, KGC_NORMAL);
+ break;
+ }
+ default: res = -1; /* invalid option */
+ }
+ lua_unlock(L);
+ return res;
+}
+
+
+
+/*
+** miscellaneous functions
+*/
+
+
+LUA_API int lua_error (lua_State *L) {
+ lua_lock(L);
+ api_checknelems(L, 1);
+ luaG_errormsg(L);
+ /* code unreachable; will unlock when control actually leaves the kernel */
+ return 0; /* to avoid warnings */
+}
+
+
+LUA_API int lua_next (lua_State *L, int idx) {
+ StkId t;
+ int more;
+ lua_lock(L);
+ t = index2addr(L, idx);
+ api_check(L, ttistable(t), "table expected");
+ more = luaH_next(L, hvalue(t), L->top - 1);
+ if (more) {
+ api_incr_top(L);
+ }
+ else /* no more elements */
+ L->top -= 1; /* remove key */
+ lua_unlock(L);
+ return more;
+}
+
+
+LUA_API void lua_concat (lua_State *L, int n) {
+ lua_lock(L);
+ api_checknelems(L, n);
+ if (n >= 2) {
+ luaC_checkGC(L);
+ luaV_concat(L, n);
+ }
+ else if (n == 0) { /* push empty string */
+ setsvalue2s(L, L->top, luaS_newlstr(L, "", 0));
+ api_incr_top(L);
+ }
+ /* else n == 1; nothing to do */
+ lua_unlock(L);
+}
+
+
+LUA_API void lua_len (lua_State *L, int idx) {
+ StkId t;
+ lua_lock(L);
+ t = index2addr(L, idx);
+ luaV_objlen(L, L->top, t);
+ api_incr_top(L);
+ lua_unlock(L);
+}
+
+
+LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) {
+ lua_Alloc f;
+ lua_lock(L);
+ if (ud) *ud = G(L)->ud;
+ f = G(L)->frealloc;
+ lua_unlock(L);
+ return f;
+}
+
+
+LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
+ lua_lock(L);
+ G(L)->ud = ud;
+ G(L)->frealloc = f;
+ lua_unlock(L);
+}
+
+
+LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
+ Udata *u;
+ lua_lock(L);
+ luaC_checkGC(L);
+ u = luaS_newudata(L, size, NULL);
+ setuvalue(L, L->top, u);
+ api_incr_top(L);
+ lua_unlock(L);
+ return u + 1;
+}
+
+
+
+static const char *aux_upvalue (StkId fi, int n, TValue **val,
+ GCObject **owner) {
+ switch (ttype(fi)) {
+ case LUA_TCCL: { /* C closure */
+ CClosure *f = clCvalue(fi);
+ if (!(1 <= n && n <= f->nupvalues)) return NULL;
+ *val = &f->upvalue[n-1];
+ if (owner) *owner = obj2gco(f);
+ return "";
+ }
+ case LUA_TLCL: { /* Lua closure */
+ LClosure *f = clLvalue(fi);
+ TString *name;
+ Proto *p = f->p;
+ if (!(1 <= n && n <= p->sizeupvalues)) return NULL;
+ *val = f->upvals[n-1]->v;
+ if (owner) *owner = obj2gco(f->upvals[n - 1]);
+ name = p->upvalues[n-1].name;
+ return (name == NULL) ? "" : getstr(name);
+ }
+ default: return NULL; /* not a closure */
+ }
+}
+
+
+LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
+ const char *name;
+ TValue *val = NULL; /* to avoid warnings */
+ lua_lock(L);
+ name = aux_upvalue(index2addr(L, funcindex), n, &val, NULL);
+ if (name) {
+ setobj2s(L, L->top, val);
+ api_incr_top(L);
+ }
+ lua_unlock(L);
+ return name;
+}
+
+
+LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
+ const char *name;
+ TValue *val = NULL; /* to avoid warnings */
+ GCObject *owner = NULL; /* to avoid warnings */
+ StkId fi;
+ lua_lock(L);
+ fi = index2addr(L, funcindex);
+ api_checknelems(L, 1);
+ name = aux_upvalue(fi, n, &val, &owner);
+ if (name) {
+ L->top--;
+ setobj(L, val, L->top);
+ luaC_barrier(L, owner, L->top);
+ }
+ lua_unlock(L);
+ return name;
+}
+
+
+static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) {
+ LClosure *f;
+ StkId fi = index2addr(L, fidx);
+ api_check(L, ttisLclosure(fi), "Lua function expected");
+ f = clLvalue(fi);
+ api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index");
+ if (pf) *pf = f;
+ return &f->upvals[n - 1]; /* get its upvalue pointer */
+}
+
+
+LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) {
+ StkId fi = index2addr(L, fidx);
+ switch (ttype(fi)) {
+ case LUA_TLCL: { /* lua closure */
+ return *getupvalref(L, fidx, n, NULL);
+ }
+ case LUA_TCCL: { /* C closure */
+ CClosure *f = clCvalue(fi);
+ api_check(L, 1 <= n && n <= f->nupvalues, "invalid upvalue index");
+ return &f->upvalue[n - 1];
+ }
+ default: {
+ api_check(L, 0, "closure expected");
+ return NULL;
+ }
+ }
+}
+
+
+LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1,
+ int fidx2, int n2) {
+ LClosure *f1;
+ UpVal **up1 = getupvalref(L, fidx1, n1, &f1);
+ UpVal **up2 = getupvalref(L, fidx2, n2, NULL);
+ *up1 = *up2;
+ luaC_objbarrier(L, f1, *up2);
+}
+
diff --git a/ext/lua/src/lauxlib.c b/ext/lua/src/lauxlib.c
new file mode 100644
index 0000000000..b00f8c7096
--- /dev/null
+++ b/ext/lua/src/lauxlib.c
@@ -0,0 +1,959 @@
+/*
+** $Id: lauxlib.c,v 1.248.1.1 2013/04/12 18:48:47 roberto Exp $
+** Auxiliary functions for building Lua libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+#include
+#include
+#include
+#include
+
+
+/* This file uses only the official API of Lua.
+** Any function declared here could be written as an application function.
+*/
+
+#define lauxlib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+
+
+/*
+** {======================================================
+** Traceback
+** =======================================================
+*/
+
+
+#define LEVELS1 12 /* size of the first part of the stack */
+#define LEVELS2 10 /* size of the second part of the stack */
+
+
+
+/*
+** search for 'objidx' in table at index -1.
+** return 1 + string at top if find a good name.
+*/
+static int findfield (lua_State *L, int objidx, int level) {
+ if (level == 0 || !lua_istable(L, -1))
+ return 0; /* not found */
+ lua_pushnil(L); /* start 'next' loop */
+ while (lua_next(L, -2)) { /* for each pair in table */
+ if (lua_type(L, -2) == LUA_TSTRING) { /* ignore non-string keys */
+ if (lua_rawequal(L, objidx, -1)) { /* found object? */
+ lua_pop(L, 1); /* remove value (but keep name) */
+ return 1;
+ }
+ else if (findfield(L, objidx, level - 1)) { /* try recursively */
+ lua_remove(L, -2); /* remove table (but keep name) */
+ lua_pushliteral(L, ".");
+ lua_insert(L, -2); /* place '.' between the two names */
+ lua_concat(L, 3);
+ return 1;
+ }
+ }
+ lua_pop(L, 1); /* remove value */
+ }
+ return 0; /* not found */
+}
+
+
+static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
+ int top = lua_gettop(L);
+ lua_getinfo(L, "f", ar); /* push function */
+ lua_pushglobaltable(L);
+ if (findfield(L, top + 1, 2)) {
+ lua_copy(L, -1, top + 1); /* move name to proper place */
+ lua_pop(L, 2); /* remove pushed values */
+ return 1;
+ }
+ else {
+ lua_settop(L, top); /* remove function and global table */
+ return 0;
+ }
+}
+
+
+static void pushfuncname (lua_State *L, lua_Debug *ar) {
+ if (*ar->namewhat != '\0') /* is there a name? */
+ lua_pushfstring(L, "function " LUA_QS, ar->name);
+ else if (*ar->what == 'm') /* main? */
+ lua_pushliteral(L, "main chunk");
+ else if (*ar->what == 'C') {
+ if (pushglobalfuncname(L, ar)) {
+ lua_pushfstring(L, "function " LUA_QS, lua_tostring(L, -1));
+ lua_remove(L, -2); /* remove name */
+ }
+ else
+ lua_pushliteral(L, "?");
+ }
+ else
+ lua_pushfstring(L, "function <%s:%d>", ar->short_src, ar->linedefined);
+}
+
+
+static int countlevels (lua_State *L) {
+ lua_Debug ar;
+ int li = 1, le = 1;
+ /* find an upper bound */
+ while (lua_getstack(L, le, &ar)) { li = le; le *= 2; }
+ /* do a binary search */
+ while (li < le) {
+ int m = (li + le)/2;
+ if (lua_getstack(L, m, &ar)) li = m + 1;
+ else le = m;
+ }
+ return le - 1;
+}
+
+
+LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1,
+ const char *msg, int level) {
+ lua_Debug ar;
+ int top = lua_gettop(L);
+ int numlevels = countlevels(L1);
+ int mark = (numlevels > LEVELS1 + LEVELS2) ? LEVELS1 : 0;
+ if (msg) lua_pushfstring(L, "%s\n", msg);
+ lua_pushliteral(L, "stack traceback:");
+ while (lua_getstack(L1, level++, &ar)) {
+ if (level == mark) { /* too many levels? */
+ lua_pushliteral(L, "\n\t..."); /* add a '...' */
+ level = numlevels - LEVELS2; /* and skip to last ones */
+ }
+ else {
+ lua_getinfo(L1, "Slnt", &ar);
+ lua_pushfstring(L, "\n\t%s:", ar.short_src);
+ if (ar.currentline > 0)
+ lua_pushfstring(L, "%d:", ar.currentline);
+ lua_pushliteral(L, " in ");
+ pushfuncname(L, &ar);
+ if (ar.istailcall)
+ lua_pushliteral(L, "\n\t(...tail calls...)");
+ lua_concat(L, lua_gettop(L) - top);
+ }
+ }
+ lua_concat(L, lua_gettop(L) - top);
+}
+
+/* }====================================================== */
+
+
+/*
+** {======================================================
+** Error-report functions
+** =======================================================
+*/
+
+LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
+ lua_Debug ar;
+ if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
+ return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
+ lua_getinfo(L, "n", &ar);
+ if (strcmp(ar.namewhat, "method") == 0) {
+ narg--; /* do not count `self' */
+ if (narg == 0) /* error is in the self argument itself? */
+ return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
+ ar.name, extramsg);
+ }
+ if (ar.name == NULL)
+ ar.name = (pushglobalfuncname(L, &ar)) ? lua_tostring(L, -1) : "?";
+ return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)",
+ narg, ar.name, extramsg);
+}
+
+
+static int typeerror (lua_State *L, int narg, const char *tname) {
+ const char *msg = lua_pushfstring(L, "%s expected, got %s",
+ tname, luaL_typename(L, narg));
+ return luaL_argerror(L, narg, msg);
+}
+
+
+static void tag_error (lua_State *L, int narg, int tag) {
+ typeerror(L, narg, lua_typename(L, tag));
+}
+
+
+LUALIB_API void luaL_where (lua_State *L, int level) {
+ lua_Debug ar;
+ if (lua_getstack(L, level, &ar)) { /* check function at level */
+ lua_getinfo(L, "Sl", &ar); /* get info about it */
+ if (ar.currentline > 0) { /* is there info? */
+ lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline);
+ return;
+ }
+ }
+ lua_pushliteral(L, ""); /* else, no information available... */
+}
+
+
+LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
+ va_list argp;
+ va_start(argp, fmt);
+ luaL_where(L, 1);
+ lua_pushvfstring(L, fmt, argp);
+ va_end(argp);
+ lua_concat(L, 2);
+ return lua_error(L);
+}
+
+
+LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) {
+ int en = errno; /* calls to Lua API may change this value */
+ if (stat) {
+ lua_pushboolean(L, 1);
+ return 1;
+ }
+ else {
+ lua_pushnil(L);
+ if (fname)
+ lua_pushfstring(L, "%s: %s", fname, strerror(en));
+ else
+ lua_pushstring(L, strerror(en));
+ lua_pushinteger(L, en);
+ return 3;
+ }
+}
+
+
+#if !defined(inspectstat) /* { */
+
+#if defined(LUA_USE_POSIX)
+
+#include
+
+/*
+** use appropriate macros to interpret 'pclose' return status
+*/
+#define inspectstat(stat,what) \
+ if (WIFEXITED(stat)) { stat = WEXITSTATUS(stat); } \
+ else if (WIFSIGNALED(stat)) { stat = WTERMSIG(stat); what = "signal"; }
+
+#else
+
+#define inspectstat(stat,what) /* no op */
+
+#endif
+
+#endif /* } */
+
+
+LUALIB_API int luaL_execresult (lua_State *L, int stat) {
+ const char *what = "exit"; /* type of termination */
+ if (stat == -1) /* error? */
+ return luaL_fileresult(L, 0, NULL);
+ else {
+ inspectstat(stat, what); /* interpret result */
+ if (*what == 'e' && stat == 0) /* successful termination? */
+ lua_pushboolean(L, 1);
+ else
+ lua_pushnil(L);
+ lua_pushstring(L, what);
+ lua_pushinteger(L, stat);
+ return 3; /* return true/nil,what,code */
+ }
+}
+
+/* }====================================================== */
+
+
+/*
+** {======================================================
+** Userdata's metatable manipulation
+** =======================================================
+*/
+
+LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
+ luaL_getmetatable(L, tname); /* try to get metatable */
+ if (!lua_isnil(L, -1)) /* name already in use? */
+ return 0; /* leave previous value on top, but return 0 */
+ lua_pop(L, 1);
+ lua_newtable(L); /* create metatable */
+ lua_pushvalue(L, -1);
+ lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */
+ return 1;
+}
+
+
+LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) {
+ luaL_getmetatable(L, tname);
+ lua_setmetatable(L, -2);
+}
+
+
+LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) {
+ void *p = lua_touserdata(L, ud);
+ if (p != NULL) { /* value is a userdata? */
+ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
+ luaL_getmetatable(L, tname); /* get correct metatable */
+ if (!lua_rawequal(L, -1, -2)) /* not the same? */
+ p = NULL; /* value is a userdata with wrong metatable */
+ lua_pop(L, 2); /* remove both metatables */
+ return p;
+ }
+ }
+ return NULL; /* value is not a userdata with a metatable */
+}
+
+
+LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
+ void *p = luaL_testudata(L, ud, tname);
+ if (p == NULL) typeerror(L, ud, tname);
+ return p;
+}
+
+/* }====================================================== */
+
+
+/*
+** {======================================================
+** Argument check functions
+** =======================================================
+*/
+
+LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
+ const char *const lst[]) {
+ const char *name = (def) ? luaL_optstring(L, narg, def) :
+ luaL_checkstring(L, narg);
+ int i;
+ for (i=0; lst[i]; i++)
+ if (strcmp(lst[i], name) == 0)
+ return i;
+ return luaL_argerror(L, narg,
+ lua_pushfstring(L, "invalid option " LUA_QS, name));
+}
+
+
+LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) {
+ /* keep some extra space to run error routines, if needed */
+ const int extra = LUA_MINSTACK;
+ if (!lua_checkstack(L, space + extra)) {
+ if (msg)
+ luaL_error(L, "stack overflow (%s)", msg);
+ else
+ luaL_error(L, "stack overflow");
+ }
+}
+
+
+LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
+ if (lua_type(L, narg) != t)
+ tag_error(L, narg, t);
+}
+
+
+LUALIB_API void luaL_checkany (lua_State *L, int narg) {
+ if (lua_type(L, narg) == LUA_TNONE)
+ luaL_argerror(L, narg, "value expected");
+}
+
+
+LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) {
+ const char *s = lua_tolstring(L, narg, len);
+ if (!s) tag_error(L, narg, LUA_TSTRING);
+ return s;
+}
+
+
+LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
+ const char *def, size_t *len) {
+ if (lua_isnoneornil(L, narg)) {
+ if (len)
+ *len = (def ? strlen(def) : 0);
+ return def;
+ }
+ else return luaL_checklstring(L, narg, len);
+}
+
+
+LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
+ int isnum;
+ lua_Number d = lua_tonumberx(L, narg, &isnum);
+ if (!isnum)
+ tag_error(L, narg, LUA_TNUMBER);
+ return d;
+}
+
+
+LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) {
+ return luaL_opt(L, luaL_checknumber, narg, def);
+}
+
+
+LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
+ int isnum;
+ lua_Integer d = lua_tointegerx(L, narg, &isnum);
+ if (!isnum)
+ tag_error(L, narg, LUA_TNUMBER);
+ return d;
+}
+
+
+LUALIB_API lua_Unsigned luaL_checkunsigned (lua_State *L, int narg) {
+ int isnum;
+ lua_Unsigned d = lua_tounsignedx(L, narg, &isnum);
+ if (!isnum)
+ tag_error(L, narg, LUA_TNUMBER);
+ return d;
+}
+
+
+LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg,
+ lua_Integer def) {
+ return luaL_opt(L, luaL_checkinteger, narg, def);
+}
+
+
+LUALIB_API lua_Unsigned luaL_optunsigned (lua_State *L, int narg,
+ lua_Unsigned def) {
+ return luaL_opt(L, luaL_checkunsigned, narg, def);
+}
+
+/* }====================================================== */
+
+
+/*
+** {======================================================
+** Generic Buffer manipulation
+** =======================================================
+*/
+
+/*
+** check whether buffer is using a userdata on the stack as a temporary
+** buffer
+*/
+#define buffonstack(B) ((B)->b != (B)->initb)
+
+
+/*
+** returns a pointer to a free area with at least 'sz' bytes
+*/
+LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) {
+ lua_State *L = B->L;
+ if (B->size - B->n < sz) { /* not enough space? */
+ char *newbuff;
+ size_t newsize = B->size * 2; /* double buffer size */
+ if (newsize - B->n < sz) /* not big enough? */
+ newsize = B->n + sz;
+ if (newsize < B->n || newsize - B->n < sz)
+ luaL_error(L, "buffer too large");
+ /* create larger buffer */
+ newbuff = (char *)lua_newuserdata(L, newsize * sizeof(char));
+ /* move content to new buffer */
+ memcpy(newbuff, B->b, B->n * sizeof(char));
+ if (buffonstack(B))
+ lua_remove(L, -2); /* remove old buffer */
+ B->b = newbuff;
+ B->size = newsize;
+ }
+ return &B->b[B->n];
+}
+
+
+LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
+ char *b = luaL_prepbuffsize(B, l);
+ memcpy(b, s, l * sizeof(char));
+ luaL_addsize(B, l);
+}
+
+
+LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
+ luaL_addlstring(B, s, strlen(s));
+}
+
+
+LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
+ lua_State *L = B->L;
+ lua_pushlstring(L, B->b, B->n);
+ if (buffonstack(B))
+ lua_remove(L, -2); /* remove old buffer */
+}
+
+
+LUALIB_API void luaL_pushresultsize (luaL_Buffer *B, size_t sz) {
+ luaL_addsize(B, sz);
+ luaL_pushresult(B);
+}
+
+
+LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
+ lua_State *L = B->L;
+ size_t l;
+ const char *s = lua_tolstring(L, -1, &l);
+ if (buffonstack(B))
+ lua_insert(L, -2); /* put value below buffer */
+ luaL_addlstring(B, s, l);
+ lua_remove(L, (buffonstack(B)) ? -2 : -1); /* remove value */
+}
+
+
+LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
+ B->L = L;
+ B->b = B->initb;
+ B->n = 0;
+ B->size = LUAL_BUFFERSIZE;
+}
+
+
+LUALIB_API char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz) {
+ luaL_buffinit(L, B);
+ return luaL_prepbuffsize(B, sz);
+}
+
+/* }====================================================== */
+
+
+/*
+** {======================================================
+** Reference system
+** =======================================================
+*/
+
+/* index of free-list header */
+#define freelist 0
+
+
+LUALIB_API int luaL_ref (lua_State *L, int t) {
+ int ref;
+ if (lua_isnil(L, -1)) {
+ lua_pop(L, 1); /* remove from stack */
+ return LUA_REFNIL; /* `nil' has a unique fixed reference */
+ }
+ t = lua_absindex(L, t);
+ lua_rawgeti(L, t, freelist); /* get first free element */
+ ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */
+ lua_pop(L, 1); /* remove it from stack */
+ if (ref != 0) { /* any free element? */
+ lua_rawgeti(L, t, ref); /* remove it from list */
+ lua_rawseti(L, t, freelist); /* (t[freelist] = t[ref]) */
+ }
+ else /* no free elements */
+ ref = (int)lua_rawlen(L, t) + 1; /* get a new reference */
+ lua_rawseti(L, t, ref);
+ return ref;
+}
+
+
+LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
+ if (ref >= 0) {
+ t = lua_absindex(L, t);
+ lua_rawgeti(L, t, freelist);
+ lua_rawseti(L, t, ref); /* t[ref] = t[freelist] */
+ lua_pushinteger(L, ref);
+ lua_rawseti(L, t, freelist); /* t[freelist] = ref */
+ }
+}
+
+/* }====================================================== */
+
+
+/*
+** {======================================================
+** Load functions
+** =======================================================
+*/
+
+typedef struct LoadF {
+ int n; /* number of pre-read characters */
+ FILE *f; /* file being read */
+ char buff[LUAL_BUFFERSIZE]; /* area for reading file */
+} LoadF;
+
+
+static const char *getF (lua_State *L, void *ud, size_t *size) {
+ LoadF *lf = (LoadF *)ud;
+ (void)L; /* not used */
+ if (lf->n > 0) { /* are there pre-read characters to be read? */
+ *size = lf->n; /* return them (chars already in buffer) */
+ lf->n = 0; /* no more pre-read characters */
+ }
+ else { /* read a block from file */
+ /* 'fread' can return > 0 *and* set the EOF flag. If next call to
+ 'getF' called 'fread', it might still wait for user input.
+ The next check avoids this problem. */
+ if (feof(lf->f)) return NULL;
+ *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); /* read block */
+ }
+ return lf->buff;
+}
+
+
+static int errfile (lua_State *L, const char *what, int fnameindex) {
+ const char *serr = strerror(errno);
+ const char *filename = lua_tostring(L, fnameindex) + 1;
+ lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
+ lua_remove(L, fnameindex);
+ return LUA_ERRFILE;
+}
+
+
+static int skipBOM (LoadF *lf) {
+ const char *p = "\xEF\xBB\xBF"; /* Utf8 BOM mark */
+ int c;
+ lf->n = 0;
+ do {
+ c = getc(lf->f);
+ if (c == EOF || c != *(const unsigned char *)p++) return c;
+ lf->buff[lf->n++] = c; /* to be read by the parser */
+ } while (*p != '\0');
+ lf->n = 0; /* prefix matched; discard it */
+ return getc(lf->f); /* return next character */
+}
+
+
+/*
+** reads the first character of file 'f' and skips an optional BOM mark
+** in its beginning plus its first line if it starts with '#'. Returns
+** true if it skipped the first line. In any case, '*cp' has the
+** first "valid" character of the file (after the optional BOM and
+** a first-line comment).
+*/
+static int skipcomment (LoadF *lf, int *cp) {
+ int c = *cp = skipBOM(lf);
+ if (c == '#') { /* first line is a comment (Unix exec. file)? */
+ do { /* skip first line */
+ c = getc(lf->f);
+ } while (c != EOF && c != '\n') ;
+ *cp = getc(lf->f); /* skip end-of-line, if present */
+ return 1; /* there was a comment */
+ }
+ else return 0; /* no comment */
+}
+
+
+LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename,
+ const char *mode) {
+ LoadF lf;
+ int status, readstatus;
+ int c;
+ int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
+ if (filename == NULL) {
+ lua_pushliteral(L, "=stdin");
+ lf.f = stdin;
+ }
+ else {
+ lua_pushfstring(L, "@%s", filename);
+ lf.f = fopen(filename, "r");
+ if (lf.f == NULL) return errfile(L, "open", fnameindex);
+ }
+ if (skipcomment(&lf, &c)) /* read initial portion */
+ lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */
+ if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
+ lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
+ if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
+ skipcomment(&lf, &c); /* re-read initial portion */
+ }
+ if (c != EOF)
+ lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */
+ status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode);
+ readstatus = ferror(lf.f);
+ if (filename) fclose(lf.f); /* close file (even in case of errors) */
+ if (readstatus) {
+ lua_settop(L, fnameindex); /* ignore results from `lua_load' */
+ return errfile(L, "read", fnameindex);
+ }
+ lua_remove(L, fnameindex);
+ return status;
+}
+
+
+typedef struct LoadS {
+ const char *s;
+ size_t size;
+} LoadS;
+
+
+static const char *getS (lua_State *L, void *ud, size_t *size) {
+ LoadS *ls = (LoadS *)ud;
+ (void)L; /* not used */
+ if (ls->size == 0) return NULL;
+ *size = ls->size;
+ ls->size = 0;
+ return ls->s;
+}
+
+
+LUALIB_API int luaL_loadbufferx (lua_State *L, const char *buff, size_t size,
+ const char *name, const char *mode) {
+ LoadS ls;
+ ls.s = buff;
+ ls.size = size;
+ return lua_load(L, getS, &ls, name, mode);
+}
+
+
+LUALIB_API int luaL_loadstring (lua_State *L, const char *s) {
+ return luaL_loadbuffer(L, s, strlen(s), s);
+}
+
+/* }====================================================== */
+
+
+
+LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
+ if (!lua_getmetatable(L, obj)) /* no metatable? */
+ return 0;
+ lua_pushstring(L, event);
+ lua_rawget(L, -2);
+ if (lua_isnil(L, -1)) {
+ lua_pop(L, 2); /* remove metatable and metafield */
+ return 0;
+ }
+ else {
+ lua_remove(L, -2); /* remove only metatable */
+ return 1;
+ }
+}
+
+
+LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
+ obj = lua_absindex(L, obj);
+ if (!luaL_getmetafield(L, obj, event)) /* no metafield? */
+ return 0;
+ lua_pushvalue(L, obj);
+ lua_call(L, 1, 1);
+ return 1;
+}
+
+
+LUALIB_API int luaL_len (lua_State *L, int idx) {
+ int l;
+ int isnum;
+ lua_len(L, idx);
+ l = (int)lua_tointegerx(L, -1, &isnum);
+ if (!isnum)
+ luaL_error(L, "object length is not a number");
+ lua_pop(L, 1); /* remove object */
+ return l;
+}
+
+
+LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
+ if (!luaL_callmeta(L, idx, "__tostring")) { /* no metafield? */
+ switch (lua_type(L, idx)) {
+ case LUA_TNUMBER:
+ case LUA_TSTRING:
+ lua_pushvalue(L, idx);
+ break;
+ case LUA_TBOOLEAN:
+ lua_pushstring(L, (lua_toboolean(L, idx) ? "true" : "false"));
+ break;
+ case LUA_TNIL:
+ lua_pushliteral(L, "nil");
+ break;
+ default:
+ lua_pushfstring(L, "%s: %p", luaL_typename(L, idx),
+ lua_topointer(L, idx));
+ break;
+ }
+ }
+ return lua_tolstring(L, -1, len);
+}
+
+
+/*
+** {======================================================
+** Compatibility with 5.1 module functions
+** =======================================================
+*/
+#if defined(LUA_COMPAT_MODULE)
+
+static const char *luaL_findtable (lua_State *L, int idx,
+ const char *fname, int szhint) {
+ const char *e;
+ if (idx) lua_pushvalue(L, idx);
+ do {
+ e = strchr(fname, '.');
+ if (e == NULL) e = fname + strlen(fname);
+ lua_pushlstring(L, fname, e - fname);
+ lua_rawget(L, -2);
+ if (lua_isnil(L, -1)) { /* no such field? */
+ lua_pop(L, 1); /* remove this nil */
+ lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
+ lua_pushlstring(L, fname, e - fname);
+ lua_pushvalue(L, -2);
+ lua_settable(L, -4); /* set new table into field */
+ }
+ else if (!lua_istable(L, -1)) { /* field has a non-table value? */
+ lua_pop(L, 2); /* remove table and value */
+ return fname; /* return problematic part of the name */
+ }
+ lua_remove(L, -2); /* remove previous table */
+ fname = e + 1;
+ } while (*e == '.');
+ return NULL;
+}
+
+
+/*
+** Count number of elements in a luaL_Reg list.
+*/
+static int libsize (const luaL_Reg *l) {
+ int size = 0;
+ for (; l && l->name; l++) size++;
+ return size;
+}
+
+
+/*
+** Find or create a module table with a given name. The function
+** first looks at the _LOADED table and, if that fails, try a
+** global variable with that name. In any case, leaves on the stack
+** the module table.
+*/
+LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname,
+ int sizehint) {
+ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); /* get _LOADED table */
+ lua_getfield(L, -1, modname); /* get _LOADED[modname] */
+ if (!lua_istable(L, -1)) { /* not found? */
+ lua_pop(L, 1); /* remove previous result */
+ /* try global variable (and create one if it does not exist) */
+ lua_pushglobaltable(L);
+ if (luaL_findtable(L, 0, modname, sizehint) != NULL)
+ luaL_error(L, "name conflict for module " LUA_QS, modname);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -3, modname); /* _LOADED[modname] = new table */
+ }
+ lua_remove(L, -2); /* remove _LOADED table */
+}
+
+
+LUALIB_API void luaL_openlib (lua_State *L, const char *libname,
+ const luaL_Reg *l, int nup) {
+ luaL_checkversion(L);
+ if (libname) {
+ luaL_pushmodule(L, libname, libsize(l)); /* get/create library table */
+ lua_insert(L, -(nup + 1)); /* move library table to below upvalues */
+ }
+ if (l)
+ luaL_setfuncs(L, l, nup);
+ else
+ lua_pop(L, nup); /* remove upvalues */
+}
+
+#endif
+/* }====================================================== */
+
+/*
+** set functions from list 'l' into table at top - 'nup'; each
+** function gets the 'nup' elements at the top as upvalues.
+** Returns with only the table at the stack.
+*/
+LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
+ luaL_checkversion(L);
+ luaL_checkstack(L, nup, "too many upvalues");
+ for (; l->name != NULL; l++) { /* fill the table with given functions */
+ int i;
+ for (i = 0; i < nup; i++) /* copy upvalues to the top */
+ lua_pushvalue(L, -nup);
+ lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
+ lua_setfield(L, -(nup + 2), l->name);
+ }
+ lua_pop(L, nup); /* remove upvalues */
+}
+
+
+/*
+** ensure that stack[idx][fname] has a table and push that table
+** into the stack
+*/
+LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) {
+ lua_getfield(L, idx, fname);
+ if (lua_istable(L, -1)) return 1; /* table already there */
+ else {
+ lua_pop(L, 1); /* remove previous result */
+ idx = lua_absindex(L, idx);
+ lua_newtable(L);
+ lua_pushvalue(L, -1); /* copy to be left at top */
+ lua_setfield(L, idx, fname); /* assign new table to field */
+ return 0; /* false, because did not find table there */
+ }
+}
+
+
+/*
+** stripped-down 'require'. Calls 'openf' to open a module,
+** registers the result in 'package.loaded' table and, if 'glb'
+** is true, also registers the result in the global table.
+** Leaves resulting module on the top.
+*/
+LUALIB_API void luaL_requiref (lua_State *L, const char *modname,
+ lua_CFunction openf, int glb) {
+ lua_pushcfunction(L, openf);
+ lua_pushstring(L, modname); /* argument to open function */
+ lua_call(L, 1, 1); /* open module */
+ luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
+ lua_pushvalue(L, -2); /* make copy of module (call result) */
+ lua_setfield(L, -2, modname); /* _LOADED[modname] = module */
+ lua_pop(L, 1); /* remove _LOADED table */
+ if (glb) {
+ lua_pushvalue(L, -1); /* copy of 'mod' */
+ lua_setglobal(L, modname); /* _G[modname] = module */
+ }
+}
+
+
+LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
+ const char *r) {
+ const char *wild;
+ size_t l = strlen(p);
+ luaL_Buffer b;
+ luaL_buffinit(L, &b);
+ while ((wild = strstr(s, p)) != NULL) {
+ luaL_addlstring(&b, s, wild - s); /* push prefix */
+ luaL_addstring(&b, r); /* push replacement in place of pattern */
+ s = wild + l; /* continue after `p' */
+ }
+ luaL_addstring(&b, s); /* push last suffix */
+ luaL_pushresult(&b);
+ return lua_tostring(L, -1);
+}
+
+
+static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
+ (void)ud; (void)osize; /* not used */
+ if (nsize == 0) {
+ free(ptr);
+ return NULL;
+ }
+ else
+ return realloc(ptr, nsize);
+}
+
+
+static int panic (lua_State *L) {
+ luai_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n",
+ lua_tostring(L, -1));
+ return 0; /* return to Lua to abort */
+}
+
+
+LUALIB_API lua_State *luaL_newstate (void) {
+ lua_State *L = lua_newstate(l_alloc, NULL);
+ if (L) lua_atpanic(L, &panic);
+ return L;
+}
+
+
+LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) {
+ const lua_Number *v = lua_version(L);
+ if (v != lua_version(NULL))
+ luaL_error(L, "multiple Lua VMs detected");
+ else if (*v != ver)
+ luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f",
+ ver, *v);
+ /* check conversions number -> integer types */
+ lua_pushnumber(L, -(lua_Number)0x1234);
+ if (lua_tointeger(L, -1) != -0x1234 ||
+ lua_tounsigned(L, -1) != (lua_Unsigned)-0x1234)
+ luaL_error(L, "bad conversion number->int;"
+ " must recompile Lua with proper settings");
+ lua_pop(L, 1);
+}
+
diff --git a/ext/lua/src/lbaselib.c b/ext/lua/src/lbaselib.c
new file mode 100644
index 0000000000..5255b3cd9b
--- /dev/null
+++ b/ext/lua/src/lbaselib.c
@@ -0,0 +1,458 @@
+/*
+** $Id: lbaselib.c,v 1.276.1.1 2013/04/12 18:48:47 roberto Exp $
+** Basic library
+** See Copyright Notice in lua.h
+*/
+
+
+
+#include
+#include
+#include
+#include
+
+#define lbaselib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+static int luaB_print (lua_State *L) {
+ int n = lua_gettop(L); /* number of arguments */
+ int i;
+ lua_getglobal(L, "tostring");
+ for (i=1; i<=n; i++) {
+ const char *s;
+ size_t l;
+ lua_pushvalue(L, -1); /* function to be called */
+ lua_pushvalue(L, i); /* value to print */
+ lua_call(L, 1, 1);
+ s = lua_tolstring(L, -1, &l); /* get result */
+ if (s == NULL)
+ return luaL_error(L,
+ LUA_QL("tostring") " must return a string to " LUA_QL("print"));
+ if (i>1) luai_writestring("\t", 1);
+ luai_writestring(s, l);
+ lua_pop(L, 1); /* pop result */
+ }
+ luai_writeline();
+ return 0;
+}
+
+
+#define SPACECHARS " \f\n\r\t\v"
+
+static int luaB_tonumber (lua_State *L) {
+ if (lua_isnoneornil(L, 2)) { /* standard conversion */
+ int isnum;
+ lua_Number n = lua_tonumberx(L, 1, &isnum);
+ if (isnum) {
+ lua_pushnumber(L, n);
+ return 1;
+ } /* else not a number; must be something */
+ luaL_checkany(L, 1);
+ }
+ else {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ const char *e = s + l; /* end point for 's' */
+ int base = luaL_checkint(L, 2);
+ int neg = 0;
+ luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
+ s += strspn(s, SPACECHARS); /* skip initial spaces */
+ if (*s == '-') { s++; neg = 1; } /* handle signal */
+ else if (*s == '+') s++;
+ if (isalnum((unsigned char)*s)) {
+ lua_Number n = 0;
+ do {
+ int digit = (isdigit((unsigned char)*s)) ? *s - '0'
+ : toupper((unsigned char)*s) - 'A' + 10;
+ if (digit >= base) break; /* invalid numeral; force a fail */
+ n = n * (lua_Number)base + (lua_Number)digit;
+ s++;
+ } while (isalnum((unsigned char)*s));
+ s += strspn(s, SPACECHARS); /* skip trailing spaces */
+ if (s == e) { /* no invalid trailing characters? */
+ lua_pushnumber(L, (neg) ? -n : n);
+ return 1;
+ } /* else not a number */
+ } /* else not a number */
+ }
+ lua_pushnil(L); /* not a number */
+ return 1;
+}
+
+
+static int luaB_error (lua_State *L) {
+ int level = luaL_optint(L, 2, 1);
+ lua_settop(L, 1);
+ if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
+ luaL_where(L, level);
+ lua_pushvalue(L, 1);
+ lua_concat(L, 2);
+ }
+ return lua_error(L);
+}
+
+
+static int luaB_getmetatable (lua_State *L) {
+ luaL_checkany(L, 1);
+ if (!lua_getmetatable(L, 1)) {
+ lua_pushnil(L);
+ return 1; /* no metatable */
+ }
+ luaL_getmetafield(L, 1, "__metatable");
+ return 1; /* returns either __metatable field (if present) or metatable */
+}
+
+
+static int luaB_setmetatable (lua_State *L) {
+ int t = lua_type(L, 2);
+ luaL_checktype(L, 1, LUA_TTABLE);
+ luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
+ "nil or table expected");
+ if (luaL_getmetafield(L, 1, "__metatable"))
+ return luaL_error(L, "cannot change a protected metatable");
+ lua_settop(L, 2);
+ lua_setmetatable(L, 1);
+ return 1;
+}
+
+
+static int luaB_rawequal (lua_State *L) {
+ luaL_checkany(L, 1);
+ luaL_checkany(L, 2);
+ lua_pushboolean(L, lua_rawequal(L, 1, 2));
+ return 1;
+}
+
+
+static int luaB_rawlen (lua_State *L) {
+ int t = lua_type(L, 1);
+ luaL_argcheck(L, t == LUA_TTABLE || t == LUA_TSTRING, 1,
+ "table or string expected");
+ lua_pushinteger(L, lua_rawlen(L, 1));
+ return 1;
+}
+
+
+static int luaB_rawget (lua_State *L) {
+ luaL_checktype(L, 1, LUA_TTABLE);
+ luaL_checkany(L, 2);
+ lua_settop(L, 2);
+ lua_rawget(L, 1);
+ return 1;
+}
+
+static int luaB_rawset (lua_State *L) {
+ luaL_checktype(L, 1, LUA_TTABLE);
+ luaL_checkany(L, 2);
+ luaL_checkany(L, 3);
+ lua_settop(L, 3);
+ lua_rawset(L, 1);
+ return 1;
+}
+
+
+static int luaB_collectgarbage (lua_State *L) {
+ static const char *const opts[] = {"stop", "restart", "collect",
+ "count", "step", "setpause", "setstepmul",
+ "setmajorinc", "isrunning", "generational", "incremental", NULL};
+ static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
+ LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL,
+ LUA_GCSETMAJORINC, LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC};
+ int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
+ int ex = luaL_optint(L, 2, 0);
+ int res = lua_gc(L, o, ex);
+ switch (o) {
+ case LUA_GCCOUNT: {
+ int b = lua_gc(L, LUA_GCCOUNTB, 0);
+ lua_pushnumber(L, res + ((lua_Number)b/1024));
+ lua_pushinteger(L, b);
+ return 2;
+ }
+ case LUA_GCSTEP: case LUA_GCISRUNNING: {
+ lua_pushboolean(L, res);
+ return 1;
+ }
+ default: {
+ lua_pushinteger(L, res);
+ return 1;
+ }
+ }
+}
+
+
+static int luaB_type (lua_State *L) {
+ luaL_checkany(L, 1);
+ lua_pushstring(L, luaL_typename(L, 1));
+ return 1;
+}
+
+
+static int pairsmeta (lua_State *L, const char *method, int iszero,
+ lua_CFunction iter) {
+ if (!luaL_getmetafield(L, 1, method)) { /* no metamethod? */
+ luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */
+ lua_pushcfunction(L, iter); /* will return generator, */
+ lua_pushvalue(L, 1); /* state, */
+ if (iszero) lua_pushinteger(L, 0); /* and initial value */
+ else lua_pushnil(L);
+ }
+ else {
+ lua_pushvalue(L, 1); /* argument 'self' to metamethod */
+ lua_call(L, 1, 3); /* get 3 values from metamethod */
+ }
+ return 3;
+}
+
+
+static int luaB_next (lua_State *L) {
+ luaL_checktype(L, 1, LUA_TTABLE);
+ lua_settop(L, 2); /* create a 2nd argument if there isn't one */
+ if (lua_next(L, 1))
+ return 2;
+ else {
+ lua_pushnil(L);
+ return 1;
+ }
+}
+
+
+static int luaB_pairs (lua_State *L) {
+ return pairsmeta(L, "__pairs", 0, luaB_next);
+}
+
+
+static int ipairsaux (lua_State *L) {
+ int i = luaL_checkint(L, 2);
+ luaL_checktype(L, 1, LUA_TTABLE);
+ i++; /* next value */
+ lua_pushinteger(L, i);
+ lua_rawgeti(L, 1, i);
+ return (lua_isnil(L, -1)) ? 1 : 2;
+}
+
+
+static int luaB_ipairs (lua_State *L) {
+ return pairsmeta(L, "__ipairs", 1, ipairsaux);
+}
+
+
+static int load_aux (lua_State *L, int status, int envidx) {
+ if (status == LUA_OK) {
+ if (envidx != 0) { /* 'env' parameter? */
+ lua_pushvalue(L, envidx); /* environment for loaded function */
+ if (!lua_setupvalue(L, -2, 1)) /* set it as 1st upvalue */
+ lua_pop(L, 1); /* remove 'env' if not used by previous call */
+ }
+ return 1;
+ }
+ else { /* error (message is on top of the stack) */
+ lua_pushnil(L);
+ lua_insert(L, -2); /* put before error message */
+ return 2; /* return nil plus error message */
+ }
+}
+
+
+static int luaB_loadfile (lua_State *L) {
+ const char *fname = luaL_optstring(L, 1, NULL);
+ const char *mode = luaL_optstring(L, 2, NULL);
+ int env = (!lua_isnone(L, 3) ? 3 : 0); /* 'env' index or 0 if no 'env' */
+ int status = luaL_loadfilex(L, fname, mode);
+ return load_aux(L, status, env);
+}
+
+
+/*
+** {======================================================
+** Generic Read function
+** =======================================================
+*/
+
+
+/*
+** reserved slot, above all arguments, to hold a copy of the returned
+** string to avoid it being collected while parsed. 'load' has four
+** optional arguments (chunk, source name, mode, and environment).
+*/
+#define RESERVEDSLOT 5
+
+
+/*
+** Reader for generic `load' function: `lua_load' uses the
+** stack for internal stuff, so the reader cannot change the
+** stack top. Instead, it keeps its resulting string in a
+** reserved slot inside the stack.
+*/
+static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
+ (void)(ud); /* not used */
+ luaL_checkstack(L, 2, "too many nested functions");
+ lua_pushvalue(L, 1); /* get function */
+ lua_call(L, 0, 1); /* call it */
+ if (lua_isnil(L, -1)) {
+ lua_pop(L, 1); /* pop result */
+ *size = 0;
+ return NULL;
+ }
+ else if (!lua_isstring(L, -1))
+ luaL_error(L, "reader function must return a string");
+ lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */
+ return lua_tolstring(L, RESERVEDSLOT, size);
+}
+
+
+static int luaB_load (lua_State *L) {
+ int status;
+ size_t l;
+ const char *s = lua_tolstring(L, 1, &l);
+ const char *mode = luaL_optstring(L, 3, "bt");
+ int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */
+ if (s != NULL) { /* loading a string? */
+ const char *chunkname = luaL_optstring(L, 2, s);
+ status = luaL_loadbufferx(L, s, l, chunkname, mode);
+ }
+ else { /* loading from a reader function */
+ const char *chunkname = luaL_optstring(L, 2, "=(load)");
+ luaL_checktype(L, 1, LUA_TFUNCTION);
+ lua_settop(L, RESERVEDSLOT); /* create reserved slot */
+ status = lua_load(L, generic_reader, NULL, chunkname, mode);
+ }
+ return load_aux(L, status, env);
+}
+
+/* }====================================================== */
+
+
+static int dofilecont (lua_State *L) {
+ return lua_gettop(L) - 1;
+}
+
+
+static int luaB_dofile (lua_State *L) {
+ const char *fname = luaL_optstring(L, 1, NULL);
+ lua_settop(L, 1);
+ if (luaL_loadfile(L, fname) != LUA_OK)
+ return lua_error(L);
+ lua_callk(L, 0, LUA_MULTRET, 0, dofilecont);
+ return dofilecont(L);
+}
+
+
+static int luaB_assert (lua_State *L) {
+ if (!lua_toboolean(L, 1))
+ return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!"));
+ return lua_gettop(L);
+}
+
+
+static int luaB_select (lua_State *L) {
+ int n = lua_gettop(L);
+ if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') {
+ lua_pushinteger(L, n-1);
+ return 1;
+ }
+ else {
+ int i = luaL_checkint(L, 1);
+ if (i < 0) i = n + i;
+ else if (i > n) i = n;
+ luaL_argcheck(L, 1 <= i, 1, "index out of range");
+ return n - i;
+ }
+}
+
+
+static int finishpcall (lua_State *L, int status) {
+ if (!lua_checkstack(L, 1)) { /* no space for extra boolean? */
+ lua_settop(L, 0); /* create space for return values */
+ lua_pushboolean(L, 0);
+ lua_pushstring(L, "stack overflow");
+ return 2; /* return false, msg */
+ }
+ lua_pushboolean(L, status); /* first result (status) */
+ lua_replace(L, 1); /* put first result in first slot */
+ return lua_gettop(L);
+}
+
+
+static int pcallcont (lua_State *L) {
+ int status = lua_getctx(L, NULL);
+ return finishpcall(L, (status == LUA_YIELD));
+}
+
+
+static int luaB_pcall (lua_State *L) {
+ int status;
+ luaL_checkany(L, 1);
+ lua_pushnil(L);
+ lua_insert(L, 1); /* create space for status result */
+ status = lua_pcallk(L, lua_gettop(L) - 2, LUA_MULTRET, 0, 0, pcallcont);
+ return finishpcall(L, (status == LUA_OK));
+}
+
+
+static int luaB_xpcall (lua_State *L) {
+ int status;
+ int n = lua_gettop(L);
+ luaL_argcheck(L, n >= 2, 2, "value expected");
+ lua_pushvalue(L, 1); /* exchange function... */
+ lua_copy(L, 2, 1); /* ...and error handler */
+ lua_replace(L, 2);
+ status = lua_pcallk(L, n - 2, LUA_MULTRET, 1, 0, pcallcont);
+ return finishpcall(L, (status == LUA_OK));
+}
+
+
+static int luaB_tostring (lua_State *L) {
+ luaL_checkany(L, 1);
+ luaL_tolstring(L, 1, NULL);
+ return 1;
+}
+
+
+static const luaL_Reg base_funcs[] = {
+ {"assert", luaB_assert},
+ {"collectgarbage", luaB_collectgarbage},
+ {"dofile", luaB_dofile},
+ {"error", luaB_error},
+ {"getmetatable", luaB_getmetatable},
+ {"ipairs", luaB_ipairs},
+ {"loadfile", luaB_loadfile},
+ {"load", luaB_load},
+#if defined(LUA_COMPAT_LOADSTRING)
+ {"loadstring", luaB_load},
+#endif
+ {"next", luaB_next},
+ {"pairs", luaB_pairs},
+ {"pcall", luaB_pcall},
+ {"print", luaB_print},
+ {"rawequal", luaB_rawequal},
+ {"rawlen", luaB_rawlen},
+ {"rawget", luaB_rawget},
+ {"rawset", luaB_rawset},
+ {"select", luaB_select},
+ {"setmetatable", luaB_setmetatable},
+ {"tonumber", luaB_tonumber},
+ {"tostring", luaB_tostring},
+ {"type", luaB_type},
+ {"xpcall", luaB_xpcall},
+ {NULL, NULL}
+};
+
+
+LUAMOD_API int luaopen_base (lua_State *L) {
+ /* set global _G */
+ lua_pushglobaltable(L);
+ lua_pushglobaltable(L);
+ lua_setfield(L, -2, "_G");
+ /* open lib into global table */
+ luaL_setfuncs(L, base_funcs, 0);
+ lua_pushliteral(L, LUA_VERSION);
+ lua_setfield(L, -2, "_VERSION"); /* set global _VERSION */
+ return 1;
+}
+
diff --git a/ext/lua/src/lbitlib.c b/ext/lua/src/lbitlib.c
new file mode 100644
index 0000000000..31c7b66f12
--- /dev/null
+++ b/ext/lua/src/lbitlib.c
@@ -0,0 +1,212 @@
+/*
+** $Id: lbitlib.c,v 1.18.1.2 2013/07/09 18:01:41 roberto Exp $
+** Standard library for bitwise operations
+** See Copyright Notice in lua.h
+*/
+
+#define lbitlib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+/* number of bits to consider in a number */
+#if !defined(LUA_NBITS)
+#define LUA_NBITS 32
+#endif
+
+
+#define ALLONES (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1))
+
+/* macro to trim extra bits */
+#define trim(x) ((x) & ALLONES)
+
+
+/* builds a number with 'n' ones (1 <= n <= LUA_NBITS) */
+#define mask(n) (~((ALLONES << 1) << ((n) - 1)))
+
+
+typedef lua_Unsigned b_uint;
+
+
+
+static b_uint andaux (lua_State *L) {
+ int i, n = lua_gettop(L);
+ b_uint r = ~(b_uint)0;
+ for (i = 1; i <= n; i++)
+ r &= luaL_checkunsigned(L, i);
+ return trim(r);
+}
+
+
+static int b_and (lua_State *L) {
+ b_uint r = andaux(L);
+ lua_pushunsigned(L, r);
+ return 1;
+}
+
+
+static int b_test (lua_State *L) {
+ b_uint r = andaux(L);
+ lua_pushboolean(L, r != 0);
+ return 1;
+}
+
+
+static int b_or (lua_State *L) {
+ int i, n = lua_gettop(L);
+ b_uint r = 0;
+ for (i = 1; i <= n; i++)
+ r |= luaL_checkunsigned(L, i);
+ lua_pushunsigned(L, trim(r));
+ return 1;
+}
+
+
+static int b_xor (lua_State *L) {
+ int i, n = lua_gettop(L);
+ b_uint r = 0;
+ for (i = 1; i <= n; i++)
+ r ^= luaL_checkunsigned(L, i);
+ lua_pushunsigned(L, trim(r));
+ return 1;
+}
+
+
+static int b_not (lua_State *L) {
+ b_uint r = ~luaL_checkunsigned(L, 1);
+ lua_pushunsigned(L, trim(r));
+ return 1;
+}
+
+
+static int b_shift (lua_State *L, b_uint r, int i) {
+ if (i < 0) { /* shift right? */
+ i = -i;
+ r = trim(r);
+ if (i >= LUA_NBITS) r = 0;
+ else r >>= i;
+ }
+ else { /* shift left */
+ if (i >= LUA_NBITS) r = 0;
+ else r <<= i;
+ r = trim(r);
+ }
+ lua_pushunsigned(L, r);
+ return 1;
+}
+
+
+static int b_lshift (lua_State *L) {
+ return b_shift(L, luaL_checkunsigned(L, 1), luaL_checkint(L, 2));
+}
+
+
+static int b_rshift (lua_State *L) {
+ return b_shift(L, luaL_checkunsigned(L, 1), -luaL_checkint(L, 2));
+}
+
+
+static int b_arshift (lua_State *L) {
+ b_uint r = luaL_checkunsigned(L, 1);
+ int i = luaL_checkint(L, 2);
+ if (i < 0 || !(r & ((b_uint)1 << (LUA_NBITS - 1))))
+ return b_shift(L, r, -i);
+ else { /* arithmetic shift for 'negative' number */
+ if (i >= LUA_NBITS) r = ALLONES;
+ else
+ r = trim((r >> i) | ~(~(b_uint)0 >> i)); /* add signal bit */
+ lua_pushunsigned(L, r);
+ return 1;
+ }
+}
+
+
+static int b_rot (lua_State *L, int i) {
+ b_uint r = luaL_checkunsigned(L, 1);
+ i &= (LUA_NBITS - 1); /* i = i % NBITS */
+ r = trim(r);
+ if (i != 0) /* avoid undefined shift of LUA_NBITS when i == 0 */
+ r = (r << i) | (r >> (LUA_NBITS - i));
+ lua_pushunsigned(L, trim(r));
+ return 1;
+}
+
+
+static int b_lrot (lua_State *L) {
+ return b_rot(L, luaL_checkint(L, 2));
+}
+
+
+static int b_rrot (lua_State *L) {
+ return b_rot(L, -luaL_checkint(L, 2));
+}
+
+
+/*
+** get field and width arguments for field-manipulation functions,
+** checking whether they are valid.
+** ('luaL_error' called without 'return' to avoid later warnings about
+** 'width' being used uninitialized.)
+*/
+static int fieldargs (lua_State *L, int farg, int *width) {
+ int f = luaL_checkint(L, farg);
+ int w = luaL_optint(L, farg + 1, 1);
+ luaL_argcheck(L, 0 <= f, farg, "field cannot be negative");
+ luaL_argcheck(L, 0 < w, farg + 1, "width must be positive");
+ if (f + w > LUA_NBITS)
+ luaL_error(L, "trying to access non-existent bits");
+ *width = w;
+ return f;
+}
+
+
+static int b_extract (lua_State *L) {
+ int w;
+ b_uint r = luaL_checkunsigned(L, 1);
+ int f = fieldargs(L, 2, &w);
+ r = (r >> f) & mask(w);
+ lua_pushunsigned(L, r);
+ return 1;
+}
+
+
+static int b_replace (lua_State *L) {
+ int w;
+ b_uint r = luaL_checkunsigned(L, 1);
+ b_uint v = luaL_checkunsigned(L, 2);
+ int f = fieldargs(L, 3, &w);
+ int m = mask(w);
+ v &= m; /* erase bits outside given width */
+ r = (r & ~(m << f)) | (v << f);
+ lua_pushunsigned(L, r);
+ return 1;
+}
+
+
+static const luaL_Reg bitlib[] = {
+ {"arshift", b_arshift},
+ {"band", b_and},
+ {"bnot", b_not},
+ {"bor", b_or},
+ {"bxor", b_xor},
+ {"btest", b_test},
+ {"extract", b_extract},
+ {"lrotate", b_lrot},
+ {"lshift", b_lshift},
+ {"replace", b_replace},
+ {"rrotate", b_rrot},
+ {"rshift", b_rshift},
+ {NULL, NULL}
+};
+
+
+
+LUAMOD_API int luaopen_bit32 (lua_State *L) {
+ luaL_newlib(L, bitlib);
+ return 1;
+}
+
diff --git a/ext/lua/src/lcode.c b/ext/lua/src/lcode.c
new file mode 100644
index 0000000000..820b95c0e1
--- /dev/null
+++ b/ext/lua/src/lcode.c
@@ -0,0 +1,881 @@
+/*
+** $Id: lcode.c,v 2.62.1.1 2013/04/12 18:48:47 roberto Exp $
+** Code generator for Lua
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+
+#define lcode_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lcode.h"
+#include "ldebug.h"
+#include "ldo.h"
+#include "lgc.h"
+#include "llex.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lopcodes.h"
+#include "lparser.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "lvm.h"
+
+
+#define hasjumps(e) ((e)->t != (e)->f)
+
+
+static int isnumeral(expdesc *e) {
+ return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
+}
+
+
+void luaK_nil (FuncState *fs, int from, int n) {
+ Instruction *previous;
+ int l = from + n - 1; /* last register to set nil */
+ if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
+ previous = &fs->f->code[fs->pc-1];
+ if (GET_OPCODE(*previous) == OP_LOADNIL) {
+ int pfrom = GETARG_A(*previous);
+ int pl = pfrom + GETARG_B(*previous);
+ if ((pfrom <= from && from <= pl + 1) ||
+ (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */
+ if (pfrom < from) from = pfrom; /* from = min(from, pfrom) */
+ if (pl > l) l = pl; /* l = max(l, pl) */
+ SETARG_A(*previous, from);
+ SETARG_B(*previous, l - from);
+ return;
+ }
+ } /* else go through */
+ }
+ luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0); /* else no optimization */
+}
+
+
+int luaK_jump (FuncState *fs) {
+ int jpc = fs->jpc; /* save list of jumps to here */
+ int j;
+ fs->jpc = NO_JUMP;
+ j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
+ luaK_concat(fs, &j, jpc); /* keep them on hold */
+ return j;
+}
+
+
+void luaK_ret (FuncState *fs, int first, int nret) {
+ luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
+}
+
+
+static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
+ luaK_codeABC(fs, op, A, B, C);
+ return luaK_jump(fs);
+}
+
+
+static void fixjump (FuncState *fs, int pc, int dest) {
+ Instruction *jmp = &fs->f->code[pc];
+ int offset = dest-(pc+1);
+ lua_assert(dest != NO_JUMP);
+ if (abs(offset) > MAXARG_sBx)
+ luaX_syntaxerror(fs->ls, "control structure too long");
+ SETARG_sBx(*jmp, offset);
+}
+
+
+/*
+** returns current `pc' and marks it as a jump target (to avoid wrong
+** optimizations with consecutive instructions not in the same basic block).
+*/
+int luaK_getlabel (FuncState *fs) {
+ fs->lasttarget = fs->pc;
+ return fs->pc;
+}
+
+
+static int getjump (FuncState *fs, int pc) {
+ int offset = GETARG_sBx(fs->f->code[pc]);
+ if (offset == NO_JUMP) /* point to itself represents end of list */
+ return NO_JUMP; /* end of list */
+ else
+ return (pc+1)+offset; /* turn offset into absolute position */
+}
+
+
+static Instruction *getjumpcontrol (FuncState *fs, int pc) {
+ Instruction *pi = &fs->f->code[pc];
+ if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
+ return pi-1;
+ else
+ return pi;
+}
+
+
+/*
+** check whether list has any jump that do not produce a value
+** (or produce an inverted value)
+*/
+static int need_value (FuncState *fs, int list) {
+ for (; list != NO_JUMP; list = getjump(fs, list)) {
+ Instruction i = *getjumpcontrol(fs, list);
+ if (GET_OPCODE(i) != OP_TESTSET) return 1;
+ }
+ return 0; /* not found */
+}
+
+
+static int patchtestreg (FuncState *fs, int node, int reg) {
+ Instruction *i = getjumpcontrol(fs, node);
+ if (GET_OPCODE(*i) != OP_TESTSET)
+ return 0; /* cannot patch other instructions */
+ if (reg != NO_REG && reg != GETARG_B(*i))
+ SETARG_A(*i, reg);
+ else /* no register to put value or register already has the value */
+ *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));
+
+ return 1;
+}
+
+
+static void removevalues (FuncState *fs, int list) {
+ for (; list != NO_JUMP; list = getjump(fs, list))
+ patchtestreg(fs, list, NO_REG);
+}
+
+
+static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
+ int dtarget) {
+ while (list != NO_JUMP) {
+ int next = getjump(fs, list);
+ if (patchtestreg(fs, list, reg))
+ fixjump(fs, list, vtarget);
+ else
+ fixjump(fs, list, dtarget); /* jump to default target */
+ list = next;
+ }
+}
+
+
+static void dischargejpc (FuncState *fs) {
+ patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
+ fs->jpc = NO_JUMP;
+}
+
+
+void luaK_patchlist (FuncState *fs, int list, int target) {
+ if (target == fs->pc)
+ luaK_patchtohere(fs, list);
+ else {
+ lua_assert(target < fs->pc);
+ patchlistaux(fs, list, target, NO_REG, target);
+ }
+}
+
+
+LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level) {
+ level++; /* argument is +1 to reserve 0 as non-op */
+ while (list != NO_JUMP) {
+ int next = getjump(fs, list);
+ lua_assert(GET_OPCODE(fs->f->code[list]) == OP_JMP &&
+ (GETARG_A(fs->f->code[list]) == 0 ||
+ GETARG_A(fs->f->code[list]) >= level));
+ SETARG_A(fs->f->code[list], level);
+ list = next;
+ }
+}
+
+
+void luaK_patchtohere (FuncState *fs, int list) {
+ luaK_getlabel(fs);
+ luaK_concat(fs, &fs->jpc, list);
+}
+
+
+void luaK_concat (FuncState *fs, int *l1, int l2) {
+ if (l2 == NO_JUMP) return;
+ else if (*l1 == NO_JUMP)
+ *l1 = l2;
+ else {
+ int list = *l1;
+ int next;
+ while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */
+ list = next;
+ fixjump(fs, list, l2);
+ }
+}
+
+
+static int luaK_code (FuncState *fs, Instruction i) {
+ Proto *f = fs->f;
+ dischargejpc(fs); /* `pc' will change */
+ /* put new instruction in code array */
+ luaM_growvector(fs->ls->L, f->code, fs->pc, f->sizecode, Instruction,
+ MAX_INT, "opcodes");
+ f->code[fs->pc] = i;
+ /* save corresponding line information */
+ luaM_growvector(fs->ls->L, f->lineinfo, fs->pc, f->sizelineinfo, int,
+ MAX_INT, "opcodes");
+ f->lineinfo[fs->pc] = fs->ls->lastline;
+ return fs->pc++;
+}
+
+
+int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
+ lua_assert(getOpMode(o) == iABC);
+ lua_assert(getBMode(o) != OpArgN || b == 0);
+ lua_assert(getCMode(o) != OpArgN || c == 0);
+ lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C);
+ return luaK_code(fs, CREATE_ABC(o, a, b, c));
+}
+
+
+int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
+ lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
+ lua_assert(getCMode(o) == OpArgN);
+ lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx);
+ return luaK_code(fs, CREATE_ABx(o, a, bc));
+}
+
+
+static int codeextraarg (FuncState *fs, int a) {
+ lua_assert(a <= MAXARG_Ax);
+ return luaK_code(fs, CREATE_Ax(OP_EXTRAARG, a));
+}
+
+
+int luaK_codek (FuncState *fs, int reg, int k) {
+ if (k <= MAXARG_Bx)
+ return luaK_codeABx(fs, OP_LOADK, reg, k);
+ else {
+ int p = luaK_codeABx(fs, OP_LOADKX, reg, 0);
+ codeextraarg(fs, k);
+ return p;
+ }
+}
+
+
+void luaK_checkstack (FuncState *fs, int n) {
+ int newstack = fs->freereg + n;
+ if (newstack > fs->f->maxstacksize) {
+ if (newstack >= MAXSTACK)
+ luaX_syntaxerror(fs->ls, "function or expression too complex");
+ fs->f->maxstacksize = cast_byte(newstack);
+ }
+}
+
+
+void luaK_reserveregs (FuncState *fs, int n) {
+ luaK_checkstack(fs, n);
+ fs->freereg += n;
+}
+
+
+static void freereg (FuncState *fs, int reg) {
+ if (!ISK(reg) && reg >= fs->nactvar) {
+ fs->freereg--;
+ lua_assert(reg == fs->freereg);
+ }
+}
+
+
+static void freeexp (FuncState *fs, expdesc *e) {
+ if (e->k == VNONRELOC)
+ freereg(fs, e->u.info);
+}
+
+
+static int addk (FuncState *fs, TValue *key, TValue *v) {
+ lua_State *L = fs->ls->L;
+ TValue *idx = luaH_set(L, fs->h, key);
+ Proto *f = fs->f;
+ int k, oldsize;
+ if (ttisnumber(idx)) {
+ lua_Number n = nvalue(idx);
+ lua_number2int(k, n);
+ if (luaV_rawequalobj(&f->k[k], v))
+ return k;
+ /* else may be a collision (e.g., between 0.0 and "\0\0\0\0\0\0\0\0");
+ go through and create a new entry for this value */
+ }
+ /* constant not found; create a new entry */
+ oldsize = f->sizek;
+ k = fs->nk;
+ /* numerical value does not need GC barrier;
+ table has no metatable, so it does not need to invalidate cache */
+ setnvalue(idx, cast_num(k));
+ luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants");
+ while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
+ setobj(L, &f->k[k], v);
+ fs->nk++;
+ luaC_barrier(L, f, v);
+ return k;
+}
+
+
+int luaK_stringK (FuncState *fs, TString *s) {
+ TValue o;
+ setsvalue(fs->ls->L, &o, s);
+ return addk(fs, &o, &o);
+}
+
+
+int luaK_numberK (FuncState *fs, lua_Number r) {
+ int n;
+ lua_State *L = fs->ls->L;
+ TValue o;
+ setnvalue(&o, r);
+ if (r == 0 || luai_numisnan(NULL, r)) { /* handle -0 and NaN */
+ /* use raw representation as key to avoid numeric problems */
+ setsvalue(L, L->top++, luaS_newlstr(L, (char *)&r, sizeof(r)));
+ n = addk(fs, L->top - 1, &o);
+ L->top--;
+ }
+ else
+ n = addk(fs, &o, &o); /* regular case */
+ return n;
+}
+
+
+static int boolK (FuncState *fs, int b) {
+ TValue o;
+ setbvalue(&o, b);
+ return addk(fs, &o, &o);
+}
+
+
+static int nilK (FuncState *fs) {
+ TValue k, v;
+ setnilvalue(&v);
+ /* cannot use nil as key; instead use table itself to represent nil */
+ sethvalue(fs->ls->L, &k, fs->h);
+ return addk(fs, &k, &v);
+}
+
+
+void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
+ if (e->k == VCALL) { /* expression is an open function call? */
+ SETARG_C(getcode(fs, e), nresults+1);
+ }
+ else if (e->k == VVARARG) {
+ SETARG_B(getcode(fs, e), nresults+1);
+ SETARG_A(getcode(fs, e), fs->freereg);
+ luaK_reserveregs(fs, 1);
+ }
+}
+
+
+void luaK_setoneret (FuncState *fs, expdesc *e) {
+ if (e->k == VCALL) { /* expression is an open function call? */
+ e->k = VNONRELOC;
+ e->u.info = GETARG_A(getcode(fs, e));
+ }
+ else if (e->k == VVARARG) {
+ SETARG_B(getcode(fs, e), 2);
+ e->k = VRELOCABLE; /* can relocate its simple result */
+ }
+}
+
+
+void luaK_dischargevars (FuncState *fs, expdesc *e) {
+ switch (e->k) {
+ case VLOCAL: {
+ e->k = VNONRELOC;
+ break;
+ }
+ case VUPVAL: {
+ e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0);
+ e->k = VRELOCABLE;
+ break;
+ }
+ case VINDEXED: {
+ OpCode op = OP_GETTABUP; /* assume 't' is in an upvalue */
+ freereg(fs, e->u.ind.idx);
+ if (e->u.ind.vt == VLOCAL) { /* 't' is in a register? */
+ freereg(fs, e->u.ind.t);
+ op = OP_GETTABLE;
+ }
+ e->u.info = luaK_codeABC(fs, op, 0, e->u.ind.t, e->u.ind.idx);
+ e->k = VRELOCABLE;
+ break;
+ }
+ case VVARARG:
+ case VCALL: {
+ luaK_setoneret(fs, e);
+ break;
+ }
+ default: break; /* there is one value available (somewhere) */
+ }
+}
+
+
+static int code_label (FuncState *fs, int A, int b, int jump) {
+ luaK_getlabel(fs); /* those instructions may be jump targets */
+ return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
+}
+
+
+static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
+ luaK_dischargevars(fs, e);
+ switch (e->k) {
+ case VNIL: {
+ luaK_nil(fs, reg, 1);
+ break;
+ }
+ case VFALSE: case VTRUE: {
+ luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0);
+ break;
+ }
+ case VK: {
+ luaK_codek(fs, reg, e->u.info);
+ break;
+ }
+ case VKNUM: {
+ luaK_codek(fs, reg, luaK_numberK(fs, e->u.nval));
+ break;
+ }
+ case VRELOCABLE: {
+ Instruction *pc = &getcode(fs, e);
+ SETARG_A(*pc, reg);
+ break;
+ }
+ case VNONRELOC: {
+ if (reg != e->u.info)
+ luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0);
+ break;
+ }
+ default: {
+ lua_assert(e->k == VVOID || e->k == VJMP);
+ return; /* nothing to do... */
+ }
+ }
+ e->u.info = reg;
+ e->k = VNONRELOC;
+}
+
+
+static void discharge2anyreg (FuncState *fs, expdesc *e) {
+ if (e->k != VNONRELOC) {
+ luaK_reserveregs(fs, 1);
+ discharge2reg(fs, e, fs->freereg-1);
+ }
+}
+
+
+static void exp2reg (FuncState *fs, expdesc *e, int reg) {
+ discharge2reg(fs, e, reg);
+ if (e->k == VJMP)
+ luaK_concat(fs, &e->t, e->u.info); /* put this jump in `t' list */
+ if (hasjumps(e)) {
+ int final; /* position after whole expression */
+ int p_f = NO_JUMP; /* position of an eventual LOAD false */
+ int p_t = NO_JUMP; /* position of an eventual LOAD true */
+ if (need_value(fs, e->t) || need_value(fs, e->f)) {
+ int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs);
+ p_f = code_label(fs, reg, 0, 1);
+ p_t = code_label(fs, reg, 1, 0);
+ luaK_patchtohere(fs, fj);
+ }
+ final = luaK_getlabel(fs);
+ patchlistaux(fs, e->f, final, reg, p_f);
+ patchlistaux(fs, e->t, final, reg, p_t);
+ }
+ e->f = e->t = NO_JUMP;
+ e->u.info = reg;
+ e->k = VNONRELOC;
+}
+
+
+void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
+ luaK_dischargevars(fs, e);
+ freeexp(fs, e);
+ luaK_reserveregs(fs, 1);
+ exp2reg(fs, e, fs->freereg - 1);
+}
+
+
+int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
+ luaK_dischargevars(fs, e);
+ if (e->k == VNONRELOC) {
+ if (!hasjumps(e)) return e->u.info; /* exp is already in a register */
+ if (e->u.info >= fs->nactvar) { /* reg. is not a local? */
+ exp2reg(fs, e, e->u.info); /* put value on it */
+ return e->u.info;
+ }
+ }
+ luaK_exp2nextreg(fs, e); /* default */
+ return e->u.info;
+}
+
+
+void luaK_exp2anyregup (FuncState *fs, expdesc *e) {
+ if (e->k != VUPVAL || hasjumps(e))
+ luaK_exp2anyreg(fs, e);
+}
+
+
+void luaK_exp2val (FuncState *fs, expdesc *e) {
+ if (hasjumps(e))
+ luaK_exp2anyreg(fs, e);
+ else
+ luaK_dischargevars(fs, e);
+}
+
+
+int luaK_exp2RK (FuncState *fs, expdesc *e) {
+ luaK_exp2val(fs, e);
+ switch (e->k) {
+ case VTRUE:
+ case VFALSE:
+ case VNIL: {
+ if (fs->nk <= MAXINDEXRK) { /* constant fits in RK operand? */
+ e->u.info = (e->k == VNIL) ? nilK(fs) : boolK(fs, (e->k == VTRUE));
+ e->k = VK;
+ return RKASK(e->u.info);
+ }
+ else break;
+ }
+ case VKNUM: {
+ e->u.info = luaK_numberK(fs, e->u.nval);
+ e->k = VK;
+ /* go through */
+ }
+ case VK: {
+ if (e->u.info <= MAXINDEXRK) /* constant fits in argC? */
+ return RKASK(e->u.info);
+ else break;
+ }
+ default: break;
+ }
+ /* not a constant in the right range: put it in a register */
+ return luaK_exp2anyreg(fs, e);
+}
+
+
+void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
+ switch (var->k) {
+ case VLOCAL: {
+ freeexp(fs, ex);
+ exp2reg(fs, ex, var->u.info);
+ return;
+ }
+ case VUPVAL: {
+ int e = luaK_exp2anyreg(fs, ex);
+ luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0);
+ break;
+ }
+ case VINDEXED: {
+ OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE : OP_SETTABUP;
+ int e = luaK_exp2RK(fs, ex);
+ luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e);
+ break;
+ }
+ default: {
+ lua_assert(0); /* invalid var kind to store */
+ break;
+ }
+ }
+ freeexp(fs, ex);
+}
+
+
+void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
+ int ereg;
+ luaK_exp2anyreg(fs, e);
+ ereg = e->u.info; /* register where 'e' was placed */
+ freeexp(fs, e);
+ e->u.info = fs->freereg; /* base register for op_self */
+ e->k = VNONRELOC;
+ luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */
+ luaK_codeABC(fs, OP_SELF, e->u.info, ereg, luaK_exp2RK(fs, key));
+ freeexp(fs, key);
+}
+
+
+static void invertjump (FuncState *fs, expdesc *e) {
+ Instruction *pc = getjumpcontrol(fs, e->u.info);
+ lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
+ GET_OPCODE(*pc) != OP_TEST);
+ SETARG_A(*pc, !(GETARG_A(*pc)));
+}
+
+
+static int jumponcond (FuncState *fs, expdesc *e, int cond) {
+ if (e->k == VRELOCABLE) {
+ Instruction ie = getcode(fs, e);
+ if (GET_OPCODE(ie) == OP_NOT) {
+ fs->pc--; /* remove previous OP_NOT */
+ return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond);
+ }
+ /* else go through */
+ }
+ discharge2anyreg(fs, e);
+ freeexp(fs, e);
+ return condjump(fs, OP_TESTSET, NO_REG, e->u.info, cond);
+}
+
+
+void luaK_goiftrue (FuncState *fs, expdesc *e) {
+ int pc; /* pc of last jump */
+ luaK_dischargevars(fs, e);
+ switch (e->k) {
+ case VJMP: {
+ invertjump(fs, e);
+ pc = e->u.info;
+ break;
+ }
+ case VK: case VKNUM: case VTRUE: {
+ pc = NO_JUMP; /* always true; do nothing */
+ break;
+ }
+ default: {
+ pc = jumponcond(fs, e, 0);
+ break;
+ }
+ }
+ luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */
+ luaK_patchtohere(fs, e->t);
+ e->t = NO_JUMP;
+}
+
+
+void luaK_goiffalse (FuncState *fs, expdesc *e) {
+ int pc; /* pc of last jump */
+ luaK_dischargevars(fs, e);
+ switch (e->k) {
+ case VJMP: {
+ pc = e->u.info;
+ break;
+ }
+ case VNIL: case VFALSE: {
+ pc = NO_JUMP; /* always false; do nothing */
+ break;
+ }
+ default: {
+ pc = jumponcond(fs, e, 1);
+ break;
+ }
+ }
+ luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */
+ luaK_patchtohere(fs, e->f);
+ e->f = NO_JUMP;
+}
+
+
+static void codenot (FuncState *fs, expdesc *e) {
+ luaK_dischargevars(fs, e);
+ switch (e->k) {
+ case VNIL: case VFALSE: {
+ e->k = VTRUE;
+ break;
+ }
+ case VK: case VKNUM: case VTRUE: {
+ e->k = VFALSE;
+ break;
+ }
+ case VJMP: {
+ invertjump(fs, e);
+ break;
+ }
+ case VRELOCABLE:
+ case VNONRELOC: {
+ discharge2anyreg(fs, e);
+ freeexp(fs, e);
+ e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0);
+ e->k = VRELOCABLE;
+ break;
+ }
+ default: {
+ lua_assert(0); /* cannot happen */
+ break;
+ }
+ }
+ /* interchange true and false lists */
+ { int temp = e->f; e->f = e->t; e->t = temp; }
+ removevalues(fs, e->f);
+ removevalues(fs, e->t);
+}
+
+
+void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
+ lua_assert(!hasjumps(t));
+ t->u.ind.t = t->u.info;
+ t->u.ind.idx = luaK_exp2RK(fs, k);
+ t->u.ind.vt = (t->k == VUPVAL) ? VUPVAL
+ : check_exp(vkisinreg(t->k), VLOCAL);
+ t->k = VINDEXED;
+}
+
+
+static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
+ lua_Number r;
+ if (!isnumeral(e1) || !isnumeral(e2)) return 0;
+ if ((op == OP_DIV || op == OP_MOD) && e2->u.nval == 0)
+ return 0; /* do not attempt to divide by 0 */
+ r = luaO_arith(op - OP_ADD + LUA_OPADD, e1->u.nval, e2->u.nval);
+ e1->u.nval = r;
+ return 1;
+}
+
+
+static void codearith (FuncState *fs, OpCode op,
+ expdesc *e1, expdesc *e2, int line) {
+ if (constfolding(op, e1, e2))
+ return;
+ else {
+ int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0;
+ int o1 = luaK_exp2RK(fs, e1);
+ if (o1 > o2) {
+ freeexp(fs, e1);
+ freeexp(fs, e2);
+ }
+ else {
+ freeexp(fs, e2);
+ freeexp(fs, e1);
+ }
+ e1->u.info = luaK_codeABC(fs, op, 0, o1, o2);
+ e1->k = VRELOCABLE;
+ luaK_fixline(fs, line);
+ }
+}
+
+
+static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
+ expdesc *e2) {
+ int o1 = luaK_exp2RK(fs, e1);
+ int o2 = luaK_exp2RK(fs, e2);
+ freeexp(fs, e2);
+ freeexp(fs, e1);
+ if (cond == 0 && op != OP_EQ) {
+ int temp; /* exchange args to replace by `<' or `<=' */
+ temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */
+ cond = 1;
+ }
+ e1->u.info = condjump(fs, op, cond, o1, o2);
+ e1->k = VJMP;
+}
+
+
+void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) {
+ expdesc e2;
+ e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
+ switch (op) {
+ case OPR_MINUS: {
+ if (isnumeral(e)) /* minus constant? */
+ e->u.nval = luai_numunm(NULL, e->u.nval); /* fold it */
+ else {
+ luaK_exp2anyreg(fs, e);
+ codearith(fs, OP_UNM, e, &e2, line);
+ }
+ break;
+ }
+ case OPR_NOT: codenot(fs, e); break;
+ case OPR_LEN: {
+ luaK_exp2anyreg(fs, e); /* cannot operate on constants */
+ codearith(fs, OP_LEN, e, &e2, line);
+ break;
+ }
+ default: lua_assert(0);
+ }
+}
+
+
+void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
+ switch (op) {
+ case OPR_AND: {
+ luaK_goiftrue(fs, v);
+ break;
+ }
+ case OPR_OR: {
+ luaK_goiffalse(fs, v);
+ break;
+ }
+ case OPR_CONCAT: {
+ luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */
+ break;
+ }
+ case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
+ case OPR_MOD: case OPR_POW: {
+ if (!isnumeral(v)) luaK_exp2RK(fs, v);
+ break;
+ }
+ default: {
+ luaK_exp2RK(fs, v);
+ break;
+ }
+ }
+}
+
+
+void luaK_posfix (FuncState *fs, BinOpr op,
+ expdesc *e1, expdesc *e2, int line) {
+ switch (op) {
+ case OPR_AND: {
+ lua_assert(e1->t == NO_JUMP); /* list must be closed */
+ luaK_dischargevars(fs, e2);
+ luaK_concat(fs, &e2->f, e1->f);
+ *e1 = *e2;
+ break;
+ }
+ case OPR_OR: {
+ lua_assert(e1->f == NO_JUMP); /* list must be closed */
+ luaK_dischargevars(fs, e2);
+ luaK_concat(fs, &e2->t, e1->t);
+ *e1 = *e2;
+ break;
+ }
+ case OPR_CONCAT: {
+ luaK_exp2val(fs, e2);
+ if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) {
+ lua_assert(e1->u.info == GETARG_B(getcode(fs, e2))-1);
+ freeexp(fs, e1);
+ SETARG_B(getcode(fs, e2), e1->u.info);
+ e1->k = VRELOCABLE; e1->u.info = e2->u.info;
+ }
+ else {
+ luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */
+ codearith(fs, OP_CONCAT, e1, e2, line);
+ }
+ break;
+ }
+ case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
+ case OPR_MOD: case OPR_POW: {
+ codearith(fs, cast(OpCode, op - OPR_ADD + OP_ADD), e1, e2, line);
+ break;
+ }
+ case OPR_EQ: case OPR_LT: case OPR_LE: {
+ codecomp(fs, cast(OpCode, op - OPR_EQ + OP_EQ), 1, e1, e2);
+ break;
+ }
+ case OPR_NE: case OPR_GT: case OPR_GE: {
+ codecomp(fs, cast(OpCode, op - OPR_NE + OP_EQ), 0, e1, e2);
+ break;
+ }
+ default: lua_assert(0);
+ }
+}
+
+
+void luaK_fixline (FuncState *fs, int line) {
+ fs->f->lineinfo[fs->pc - 1] = line;
+}
+
+
+void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
+ int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
+ int b = (tostore == LUA_MULTRET) ? 0 : tostore;
+ lua_assert(tostore != 0);
+ if (c <= MAXARG_C)
+ luaK_codeABC(fs, OP_SETLIST, base, b, c);
+ else if (c <= MAXARG_Ax) {
+ luaK_codeABC(fs, OP_SETLIST, base, b, 0);
+ codeextraarg(fs, c);
+ }
+ else
+ luaX_syntaxerror(fs->ls, "constructor too long");
+ fs->freereg = base + 1; /* free registers with list values */
+}
+
diff --git a/ext/lua/src/lcorolib.c b/ext/lua/src/lcorolib.c
new file mode 100644
index 0000000000..ce4f6ad42c
--- /dev/null
+++ b/ext/lua/src/lcorolib.c
@@ -0,0 +1,155 @@
+/*
+** $Id: lcorolib.c,v 1.5.1.1 2013/04/12 18:48:47 roberto Exp $
+** Coroutine Library
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+
+
+#define lcorolib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+static int auxresume (lua_State *L, lua_State *co, int narg) {
+ int status;
+ if (!lua_checkstack(co, narg)) {
+ lua_pushliteral(L, "too many arguments to resume");
+ return -1; /* error flag */
+ }
+ if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) {
+ lua_pushliteral(L, "cannot resume dead coroutine");
+ return -1; /* error flag */
+ }
+ lua_xmove(L, co, narg);
+ status = lua_resume(co, L, narg);
+ if (status == LUA_OK || status == LUA_YIELD) {
+ int nres = lua_gettop(co);
+ if (!lua_checkstack(L, nres + 1)) {
+ lua_pop(co, nres); /* remove results anyway */
+ lua_pushliteral(L, "too many results to resume");
+ return -1; /* error flag */
+ }
+ lua_xmove(co, L, nres); /* move yielded values */
+ return nres;
+ }
+ else {
+ lua_xmove(co, L, 1); /* move error message */
+ return -1; /* error flag */
+ }
+}
+
+
+static int luaB_coresume (lua_State *L) {
+ lua_State *co = lua_tothread(L, 1);
+ int r;
+ luaL_argcheck(L, co, 1, "coroutine expected");
+ r = auxresume(L, co, lua_gettop(L) - 1);
+ if (r < 0) {
+ lua_pushboolean(L, 0);
+ lua_insert(L, -2);
+ return 2; /* return false + error message */
+ }
+ else {
+ lua_pushboolean(L, 1);
+ lua_insert(L, -(r + 1));
+ return r + 1; /* return true + `resume' returns */
+ }
+}
+
+
+static int luaB_auxwrap (lua_State *L) {
+ lua_State *co = lua_tothread(L, lua_upvalueindex(1));
+ int r = auxresume(L, co, lua_gettop(L));
+ if (r < 0) {
+ if (lua_isstring(L, -1)) { /* error object is a string? */
+ luaL_where(L, 1); /* add extra info */
+ lua_insert(L, -2);
+ lua_concat(L, 2);
+ }
+ return lua_error(L); /* propagate error */
+ }
+ return r;
+}
+
+
+static int luaB_cocreate (lua_State *L) {
+ lua_State *NL;
+ luaL_checktype(L, 1, LUA_TFUNCTION);
+ NL = lua_newthread(L);
+ lua_pushvalue(L, 1); /* move function to top */
+ lua_xmove(L, NL, 1); /* move function from L to NL */
+ return 1;
+}
+
+
+static int luaB_cowrap (lua_State *L) {
+ luaB_cocreate(L);
+ lua_pushcclosure(L, luaB_auxwrap, 1);
+ return 1;
+}
+
+
+static int luaB_yield (lua_State *L) {
+ return lua_yield(L, lua_gettop(L));
+}
+
+
+static int luaB_costatus (lua_State *L) {
+ lua_State *co = lua_tothread(L, 1);
+ luaL_argcheck(L, co, 1, "coroutine expected");
+ if (L == co) lua_pushliteral(L, "running");
+ else {
+ switch (lua_status(co)) {
+ case LUA_YIELD:
+ lua_pushliteral(L, "suspended");
+ break;
+ case LUA_OK: {
+ lua_Debug ar;
+ if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
+ lua_pushliteral(L, "normal"); /* it is running */
+ else if (lua_gettop(co) == 0)
+ lua_pushliteral(L, "dead");
+ else
+ lua_pushliteral(L, "suspended"); /* initial state */
+ break;
+ }
+ default: /* some error occurred */
+ lua_pushliteral(L, "dead");
+ break;
+ }
+ }
+ return 1;
+}
+
+
+static int luaB_corunning (lua_State *L) {
+ int ismain = lua_pushthread(L);
+ lua_pushboolean(L, ismain);
+ return 2;
+}
+
+
+static const luaL_Reg co_funcs[] = {
+ {"create", luaB_cocreate},
+ {"resume", luaB_coresume},
+ {"running", luaB_corunning},
+ {"status", luaB_costatus},
+ {"wrap", luaB_cowrap},
+ {"yield", luaB_yield},
+ {NULL, NULL}
+};
+
+
+
+LUAMOD_API int luaopen_coroutine (lua_State *L) {
+ luaL_newlib(L, co_funcs);
+ return 1;
+}
+
diff --git a/ext/lua/src/lctype.c b/ext/lua/src/lctype.c
new file mode 100644
index 0000000000..93f8cadc39
--- /dev/null
+++ b/ext/lua/src/lctype.c
@@ -0,0 +1,52 @@
+/*
+** $Id: lctype.c,v 1.11.1.1 2013/04/12 18:48:47 roberto Exp $
+** 'ctype' functions for Lua
+** See Copyright Notice in lua.h
+*/
+
+#define lctype_c
+#define LUA_CORE
+
+#include "lctype.h"
+
+#if !LUA_USE_CTYPE /* { */
+
+#include
+
+LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = {
+ 0x00, /* EOZ */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */
+ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */
+ 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */
+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */
+ 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05,
+ 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */
+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */
+ 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+#endif /* } */
diff --git a/ext/lua/src/ldblib.c b/ext/lua/src/ldblib.c
new file mode 100644
index 0000000000..84fe3c7d82
--- /dev/null
+++ b/ext/lua/src/ldblib.c
@@ -0,0 +1,398 @@
+/*
+** $Id: ldblib.c,v 1.132.1.1 2013/04/12 18:48:47 roberto Exp $
+** Interface from Lua to its debug API
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+#include
+#include
+
+#define ldblib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+#define HOOKKEY "_HKEY"
+
+
+
+static int db_getregistry (lua_State *L) {
+ lua_pushvalue(L, LUA_REGISTRYINDEX);
+ return 1;
+}
+
+
+static int db_getmetatable (lua_State *L) {
+ luaL_checkany(L, 1);
+ if (!lua_getmetatable(L, 1)) {
+ lua_pushnil(L); /* no metatable */
+ }
+ return 1;
+}
+
+
+static int db_setmetatable (lua_State *L) {
+ int t = lua_type(L, 2);
+ luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
+ "nil or table expected");
+ lua_settop(L, 2);
+ lua_setmetatable(L, 1);
+ return 1; /* return 1st argument */
+}
+
+
+static int db_getuservalue (lua_State *L) {
+ if (lua_type(L, 1) != LUA_TUSERDATA)
+ lua_pushnil(L);
+ else
+ lua_getuservalue(L, 1);
+ return 1;
+}
+
+
+static int db_setuservalue (lua_State *L) {
+ if (lua_type(L, 1) == LUA_TLIGHTUSERDATA)
+ luaL_argerror(L, 1, "full userdata expected, got light userdata");
+ luaL_checktype(L, 1, LUA_TUSERDATA);
+ if (!lua_isnoneornil(L, 2))
+ luaL_checktype(L, 2, LUA_TTABLE);
+ lua_settop(L, 2);
+ lua_setuservalue(L, 1);
+ return 1;
+}
+
+
+static void settabss (lua_State *L, const char *i, const char *v) {
+ lua_pushstring(L, v);
+ lua_setfield(L, -2, i);
+}
+
+
+static void settabsi (lua_State *L, const char *i, int v) {
+ lua_pushinteger(L, v);
+ lua_setfield(L, -2, i);
+}
+
+
+static void settabsb (lua_State *L, const char *i, int v) {
+ lua_pushboolean(L, v);
+ lua_setfield(L, -2, i);
+}
+
+
+static lua_State *getthread (lua_State *L, int *arg) {
+ if (lua_isthread(L, 1)) {
+ *arg = 1;
+ return lua_tothread(L, 1);
+ }
+ else {
+ *arg = 0;
+ return L;
+ }
+}
+
+
+static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) {
+ if (L == L1) {
+ lua_pushvalue(L, -2);
+ lua_remove(L, -3);
+ }
+ else
+ lua_xmove(L1, L, 1);
+ lua_setfield(L, -2, fname);
+}
+
+
+static int db_getinfo (lua_State *L) {
+ lua_Debug ar;
+ int arg;
+ lua_State *L1 = getthread(L, &arg);
+ const char *options = luaL_optstring(L, arg+2, "flnStu");
+ if (lua_isnumber(L, arg+1)) {
+ if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) {
+ lua_pushnil(L); /* level out of range */
+ return 1;
+ }
+ }
+ else if (lua_isfunction(L, arg+1)) {
+ lua_pushfstring(L, ">%s", options);
+ options = lua_tostring(L, -1);
+ lua_pushvalue(L, arg+1);
+ lua_xmove(L, L1, 1);
+ }
+ else
+ return luaL_argerror(L, arg+1, "function or level expected");
+ if (!lua_getinfo(L1, options, &ar))
+ return luaL_argerror(L, arg+2, "invalid option");
+ lua_createtable(L, 0, 2);
+ if (strchr(options, 'S')) {
+ settabss(L, "source", ar.source);
+ settabss(L, "short_src", ar.short_src);
+ settabsi(L, "linedefined", ar.linedefined);
+ settabsi(L, "lastlinedefined", ar.lastlinedefined);
+ settabss(L, "what", ar.what);
+ }
+ if (strchr(options, 'l'))
+ settabsi(L, "currentline", ar.currentline);
+ if (strchr(options, 'u')) {
+ settabsi(L, "nups", ar.nups);
+ settabsi(L, "nparams", ar.nparams);
+ settabsb(L, "isvararg", ar.isvararg);
+ }
+ if (strchr(options, 'n')) {
+ settabss(L, "name", ar.name);
+ settabss(L, "namewhat", ar.namewhat);
+ }
+ if (strchr(options, 't'))
+ settabsb(L, "istailcall", ar.istailcall);
+ if (strchr(options, 'L'))
+ treatstackoption(L, L1, "activelines");
+ if (strchr(options, 'f'))
+ treatstackoption(L, L1, "func");
+ return 1; /* return table */
+}
+
+
+static int db_getlocal (lua_State *L) {
+ int arg;
+ lua_State *L1 = getthread(L, &arg);
+ lua_Debug ar;
+ const char *name;
+ int nvar = luaL_checkint(L, arg+2); /* local-variable index */
+ if (lua_isfunction(L, arg + 1)) { /* function argument? */
+ lua_pushvalue(L, arg + 1); /* push function */
+ lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */
+ return 1;
+ }
+ else { /* stack-level argument */
+ if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */
+ return luaL_argerror(L, arg+1, "level out of range");
+ name = lua_getlocal(L1, &ar, nvar);
+ if (name) {
+ lua_xmove(L1, L, 1); /* push local value */
+ lua_pushstring(L, name); /* push name */
+ lua_pushvalue(L, -2); /* re-order */
+ return 2;
+ }
+ else {
+ lua_pushnil(L); /* no name (nor value) */
+ return 1;
+ }
+ }
+}
+
+
+static int db_setlocal (lua_State *L) {
+ int arg;
+ lua_State *L1 = getthread(L, &arg);
+ lua_Debug ar;
+ if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */
+ return luaL_argerror(L, arg+1, "level out of range");
+ luaL_checkany(L, arg+3);
+ lua_settop(L, arg+3);
+ lua_xmove(L, L1, 1);
+ lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2)));
+ return 1;
+}
+
+
+static int auxupvalue (lua_State *L, int get) {
+ const char *name;
+ int n = luaL_checkint(L, 2);
+ luaL_checktype(L, 1, LUA_TFUNCTION);
+ name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n);
+ if (name == NULL) return 0;
+ lua_pushstring(L, name);
+ lua_insert(L, -(get+1));
+ return get + 1;
+}
+
+
+static int db_getupvalue (lua_State *L) {
+ return auxupvalue(L, 1);
+}
+
+
+static int db_setupvalue (lua_State *L) {
+ luaL_checkany(L, 3);
+ return auxupvalue(L, 0);
+}
+
+
+static int checkupval (lua_State *L, int argf, int argnup) {
+ lua_Debug ar;
+ int nup = luaL_checkint(L, argnup);
+ luaL_checktype(L, argf, LUA_TFUNCTION);
+ lua_pushvalue(L, argf);
+ lua_getinfo(L, ">u", &ar);
+ luaL_argcheck(L, 1 <= nup && nup <= ar.nups, argnup, "invalid upvalue index");
+ return nup;
+}
+
+
+static int db_upvalueid (lua_State *L) {
+ int n = checkupval(L, 1, 2);
+ lua_pushlightuserdata(L, lua_upvalueid(L, 1, n));
+ return 1;
+}
+
+
+static int db_upvaluejoin (lua_State *L) {
+ int n1 = checkupval(L, 1, 2);
+ int n2 = checkupval(L, 3, 4);
+ luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected");
+ luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected");
+ lua_upvaluejoin(L, 1, n1, 3, n2);
+ return 0;
+}
+
+
+#define gethooktable(L) luaL_getsubtable(L, LUA_REGISTRYINDEX, HOOKKEY)
+
+
+static void hookf (lua_State *L, lua_Debug *ar) {
+ static const char *const hooknames[] =
+ {"call", "return", "line", "count", "tail call"};
+ gethooktable(L);
+ lua_pushthread(L);
+ lua_rawget(L, -2);
+ if (lua_isfunction(L, -1)) {
+ lua_pushstring(L, hooknames[(int)ar->event]);
+ if (ar->currentline >= 0)
+ lua_pushinteger(L, ar->currentline);
+ else lua_pushnil(L);
+ lua_assert(lua_getinfo(L, "lS", ar));
+ lua_call(L, 2, 0);
+ }
+}
+
+
+static int makemask (const char *smask, int count) {
+ int mask = 0;
+ if (strchr(smask, 'c')) mask |= LUA_MASKCALL;
+ if (strchr(smask, 'r')) mask |= LUA_MASKRET;
+ if (strchr(smask, 'l')) mask |= LUA_MASKLINE;
+ if (count > 0) mask |= LUA_MASKCOUNT;
+ return mask;
+}
+
+
+static char *unmakemask (int mask, char *smask) {
+ int i = 0;
+ if (mask & LUA_MASKCALL) smask[i++] = 'c';
+ if (mask & LUA_MASKRET) smask[i++] = 'r';
+ if (mask & LUA_MASKLINE) smask[i++] = 'l';
+ smask[i] = '\0';
+ return smask;
+}
+
+
+static int db_sethook (lua_State *L) {
+ int arg, mask, count;
+ lua_Hook func;
+ lua_State *L1 = getthread(L, &arg);
+ if (lua_isnoneornil(L, arg+1)) {
+ lua_settop(L, arg+1);
+ func = NULL; mask = 0; count = 0; /* turn off hooks */
+ }
+ else {
+ const char *smask = luaL_checkstring(L, arg+2);
+ luaL_checktype(L, arg+1, LUA_TFUNCTION);
+ count = luaL_optint(L, arg+3, 0);
+ func = hookf; mask = makemask(smask, count);
+ }
+ if (gethooktable(L) == 0) { /* creating hook table? */
+ lua_pushstring(L, "k");
+ lua_setfield(L, -2, "__mode"); /** hooktable.__mode = "k" */
+ lua_pushvalue(L, -1);
+ lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */
+ }
+ lua_pushthread(L1); lua_xmove(L1, L, 1);
+ lua_pushvalue(L, arg+1);
+ lua_rawset(L, -3); /* set new hook */
+ lua_sethook(L1, func, mask, count); /* set hooks */
+ return 0;
+}
+
+
+static int db_gethook (lua_State *L) {
+ int arg;
+ lua_State *L1 = getthread(L, &arg);
+ char buff[5];
+ int mask = lua_gethookmask(L1);
+ lua_Hook hook = lua_gethook(L1);
+ if (hook != NULL && hook != hookf) /* external hook? */
+ lua_pushliteral(L, "external hook");
+ else {
+ gethooktable(L);
+ lua_pushthread(L1); lua_xmove(L1, L, 1);
+ lua_rawget(L, -2); /* get hook */
+ lua_remove(L, -2); /* remove hook table */
+ }
+ lua_pushstring(L, unmakemask(mask, buff));
+ lua_pushinteger(L, lua_gethookcount(L1));
+ return 3;
+}
+
+
+static int db_debug (lua_State *L) {
+ for (;;) {
+ char buffer[250];
+ luai_writestringerror("%s", "lua_debug> ");
+ if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
+ strcmp(buffer, "cont\n") == 0)
+ return 0;
+ if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
+ lua_pcall(L, 0, 0, 0))
+ luai_writestringerror("%s\n", lua_tostring(L, -1));
+ lua_settop(L, 0); /* remove eventual returns */
+ }
+}
+
+
+static int db_traceback (lua_State *L) {
+ int arg;
+ lua_State *L1 = getthread(L, &arg);
+ const char *msg = lua_tostring(L, arg + 1);
+ if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */
+ lua_pushvalue(L, arg + 1); /* return it untouched */
+ else {
+ int level = luaL_optint(L, arg + 2, (L == L1) ? 1 : 0);
+ luaL_traceback(L, L1, msg, level);
+ }
+ return 1;
+}
+
+
+static const luaL_Reg dblib[] = {
+ {"debug", db_debug},
+ {"getuservalue", db_getuservalue},
+ {"gethook", db_gethook},
+ {"getinfo", db_getinfo},
+ {"getlocal", db_getlocal},
+ {"getregistry", db_getregistry},
+ {"getmetatable", db_getmetatable},
+ {"getupvalue", db_getupvalue},
+ {"upvaluejoin", db_upvaluejoin},
+ {"upvalueid", db_upvalueid},
+ {"setuservalue", db_setuservalue},
+ {"sethook", db_sethook},
+ {"setlocal", db_setlocal},
+ {"setmetatable", db_setmetatable},
+ {"setupvalue", db_setupvalue},
+ {"traceback", db_traceback},
+ {NULL, NULL}
+};
+
+
+LUAMOD_API int luaopen_debug (lua_State *L) {
+ luaL_newlib(L, dblib);
+ return 1;
+}
+
diff --git a/ext/lua/src/ldebug.c b/ext/lua/src/ldebug.c
new file mode 100644
index 0000000000..20d663efff
--- /dev/null
+++ b/ext/lua/src/ldebug.c
@@ -0,0 +1,593 @@
+/*
+** $Id: ldebug.c,v 2.90.1.3 2013/05/16 16:04:15 roberto Exp $
+** Debug Interface
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+#include
+#include
+
+
+#define ldebug_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lapi.h"
+#include "lcode.h"
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lobject.h"
+#include "lopcodes.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+#include "lvm.h"
+
+
+
+#define noLuaClosure(f) ((f) == NULL || (f)->c.tt == LUA_TCCL)
+
+
+static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
+
+
+static int currentpc (CallInfo *ci) {
+ lua_assert(isLua(ci));
+ return pcRel(ci->u.l.savedpc, ci_func(ci)->p);
+}
+
+
+static int currentline (CallInfo *ci) {
+ return getfuncline(ci_func(ci)->p, currentpc(ci));
+}
+
+
+/*
+** this function can be called asynchronous (e.g. during a signal)
+*/
+LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
+ if (func == NULL || mask == 0) { /* turn off hooks? */
+ mask = 0;
+ func = NULL;
+ }
+ if (isLua(L->ci))
+ L->oldpc = L->ci->u.l.savedpc;
+ L->hook = func;
+ L->basehookcount = count;
+ resethookcount(L);
+ L->hookmask = cast_byte(mask);
+ return 1;
+}
+
+
+LUA_API lua_Hook lua_gethook (lua_State *L) {
+ return L->hook;
+}
+
+
+LUA_API int lua_gethookmask (lua_State *L) {
+ return L->hookmask;
+}
+
+
+LUA_API int lua_gethookcount (lua_State *L) {
+ return L->basehookcount;
+}
+
+
+LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
+ int status;
+ CallInfo *ci;
+ if (level < 0) return 0; /* invalid (negative) level */
+ lua_lock(L);
+ for (ci = L->ci; level > 0 && ci != &L->base_ci; ci = ci->previous)
+ level--;
+ if (level == 0 && ci != &L->base_ci) { /* level found? */
+ status = 1;
+ ar->i_ci = ci;
+ }
+ else status = 0; /* no such level */
+ lua_unlock(L);
+ return status;
+}
+
+
+static const char *upvalname (Proto *p, int uv) {
+ TString *s = check_exp(uv < p->sizeupvalues, p->upvalues[uv].name);
+ if (s == NULL) return "?";
+ else return getstr(s);
+}
+
+
+static const char *findvararg (CallInfo *ci, int n, StkId *pos) {
+ int nparams = clLvalue(ci->func)->p->numparams;
+ if (n >= ci->u.l.base - ci->func - nparams)
+ return NULL; /* no such vararg */
+ else {
+ *pos = ci->func + nparams + n;
+ return "(*vararg)"; /* generic name for any vararg */
+ }
+}
+
+
+static const char *findlocal (lua_State *L, CallInfo *ci, int n,
+ StkId *pos) {
+ const char *name = NULL;
+ StkId base;
+ if (isLua(ci)) {
+ if (n < 0) /* access to vararg values? */
+ return findvararg(ci, -n, pos);
+ else {
+ base = ci->u.l.base;
+ name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci));
+ }
+ }
+ else
+ base = ci->func + 1;
+ if (name == NULL) { /* no 'standard' name? */
+ StkId limit = (ci == L->ci) ? L->top : ci->next->func;
+ if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */
+ name = "(*temporary)"; /* generic name for any valid slot */
+ else
+ return NULL; /* no name */
+ }
+ *pos = base + (n - 1);
+ return name;
+}
+
+
+LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
+ const char *name;
+ lua_lock(L);
+ if (ar == NULL) { /* information about non-active function? */
+ if (!isLfunction(L->top - 1)) /* not a Lua function? */
+ name = NULL;
+ else /* consider live variables at function start (parameters) */
+ name = luaF_getlocalname(clLvalue(L->top - 1)->p, n, 0);
+ }
+ else { /* active function; get information through 'ar' */
+ StkId pos = 0; /* to avoid warnings */
+ name = findlocal(L, ar->i_ci, n, &pos);
+ if (name) {
+ setobj2s(L, L->top, pos);
+ api_incr_top(L);
+ }
+ }
+ lua_unlock(L);
+ return name;
+}
+
+
+LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
+ StkId pos = 0; /* to avoid warnings */
+ const char *name = findlocal(L, ar->i_ci, n, &pos);
+ lua_lock(L);
+ if (name)
+ setobjs2s(L, pos, L->top - 1);
+ L->top--; /* pop value */
+ lua_unlock(L);
+ return name;
+}
+
+
+static void funcinfo (lua_Debug *ar, Closure *cl) {
+ if (noLuaClosure(cl)) {
+ ar->source = "=[C]";
+ ar->linedefined = -1;
+ ar->lastlinedefined = -1;
+ ar->what = "C";
+ }
+ else {
+ Proto *p = cl->l.p;
+ ar->source = p->source ? getstr(p->source) : "=?";
+ ar->linedefined = p->linedefined;
+ ar->lastlinedefined = p->lastlinedefined;
+ ar->what = (ar->linedefined == 0) ? "main" : "Lua";
+ }
+ luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
+}
+
+
+static void collectvalidlines (lua_State *L, Closure *f) {
+ if (noLuaClosure(f)) {
+ setnilvalue(L->top);
+ api_incr_top(L);
+ }
+ else {
+ int i;
+ TValue v;
+ int *lineinfo = f->l.p->lineinfo;
+ Table *t = luaH_new(L); /* new table to store active lines */
+ sethvalue(L, L->top, t); /* push it on stack */
+ api_incr_top(L);
+ setbvalue(&v, 1); /* boolean 'true' to be the value of all indices */
+ for (i = 0; i < f->l.p->sizelineinfo; i++) /* for all lines with code */
+ luaH_setint(L, t, lineinfo[i], &v); /* table[line] = true */
+ }
+}
+
+
+static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
+ Closure *f, CallInfo *ci) {
+ int status = 1;
+ for (; *what; what++) {
+ switch (*what) {
+ case 'S': {
+ funcinfo(ar, f);
+ break;
+ }
+ case 'l': {
+ ar->currentline = (ci && isLua(ci)) ? currentline(ci) : -1;
+ break;
+ }
+ case 'u': {
+ ar->nups = (f == NULL) ? 0 : f->c.nupvalues;
+ if (noLuaClosure(f)) {
+ ar->isvararg = 1;
+ ar->nparams = 0;
+ }
+ else {
+ ar->isvararg = f->l.p->is_vararg;
+ ar->nparams = f->l.p->numparams;
+ }
+ break;
+ }
+ case 't': {
+ ar->istailcall = (ci) ? ci->callstatus & CIST_TAIL : 0;
+ break;
+ }
+ case 'n': {
+ /* calling function is a known Lua function? */
+ if (ci && !(ci->callstatus & CIST_TAIL) && isLua(ci->previous))
+ ar->namewhat = getfuncname(L, ci->previous, &ar->name);
+ else
+ ar->namewhat = NULL;
+ if (ar->namewhat == NULL) {
+ ar->namewhat = ""; /* not found */
+ ar->name = NULL;
+ }
+ break;
+ }
+ case 'L':
+ case 'f': /* handled by lua_getinfo */
+ break;
+ default: status = 0; /* invalid option */
+ }
+ }
+ return status;
+}
+
+
+LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
+ int status;
+ Closure *cl;
+ CallInfo *ci;
+ StkId func;
+ lua_lock(L);
+ if (*what == '>') {
+ ci = NULL;
+ func = L->top - 1;
+ api_check(L, ttisfunction(func), "function expected");
+ what++; /* skip the '>' */
+ L->top--; /* pop function */
+ }
+ else {
+ ci = ar->i_ci;
+ func = ci->func;
+ lua_assert(ttisfunction(ci->func));
+ }
+ cl = ttisclosure(func) ? clvalue(func) : NULL;
+ status = auxgetinfo(L, what, ar, cl, ci);
+ if (strchr(what, 'f')) {
+ setobjs2s(L, L->top, func);
+ api_incr_top(L);
+ }
+ if (strchr(what, 'L'))
+ collectvalidlines(L, cl);
+ lua_unlock(L);
+ return status;
+}
+
+
+/*
+** {======================================================
+** Symbolic Execution
+** =======================================================
+*/
+
+static const char *getobjname (Proto *p, int lastpc, int reg,
+ const char **name);
+
+
+/*
+** find a "name" for the RK value 'c'
+*/
+static void kname (Proto *p, int pc, int c, const char **name) {
+ if (ISK(c)) { /* is 'c' a constant? */
+ TValue *kvalue = &p->k[INDEXK(c)];
+ if (ttisstring(kvalue)) { /* literal constant? */
+ *name = svalue(kvalue); /* it is its own name */
+ return;
+ }
+ /* else no reasonable name found */
+ }
+ else { /* 'c' is a register */
+ const char *what = getobjname(p, pc, c, name); /* search for 'c' */
+ if (what && *what == 'c') { /* found a constant name? */
+ return; /* 'name' already filled */
+ }
+ /* else no reasonable name found */
+ }
+ *name = "?"; /* no reasonable name found */
+}
+
+
+static int filterpc (int pc, int jmptarget) {
+ if (pc < jmptarget) /* is code conditional (inside a jump)? */
+ return -1; /* cannot know who sets that register */
+ else return pc; /* current position sets that register */
+}
+
+
+/*
+** try to find last instruction before 'lastpc' that modified register 'reg'
+*/
+static int findsetreg (Proto *p, int lastpc, int reg) {
+ int pc;
+ int setreg = -1; /* keep last instruction that changed 'reg' */
+ int jmptarget = 0; /* any code before this address is conditional */
+ for (pc = 0; pc < lastpc; pc++) {
+ Instruction i = p->code[pc];
+ OpCode op = GET_OPCODE(i);
+ int a = GETARG_A(i);
+ switch (op) {
+ case OP_LOADNIL: {
+ int b = GETARG_B(i);
+ if (a <= reg && reg <= a + b) /* set registers from 'a' to 'a+b' */
+ setreg = filterpc(pc, jmptarget);
+ break;
+ }
+ case OP_TFORCALL: {
+ if (reg >= a + 2) /* affect all regs above its base */
+ setreg = filterpc(pc, jmptarget);
+ break;
+ }
+ case OP_CALL:
+ case OP_TAILCALL: {
+ if (reg >= a) /* affect all registers above base */
+ setreg = filterpc(pc, jmptarget);
+ break;
+ }
+ case OP_JMP: {
+ int b = GETARG_sBx(i);
+ int dest = pc + 1 + b;
+ /* jump is forward and do not skip `lastpc'? */
+ if (pc < dest && dest <= lastpc) {
+ if (dest > jmptarget)
+ jmptarget = dest; /* update 'jmptarget' */
+ }
+ break;
+ }
+ case OP_TEST: {
+ if (reg == a) /* jumped code can change 'a' */
+ setreg = filterpc(pc, jmptarget);
+ break;
+ }
+ default:
+ if (testAMode(op) && reg == a) /* any instruction that set A */
+ setreg = filterpc(pc, jmptarget);
+ break;
+ }
+ }
+ return setreg;
+}
+
+
+static const char *getobjname (Proto *p, int lastpc, int reg,
+ const char **name) {
+ int pc;
+ *name = luaF_getlocalname(p, reg + 1, lastpc);
+ if (*name) /* is a local? */
+ return "local";
+ /* else try symbolic execution */
+ pc = findsetreg(p, lastpc, reg);
+ if (pc != -1) { /* could find instruction? */
+ Instruction i = p->code[pc];
+ OpCode op = GET_OPCODE(i);
+ switch (op) {
+ case OP_MOVE: {
+ int b = GETARG_B(i); /* move from 'b' to 'a' */
+ if (b < GETARG_A(i))
+ return getobjname(p, pc, b, name); /* get name for 'b' */
+ break;
+ }
+ case OP_GETTABUP:
+ case OP_GETTABLE: {
+ int k = GETARG_C(i); /* key index */
+ int t = GETARG_B(i); /* table index */
+ const char *vn = (op == OP_GETTABLE) /* name of indexed variable */
+ ? luaF_getlocalname(p, t + 1, pc)
+ : upvalname(p, t);
+ kname(p, pc, k, name);
+ return (vn && strcmp(vn, LUA_ENV) == 0) ? "global" : "field";
+ }
+ case OP_GETUPVAL: {
+ *name = upvalname(p, GETARG_B(i));
+ return "upvalue";
+ }
+ case OP_LOADK:
+ case OP_LOADKX: {
+ int b = (op == OP_LOADK) ? GETARG_Bx(i)
+ : GETARG_Ax(p->code[pc + 1]);
+ if (ttisstring(&p->k[b])) {
+ *name = svalue(&p->k[b]);
+ return "constant";
+ }
+ break;
+ }
+ case OP_SELF: {
+ int k = GETARG_C(i); /* key index */
+ kname(p, pc, k, name);
+ return "method";
+ }
+ default: break; /* go through to return NULL */
+ }
+ }
+ return NULL; /* could not find reasonable name */
+}
+
+
+static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
+ TMS tm;
+ Proto *p = ci_func(ci)->p; /* calling function */
+ int pc = currentpc(ci); /* calling instruction index */
+ Instruction i = p->code[pc]; /* calling instruction */
+ switch (GET_OPCODE(i)) {
+ case OP_CALL:
+ case OP_TAILCALL: /* get function name */
+ return getobjname(p, pc, GETARG_A(i), name);
+ case OP_TFORCALL: { /* for iterator */
+ *name = "for iterator";
+ return "for iterator";
+ }
+ /* all other instructions can call only through metamethods */
+ case OP_SELF:
+ case OP_GETTABUP:
+ case OP_GETTABLE: tm = TM_INDEX; break;
+ case OP_SETTABUP:
+ case OP_SETTABLE: tm = TM_NEWINDEX; break;
+ case OP_EQ: tm = TM_EQ; break;
+ case OP_ADD: tm = TM_ADD; break;
+ case OP_SUB: tm = TM_SUB; break;
+ case OP_MUL: tm = TM_MUL; break;
+ case OP_DIV: tm = TM_DIV; break;
+ case OP_MOD: tm = TM_MOD; break;
+ case OP_POW: tm = TM_POW; break;
+ case OP_UNM: tm = TM_UNM; break;
+ case OP_LEN: tm = TM_LEN; break;
+ case OP_LT: tm = TM_LT; break;
+ case OP_LE: tm = TM_LE; break;
+ case OP_CONCAT: tm = TM_CONCAT; break;
+ default:
+ return NULL; /* else no useful name can be found */
+ }
+ *name = getstr(G(L)->tmname[tm]);
+ return "metamethod";
+}
+
+/* }====================================================== */
+
+
+
+/*
+** only ANSI way to check whether a pointer points to an array
+** (used only for error messages, so efficiency is not a big concern)
+*/
+static int isinstack (CallInfo *ci, const TValue *o) {
+ StkId p;
+ for (p = ci->u.l.base; p < ci->top; p++)
+ if (o == p) return 1;
+ return 0;
+}
+
+
+static const char *getupvalname (CallInfo *ci, const TValue *o,
+ const char **name) {
+ LClosure *c = ci_func(ci);
+ int i;
+ for (i = 0; i < c->nupvalues; i++) {
+ if (c->upvals[i]->v == o) {
+ *name = upvalname(c->p, i);
+ return "upvalue";
+ }
+ }
+ return NULL;
+}
+
+
+l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
+ CallInfo *ci = L->ci;
+ const char *name = NULL;
+ const char *t = objtypename(o);
+ const char *kind = NULL;
+ if (isLua(ci)) {
+ kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */
+ if (!kind && isinstack(ci, o)) /* no? try a register */
+ kind = getobjname(ci_func(ci)->p, currentpc(ci),
+ cast_int(o - ci->u.l.base), &name);
+ }
+ if (kind)
+ luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)",
+ op, kind, name, t);
+ else
+ luaG_runerror(L, "attempt to %s a %s value", op, t);
+}
+
+
+l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
+ if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
+ lua_assert(!ttisstring(p1) && !ttisnumber(p1));
+ luaG_typeerror(L, p1, "concatenate");
+}
+
+
+l_noret luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
+ TValue temp;
+ if (luaV_tonumber(p1, &temp) == NULL)
+ p2 = p1; /* first operand is wrong */
+ luaG_typeerror(L, p2, "perform arithmetic on");
+}
+
+
+l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
+ const char *t1 = objtypename(p1);
+ const char *t2 = objtypename(p2);
+ if (t1 == t2)
+ luaG_runerror(L, "attempt to compare two %s values", t1);
+ else
+ luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
+}
+
+
+static void addinfo (lua_State *L, const char *msg) {
+ CallInfo *ci = L->ci;
+ if (isLua(ci)) { /* is Lua code? */
+ char buff[LUA_IDSIZE]; /* add file:line information */
+ int line = currentline(ci);
+ TString *src = ci_func(ci)->p->source;
+ if (src)
+ luaO_chunkid(buff, getstr(src), LUA_IDSIZE);
+ else { /* no source available; use "?" instead */
+ buff[0] = '?'; buff[1] = '\0';
+ }
+ luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
+ }
+}
+
+
+l_noret luaG_errormsg (lua_State *L) {
+ if (L->errfunc != 0) { /* is there an error handling function? */
+ StkId errfunc = restorestack(L, L->errfunc);
+ if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
+ setobjs2s(L, L->top, L->top - 1); /* move argument */
+ setobjs2s(L, L->top - 1, errfunc); /* push function */
+ L->top++;
+ luaD_call(L, L->top - 2, 1, 0); /* call it */
+ }
+ luaD_throw(L, LUA_ERRRUN);
+}
+
+
+l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {
+ va_list argp;
+ va_start(argp, fmt);
+ addinfo(L, luaO_pushvfstring(L, fmt, argp));
+ va_end(argp);
+ luaG_errormsg(L);
+}
+
diff --git a/ext/lua/src/ldo.c b/ext/lua/src/ldo.c
new file mode 100644
index 0000000000..e9dd5fa951
--- /dev/null
+++ b/ext/lua/src/ldo.c
@@ -0,0 +1,681 @@
+/*
+** $Id: ldo.c,v 2.108.1.3 2013/11/08 18:22:50 roberto Exp $
+** Stack and Call structure of Lua
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+#include
+#include
+
+#define ldo_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lapi.h"
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lgc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lopcodes.h"
+#include "lparser.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+#include "lundump.h"
+#include "lvm.h"
+#include "lzio.h"
+
+
+
+
+/*
+** {======================================================
+** Error-recovery functions
+** =======================================================
+*/
+
+/*
+** LUAI_THROW/LUAI_TRY define how Lua does exception handling. By
+** default, Lua handles errors with exceptions when compiling as
+** C++ code, with _longjmp/_setjmp when asked to use them, and with
+** longjmp/setjmp otherwise.
+*/
+#if !defined(LUAI_THROW)
+
+#if defined(__cplusplus) && !defined(LUA_USE_LONGJMP)
+/* C++ exceptions */
+#define LUAI_THROW(L,c) throw(c)
+#define LUAI_TRY(L,c,a) \
+ try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; }
+#define luai_jmpbuf int /* dummy variable */
+
+#elif defined(LUA_USE_ULONGJMP)
+/* in Unix, try _longjmp/_setjmp (more efficient) */
+#define LUAI_THROW(L,c) _longjmp((c)->b, 1)
+#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
+#define luai_jmpbuf jmp_buf
+
+#else
+/* default handling with long jumps */
+#define LUAI_THROW(L,c) longjmp((c)->b, 1)
+#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
+#define luai_jmpbuf jmp_buf
+
+#endif
+
+#endif
+
+
+
+/* chain list of long jump buffers */
+struct lua_longjmp {
+ struct lua_longjmp *previous;
+ luai_jmpbuf b;
+ volatile int status; /* error code */
+};
+
+
+static void seterrorobj (lua_State *L, int errcode, StkId oldtop) {
+ switch (errcode) {
+ case LUA_ERRMEM: { /* memory error? */
+ setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */
+ break;
+ }
+ case LUA_ERRERR: {
+ setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
+ break;
+ }
+ default: {
+ setobjs2s(L, oldtop, L->top - 1); /* error message on current top */
+ break;
+ }
+ }
+ L->top = oldtop + 1;
+}
+
+
+l_noret luaD_throw (lua_State *L, int errcode) {
+ if (L->errorJmp) { /* thread has an error handler? */
+ L->errorJmp->status = errcode; /* set status */
+ LUAI_THROW(L, L->errorJmp); /* jump to it */
+ }
+ else { /* thread has no error handler */
+ L->status = cast_byte(errcode); /* mark it as dead */
+ if (G(L)->mainthread->errorJmp) { /* main thread has a handler? */
+ setobjs2s(L, G(L)->mainthread->top++, L->top - 1); /* copy error obj. */
+ luaD_throw(G(L)->mainthread, errcode); /* re-throw in main thread */
+ }
+ else { /* no handler at all; abort */
+ if (G(L)->panic) { /* panic function? */
+ lua_unlock(L);
+ G(L)->panic(L); /* call it (last chance to jump out) */
+ }
+ abort();
+ }
+ }
+}
+
+
+int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
+ unsigned short oldnCcalls = L->nCcalls;
+ struct lua_longjmp lj;
+ lj.status = LUA_OK;
+ lj.previous = L->errorJmp; /* chain new error handler */
+ L->errorJmp = &lj;
+ LUAI_TRY(L, &lj,
+ (*f)(L, ud);
+ );
+ L->errorJmp = lj.previous; /* restore old error handler */
+ L->nCcalls = oldnCcalls;
+ return lj.status;
+}
+
+/* }====================================================== */
+
+
+static void correctstack (lua_State *L, TValue *oldstack) {
+ CallInfo *ci;
+ GCObject *up;
+ L->top = (L->top - oldstack) + L->stack;
+ for (up = L->openupval; up != NULL; up = up->gch.next)
+ gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack;
+ for (ci = L->ci; ci != NULL; ci = ci->previous) {
+ ci->top = (ci->top - oldstack) + L->stack;
+ ci->func = (ci->func - oldstack) + L->stack;
+ if (isLua(ci))
+ ci->u.l.base = (ci->u.l.base - oldstack) + L->stack;
+ }
+}
+
+
+/* some space for error handling */
+#define ERRORSTACKSIZE (LUAI_MAXSTACK + 200)
+
+
+void luaD_reallocstack (lua_State *L, int newsize) {
+ TValue *oldstack = L->stack;
+ int lim = L->stacksize;
+ lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE);
+ lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK);
+ luaM_reallocvector(L, L->stack, L->stacksize, newsize, TValue);
+ for (; lim < newsize; lim++)
+ setnilvalue(L->stack + lim); /* erase new segment */
+ L->stacksize = newsize;
+ L->stack_last = L->stack + newsize - EXTRA_STACK;
+ correctstack(L, oldstack);
+}
+
+
+void luaD_growstack (lua_State *L, int n) {
+ int size = L->stacksize;
+ if (size > LUAI_MAXSTACK) /* error after extra size? */
+ luaD_throw(L, LUA_ERRERR);
+ else {
+ int needed = cast_int(L->top - L->stack) + n + EXTRA_STACK;
+ int newsize = 2 * size;
+ if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK;
+ if (newsize < needed) newsize = needed;
+ if (newsize > LUAI_MAXSTACK) { /* stack overflow? */
+ luaD_reallocstack(L, ERRORSTACKSIZE);
+ luaG_runerror(L, "stack overflow");
+ }
+ else
+ luaD_reallocstack(L, newsize);
+ }
+}
+
+
+static int stackinuse (lua_State *L) {
+ CallInfo *ci;
+ StkId lim = L->top;
+ for (ci = L->ci; ci != NULL; ci = ci->previous) {
+ lua_assert(ci->top <= L->stack_last);
+ if (lim < ci->top) lim = ci->top;
+ }
+ return cast_int(lim - L->stack) + 1; /* part of stack in use */
+}
+
+
+void luaD_shrinkstack (lua_State *L) {
+ int inuse = stackinuse(L);
+ int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK;
+ if (goodsize > LUAI_MAXSTACK) goodsize = LUAI_MAXSTACK;
+ if (inuse > LUAI_MAXSTACK || /* handling stack overflow? */
+ goodsize >= L->stacksize) /* would grow instead of shrink? */
+ condmovestack(L); /* don't change stack (change only for debugging) */
+ else
+ luaD_reallocstack(L, goodsize); /* shrink it */
+}
+
+
+void luaD_hook (lua_State *L, int event, int line) {
+ lua_Hook hook = L->hook;
+ if (hook && L->allowhook) {
+ CallInfo *ci = L->ci;
+ ptrdiff_t top = savestack(L, L->top);
+ ptrdiff_t ci_top = savestack(L, ci->top);
+ lua_Debug ar;
+ ar.event = event;
+ ar.currentline = line;
+ ar.i_ci = ci;
+ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
+ ci->top = L->top + LUA_MINSTACK;
+ lua_assert(ci->top <= L->stack_last);
+ L->allowhook = 0; /* cannot call hooks inside a hook */
+ ci->callstatus |= CIST_HOOKED;
+ lua_unlock(L);
+ (*hook)(L, &ar);
+ lua_lock(L);
+ lua_assert(!L->allowhook);
+ L->allowhook = 1;
+ ci->top = restorestack(L, ci_top);
+ L->top = restorestack(L, top);
+ ci->callstatus &= ~CIST_HOOKED;
+ }
+}
+
+
+static void callhook (lua_State *L, CallInfo *ci) {
+ int hook = LUA_HOOKCALL;
+ ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */
+ if (isLua(ci->previous) &&
+ GET_OPCODE(*(ci->previous->u.l.savedpc - 1)) == OP_TAILCALL) {
+ ci->callstatus |= CIST_TAIL;
+ hook = LUA_HOOKTAILCALL;
+ }
+ luaD_hook(L, hook, -1);
+ ci->u.l.savedpc--; /* correct 'pc' */
+}
+
+
+static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
+ int i;
+ int nfixargs = p->numparams;
+ StkId base, fixed;
+ lua_assert(actual >= nfixargs);
+ /* move fixed parameters to final position */
+ luaD_checkstack(L, p->maxstacksize); /* check again for new 'base' */
+ fixed = L->top - actual; /* first fixed argument */
+ base = L->top; /* final position of first argument */
+ for (i=0; itop++, fixed + i);
+ setnilvalue(fixed + i);
+ }
+ return base;
+}
+
+
+static StkId tryfuncTM (lua_State *L, StkId func) {
+ const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
+ StkId p;
+ ptrdiff_t funcr = savestack(L, func);
+ if (!ttisfunction(tm))
+ luaG_typeerror(L, func, "call");
+ /* Open a hole inside the stack at `func' */
+ for (p = L->top; p > func; p--) setobjs2s(L, p, p-1);
+ incr_top(L);
+ func = restorestack(L, funcr); /* previous call may change stack */
+ setobj2s(L, func, tm); /* tag method is the new function to be called */
+ return func;
+}
+
+
+
+#define next_ci(L) (L->ci = (L->ci->next ? L->ci->next : luaE_extendCI(L)))
+
+
+/*
+** returns true if function has been executed (C function)
+*/
+int luaD_precall (lua_State *L, StkId func, int nresults) {
+ lua_CFunction f;
+ CallInfo *ci;
+ int n; /* number of arguments (Lua) or returns (C) */
+ ptrdiff_t funcr = savestack(L, func);
+ switch (ttype(func)) {
+ case LUA_TLCF: /* light C function */
+ f = fvalue(func);
+ goto Cfunc;
+ case LUA_TCCL: { /* C closure */
+ f = clCvalue(func)->f;
+ Cfunc:
+ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
+ ci = next_ci(L); /* now 'enter' new function */
+ ci->nresults = nresults;
+ ci->func = restorestack(L, funcr);
+ ci->top = L->top + LUA_MINSTACK;
+ lua_assert(ci->top <= L->stack_last);
+ ci->callstatus = 0;
+ luaC_checkGC(L); /* stack grow uses memory */
+ if (L->hookmask & LUA_MASKCALL)
+ luaD_hook(L, LUA_HOOKCALL, -1);
+ lua_unlock(L);
+ n = (*f)(L); /* do the actual call */
+ lua_lock(L);
+ api_checknelems(L, n);
+ luaD_poscall(L, L->top - n);
+ return 1;
+ }
+ case LUA_TLCL: { /* Lua function: prepare its call */
+ StkId base;
+ Proto *p = clLvalue(func)->p;
+ n = cast_int(L->top - func) - 1; /* number of real arguments */
+ luaD_checkstack(L, p->maxstacksize);
+ for (; n < p->numparams; n++)
+ setnilvalue(L->top++); /* complete missing arguments */
+ if (!p->is_vararg) {
+ func = restorestack(L, funcr);
+ base = func + 1;
+ }
+ else {
+ base = adjust_varargs(L, p, n);
+ func = restorestack(L, funcr); /* previous call can change stack */
+ }
+ ci = next_ci(L); /* now 'enter' new function */
+ ci->nresults = nresults;
+ ci->func = func;
+ ci->u.l.base = base;
+ ci->top = base + p->maxstacksize;
+ lua_assert(ci->top <= L->stack_last);
+ ci->u.l.savedpc = p->code; /* starting point */
+ ci->callstatus = CIST_LUA;
+ L->top = ci->top;
+ luaC_checkGC(L); /* stack grow uses memory */
+ if (L->hookmask & LUA_MASKCALL)
+ callhook(L, ci);
+ return 0;
+ }
+ default: { /* not a function */
+ func = tryfuncTM(L, func); /* retry with 'function' tag method */
+ return luaD_precall(L, func, nresults); /* now it must be a function */
+ }
+ }
+}
+
+
+int luaD_poscall (lua_State *L, StkId firstResult) {
+ StkId res;
+ int wanted, i;
+ CallInfo *ci = L->ci;
+ if (L->hookmask & (LUA_MASKRET | LUA_MASKLINE)) {
+ if (L->hookmask & LUA_MASKRET) {
+ ptrdiff_t fr = savestack(L, firstResult); /* hook may change stack */
+ luaD_hook(L, LUA_HOOKRET, -1);
+ firstResult = restorestack(L, fr);
+ }
+ L->oldpc = ci->previous->u.l.savedpc; /* 'oldpc' for caller function */
+ }
+ res = ci->func; /* res == final position of 1st result */
+ wanted = ci->nresults;
+ L->ci = ci = ci->previous; /* back to caller */
+ /* move results to correct place */
+ for (i = wanted; i != 0 && firstResult < L->top; i--)
+ setobjs2s(L, res++, firstResult++);
+ while (i-- > 0)
+ setnilvalue(res++);
+ L->top = res;
+ return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */
+}
+
+
+/*
+** Call a function (C or Lua). The function to be called is at *func.
+** The arguments are on the stack, right after the function.
+** When returns, all the results are on the stack, starting at the original
+** function position.
+*/
+void luaD_call (lua_State *L, StkId func, int nResults, int allowyield) {
+ if (++L->nCcalls >= LUAI_MAXCCALLS) {
+ if (L->nCcalls == LUAI_MAXCCALLS)
+ luaG_runerror(L, "C stack overflow");
+ else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3)))
+ luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
+ }
+ if (!allowyield) L->nny++;
+ if (!luaD_precall(L, func, nResults)) /* is a Lua function? */
+ luaV_execute(L); /* call it */
+ if (!allowyield) L->nny--;
+ L->nCcalls--;
+}
+
+
+static void finishCcall (lua_State *L) {
+ CallInfo *ci = L->ci;
+ int n;
+ lua_assert(ci->u.c.k != NULL); /* must have a continuation */
+ lua_assert(L->nny == 0);
+ if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */
+ ci->callstatus &= ~CIST_YPCALL; /* finish 'lua_pcall' */
+ L->errfunc = ci->u.c.old_errfunc;
+ }
+ /* finish 'lua_callk'/'lua_pcall' */
+ adjustresults(L, ci->nresults);
+ /* call continuation function */
+ if (!(ci->callstatus & CIST_STAT)) /* no call status? */
+ ci->u.c.status = LUA_YIELD; /* 'default' status */
+ lua_assert(ci->u.c.status != LUA_OK);
+ ci->callstatus = (ci->callstatus & ~(CIST_YPCALL | CIST_STAT)) | CIST_YIELDED;
+ lua_unlock(L);
+ n = (*ci->u.c.k)(L);
+ lua_lock(L);
+ api_checknelems(L, n);
+ /* finish 'luaD_precall' */
+ luaD_poscall(L, L->top - n);
+}
+
+
+static void unroll (lua_State *L, void *ud) {
+ UNUSED(ud);
+ for (;;) {
+ if (L->ci == &L->base_ci) /* stack is empty? */
+ return; /* coroutine finished normally */
+ if (!isLua(L->ci)) /* C function? */
+ finishCcall(L);
+ else { /* Lua function */
+ luaV_finishOp(L); /* finish interrupted instruction */
+ luaV_execute(L); /* execute down to higher C 'boundary' */
+ }
+ }
+}
+
+
+/*
+** check whether thread has a suspended protected call
+*/
+static CallInfo *findpcall (lua_State *L) {
+ CallInfo *ci;
+ for (ci = L->ci; ci != NULL; ci = ci->previous) { /* search for a pcall */
+ if (ci->callstatus & CIST_YPCALL)
+ return ci;
+ }
+ return NULL; /* no pending pcall */
+}
+
+
+static int recover (lua_State *L, int status) {
+ StkId oldtop;
+ CallInfo *ci = findpcall(L);
+ if (ci == NULL) return 0; /* no recovery point */
+ /* "finish" luaD_pcall */
+ oldtop = restorestack(L, ci->extra);
+ luaF_close(L, oldtop);
+ seterrorobj(L, status, oldtop);
+ L->ci = ci;
+ L->allowhook = ci->u.c.old_allowhook;
+ L->nny = 0; /* should be zero to be yieldable */
+ luaD_shrinkstack(L);
+ L->errfunc = ci->u.c.old_errfunc;
+ ci->callstatus |= CIST_STAT; /* call has error status */
+ ci->u.c.status = status; /* (here it is) */
+ return 1; /* continue running the coroutine */
+}
+
+
+/*
+** signal an error in the call to 'resume', not in the execution of the
+** coroutine itself. (Such errors should not be handled by any coroutine
+** error handler and should not kill the coroutine.)
+*/
+static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) {
+ L->top = firstArg; /* remove args from the stack */
+ setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */
+ api_incr_top(L);
+ luaD_throw(L, -1); /* jump back to 'lua_resume' */
+}
+
+
+/*
+** do the work for 'lua_resume' in protected mode
+*/
+static void resume (lua_State *L, void *ud) {
+ int nCcalls = L->nCcalls;
+ StkId firstArg = cast(StkId, ud);
+ CallInfo *ci = L->ci;
+ if (nCcalls >= LUAI_MAXCCALLS)
+ resume_error(L, "C stack overflow", firstArg);
+ if (L->status == LUA_OK) { /* may be starting a coroutine */
+ if (ci != &L->base_ci) /* not in base level? */
+ resume_error(L, "cannot resume non-suspended coroutine", firstArg);
+ /* coroutine is in base level; start running it */
+ if (!luaD_precall(L, firstArg - 1, LUA_MULTRET)) /* Lua function? */
+ luaV_execute(L); /* call it */
+ }
+ else if (L->status != LUA_YIELD)
+ resume_error(L, "cannot resume dead coroutine", firstArg);
+ else { /* resuming from previous yield */
+ L->status = LUA_OK;
+ ci->func = restorestack(L, ci->extra);
+ if (isLua(ci)) /* yielded inside a hook? */
+ luaV_execute(L); /* just continue running Lua code */
+ else { /* 'common' yield */
+ if (ci->u.c.k != NULL) { /* does it have a continuation? */
+ int n;
+ ci->u.c.status = LUA_YIELD; /* 'default' status */
+ ci->callstatus |= CIST_YIELDED;
+ lua_unlock(L);
+ n = (*ci->u.c.k)(L); /* call continuation */
+ lua_lock(L);
+ api_checknelems(L, n);
+ firstArg = L->top - n; /* yield results come from continuation */
+ }
+ luaD_poscall(L, firstArg); /* finish 'luaD_precall' */
+ }
+ unroll(L, NULL);
+ }
+ lua_assert(nCcalls == L->nCcalls);
+}
+
+
+LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) {
+ int status;
+ int oldnny = L->nny; /* save 'nny' */
+ lua_lock(L);
+ luai_userstateresume(L, nargs);
+ L->nCcalls = (from) ? from->nCcalls + 1 : 1;
+ L->nny = 0; /* allow yields */
+ api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
+ status = luaD_rawrunprotected(L, resume, L->top - nargs);
+ if (status == -1) /* error calling 'lua_resume'? */
+ status = LUA_ERRRUN;
+ else { /* yield or regular error */
+ while (status != LUA_OK && status != LUA_YIELD) { /* error? */
+ if (recover(L, status)) /* recover point? */
+ status = luaD_rawrunprotected(L, unroll, NULL); /* run continuation */
+ else { /* unrecoverable error */
+ L->status = cast_byte(status); /* mark thread as `dead' */
+ seterrorobj(L, status, L->top);
+ L->ci->top = L->top;
+ break;
+ }
+ }
+ lua_assert(status == L->status);
+ }
+ L->nny = oldnny; /* restore 'nny' */
+ L->nCcalls--;
+ lua_assert(L->nCcalls == ((from) ? from->nCcalls : 0));
+ lua_unlock(L);
+ return status;
+}
+
+
+LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) {
+ CallInfo *ci = L->ci;
+ luai_userstateyield(L, nresults);
+ lua_lock(L);
+ api_checknelems(L, nresults);
+ if (L->nny > 0) {
+ if (L != G(L)->mainthread)
+ luaG_runerror(L, "attempt to yield across a C-call boundary");
+ else
+ luaG_runerror(L, "attempt to yield from outside a coroutine");
+ }
+ L->status = LUA_YIELD;
+ ci->extra = savestack(L, ci->func); /* save current 'func' */
+ if (isLua(ci)) { /* inside a hook? */
+ api_check(L, k == NULL, "hooks cannot continue after yielding");
+ }
+ else {
+ if ((ci->u.c.k = k) != NULL) /* is there a continuation? */
+ ci->u.c.ctx = ctx; /* save context */
+ ci->func = L->top - nresults - 1; /* protect stack below results */
+ luaD_throw(L, LUA_YIELD);
+ }
+ lua_assert(ci->callstatus & CIST_HOOKED); /* must be inside a hook */
+ lua_unlock(L);
+ return 0; /* return to 'luaD_hook' */
+}
+
+
+int luaD_pcall (lua_State *L, Pfunc func, void *u,
+ ptrdiff_t old_top, ptrdiff_t ef) {
+ int status;
+ CallInfo *old_ci = L->ci;
+ lu_byte old_allowhooks = L->allowhook;
+ unsigned short old_nny = L->nny;
+ ptrdiff_t old_errfunc = L->errfunc;
+ L->errfunc = ef;
+ status = luaD_rawrunprotected(L, func, u);
+ if (status != LUA_OK) { /* an error occurred? */
+ StkId oldtop = restorestack(L, old_top);
+ luaF_close(L, oldtop); /* close possible pending closures */
+ seterrorobj(L, status, oldtop);
+ L->ci = old_ci;
+ L->allowhook = old_allowhooks;
+ L->nny = old_nny;
+ luaD_shrinkstack(L);
+ }
+ L->errfunc = old_errfunc;
+ return status;
+}
+
+
+
+/*
+** Execute a protected parser.
+*/
+struct SParser { /* data to `f_parser' */
+ ZIO *z;
+ Mbuffer buff; /* dynamic structure used by the scanner */
+ Dyndata dyd; /* dynamic structures used by the parser */
+ const char *mode;
+ const char *name;
+};
+
+
+static void checkmode (lua_State *L, const char *mode, const char *x) {
+ if (mode && strchr(mode, x[0]) == NULL) {
+ luaO_pushfstring(L,
+ "attempt to load a %s chunk (mode is " LUA_QS ")", x, mode);
+ luaD_throw(L, LUA_ERRSYNTAX);
+ }
+}
+
+
+static void f_parser (lua_State *L, void *ud) {
+ int i;
+ Closure *cl;
+ struct SParser *p = cast(struct SParser *, ud);
+ int c = zgetc(p->z); /* read first character */
+ if (c == LUA_SIGNATURE[0]) {
+ checkmode(L, p->mode, "binary");
+ cl = luaU_undump(L, p->z, &p->buff, p->name);
+ }
+ else {
+ checkmode(L, p->mode, "text");
+ cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c);
+ }
+ lua_assert(cl->l.nupvalues == cl->l.p->sizeupvalues);
+ for (i = 0; i < cl->l.nupvalues; i++) { /* initialize upvalues */
+ UpVal *up = luaF_newupval(L);
+ cl->l.upvals[i] = up;
+ luaC_objbarrier(L, cl, up);
+ }
+}
+
+
+int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
+ const char *mode) {
+ struct SParser p;
+ int status;
+ L->nny++; /* cannot yield during parsing */
+ p.z = z; p.name = name; p.mode = mode;
+ p.dyd.actvar.arr = NULL; p.dyd.actvar.size = 0;
+ p.dyd.gt.arr = NULL; p.dyd.gt.size = 0;
+ p.dyd.label.arr = NULL; p.dyd.label.size = 0;
+ luaZ_initbuffer(L, &p.buff);
+ status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc);
+ luaZ_freebuffer(L, &p.buff);
+ luaM_freearray(L, p.dyd.actvar.arr, p.dyd.actvar.size);
+ luaM_freearray(L, p.dyd.gt.arr, p.dyd.gt.size);
+ luaM_freearray(L, p.dyd.label.arr, p.dyd.label.size);
+ L->nny--;
+ return status;
+}
+
+
diff --git a/ext/lua/src/ldump.c b/ext/lua/src/ldump.c
new file mode 100644
index 0000000000..61fa2cd892
--- /dev/null
+++ b/ext/lua/src/ldump.c
@@ -0,0 +1,173 @@
+/*
+** $Id: ldump.c,v 2.17.1.1 2013/04/12 18:48:47 roberto Exp $
+** save precompiled Lua chunks
+** See Copyright Notice in lua.h
+*/
+
+#include
+
+#define ldump_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lobject.h"
+#include "lstate.h"
+#include "lundump.h"
+
+typedef struct {
+ lua_State* L;
+ lua_Writer writer;
+ void* data;
+ int strip;
+ int status;
+} DumpState;
+
+#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D)
+#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
+
+static void DumpBlock(const void* b, size_t size, DumpState* D)
+{
+ if (D->status==0)
+ {
+ lua_unlock(D->L);
+ D->status=(*D->writer)(D->L,b,size,D->data);
+ lua_lock(D->L);
+ }
+}
+
+static void DumpChar(int y, DumpState* D)
+{
+ char x=(char)y;
+ DumpVar(x,D);
+}
+
+static void DumpInt(int x, DumpState* D)
+{
+ DumpVar(x,D);
+}
+
+static void DumpNumber(lua_Number x, DumpState* D)
+{
+ DumpVar(x,D);
+}
+
+static void DumpVector(const void* b, int n, size_t size, DumpState* D)
+{
+ DumpInt(n,D);
+ DumpMem(b,n,size,D);
+}
+
+static void DumpString(const TString* s, DumpState* D)
+{
+ if (s==NULL)
+ {
+ size_t size=0;
+ DumpVar(size,D);
+ }
+ else
+ {
+ size_t size=s->tsv.len+1; /* include trailing '\0' */
+ DumpVar(size,D);
+ DumpBlock(getstr(s),size*sizeof(char),D);
+ }
+}
+
+#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D)
+
+static void DumpFunction(const Proto* f, DumpState* D);
+
+static void DumpConstants(const Proto* f, DumpState* D)
+{
+ int i,n=f->sizek;
+ DumpInt(n,D);
+ for (i=0; ik[i];
+ DumpChar(ttypenv(o),D);
+ switch (ttypenv(o))
+ {
+ case LUA_TNIL:
+ break;
+ case LUA_TBOOLEAN:
+ DumpChar(bvalue(o),D);
+ break;
+ case LUA_TNUMBER:
+ DumpNumber(nvalue(o),D);
+ break;
+ case LUA_TSTRING:
+ DumpString(rawtsvalue(o),D);
+ break;
+ default: lua_assert(0);
+ }
+ }
+ n=f->sizep;
+ DumpInt(n,D);
+ for (i=0; ip[i],D);
+}
+
+static void DumpUpvalues(const Proto* f, DumpState* D)
+{
+ int i,n=f->sizeupvalues;
+ DumpInt(n,D);
+ for (i=0; iupvalues[i].instack,D);
+ DumpChar(f->upvalues[i].idx,D);
+ }
+}
+
+static void DumpDebug(const Proto* f, DumpState* D)
+{
+ int i,n;
+ DumpString((D->strip) ? NULL : f->source,D);
+ n= (D->strip) ? 0 : f->sizelineinfo;
+ DumpVector(f->lineinfo,n,sizeof(int),D);
+ n= (D->strip) ? 0 : f->sizelocvars;
+ DumpInt(n,D);
+ for (i=0; ilocvars[i].varname,D);
+ DumpInt(f->locvars[i].startpc,D);
+ DumpInt(f->locvars[i].endpc,D);
+ }
+ n= (D->strip) ? 0 : f->sizeupvalues;
+ DumpInt(n,D);
+ for (i=0; iupvalues[i].name,D);
+}
+
+static void DumpFunction(const Proto* f, DumpState* D)
+{
+ DumpInt(f->linedefined,D);
+ DumpInt(f->lastlinedefined,D);
+ DumpChar(f->numparams,D);
+ DumpChar(f->is_vararg,D);
+ DumpChar(f->maxstacksize,D);
+ DumpCode(f,D);
+ DumpConstants(f,D);
+ DumpUpvalues(f,D);
+ DumpDebug(f,D);
+}
+
+static void DumpHeader(DumpState* D)
+{
+ lu_byte h[LUAC_HEADERSIZE];
+ luaU_header(h);
+ DumpBlock(h,LUAC_HEADERSIZE,D);
+}
+
+/*
+** dump Lua function as precompiled chunk
+*/
+int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
+{
+ DumpState D;
+ D.L=L;
+ D.writer=w;
+ D.data=data;
+ D.strip=strip;
+ D.status=0;
+ DumpHeader(&D);
+ DumpFunction(f,&D);
+ return D.status;
+}
diff --git a/ext/lua/src/lfunc.c b/ext/lua/src/lfunc.c
new file mode 100644
index 0000000000..e90e1520ce
--- /dev/null
+++ b/ext/lua/src/lfunc.c
@@ -0,0 +1,161 @@
+/*
+** $Id: lfunc.c,v 2.30.1.1 2013/04/12 18:48:47 roberto Exp $
+** Auxiliary functions to manipulate prototypes and closures
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+
+#define lfunc_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lfunc.h"
+#include "lgc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+
+
+
+Closure *luaF_newCclosure (lua_State *L, int n) {
+ Closure *c = &luaC_newobj(L, LUA_TCCL, sizeCclosure(n), NULL, 0)->cl;
+ c->c.nupvalues = cast_byte(n);
+ return c;
+}
+
+
+Closure *luaF_newLclosure (lua_State *L, int n) {
+ Closure *c = &luaC_newobj(L, LUA_TLCL, sizeLclosure(n), NULL, 0)->cl;
+ c->l.p = NULL;
+ c->l.nupvalues = cast_byte(n);
+ while (n--) c->l.upvals[n] = NULL;
+ return c;
+}
+
+
+UpVal *luaF_newupval (lua_State *L) {
+ UpVal *uv = &luaC_newobj(L, LUA_TUPVAL, sizeof(UpVal), NULL, 0)->uv;
+ uv->v = &uv->u.value;
+ setnilvalue(uv->v);
+ return uv;
+}
+
+
+UpVal *luaF_findupval (lua_State *L, StkId level) {
+ global_State *g = G(L);
+ GCObject **pp = &L->openupval;
+ UpVal *p;
+ UpVal *uv;
+ while (*pp != NULL && (p = gco2uv(*pp))->v >= level) {
+ GCObject *o = obj2gco(p);
+ lua_assert(p->v != &p->u.value);
+ lua_assert(!isold(o) || isold(obj2gco(L)));
+ if (p->v == level) { /* found a corresponding upvalue? */
+ if (isdead(g, o)) /* is it dead? */
+ changewhite(o); /* resurrect it */
+ return p;
+ }
+ pp = &p->next;
+ }
+ /* not found: create a new one */
+ uv = &luaC_newobj(L, LUA_TUPVAL, sizeof(UpVal), pp, 0)->uv;
+ uv->v = level; /* current value lives in the stack */
+ uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */
+ uv->u.l.next = g->uvhead.u.l.next;
+ uv->u.l.next->u.l.prev = uv;
+ g->uvhead.u.l.next = uv;
+ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
+ return uv;
+}
+
+
+static void unlinkupval (UpVal *uv) {
+ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
+ uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */
+ uv->u.l.prev->u.l.next = uv->u.l.next;
+}
+
+
+void luaF_freeupval (lua_State *L, UpVal *uv) {
+ if (uv->v != &uv->u.value) /* is it open? */
+ unlinkupval(uv); /* remove from open list */
+ luaM_free(L, uv); /* free upvalue */
+}
+
+
+void luaF_close (lua_State *L, StkId level) {
+ UpVal *uv;
+ global_State *g = G(L);
+ while (L->openupval != NULL && (uv = gco2uv(L->openupval))->v >= level) {
+ GCObject *o = obj2gco(uv);
+ lua_assert(!isblack(o) && uv->v != &uv->u.value);
+ L->openupval = uv->next; /* remove from `open' list */
+ if (isdead(g, o))
+ luaF_freeupval(L, uv); /* free upvalue */
+ else {
+ unlinkupval(uv); /* remove upvalue from 'uvhead' list */
+ setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */
+ uv->v = &uv->u.value; /* now current value lives here */
+ gch(o)->next = g->allgc; /* link upvalue into 'allgc' list */
+ g->allgc = o;
+ luaC_checkupvalcolor(g, uv);
+ }
+ }
+}
+
+
+Proto *luaF_newproto (lua_State *L) {
+ Proto *f = &luaC_newobj(L, LUA_TPROTO, sizeof(Proto), NULL, 0)->p;
+ f->k = NULL;
+ f->sizek = 0;
+ f->p = NULL;
+ f->sizep = 0;
+ f->code = NULL;
+ f->cache = NULL;
+ f->sizecode = 0;
+ f->lineinfo = NULL;
+ f->sizelineinfo = 0;
+ f->upvalues = NULL;
+ f->sizeupvalues = 0;
+ f->numparams = 0;
+ f->is_vararg = 0;
+ f->maxstacksize = 0;
+ f->locvars = NULL;
+ f->sizelocvars = 0;
+ f->linedefined = 0;
+ f->lastlinedefined = 0;
+ f->source = NULL;
+ return f;
+}
+
+
+void luaF_freeproto (lua_State *L, Proto *f) {
+ luaM_freearray(L, f->code, f->sizecode);
+ luaM_freearray(L, f->p, f->sizep);
+ luaM_freearray(L, f->k, f->sizek);
+ luaM_freearray(L, f->lineinfo, f->sizelineinfo);
+ luaM_freearray(L, f->locvars, f->sizelocvars);
+ luaM_freearray(L, f->upvalues, f->sizeupvalues);
+ luaM_free(L, f);
+}
+
+
+/*
+** Look for n-th local variable at line `line' in function `func'.
+** Returns NULL if not found.
+*/
+const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
+ int i;
+ for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) {
+ if (pc < f->locvars[i].endpc) { /* is variable active? */
+ local_number--;
+ if (local_number == 0)
+ return getstr(f->locvars[i].varname);
+ }
+ }
+ return NULL; /* not found */
+}
+
diff --git a/ext/lua/src/lgc.c b/ext/lua/src/lgc.c
new file mode 100644
index 0000000000..52460dcdd5
--- /dev/null
+++ b/ext/lua/src/lgc.c
@@ -0,0 +1,1220 @@
+/*
+** $Id: lgc.c,v 2.140.1.2 2013/04/26 18:22:05 roberto Exp $
+** Garbage Collector
+** See Copyright Notice in lua.h
+*/
+
+#include
+
+#define lgc_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lgc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+
+
+
+/*
+** cost of sweeping one element (the size of a small object divided
+** by some adjust for the sweep speed)
+*/
+#define GCSWEEPCOST ((sizeof(TString) + 4) / 4)
+
+/* maximum number of elements to sweep in each single step */
+#define GCSWEEPMAX (cast_int((GCSTEPSIZE / GCSWEEPCOST) / 4))
+
+/* maximum number of finalizers to call in each GC step */
+#define GCFINALIZENUM 4
+
+
+/*
+** macro to adjust 'stepmul': 'stepmul' is actually used like
+** 'stepmul / STEPMULADJ' (value chosen by tests)
+*/
+#define STEPMULADJ 200
+
+
+/*
+** macro to adjust 'pause': 'pause' is actually used like
+** 'pause / PAUSEADJ' (value chosen by tests)
+*/
+#define PAUSEADJ 100
+
+
+/*
+** 'makewhite' erases all color bits plus the old bit and then
+** sets only the current white bit
+*/
+#define maskcolors (~(bit2mask(BLACKBIT, OLDBIT) | WHITEBITS))
+#define makewhite(g,x) \
+ (gch(x)->marked = cast_byte((gch(x)->marked & maskcolors) | luaC_white(g)))
+
+#define white2gray(x) resetbits(gch(x)->marked, WHITEBITS)
+#define black2gray(x) resetbit(gch(x)->marked, BLACKBIT)
+
+
+#define isfinalized(x) testbit(gch(x)->marked, FINALIZEDBIT)
+
+#define checkdeadkey(n) lua_assert(!ttisdeadkey(gkey(n)) || ttisnil(gval(n)))
+
+
+#define checkconsistency(obj) \
+ lua_longassert(!iscollectable(obj) || righttt(obj))
+
+
+#define markvalue(g,o) { checkconsistency(o); \
+ if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); }
+
+#define markobject(g,t) { if ((t) && iswhite(obj2gco(t))) \
+ reallymarkobject(g, obj2gco(t)); }
+
+static void reallymarkobject (global_State *g, GCObject *o);
+
+
+/*
+** {======================================================
+** Generic functions
+** =======================================================
+*/
+
+
+/*
+** one after last element in a hash array
+*/
+#define gnodelast(h) gnode(h, cast(size_t, sizenode(h)))
+
+
+/*
+** link table 'h' into list pointed by 'p'
+*/
+#define linktable(h,p) ((h)->gclist = *(p), *(p) = obj2gco(h))
+
+
+/*
+** if key is not marked, mark its entry as dead (therefore removing it
+** from the table)
+*/
+static void removeentry (Node *n) {
+ lua_assert(ttisnil(gval(n)));
+ if (valiswhite(gkey(n)))
+ setdeadvalue(gkey(n)); /* unused and unmarked key; remove it */
+}
+
+
+/*
+** tells whether a key or value can be cleared from a weak
+** table. Non-collectable objects are never removed from weak
+** tables. Strings behave as `values', so are never removed too. for
+** other objects: if really collected, cannot keep them; for objects
+** being finalized, keep them in keys, but not in values
+*/
+static int iscleared (global_State *g, const TValue *o) {
+ if (!iscollectable(o)) return 0;
+ else if (ttisstring(o)) {
+ markobject(g, rawtsvalue(o)); /* strings are `values', so are never weak */
+ return 0;
+ }
+ else return iswhite(gcvalue(o));
+}
+
+
+/*
+** barrier that moves collector forward, that is, mark the white object
+** being pointed by a black object.
+*/
+void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) {
+ global_State *g = G(L);
+ lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
+ lua_assert(g->gcstate != GCSpause);
+ lua_assert(gch(o)->tt != LUA_TTABLE);
+ if (keepinvariantout(g)) /* must keep invariant? */
+ reallymarkobject(g, v); /* restore invariant */
+ else { /* sweep phase */
+ lua_assert(issweepphase(g));
+ makewhite(g, o); /* mark main obj. as white to avoid other barriers */
+ }
+}
+
+
+/*
+** barrier that moves collector backward, that is, mark the black object
+** pointing to a white object as gray again. (Current implementation
+** only works for tables; access to 'gclist' is not uniform across
+** different types.)
+*/
+void luaC_barrierback_ (lua_State *L, GCObject *o) {
+ global_State *g = G(L);
+ lua_assert(isblack(o) && !isdead(g, o) && gch(o)->tt == LUA_TTABLE);
+ black2gray(o); /* make object gray (again) */
+ gco2t(o)->gclist = g->grayagain;
+ g->grayagain = o;
+}
+
+
+/*
+** barrier for prototypes. When creating first closure (cache is
+** NULL), use a forward barrier; this may be the only closure of the
+** prototype (if it is a "regular" function, with a single instance)
+** and the prototype may be big, so it is better to avoid traversing
+** it again. Otherwise, use a backward barrier, to avoid marking all
+** possible instances.
+*/
+LUAI_FUNC void luaC_barrierproto_ (lua_State *L, Proto *p, Closure *c) {
+ global_State *g = G(L);
+ lua_assert(isblack(obj2gco(p)));
+ if (p->cache == NULL) { /* first time? */
+ luaC_objbarrier(L, p, c);
+ }
+ else { /* use a backward barrier */
+ black2gray(obj2gco(p)); /* make prototype gray (again) */
+ p->gclist = g->grayagain;
+ g->grayagain = obj2gco(p);
+ }
+}
+
+
+/*
+** check color (and invariants) for an upvalue that was closed,
+** i.e., moved into the 'allgc' list
+*/
+void luaC_checkupvalcolor (global_State *g, UpVal *uv) {
+ GCObject *o = obj2gco(uv);
+ lua_assert(!isblack(o)); /* open upvalues are never black */
+ if (isgray(o)) {
+ if (keepinvariant(g)) {
+ resetoldbit(o); /* see MOVE OLD rule */
+ gray2black(o); /* it is being visited now */
+ markvalue(g, uv->v);
+ }
+ else {
+ lua_assert(issweepphase(g));
+ makewhite(g, o);
+ }
+ }
+}
+
+
+/*
+** create a new collectable object (with given type and size) and link
+** it to '*list'. 'offset' tells how many bytes to allocate before the
+** object itself (used only by states).
+*/
+GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, GCObject **list,
+ int offset) {
+ global_State *g = G(L);
+ char *raw = cast(char *, luaM_newobject(L, novariant(tt), sz));
+ GCObject *o = obj2gco(raw + offset);
+ if (list == NULL)
+ list = &g->allgc; /* standard list for collectable objects */
+ gch(o)->marked = luaC_white(g);
+ gch(o)->tt = tt;
+ gch(o)->next = *list;
+ *list = o;
+ return o;
+}
+
+/* }====================================================== */
+
+
+
+/*
+** {======================================================
+** Mark functions
+** =======================================================
+*/
+
+
+/*
+** mark an object. Userdata, strings, and closed upvalues are visited
+** and turned black here. Other objects are marked gray and added
+** to appropriate list to be visited (and turned black) later. (Open
+** upvalues are already linked in 'headuv' list.)
+*/
+static void reallymarkobject (global_State *g, GCObject *o) {
+ lu_mem size;
+ white2gray(o);
+ switch (gch(o)->tt) {
+ case LUA_TSHRSTR:
+ case LUA_TLNGSTR: {
+ size = sizestring(gco2ts(o));
+ break; /* nothing else to mark; make it black */
+ }
+ case LUA_TUSERDATA: {
+ Table *mt = gco2u(o)->metatable;
+ markobject(g, mt);
+ markobject(g, gco2u(o)->env);
+ size = sizeudata(gco2u(o));
+ break;
+ }
+ case LUA_TUPVAL: {
+ UpVal *uv = gco2uv(o);
+ markvalue(g, uv->v);
+ if (uv->v != &uv->u.value) /* open? */
+ return; /* open upvalues remain gray */
+ size = sizeof(UpVal);
+ break;
+ }
+ case LUA_TLCL: {
+ gco2lcl(o)->gclist = g->gray;
+ g->gray = o;
+ return;
+ }
+ case LUA_TCCL: {
+ gco2ccl(o)->gclist = g->gray;
+ g->gray = o;
+ return;
+ }
+ case LUA_TTABLE: {
+ linktable(gco2t(o), &g->gray);
+ return;
+ }
+ case LUA_TTHREAD: {
+ gco2th(o)->gclist = g->gray;
+ g->gray = o;
+ return;
+ }
+ case LUA_TPROTO: {
+ gco2p(o)->gclist = g->gray;
+ g->gray = o;
+ return;
+ }
+ default: lua_assert(0); return;
+ }
+ gray2black(o);
+ g->GCmemtrav += size;
+}
+
+
+/*
+** mark metamethods for basic types
+*/
+static void markmt (global_State *g) {
+ int i;
+ for (i=0; i < LUA_NUMTAGS; i++)
+ markobject(g, g->mt[i]);
+}
+
+
+/*
+** mark all objects in list of being-finalized
+*/
+static void markbeingfnz (global_State *g) {
+ GCObject *o;
+ for (o = g->tobefnz; o != NULL; o = gch(o)->next) {
+ makewhite(g, o);
+ reallymarkobject(g, o);
+ }
+}
+
+
+/*
+** mark all values stored in marked open upvalues. (See comment in
+** 'lstate.h'.)
+*/
+static void remarkupvals (global_State *g) {
+ UpVal *uv;
+ for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
+ if (isgray(obj2gco(uv)))
+ markvalue(g, uv->v);
+ }
+}
+
+
+/*
+** mark root set and reset all gray lists, to start a new
+** incremental (or full) collection
+*/
+static void restartcollection (global_State *g) {
+ g->gray = g->grayagain = NULL;
+ g->weak = g->allweak = g->ephemeron = NULL;
+ markobject(g, g->mainthread);
+ markvalue(g, &g->l_registry);
+ markmt(g);
+ markbeingfnz(g); /* mark any finalizing object left from previous cycle */
+}
+
+/* }====================================================== */
+
+
+/*
+** {======================================================
+** Traverse functions
+** =======================================================
+*/
+
+static void traverseweakvalue (global_State *g, Table *h) {
+ Node *n, *limit = gnodelast(h);
+ /* if there is array part, assume it may have white values (do not
+ traverse it just to check) */
+ int hasclears = (h->sizearray > 0);
+ for (n = gnode(h, 0); n < limit; n++) {
+ checkdeadkey(n);
+ if (ttisnil(gval(n))) /* entry is empty? */
+ removeentry(n); /* remove it */
+ else {
+ lua_assert(!ttisnil(gkey(n)));
+ markvalue(g, gkey(n)); /* mark key */
+ if (!hasclears && iscleared(g, gval(n))) /* is there a white value? */
+ hasclears = 1; /* table will have to be cleared */
+ }
+ }
+ if (hasclears)
+ linktable(h, &g->weak); /* has to be cleared later */
+ else /* no white values */
+ linktable(h, &g->grayagain); /* no need to clean */
+}
+
+
+static int traverseephemeron (global_State *g, Table *h) {
+ int marked = 0; /* true if an object is marked in this traversal */
+ int hasclears = 0; /* true if table has white keys */
+ int prop = 0; /* true if table has entry "white-key -> white-value" */
+ Node *n, *limit = gnodelast(h);
+ int i;
+ /* traverse array part (numeric keys are 'strong') */
+ for (i = 0; i < h->sizearray; i++) {
+ if (valiswhite(&h->array[i])) {
+ marked = 1;
+ reallymarkobject(g, gcvalue(&h->array[i]));
+ }
+ }
+ /* traverse hash part */
+ for (n = gnode(h, 0); n < limit; n++) {
+ checkdeadkey(n);
+ if (ttisnil(gval(n))) /* entry is empty? */
+ removeentry(n); /* remove it */
+ else if (iscleared(g, gkey(n))) { /* key is not marked (yet)? */
+ hasclears = 1; /* table must be cleared */
+ if (valiswhite(gval(n))) /* value not marked yet? */
+ prop = 1; /* must propagate again */
+ }
+ else if (valiswhite(gval(n))) { /* value not marked yet? */
+ marked = 1;
+ reallymarkobject(g, gcvalue(gval(n))); /* mark it now */
+ }
+ }
+ if (prop)
+ linktable(h, &g->ephemeron); /* have to propagate again */
+ else if (hasclears) /* does table have white keys? */
+ linktable(h, &g->allweak); /* may have to clean white keys */
+ else /* no white keys */
+ linktable(h, &g->grayagain); /* no need to clean */
+ return marked;
+}
+
+
+static void traversestrongtable (global_State *g, Table *h) {
+ Node *n, *limit = gnodelast(h);
+ int i;
+ for (i = 0; i < h->sizearray; i++) /* traverse array part */
+ markvalue(g, &h->array[i]);
+ for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */
+ checkdeadkey(n);
+ if (ttisnil(gval(n))) /* entry is empty? */
+ removeentry(n); /* remove it */
+ else {
+ lua_assert(!ttisnil(gkey(n)));
+ markvalue(g, gkey(n)); /* mark key */
+ markvalue(g, gval(n)); /* mark value */
+ }
+ }
+}
+
+
+static lu_mem traversetable (global_State *g, Table *h) {
+ const char *weakkey, *weakvalue;
+ const TValue *mode = gfasttm(g, h->metatable, TM_MODE);
+ markobject(g, h->metatable);
+ if (mode && ttisstring(mode) && /* is there a weak mode? */
+ ((weakkey = strchr(svalue(mode), 'k')),
+ (weakvalue = strchr(svalue(mode), 'v')),
+ (weakkey || weakvalue))) { /* is really weak? */
+ black2gray(obj2gco(h)); /* keep table gray */
+ if (!weakkey) /* strong keys? */
+ traverseweakvalue(g, h);
+ else if (!weakvalue) /* strong values? */
+ traverseephemeron(g, h);
+ else /* all weak */
+ linktable(h, &g->allweak); /* nothing to traverse now */
+ }
+ else /* not weak */
+ traversestrongtable(g, h);
+ return sizeof(Table) + sizeof(TValue) * h->sizearray +
+ sizeof(Node) * cast(size_t, sizenode(h));
+}
+
+
+static int traverseproto (global_State *g, Proto *f) {
+ int i;
+ if (f->cache && iswhite(obj2gco(f->cache)))
+ f->cache = NULL; /* allow cache to be collected */
+ markobject(g, f->source);
+ for (i = 0; i < f->sizek; i++) /* mark literals */
+ markvalue(g, &f->k[i]);
+ for (i = 0; i < f->sizeupvalues; i++) /* mark upvalue names */
+ markobject(g, f->upvalues[i].name);
+ for (i = 0; i < f->sizep; i++) /* mark nested protos */
+ markobject(g, f->p[i]);
+ for (i = 0; i < f->sizelocvars; i++) /* mark local-variable names */
+ markobject(g, f->locvars[i].varname);
+ return sizeof(Proto) + sizeof(Instruction) * f->sizecode +
+ sizeof(Proto *) * f->sizep +
+ sizeof(TValue) * f->sizek +
+ sizeof(int) * f->sizelineinfo +
+ sizeof(LocVar) * f->sizelocvars +
+ sizeof(Upvaldesc) * f->sizeupvalues;
+}
+
+
+static lu_mem traverseCclosure (global_State *g, CClosure *cl) {
+ int i;
+ for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */
+ markvalue(g, &cl->upvalue[i]);
+ return sizeCclosure(cl->nupvalues);
+}
+
+static lu_mem traverseLclosure (global_State *g, LClosure *cl) {
+ int i;
+ markobject(g, cl->p); /* mark its prototype */
+ for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */
+ markobject(g, cl->upvals[i]);
+ return sizeLclosure(cl->nupvalues);
+}
+
+
+static lu_mem traversestack (global_State *g, lua_State *th) {
+ int n = 0;
+ StkId o = th->stack;
+ if (o == NULL)
+ return 1; /* stack not completely built yet */
+ for (; o < th->top; o++) /* mark live elements in the stack */
+ markvalue(g, o);
+ if (g->gcstate == GCSatomic) { /* final traversal? */
+ StkId lim = th->stack + th->stacksize; /* real end of stack */
+ for (; o < lim; o++) /* clear not-marked stack slice */
+ setnilvalue(o);
+ }
+ else { /* count call infos to compute size */
+ CallInfo *ci;
+ for (ci = &th->base_ci; ci != th->ci; ci = ci->next)
+ n++;
+ }
+ return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
+ sizeof(CallInfo) * n;
+}
+
+
+/*
+** traverse one gray object, turning it to black (except for threads,
+** which are always gray).
+*/
+static void propagatemark (global_State *g) {
+ lu_mem size;
+ GCObject *o = g->gray;
+ lua_assert(isgray(o));
+ gray2black(o);
+ switch (gch(o)->tt) {
+ case LUA_TTABLE: {
+ Table *h = gco2t(o);
+ g->gray = h->gclist; /* remove from 'gray' list */
+ size = traversetable(g, h);
+ break;
+ }
+ case LUA_TLCL: {
+ LClosure *cl = gco2lcl(o);
+ g->gray = cl->gclist; /* remove from 'gray' list */
+ size = traverseLclosure(g, cl);
+ break;
+ }
+ case LUA_TCCL: {
+ CClosure *cl = gco2ccl(o);
+ g->gray = cl->gclist; /* remove from 'gray' list */
+ size = traverseCclosure(g, cl);
+ break;
+ }
+ case LUA_TTHREAD: {
+ lua_State *th = gco2th(o);
+ g->gray = th->gclist; /* remove from 'gray' list */
+ th->gclist = g->grayagain;
+ g->grayagain = o; /* insert into 'grayagain' list */
+ black2gray(o);
+ size = traversestack(g, th);
+ break;
+ }
+ case LUA_TPROTO: {
+ Proto *p = gco2p(o);
+ g->gray = p->gclist; /* remove from 'gray' list */
+ size = traverseproto(g, p);
+ break;
+ }
+ default: lua_assert(0); return;
+ }
+ g->GCmemtrav += size;
+}
+
+
+static void propagateall (global_State *g) {
+ while (g->gray) propagatemark(g);
+}
+
+
+static void propagatelist (global_State *g, GCObject *l) {
+ lua_assert(g->gray == NULL); /* no grays left */
+ g->gray = l;
+ propagateall(g); /* traverse all elements from 'l' */
+}
+
+/*
+** retraverse all gray lists. Because tables may be reinserted in other
+** lists when traversed, traverse the original lists to avoid traversing
+** twice the same table (which is not wrong, but inefficient)
+*/
+static void retraversegrays (global_State *g) {
+ GCObject *weak = g->weak; /* save original lists */
+ GCObject *grayagain = g->grayagain;
+ GCObject *ephemeron = g->ephemeron;
+ g->weak = g->grayagain = g->ephemeron = NULL;
+ propagateall(g); /* traverse main gray list */
+ propagatelist(g, grayagain);
+ propagatelist(g, weak);
+ propagatelist(g, ephemeron);
+}
+
+
+static void convergeephemerons (global_State *g) {
+ int changed;
+ do {
+ GCObject *w;
+ GCObject *next = g->ephemeron; /* get ephemeron list */
+ g->ephemeron = NULL; /* tables will return to this list when traversed */
+ changed = 0;
+ while ((w = next) != NULL) {
+ next = gco2t(w)->gclist;
+ if (traverseephemeron(g, gco2t(w))) { /* traverse marked some value? */
+ propagateall(g); /* propagate changes */
+ changed = 1; /* will have to revisit all ephemeron tables */
+ }
+ }
+ } while (changed);
+}
+
+/* }====================================================== */
+
+
+/*
+** {======================================================
+** Sweep Functions
+** =======================================================
+*/
+
+
+/*
+** clear entries with unmarked keys from all weaktables in list 'l' up
+** to element 'f'
+*/
+static void clearkeys (global_State *g, GCObject *l, GCObject *f) {
+ for (; l != f; l = gco2t(l)->gclist) {
+ Table *h = gco2t(l);
+ Node *n, *limit = gnodelast(h);
+ for (n = gnode(h, 0); n < limit; n++) {
+ if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) {
+ setnilvalue(gval(n)); /* remove value ... */
+ removeentry(n); /* and remove entry from table */
+ }
+ }
+ }
+}
+
+
+/*
+** clear entries with unmarked values from all weaktables in list 'l' up
+** to element 'f'
+*/
+static void clearvalues (global_State *g, GCObject *l, GCObject *f) {
+ for (; l != f; l = gco2t(l)->gclist) {
+ Table *h = gco2t(l);
+ Node *n, *limit = gnodelast(h);
+ int i;
+ for (i = 0; i < h->sizearray; i++) {
+ TValue *o = &h->array[i];
+ if (iscleared(g, o)) /* value was collected? */
+ setnilvalue(o); /* remove value */
+ }
+ for (n = gnode(h, 0); n < limit; n++) {
+ if (!ttisnil(gval(n)) && iscleared(g, gval(n))) {
+ setnilvalue(gval(n)); /* remove value ... */
+ removeentry(n); /* and remove entry from table */
+ }
+ }
+ }
+}
+
+
+static void freeobj (lua_State *L, GCObject *o) {
+ switch (gch(o)->tt) {
+ case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
+ case LUA_TLCL: {
+ luaM_freemem(L, o, sizeLclosure(gco2lcl(o)->nupvalues));
+ break;
+ }
+ case LUA_TCCL: {
+ luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues));
+ break;
+ }
+ case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break;
+ case LUA_TTABLE: luaH_free(L, gco2t(o)); break;
+ case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break;
+ case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break;
+ case LUA_TSHRSTR:
+ G(L)->strt.nuse--;
+ /* go through */
+ case LUA_TLNGSTR: {
+ luaM_freemem(L, o, sizestring(gco2ts(o)));
+ break;
+ }
+ default: lua_assert(0);
+ }
+}
+
+
+#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
+static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count);
+
+
+/*
+** sweep the (open) upvalues of a thread and resize its stack and
+** list of call-info structures.
+*/
+static void sweepthread (lua_State *L, lua_State *L1) {
+ if (L1->stack == NULL) return; /* stack not completely built yet */
+ sweepwholelist(L, &L1->openupval); /* sweep open upvalues */
+ luaE_freeCI(L1); /* free extra CallInfo slots */
+ /* should not change the stack during an emergency gc cycle */
+ if (G(L)->gckind != KGC_EMERGENCY)
+ luaD_shrinkstack(L1);
+}
+
+
+/*
+** sweep at most 'count' elements from a list of GCObjects erasing dead
+** objects, where a dead (not alive) object is one marked with the "old"
+** (non current) white and not fixed.
+** In non-generational mode, change all non-dead objects back to white,
+** preparing for next collection cycle.
+** In generational mode, keep black objects black, and also mark them as
+** old; stop when hitting an old object, as all objects after that
+** one will be old too.
+** When object is a thread, sweep its list of open upvalues too.
+*/
+static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
+ global_State *g = G(L);
+ int ow = otherwhite(g);
+ int toclear, toset; /* bits to clear and to set in all live objects */
+ int tostop; /* stop sweep when this is true */
+ if (isgenerational(g)) { /* generational mode? */
+ toclear = ~0; /* clear nothing */
+ toset = bitmask(OLDBIT); /* set the old bit of all surviving objects */
+ tostop = bitmask(OLDBIT); /* do not sweep old generation */
+ }
+ else { /* normal mode */
+ toclear = maskcolors; /* clear all color bits + old bit */
+ toset = luaC_white(g); /* make object white */
+ tostop = 0; /* do not stop */
+ }
+ while (*p != NULL && count-- > 0) {
+ GCObject *curr = *p;
+ int marked = gch(curr)->marked;
+ if (isdeadm(ow, marked)) { /* is 'curr' dead? */
+ *p = gch(curr)->next; /* remove 'curr' from list */
+ freeobj(L, curr); /* erase 'curr' */
+ }
+ else {
+ if (testbits(marked, tostop))
+ return NULL; /* stop sweeping this list */
+ if (gch(curr)->tt == LUA_TTHREAD)
+ sweepthread(L, gco2th(curr)); /* sweep thread's upvalues */
+ /* update marks */
+ gch(curr)->marked = cast_byte((marked & toclear) | toset);
+ p = &gch(curr)->next; /* go to next element */
+ }
+ }
+ return (*p == NULL) ? NULL : p;
+}
+
+
+/*
+** sweep a list until a live object (or end of list)
+*/
+static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) {
+ GCObject ** old = p;
+ int i = 0;
+ do {
+ i++;
+ p = sweeplist(L, p, 1);
+ } while (p == old);
+ if (n) *n += i;
+ return p;
+}
+
+/* }====================================================== */
+
+
+/*
+** {======================================================
+** Finalization
+** =======================================================
+*/
+
+static void checkSizes (lua_State *L) {
+ global_State *g = G(L);
+ if (g->gckind != KGC_EMERGENCY) { /* do not change sizes in emergency */
+ int hs = g->strt.size / 2; /* half the size of the string table */
+ if (g->strt.nuse < cast(lu_int32, hs)) /* using less than that half? */
+ luaS_resize(L, hs); /* halve its size */
+ luaZ_freebuffer(L, &g->buff); /* free concatenation buffer */
+ }
+}
+
+
+static GCObject *udata2finalize (global_State *g) {
+ GCObject *o = g->tobefnz; /* get first element */
+ lua_assert(isfinalized(o));
+ g->tobefnz = gch(o)->next; /* remove it from 'tobefnz' list */
+ gch(o)->next = g->allgc; /* return it to 'allgc' list */
+ g->allgc = o;
+ resetbit(gch(o)->marked, SEPARATED); /* mark that it is not in 'tobefnz' */
+ lua_assert(!isold(o)); /* see MOVE OLD rule */
+ if (!keepinvariantout(g)) /* not keeping invariant? */
+ makewhite(g, o); /* "sweep" object */
+ return o;
+}
+
+
+static void dothecall (lua_State *L, void *ud) {
+ UNUSED(ud);
+ luaD_call(L, L->top - 2, 0, 0);
+}
+
+
+static void GCTM (lua_State *L, int propagateerrors) {
+ global_State *g = G(L);
+ const TValue *tm;
+ TValue v;
+ setgcovalue(L, &v, udata2finalize(g));
+ tm = luaT_gettmbyobj(L, &v, TM_GC);
+ if (tm != NULL && ttisfunction(tm)) { /* is there a finalizer? */
+ int status;
+ lu_byte oldah = L->allowhook;
+ int running = g->gcrunning;
+ L->allowhook = 0; /* stop debug hooks during GC metamethod */
+ g->gcrunning = 0; /* avoid GC steps */
+ setobj2s(L, L->top, tm); /* push finalizer... */
+ setobj2s(L, L->top + 1, &v); /* ... and its argument */
+ L->top += 2; /* and (next line) call the finalizer */
+ status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0);
+ L->allowhook = oldah; /* restore hooks */
+ g->gcrunning = running; /* restore state */
+ if (status != LUA_OK && propagateerrors) { /* error while running __gc? */
+ if (status == LUA_ERRRUN) { /* is there an error object? */
+ const char *msg = (ttisstring(L->top - 1))
+ ? svalue(L->top - 1)
+ : "no message";
+ luaO_pushfstring(L, "error in __gc metamethod (%s)", msg);
+ status = LUA_ERRGCMM; /* error in __gc metamethod */
+ }
+ luaD_throw(L, status); /* re-throw error */
+ }
+ }
+}
+
+
+/*
+** move all unreachable objects (or 'all' objects) that need
+** finalization from list 'finobj' to list 'tobefnz' (to be finalized)
+*/
+static void separatetobefnz (lua_State *L, int all) {
+ global_State *g = G(L);
+ GCObject **p = &g->finobj;
+ GCObject *curr;
+ GCObject **lastnext = &g->tobefnz;
+ /* find last 'next' field in 'tobefnz' list (to add elements in its end) */
+ while (*lastnext != NULL)
+ lastnext = &gch(*lastnext)->next;
+ while ((curr = *p) != NULL) { /* traverse all finalizable objects */
+ lua_assert(!isfinalized(curr));
+ lua_assert(testbit(gch(curr)->marked, SEPARATED));
+ if (!(iswhite(curr) || all)) /* not being collected? */
+ p = &gch(curr)->next; /* don't bother with it */
+ else {
+ l_setbit(gch(curr)->marked, FINALIZEDBIT); /* won't be finalized again */
+ *p = gch(curr)->next; /* remove 'curr' from 'finobj' list */
+ gch(curr)->next = *lastnext; /* link at the end of 'tobefnz' list */
+ *lastnext = curr;
+ lastnext = &gch(curr)->next;
+ }
+ }
+}
+
+
+/*
+** if object 'o' has a finalizer, remove it from 'allgc' list (must
+** search the list to find it) and link it in 'finobj' list.
+*/
+void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) {
+ global_State *g = G(L);
+ if (testbit(gch(o)->marked, SEPARATED) || /* obj. is already separated... */
+ isfinalized(o) || /* ... or is finalized... */
+ gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */
+ return; /* nothing to be done */
+ else { /* move 'o' to 'finobj' list */
+ GCObject **p;
+ GCheader *ho = gch(o);
+ if (g->sweepgc == &ho->next) { /* avoid removing current sweep object */
+ lua_assert(issweepphase(g));
+ g->sweepgc = sweeptolive(L, g->sweepgc, NULL);
+ }
+ /* search for pointer pointing to 'o' */
+ for (p = &g->allgc; *p != o; p = &gch(*p)->next) { /* empty */ }
+ *p = ho->next; /* remove 'o' from root list */
+ ho->next = g->finobj; /* link it in list 'finobj' */
+ g->finobj = o;
+ l_setbit(ho->marked, SEPARATED); /* mark it as such */
+ if (!keepinvariantout(g)) /* not keeping invariant? */
+ makewhite(g, o); /* "sweep" object */
+ else
+ resetoldbit(o); /* see MOVE OLD rule */
+ }
+}
+
+/* }====================================================== */
+
+
+/*
+** {======================================================
+** GC control
+** =======================================================
+*/
+
+
+/*
+** set a reasonable "time" to wait before starting a new GC cycle;
+** cycle will start when memory use hits threshold
+*/
+static void setpause (global_State *g, l_mem estimate) {
+ l_mem debt, threshold;
+ estimate = estimate / PAUSEADJ; /* adjust 'estimate' */
+ threshold = (g->gcpause < MAX_LMEM / estimate) /* overflow? */
+ ? estimate * g->gcpause /* no overflow */
+ : MAX_LMEM; /* overflow; truncate to maximum */
+ debt = -cast(l_mem, threshold - gettotalbytes(g));
+ luaE_setdebt(g, debt);
+}
+
+
+#define sweepphases \
+ (bitmask(GCSsweepstring) | bitmask(GCSsweepudata) | bitmask(GCSsweep))
+
+
+/*
+** enter first sweep phase (strings) and prepare pointers for other
+** sweep phases. The calls to 'sweeptolive' make pointers point to an
+** object inside the list (instead of to the header), so that the real
+** sweep do not need to skip objects created between "now" and the start
+** of the real sweep.
+** Returns how many objects it swept.
+*/
+static int entersweep (lua_State *L) {
+ global_State *g = G(L);
+ int n = 0;
+ g->gcstate = GCSsweepstring;
+ lua_assert(g->sweepgc == NULL && g->sweepfin == NULL);
+ /* prepare to sweep strings, finalizable objects, and regular objects */
+ g->sweepstrgc = 0;
+ g->sweepfin = sweeptolive(L, &g->finobj, &n);
+ g->sweepgc = sweeptolive(L, &g->allgc, &n);
+ return n;
+}
+
+
+/*
+** change GC mode
+*/
+void luaC_changemode (lua_State *L, int mode) {
+ global_State *g = G(L);
+ if (mode == g->gckind) return; /* nothing to change */
+ if (mode == KGC_GEN) { /* change to generational mode */
+ /* make sure gray lists are consistent */
+ luaC_runtilstate(L, bitmask(GCSpropagate));
+ g->GCestimate = gettotalbytes(g);
+ g->gckind = KGC_GEN;
+ }
+ else { /* change to incremental mode */
+ /* sweep all objects to turn them back to white
+ (as white has not changed, nothing extra will be collected) */
+ g->gckind = KGC_NORMAL;
+ entersweep(L);
+ luaC_runtilstate(L, ~sweepphases);
+ }
+}
+
+
+/*
+** call all pending finalizers
+*/
+static void callallpendingfinalizers (lua_State *L, int propagateerrors) {
+ global_State *g = G(L);
+ while (g->tobefnz) {
+ resetoldbit(g->tobefnz);
+ GCTM(L, propagateerrors);
+ }
+}
+
+
+void luaC_freeallobjects (lua_State *L) {
+ global_State *g = G(L);
+ int i;
+ separatetobefnz(L, 1); /* separate all objects with finalizers */
+ lua_assert(g->finobj == NULL);
+ callallpendingfinalizers(L, 0);
+ g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */
+ g->gckind = KGC_NORMAL;
+ sweepwholelist(L, &g->finobj); /* finalizers can create objs. in 'finobj' */
+ sweepwholelist(L, &g->allgc);
+ for (i = 0; i < g->strt.size; i++) /* free all string lists */
+ sweepwholelist(L, &g->strt.hash[i]);
+ lua_assert(g->strt.nuse == 0);
+}
+
+
+static l_mem atomic (lua_State *L) {
+ global_State *g = G(L);
+ l_mem work = -cast(l_mem, g->GCmemtrav); /* start counting work */
+ GCObject *origweak, *origall;
+ lua_assert(!iswhite(obj2gco(g->mainthread)));
+ markobject(g, L); /* mark running thread */
+ /* registry and global metatables may be changed by API */
+ markvalue(g, &g->l_registry);
+ markmt(g); /* mark basic metatables */
+ /* remark occasional upvalues of (maybe) dead threads */
+ remarkupvals(g);
+ propagateall(g); /* propagate changes */
+ work += g->GCmemtrav; /* stop counting (do not (re)count grays) */
+ /* traverse objects caught by write barrier and by 'remarkupvals' */
+ retraversegrays(g);
+ work -= g->GCmemtrav; /* restart counting */
+ convergeephemerons(g);
+ /* at this point, all strongly accessible objects are marked. */
+ /* clear values from weak tables, before checking finalizers */
+ clearvalues(g, g->weak, NULL);
+ clearvalues(g, g->allweak, NULL);
+ origweak = g->weak; origall = g->allweak;
+ work += g->GCmemtrav; /* stop counting (objects being finalized) */
+ separatetobefnz(L, 0); /* separate objects to be finalized */
+ markbeingfnz(g); /* mark objects that will be finalized */
+ propagateall(g); /* remark, to propagate `preserveness' */
+ work -= g->GCmemtrav; /* restart counting */
+ convergeephemerons(g);
+ /* at this point, all resurrected objects are marked. */
+ /* remove dead objects from weak tables */
+ clearkeys(g, g->ephemeron, NULL); /* clear keys from all ephemeron tables */
+ clearkeys(g, g->allweak, NULL); /* clear keys from all allweak tables */
+ /* clear values from resurrected weak tables */
+ clearvalues(g, g->weak, origweak);
+ clearvalues(g, g->allweak, origall);
+ g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */
+ work += g->GCmemtrav; /* complete counting */
+ return work; /* estimate of memory marked by 'atomic' */
+}
+
+
+static lu_mem singlestep (lua_State *L) {
+ global_State *g = G(L);
+ switch (g->gcstate) {
+ case GCSpause: {
+ /* start to count memory traversed */
+ g->GCmemtrav = g->strt.size * sizeof(GCObject*);
+ lua_assert(!isgenerational(g));
+ restartcollection(g);
+ g->gcstate = GCSpropagate;
+ return g->GCmemtrav;
+ }
+ case GCSpropagate: {
+ if (g->gray) {
+ lu_mem oldtrav = g->GCmemtrav;
+ propagatemark(g);
+ return g->GCmemtrav - oldtrav; /* memory traversed in this step */
+ }
+ else { /* no more `gray' objects */
+ lu_mem work;
+ int sw;
+ g->gcstate = GCSatomic; /* finish mark phase */
+ g->GCestimate = g->GCmemtrav; /* save what was counted */;
+ work = atomic(L); /* add what was traversed by 'atomic' */
+ g->GCestimate += work; /* estimate of total memory traversed */
+ sw = entersweep(L);
+ return work + sw * GCSWEEPCOST;
+ }
+ }
+ case GCSsweepstring: {
+ int i;
+ for (i = 0; i < GCSWEEPMAX && g->sweepstrgc + i < g->strt.size; i++)
+ sweepwholelist(L, &g->strt.hash[g->sweepstrgc + i]);
+ g->sweepstrgc += i;
+ if (g->sweepstrgc >= g->strt.size) /* no more strings to sweep? */
+ g->gcstate = GCSsweepudata;
+ return i * GCSWEEPCOST;
+ }
+ case GCSsweepudata: {
+ if (g->sweepfin) {
+ g->sweepfin = sweeplist(L, g->sweepfin, GCSWEEPMAX);
+ return GCSWEEPMAX*GCSWEEPCOST;
+ }
+ else {
+ g->gcstate = GCSsweep;
+ return 0;
+ }
+ }
+ case GCSsweep: {
+ if (g->sweepgc) {
+ g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
+ return GCSWEEPMAX*GCSWEEPCOST;
+ }
+ else {
+ /* sweep main thread */
+ GCObject *mt = obj2gco(g->mainthread);
+ sweeplist(L, &mt, 1);
+ checkSizes(L);
+ g->gcstate = GCSpause; /* finish collection */
+ return GCSWEEPCOST;
+ }
+ }
+ default: lua_assert(0); return 0;
+ }
+}
+
+
+/*
+** advances the garbage collector until it reaches a state allowed
+** by 'statemask'
+*/
+void luaC_runtilstate (lua_State *L, int statesmask) {
+ global_State *g = G(L);
+ while (!testbit(statesmask, g->gcstate))
+ singlestep(L);
+}
+
+
+static void generationalcollection (lua_State *L) {
+ global_State *g = G(L);
+ lua_assert(g->gcstate == GCSpropagate);
+ if (g->GCestimate == 0) { /* signal for another major collection? */
+ luaC_fullgc(L, 0); /* perform a full regular collection */
+ g->GCestimate = gettotalbytes(g); /* update control */
+ }
+ else {
+ lu_mem estimate = g->GCestimate;
+ luaC_runtilstate(L, bitmask(GCSpause)); /* run complete (minor) cycle */
+ g->gcstate = GCSpropagate; /* skip restart */
+ if (gettotalbytes(g) > (estimate / 100) * g->gcmajorinc)
+ g->GCestimate = 0; /* signal for a major collection */
+ else
+ g->GCestimate = estimate; /* keep estimate from last major coll. */
+
+ }
+ setpause(g, gettotalbytes(g));
+ lua_assert(g->gcstate == GCSpropagate);
+}
+
+
+static void incstep (lua_State *L) {
+ global_State *g = G(L);
+ l_mem debt = g->GCdebt;
+ int stepmul = g->gcstepmul;
+ if (stepmul < 40) stepmul = 40; /* avoid ridiculous low values (and 0) */
+ /* convert debt from Kb to 'work units' (avoid zero debt and overflows) */
+ debt = (debt / STEPMULADJ) + 1;
+ debt = (debt < MAX_LMEM / stepmul) ? debt * stepmul : MAX_LMEM;
+ do { /* always perform at least one single step */
+ lu_mem work = singlestep(L); /* do some work */
+ debt -= work;
+ } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause);
+ if (g->gcstate == GCSpause)
+ setpause(g, g->GCestimate); /* pause until next cycle */
+ else {
+ debt = (debt / stepmul) * STEPMULADJ; /* convert 'work units' to Kb */
+ luaE_setdebt(g, debt);
+ }
+}
+
+
+/*
+** performs a basic GC step
+*/
+void luaC_forcestep (lua_State *L) {
+ global_State *g = G(L);
+ int i;
+ if (isgenerational(g)) generationalcollection(L);
+ else incstep(L);
+ /* run a few finalizers (or all of them at the end of a collect cycle) */
+ for (i = 0; g->tobefnz && (i < GCFINALIZENUM || g->gcstate == GCSpause); i++)
+ GCTM(L, 1); /* call one finalizer */
+}
+
+
+/*
+** performs a basic GC step only if collector is running
+*/
+void luaC_step (lua_State *L) {
+ global_State *g = G(L);
+ if (g->gcrunning) luaC_forcestep(L);
+ else luaE_setdebt(g, -GCSTEPSIZE); /* avoid being called too often */
+}
+
+
+
+/*
+** performs a full GC cycle; if "isemergency", does not call
+** finalizers (which could change stack positions)
+*/
+void luaC_fullgc (lua_State *L, int isemergency) {
+ global_State *g = G(L);
+ int origkind = g->gckind;
+ lua_assert(origkind != KGC_EMERGENCY);
+ if (isemergency) /* do not run finalizers during emergency GC */
+ g->gckind = KGC_EMERGENCY;
+ else {
+ g->gckind = KGC_NORMAL;
+ callallpendingfinalizers(L, 1);
+ }
+ if (keepinvariant(g)) { /* may there be some black objects? */
+ /* must sweep all objects to turn them back to white
+ (as white has not changed, nothing will be collected) */
+ entersweep(L);
+ }
+ /* finish any pending sweep phase to start a new cycle */
+ luaC_runtilstate(L, bitmask(GCSpause));
+ luaC_runtilstate(L, ~bitmask(GCSpause)); /* start new collection */
+ luaC_runtilstate(L, bitmask(GCSpause)); /* run entire collection */
+ if (origkind == KGC_GEN) { /* generational mode? */
+ /* generational mode must be kept in propagate phase */
+ luaC_runtilstate(L, bitmask(GCSpropagate));
+ }
+ g->gckind = origkind;
+ setpause(g, gettotalbytes(g));
+ if (!isemergency) /* do not run finalizers during emergency GC */
+ callallpendingfinalizers(L, 1);
+}
+
+/* }====================================================== */
+
+
diff --git a/ext/lua/src/linit.c b/ext/lua/src/linit.c
new file mode 100644
index 0000000000..c1a3830471
--- /dev/null
+++ b/ext/lua/src/linit.c
@@ -0,0 +1,67 @@
+/*
+** $Id: linit.c,v 1.32.1.1 2013/04/12 18:48:47 roberto Exp $
+** Initialization of libraries for lua.c and other clients
+** See Copyright Notice in lua.h
+*/
+
+
+/*
+** If you embed Lua in your program and need to open the standard
+** libraries, call luaL_openlibs in your program. If you need a
+** different set of libraries, copy this file to your project and edit
+** it to suit your needs.
+*/
+
+
+#define linit_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lualib.h"
+#include "lauxlib.h"
+
+
+/*
+** these libs are loaded by lua.c and are readily available to any Lua
+** program
+*/
+static const luaL_Reg loadedlibs[] = {
+ {"_G", luaopen_base},
+ {LUA_LOADLIBNAME, luaopen_package},
+ {LUA_COLIBNAME, luaopen_coroutine},
+ {LUA_TABLIBNAME, luaopen_table},
+ {LUA_IOLIBNAME, luaopen_io},
+ {LUA_OSLIBNAME, luaopen_os},
+ {LUA_STRLIBNAME, luaopen_string},
+ {LUA_BITLIBNAME, luaopen_bit32},
+ {LUA_MATHLIBNAME, luaopen_math},
+ {LUA_DBLIBNAME, luaopen_debug},
+ {NULL, NULL}
+};
+
+
+/*
+** these libs are preloaded and must be required before used
+*/
+static const luaL_Reg preloadedlibs[] = {
+ {NULL, NULL}
+};
+
+
+LUALIB_API void luaL_openlibs (lua_State *L) {
+ const luaL_Reg *lib;
+ /* call open functions from 'loadedlibs' and set results to global table */
+ for (lib = loadedlibs; lib->func; lib++) {
+ luaL_requiref(L, lib->name, lib->func, 1);
+ lua_pop(L, 1); /* remove lib */
+ }
+ /* add open functions from 'preloadedlibs' into 'package.preload' table */
+ luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
+ for (lib = preloadedlibs; lib->func; lib++) {
+ lua_pushcfunction(L, lib->func);
+ lua_setfield(L, -2, lib->name);
+ }
+ lua_pop(L, 1); /* remove _PRELOAD table */
+}
+
diff --git a/ext/lua/src/liolib.c b/ext/lua/src/liolib.c
new file mode 100644
index 0000000000..2a4ec4aa34
--- /dev/null
+++ b/ext/lua/src/liolib.c
@@ -0,0 +1,666 @@
+/*
+** $Id: liolib.c,v 2.112.1.1 2013/04/12 18:48:47 roberto Exp $
+** Standard I/O (and system) library
+** See Copyright Notice in lua.h
+*/
+
+
+/*
+** This definition must come before the inclusion of 'stdio.h'; it
+** should not affect non-POSIX systems
+*/
+#if !defined(_FILE_OFFSET_BITS)
+#define _LARGEFILE_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+#endif
+
+
+#include
+#include
+#include
+#include
+
+#define liolib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+#if !defined(lua_checkmode)
+
+/*
+** Check whether 'mode' matches '[rwa]%+?b?'.
+** Change this macro to accept other modes for 'fopen' besides
+** the standard ones.
+*/
+#define lua_checkmode(mode) \
+ (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && \
+ (*mode != '+' || ++mode) && /* skip if char is '+' */ \
+ (*mode != 'b' || ++mode) && /* skip if char is 'b' */ \
+ (*mode == '\0'))
+
+#endif
+
+/*
+** {======================================================
+** lua_popen spawns a new process connected to the current
+** one through the file streams.
+** =======================================================
+*/
+
+#if !defined(lua_popen) /* { */
+
+#if defined(LUA_USE_POPEN) /* { */
+
+#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
+#define lua_pclose(L,file) ((void)L, pclose(file))
+
+#elif defined(LUA_WIN) /* }{ */
+
+#define lua_popen(L,c,m) ((void)L, _popen(c,m))
+#define lua_pclose(L,file) ((void)L, _pclose(file))
+
+
+#else /* }{ */
+
+#define lua_popen(L,c,m) ((void)((void)c, m), \
+ luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
+#define lua_pclose(L,file) ((void)((void)L, file), -1)
+
+
+#endif /* } */
+
+#endif /* } */
+
+/* }====================================================== */
+
+
+/*
+** {======================================================
+** lua_fseek: configuration for longer offsets
+** =======================================================
+*/
+
+#if !defined(lua_fseek) && !defined(LUA_ANSI) /* { */
+
+#if defined(LUA_USE_POSIX) /* { */
+
+#define l_fseek(f,o,w) fseeko(f,o,w)
+#define l_ftell(f) ftello(f)
+#define l_seeknum off_t
+
+#elif defined(LUA_WIN) && !defined(_CRTIMP_TYPEINFO) \
+ && defined(_MSC_VER) && (_MSC_VER >= 1400) /* }{ */
+/* Windows (but not DDK) and Visual C++ 2005 or higher */
+
+#define l_fseek(f,o,w) _fseeki64(f,o,w)
+#define l_ftell(f) _ftelli64(f)
+#define l_seeknum __int64
+
+#endif /* } */
+
+#endif /* } */
+
+
+#if !defined(l_fseek) /* default definitions */
+#define l_fseek(f,o,w) fseek(f,o,w)
+#define l_ftell(f) ftell(f)
+#define l_seeknum long
+#endif
+
+/* }====================================================== */
+
+
+#define IO_PREFIX "_IO_"
+#define IO_INPUT (IO_PREFIX "input")
+#define IO_OUTPUT (IO_PREFIX "output")
+
+
+typedef luaL_Stream LStream;
+
+
+#define tolstream(L) ((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE))
+
+#define isclosed(p) ((p)->closef == NULL)
+
+
+static int io_type (lua_State *L) {
+ LStream *p;
+ luaL_checkany(L, 1);
+ p = (LStream *)luaL_testudata(L, 1, LUA_FILEHANDLE);
+ if (p == NULL)
+ lua_pushnil(L); /* not a file */
+ else if (isclosed(p))
+ lua_pushliteral(L, "closed file");
+ else
+ lua_pushliteral(L, "file");
+ return 1;
+}
+
+
+static int f_tostring (lua_State *L) {
+ LStream *p = tolstream(L);
+ if (isclosed(p))
+ lua_pushliteral(L, "file (closed)");
+ else
+ lua_pushfstring(L, "file (%p)", p->f);
+ return 1;
+}
+
+
+static FILE *tofile (lua_State *L) {
+ LStream *p = tolstream(L);
+ if (isclosed(p))
+ luaL_error(L, "attempt to use a closed file");
+ lua_assert(p->f);
+ return p->f;
+}
+
+
+/*
+** When creating file handles, always creates a `closed' file handle
+** before opening the actual file; so, if there is a memory error, the
+** file is not left opened.
+*/
+static LStream *newprefile (lua_State *L) {
+ LStream *p = (LStream *)lua_newuserdata(L, sizeof(LStream));
+ p->closef = NULL; /* mark file handle as 'closed' */
+ luaL_setmetatable(L, LUA_FILEHANDLE);
+ return p;
+}
+
+
+static int aux_close (lua_State *L) {
+ LStream *p = tolstream(L);
+ lua_CFunction cf = p->closef;
+ p->closef = NULL; /* mark stream as closed */
+ return (*cf)(L); /* close it */
+}
+
+
+static int io_close (lua_State *L) {
+ if (lua_isnone(L, 1)) /* no argument? */
+ lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use standard output */
+ tofile(L); /* make sure argument is an open stream */
+ return aux_close(L);
+}
+
+
+static int f_gc (lua_State *L) {
+ LStream *p = tolstream(L);
+ if (!isclosed(p) && p->f != NULL)
+ aux_close(L); /* ignore closed and incompletely open files */
+ return 0;
+}
+
+
+/*
+** function to close regular files
+*/
+static int io_fclose (lua_State *L) {
+ LStream *p = tolstream(L);
+ int res = fclose(p->f);
+ return luaL_fileresult(L, (res == 0), NULL);
+}
+
+
+static LStream *newfile (lua_State *L) {
+ LStream *p = newprefile(L);
+ p->f = NULL;
+ p->closef = &io_fclose;
+ return p;
+}
+
+
+static void opencheck (lua_State *L, const char *fname, const char *mode) {
+ LStream *p = newfile(L);
+ p->f = fopen(fname, mode);
+ if (p->f == NULL)
+ luaL_error(L, "cannot open file " LUA_QS " (%s)", fname, strerror(errno));
+}
+
+
+static int io_open (lua_State *L) {
+ const char *filename = luaL_checkstring(L, 1);
+ const char *mode = luaL_optstring(L, 2, "r");
+ LStream *p = newfile(L);
+ const char *md = mode; /* to traverse/check mode */
+ luaL_argcheck(L, lua_checkmode(md), 2, "invalid mode");
+ p->f = fopen(filename, mode);
+ return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;
+}
+
+
+/*
+** function to close 'popen' files
+*/
+static int io_pclose (lua_State *L) {
+ LStream *p = tolstream(L);
+ return luaL_execresult(L, lua_pclose(L, p->f));
+}
+
+
+static int io_popen (lua_State *L) {
+ const char *filename = luaL_checkstring(L, 1);
+ const char *mode = luaL_optstring(L, 2, "r");
+ LStream *p = newprefile(L);
+ p->f = lua_popen(L, filename, mode);
+ p->closef = &io_pclose;
+ return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;
+}
+
+
+static int io_tmpfile (lua_State *L) {
+ LStream *p = newfile(L);
+ p->f = tmpfile();
+ return (p->f == NULL) ? luaL_fileresult(L, 0, NULL) : 1;
+}
+
+
+static FILE *getiofile (lua_State *L, const char *findex) {
+ LStream *p;
+ lua_getfield(L, LUA_REGISTRYINDEX, findex);
+ p = (LStream *)lua_touserdata(L, -1);
+ if (isclosed(p))
+ luaL_error(L, "standard %s file is closed", findex + strlen(IO_PREFIX));
+ return p->f;
+}
+
+
+static int g_iofile (lua_State *L, const char *f, const char *mode) {
+ if (!lua_isnoneornil(L, 1)) {
+ const char *filename = lua_tostring(L, 1);
+ if (filename)
+ opencheck(L, filename, mode);
+ else {
+ tofile(L); /* check that it's a valid file handle */
+ lua_pushvalue(L, 1);
+ }
+ lua_setfield(L, LUA_REGISTRYINDEX, f);
+ }
+ /* return current value */
+ lua_getfield(L, LUA_REGISTRYINDEX, f);
+ return 1;
+}
+
+
+static int io_input (lua_State *L) {
+ return g_iofile(L, IO_INPUT, "r");
+}
+
+
+static int io_output (lua_State *L) {
+ return g_iofile(L, IO_OUTPUT, "w");
+}
+
+
+static int io_readline (lua_State *L);
+
+
+static void aux_lines (lua_State *L, int toclose) {
+ int i;
+ int n = lua_gettop(L) - 1; /* number of arguments to read */
+ /* ensure that arguments will fit here and into 'io_readline' stack */
+ luaL_argcheck(L, n <= LUA_MINSTACK - 3, LUA_MINSTACK - 3, "too many options");
+ lua_pushvalue(L, 1); /* file handle */
+ lua_pushinteger(L, n); /* number of arguments to read */
+ lua_pushboolean(L, toclose); /* close/not close file when finished */
+ for (i = 1; i <= n; i++) lua_pushvalue(L, i + 1); /* copy arguments */
+ lua_pushcclosure(L, io_readline, 3 + n);
+}
+
+
+static int f_lines (lua_State *L) {
+ tofile(L); /* check that it's a valid file handle */
+ aux_lines(L, 0);
+ return 1;
+}
+
+
+static int io_lines (lua_State *L) {
+ int toclose;
+ if (lua_isnone(L, 1)) lua_pushnil(L); /* at least one argument */
+ if (lua_isnil(L, 1)) { /* no file name? */
+ lua_getfield(L, LUA_REGISTRYINDEX, IO_INPUT); /* get default input */
+ lua_replace(L, 1); /* put it at index 1 */
+ tofile(L); /* check that it's a valid file handle */
+ toclose = 0; /* do not close it after iteration */
+ }
+ else { /* open a new file */
+ const char *filename = luaL_checkstring(L, 1);
+ opencheck(L, filename, "r");
+ lua_replace(L, 1); /* put file at index 1 */
+ toclose = 1; /* close it after iteration */
+ }
+ aux_lines(L, toclose);
+ return 1;
+}
+
+
+/*
+** {======================================================
+** READ
+** =======================================================
+*/
+
+
+static int read_number (lua_State *L, FILE *f) {
+ lua_Number d;
+ if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) {
+ lua_pushnumber(L, d);
+ return 1;
+ }
+ else {
+ lua_pushnil(L); /* "result" to be removed */
+ return 0; /* read fails */
+ }
+}
+
+
+static int test_eof (lua_State *L, FILE *f) {
+ int c = getc(f);
+ ungetc(c, f);
+ lua_pushlstring(L, NULL, 0);
+ return (c != EOF);
+}
+
+
+static int read_line (lua_State *L, FILE *f, int chop) {
+ luaL_Buffer b;
+ luaL_buffinit(L, &b);
+ for (;;) {
+ size_t l;
+ char *p = luaL_prepbuffer(&b);
+ if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */
+ luaL_pushresult(&b); /* close buffer */
+ return (lua_rawlen(L, -1) > 0); /* check whether read something */
+ }
+ l = strlen(p);
+ if (l == 0 || p[l-1] != '\n')
+ luaL_addsize(&b, l);
+ else {
+ luaL_addsize(&b, l - chop); /* chop 'eol' if needed */
+ luaL_pushresult(&b); /* close buffer */
+ return 1; /* read at least an `eol' */
+ }
+ }
+}
+
+
+#define MAX_SIZE_T (~(size_t)0)
+
+static void read_all (lua_State *L, FILE *f) {
+ size_t rlen = LUAL_BUFFERSIZE; /* how much to read in each cycle */
+ luaL_Buffer b;
+ luaL_buffinit(L, &b);
+ for (;;) {
+ char *p = luaL_prepbuffsize(&b, rlen);
+ size_t nr = fread(p, sizeof(char), rlen, f);
+ luaL_addsize(&b, nr);
+ if (nr < rlen) break; /* eof? */
+ else if (rlen <= (MAX_SIZE_T / 4)) /* avoid buffers too large */
+ rlen *= 2; /* double buffer size at each iteration */
+ }
+ luaL_pushresult(&b); /* close buffer */
+}
+
+
+static int read_chars (lua_State *L, FILE *f, size_t n) {
+ size_t nr; /* number of chars actually read */
+ char *p;
+ luaL_Buffer b;
+ luaL_buffinit(L, &b);
+ p = luaL_prepbuffsize(&b, n); /* prepare buffer to read whole block */
+ nr = fread(p, sizeof(char), n, f); /* try to read 'n' chars */
+ luaL_addsize(&b, nr);
+ luaL_pushresult(&b); /* close buffer */
+ return (nr > 0); /* true iff read something */
+}
+
+
+static int g_read (lua_State *L, FILE *f, int first) {
+ int nargs = lua_gettop(L) - 1;
+ int success;
+ int n;
+ clearerr(f);
+ if (nargs == 0) { /* no arguments? */
+ success = read_line(L, f, 1);
+ n = first+1; /* to return 1 result */
+ }
+ else { /* ensure stack space for all results and for auxlib's buffer */
+ luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments");
+ success = 1;
+ for (n = first; nargs-- && success; n++) {
+ if (lua_type(L, n) == LUA_TNUMBER) {
+ size_t l = (size_t)lua_tointeger(L, n);
+ success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
+ }
+ else {
+ const char *p = lua_tostring(L, n);
+ luaL_argcheck(L, p && p[0] == '*', n, "invalid option");
+ switch (p[1]) {
+ case 'n': /* number */
+ success = read_number(L, f);
+ break;
+ case 'l': /* line */
+ success = read_line(L, f, 1);
+ break;
+ case 'L': /* line with end-of-line */
+ success = read_line(L, f, 0);
+ break;
+ case 'a': /* file */
+ read_all(L, f); /* read entire file */
+ success = 1; /* always success */
+ break;
+ default:
+ return luaL_argerror(L, n, "invalid format");
+ }
+ }
+ }
+ }
+ if (ferror(f))
+ return luaL_fileresult(L, 0, NULL);
+ if (!success) {
+ lua_pop(L, 1); /* remove last result */
+ lua_pushnil(L); /* push nil instead */
+ }
+ return n - first;
+}
+
+
+static int io_read (lua_State *L) {
+ return g_read(L, getiofile(L, IO_INPUT), 1);
+}
+
+
+static int f_read (lua_State *L) {
+ return g_read(L, tofile(L), 2);
+}
+
+
+static int io_readline (lua_State *L) {
+ LStream *p = (LStream *)lua_touserdata(L, lua_upvalueindex(1));
+ int i;
+ int n = (int)lua_tointeger(L, lua_upvalueindex(2));
+ if (isclosed(p)) /* file is already closed? */
+ return luaL_error(L, "file is already closed");
+ lua_settop(L , 1);
+ for (i = 1; i <= n; i++) /* push arguments to 'g_read' */
+ lua_pushvalue(L, lua_upvalueindex(3 + i));
+ n = g_read(L, p->f, 2); /* 'n' is number of results */
+ lua_assert(n > 0); /* should return at least a nil */
+ if (!lua_isnil(L, -n)) /* read at least one value? */
+ return n; /* return them */
+ else { /* first result is nil: EOF or error */
+ if (n > 1) { /* is there error information? */
+ /* 2nd result is error message */
+ return luaL_error(L, "%s", lua_tostring(L, -n + 1));
+ }
+ if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */
+ lua_settop(L, 0);
+ lua_pushvalue(L, lua_upvalueindex(1));
+ aux_close(L); /* close it */
+ }
+ return 0;
+ }
+}
+
+/* }====================================================== */
+
+
+static int g_write (lua_State *L, FILE *f, int arg) {
+ int nargs = lua_gettop(L) - arg;
+ int status = 1;
+ for (; nargs--; arg++) {
+ if (lua_type(L, arg) == LUA_TNUMBER) {
+ /* optimization: could be done exactly as for strings */
+ status = status &&
+ fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
+ }
+ else {
+ size_t l;
+ const char *s = luaL_checklstring(L, arg, &l);
+ status = status && (fwrite(s, sizeof(char), l, f) == l);
+ }
+ }
+ if (status) return 1; /* file handle already on stack top */
+ else return luaL_fileresult(L, status, NULL);
+}
+
+
+static int io_write (lua_State *L) {
+ return g_write(L, getiofile(L, IO_OUTPUT), 1);
+}
+
+
+static int f_write (lua_State *L) {
+ FILE *f = tofile(L);
+ lua_pushvalue(L, 1); /* push file at the stack top (to be returned) */
+ return g_write(L, f, 2);
+}
+
+
+static int f_seek (lua_State *L) {
+ static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
+ static const char *const modenames[] = {"set", "cur", "end", NULL};
+ FILE *f = tofile(L);
+ int op = luaL_checkoption(L, 2, "cur", modenames);
+ lua_Number p3 = luaL_optnumber(L, 3, 0);
+ l_seeknum offset = (l_seeknum)p3;
+ luaL_argcheck(L, (lua_Number)offset == p3, 3,
+ "not an integer in proper range");
+ op = l_fseek(f, offset, mode[op]);
+ if (op)
+ return luaL_fileresult(L, 0, NULL); /* error */
+ else {
+ lua_pushnumber(L, (lua_Number)l_ftell(f));
+ return 1;
+ }
+}
+
+
+static int f_setvbuf (lua_State *L) {
+ static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
+ static const char *const modenames[] = {"no", "full", "line", NULL};
+ FILE *f = tofile(L);
+ int op = luaL_checkoption(L, 2, NULL, modenames);
+ lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
+ int res = setvbuf(f, NULL, mode[op], sz);
+ return luaL_fileresult(L, res == 0, NULL);
+}
+
+
+
+static int io_flush (lua_State *L) {
+ return luaL_fileresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL);
+}
+
+
+static int f_flush (lua_State *L) {
+ return luaL_fileresult(L, fflush(tofile(L)) == 0, NULL);
+}
+
+
+/*
+** functions for 'io' library
+*/
+static const luaL_Reg iolib[] = {
+ {"close", io_close},
+ {"flush", io_flush},
+ {"input", io_input},
+ {"lines", io_lines},
+ {"open", io_open},
+ {"output", io_output},
+ {"popen", io_popen},
+ {"read", io_read},
+ {"tmpfile", io_tmpfile},
+ {"type", io_type},
+ {"write", io_write},
+ {NULL, NULL}
+};
+
+
+/*
+** methods for file handles
+*/
+static const luaL_Reg flib[] = {
+ {"close", io_close},
+ {"flush", f_flush},
+ {"lines", f_lines},
+ {"read", f_read},
+ {"seek", f_seek},
+ {"setvbuf", f_setvbuf},
+ {"write", f_write},
+ {"__gc", f_gc},
+ {"__tostring", f_tostring},
+ {NULL, NULL}
+};
+
+
+static void createmeta (lua_State *L) {
+ luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */
+ lua_pushvalue(L, -1); /* push metatable */
+ lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
+ luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */
+ lua_pop(L, 1); /* pop new metatable */
+}
+
+
+/*
+** function to (not) close the standard files stdin, stdout, and stderr
+*/
+static int io_noclose (lua_State *L) {
+ LStream *p = tolstream(L);
+ p->closef = &io_noclose; /* keep file opened */
+ lua_pushnil(L);
+ lua_pushliteral(L, "cannot close standard file");
+ return 2;
+}
+
+
+static void createstdfile (lua_State *L, FILE *f, const char *k,
+ const char *fname) {
+ LStream *p = newprefile(L);
+ p->f = f;
+ p->closef = &io_noclose;
+ if (k != NULL) {
+ lua_pushvalue(L, -1);
+ lua_setfield(L, LUA_REGISTRYINDEX, k); /* add file to registry */
+ }
+ lua_setfield(L, -2, fname); /* add file to module */
+}
+
+
+LUAMOD_API int luaopen_io (lua_State *L) {
+ luaL_newlib(L, iolib); /* new module */
+ createmeta(L);
+ /* create (and set) default files */
+ createstdfile(L, stdin, IO_INPUT, "stdin");
+ createstdfile(L, stdout, IO_OUTPUT, "stdout");
+ createstdfile(L, stderr, NULL, "stderr");
+ return 1;
+}
+
diff --git a/ext/lua/src/llex.c b/ext/lua/src/llex.c
new file mode 100644
index 0000000000..c4b820e833
--- /dev/null
+++ b/ext/lua/src/llex.c
@@ -0,0 +1,530 @@
+/*
+** $Id: llex.c,v 2.63.1.2 2013/08/30 15:49:41 roberto Exp $
+** Lexical Analyzer
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+#include
+
+#define llex_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lctype.h"
+#include "ldo.h"
+#include "llex.h"
+#include "lobject.h"
+#include "lparser.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "lzio.h"
+
+
+
+#define next(ls) (ls->current = zgetc(ls->z))
+
+
+
+#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r')
+
+
+/* ORDER RESERVED */
+static const char *const luaX_tokens [] = {
+ "and", "break", "do", "else", "elseif",
+ "end", "false", "for", "function", "goto", "if",
+ "in", "local", "nil", "not", "or", "repeat",
+ "return", "then", "true", "until", "while",
+ "..", "...", "==", ">=", "<=", "~=", "::", "",
+ "", "", ""
+};
+
+
+#define save_and_next(ls) (save(ls, ls->current), next(ls))
+
+
+static l_noret lexerror (LexState *ls, const char *msg, int token);
+
+
+static void save (LexState *ls, int c) {
+ Mbuffer *b = ls->buff;
+ if (luaZ_bufflen(b) + 1 > luaZ_sizebuffer(b)) {
+ size_t newsize;
+ if (luaZ_sizebuffer(b) >= MAX_SIZET/2)
+ lexerror(ls, "lexical element too long", 0);
+ newsize = luaZ_sizebuffer(b) * 2;
+ luaZ_resizebuffer(ls->L, b, newsize);
+ }
+ b->buffer[luaZ_bufflen(b)++] = cast(char, c);
+}
+
+
+void luaX_init (lua_State *L) {
+ int i;
+ for (i=0; itsv.extra = cast_byte(i+1); /* reserved word */
+ }
+}
+
+
+const char *luaX_token2str (LexState *ls, int token) {
+ if (token < FIRST_RESERVED) { /* single-byte symbols? */
+ lua_assert(token == cast(unsigned char, token));
+ return (lisprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) :
+ luaO_pushfstring(ls->L, "char(%d)", token);
+ }
+ else {
+ const char *s = luaX_tokens[token - FIRST_RESERVED];
+ if (token < TK_EOS) /* fixed format (symbols and reserved words)? */
+ return luaO_pushfstring(ls->L, LUA_QS, s);
+ else /* names, strings, and numerals */
+ return s;
+ }
+}
+
+
+static const char *txtToken (LexState *ls, int token) {
+ switch (token) {
+ case TK_NAME:
+ case TK_STRING:
+ case TK_NUMBER:
+ save(ls, '\0');
+ return luaO_pushfstring(ls->L, LUA_QS, luaZ_buffer(ls->buff));
+ default:
+ return luaX_token2str(ls, token);
+ }
+}
+
+
+static l_noret lexerror (LexState *ls, const char *msg, int token) {
+ char buff[LUA_IDSIZE];
+ luaO_chunkid(buff, getstr(ls->source), LUA_IDSIZE);
+ msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
+ if (token)
+ luaO_pushfstring(ls->L, "%s near %s", msg, txtToken(ls, token));
+ luaD_throw(ls->L, LUA_ERRSYNTAX);
+}
+
+
+l_noret luaX_syntaxerror (LexState *ls, const char *msg) {
+ lexerror(ls, msg, ls->t.token);
+}
+
+
+/*
+** creates a new string and anchors it in function's table so that
+** it will not be collected until the end of the function's compilation
+** (by that time it should be anchored in function's prototype)
+*/
+TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
+ lua_State *L = ls->L;
+ TValue *o; /* entry for `str' */
+ TString *ts = luaS_newlstr(L, str, l); /* create new string */
+ setsvalue2s(L, L->top++, ts); /* temporarily anchor it in stack */
+ o = luaH_set(L, ls->fs->h, L->top - 1);
+ if (ttisnil(o)) { /* not in use yet? (see 'addK') */
+ /* boolean value does not need GC barrier;
+ table has no metatable, so it does not need to invalidate cache */
+ setbvalue(o, 1); /* t[string] = true */
+ luaC_checkGC(L);
+ }
+ else { /* string already present */
+ ts = rawtsvalue(keyfromval(o)); /* re-use value previously stored */
+ }
+ L->top--; /* remove string from stack */
+ return ts;
+}
+
+
+/*
+** increment line number and skips newline sequence (any of
+** \n, \r, \n\r, or \r\n)
+*/
+static void inclinenumber (LexState *ls) {
+ int old = ls->current;
+ lua_assert(currIsNewline(ls));
+ next(ls); /* skip `\n' or `\r' */
+ if (currIsNewline(ls) && ls->current != old)
+ next(ls); /* skip `\n\r' or `\r\n' */
+ if (++ls->linenumber >= MAX_INT)
+ luaX_syntaxerror(ls, "chunk has too many lines");
+}
+
+
+void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source,
+ int firstchar) {
+ ls->decpoint = '.';
+ ls->L = L;
+ ls->current = firstchar;
+ ls->lookahead.token = TK_EOS; /* no look-ahead token */
+ ls->z = z;
+ ls->fs = NULL;
+ ls->linenumber = 1;
+ ls->lastline = 1;
+ ls->source = source;
+ ls->envn = luaS_new(L, LUA_ENV); /* create env name */
+ luaS_fix(ls->envn); /* never collect this name */
+ luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */
+}
+
+
+
+/*
+** =======================================================
+** LEXICAL ANALYZER
+** =======================================================
+*/
+
+
+
+static int check_next (LexState *ls, const char *set) {
+ if (ls->current == '\0' || !strchr(set, ls->current))
+ return 0;
+ save_and_next(ls);
+ return 1;
+}
+
+
+/*
+** change all characters 'from' in buffer to 'to'
+*/
+static void buffreplace (LexState *ls, char from, char to) {
+ size_t n = luaZ_bufflen(ls->buff);
+ char *p = luaZ_buffer(ls->buff);
+ while (n--)
+ if (p[n] == from) p[n] = to;
+}
+
+
+#if !defined(getlocaledecpoint)
+#define getlocaledecpoint() (localeconv()->decimal_point[0])
+#endif
+
+
+#define buff2d(b,e) luaO_str2d(luaZ_buffer(b), luaZ_bufflen(b) - 1, e)
+
+/*
+** in case of format error, try to change decimal point separator to
+** the one defined in the current locale and check again
+*/
+static void trydecpoint (LexState *ls, SemInfo *seminfo) {
+ char old = ls->decpoint;
+ ls->decpoint = getlocaledecpoint();
+ buffreplace(ls, old, ls->decpoint); /* try new decimal separator */
+ if (!buff2d(ls->buff, &seminfo->r)) {
+ /* format error with correct decimal point: no more options */
+ buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
+ lexerror(ls, "malformed number", TK_NUMBER);
+ }
+}
+
+
+/* LUA_NUMBER */
+/*
+** this function is quite liberal in what it accepts, as 'luaO_str2d'
+** will reject ill-formed numerals.
+*/
+static void read_numeral (LexState *ls, SemInfo *seminfo) {
+ const char *expo = "Ee";
+ int first = ls->current;
+ lua_assert(lisdigit(ls->current));
+ save_and_next(ls);
+ if (first == '0' && check_next(ls, "Xx")) /* hexadecimal? */
+ expo = "Pp";
+ for (;;) {
+ if (check_next(ls, expo)) /* exponent part? */
+ check_next(ls, "+-"); /* optional exponent sign */
+ if (lisxdigit(ls->current) || ls->current == '.')
+ save_and_next(ls);
+ else break;
+ }
+ save(ls, '\0');
+ buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
+ if (!buff2d(ls->buff, &seminfo->r)) /* format error? */
+ trydecpoint(ls, seminfo); /* try to update decimal point separator */
+}
+
+
+/*
+** skip a sequence '[=*[' or ']=*]' and return its number of '='s or
+** -1 if sequence is malformed
+*/
+static int skip_sep (LexState *ls) {
+ int count = 0;
+ int s = ls->current;
+ lua_assert(s == '[' || s == ']');
+ save_and_next(ls);
+ while (ls->current == '=') {
+ save_and_next(ls);
+ count++;
+ }
+ return (ls->current == s) ? count : (-count) - 1;
+}
+
+
+static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
+ save_and_next(ls); /* skip 2nd `[' */
+ if (currIsNewline(ls)) /* string starts with a newline? */
+ inclinenumber(ls); /* skip it */
+ for (;;) {
+ switch (ls->current) {
+ case EOZ:
+ lexerror(ls, (seminfo) ? "unfinished long string" :
+ "unfinished long comment", TK_EOS);
+ break; /* to avoid warnings */
+ case ']': {
+ if (skip_sep(ls) == sep) {
+ save_and_next(ls); /* skip 2nd `]' */
+ goto endloop;
+ }
+ break;
+ }
+ case '\n': case '\r': {
+ save(ls, '\n');
+ inclinenumber(ls);
+ if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */
+ break;
+ }
+ default: {
+ if (seminfo) save_and_next(ls);
+ else next(ls);
+ }
+ }
+ } endloop:
+ if (seminfo)
+ seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep),
+ luaZ_bufflen(ls->buff) - 2*(2 + sep));
+}
+
+
+static void escerror (LexState *ls, int *c, int n, const char *msg) {
+ int i;
+ luaZ_resetbuffer(ls->buff); /* prepare error message */
+ save(ls, '\\');
+ for (i = 0; i < n && c[i] != EOZ; i++)
+ save(ls, c[i]);
+ lexerror(ls, msg, TK_STRING);
+}
+
+
+static int readhexaesc (LexState *ls) {
+ int c[3], i; /* keep input for error message */
+ int r = 0; /* result accumulator */
+ c[0] = 'x'; /* for error message */
+ for (i = 1; i < 3; i++) { /* read two hexadecimal digits */
+ c[i] = next(ls);
+ if (!lisxdigit(c[i]))
+ escerror(ls, c, i + 1, "hexadecimal digit expected");
+ r = (r << 4) + luaO_hexavalue(c[i]);
+ }
+ return r;
+}
+
+
+static int readdecesc (LexState *ls) {
+ int c[3], i;
+ int r = 0; /* result accumulator */
+ for (i = 0; i < 3 && lisdigit(ls->current); i++) { /* read up to 3 digits */
+ c[i] = ls->current;
+ r = 10*r + c[i] - '0';
+ next(ls);
+ }
+ if (r > UCHAR_MAX)
+ escerror(ls, c, i, "decimal escape too large");
+ return r;
+}
+
+
+static void read_string (LexState *ls, int del, SemInfo *seminfo) {
+ save_and_next(ls); /* keep delimiter (for error messages) */
+ while (ls->current != del) {
+ switch (ls->current) {
+ case EOZ:
+ lexerror(ls, "unfinished string", TK_EOS);
+ break; /* to avoid warnings */
+ case '\n':
+ case '\r':
+ lexerror(ls, "unfinished string", TK_STRING);
+ break; /* to avoid warnings */
+ case '\\': { /* escape sequences */
+ int c; /* final character to be saved */
+ next(ls); /* do not save the `\' */
+ switch (ls->current) {
+ case 'a': c = '\a'; goto read_save;
+ case 'b': c = '\b'; goto read_save;
+ case 'f': c = '\f'; goto read_save;
+ case 'n': c = '\n'; goto read_save;
+ case 'r': c = '\r'; goto read_save;
+ case 't': c = '\t'; goto read_save;
+ case 'v': c = '\v'; goto read_save;
+ case 'x': c = readhexaesc(ls); goto read_save;
+ case '\n': case '\r':
+ inclinenumber(ls); c = '\n'; goto only_save;
+ case '\\': case '\"': case '\'':
+ c = ls->current; goto read_save;
+ case EOZ: goto no_save; /* will raise an error next loop */
+ case 'z': { /* zap following span of spaces */
+ next(ls); /* skip the 'z' */
+ while (lisspace(ls->current)) {
+ if (currIsNewline(ls)) inclinenumber(ls);
+ else next(ls);
+ }
+ goto no_save;
+ }
+ default: {
+ if (!lisdigit(ls->current))
+ escerror(ls, &ls->current, 1, "invalid escape sequence");
+ /* digital escape \ddd */
+ c = readdecesc(ls);
+ goto only_save;
+ }
+ }
+ read_save: next(ls); /* read next character */
+ only_save: save(ls, c); /* save 'c' */
+ no_save: break;
+ }
+ default:
+ save_and_next(ls);
+ }
+ }
+ save_and_next(ls); /* skip delimiter */
+ seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1,
+ luaZ_bufflen(ls->buff) - 2);
+}
+
+
+static int llex (LexState *ls, SemInfo *seminfo) {
+ luaZ_resetbuffer(ls->buff);
+ for (;;) {
+ switch (ls->current) {
+ case '\n': case '\r': { /* line breaks */
+ inclinenumber(ls);
+ break;
+ }
+ case ' ': case '\f': case '\t': case '\v': { /* spaces */
+ next(ls);
+ break;
+ }
+ case '-': { /* '-' or '--' (comment) */
+ next(ls);
+ if (ls->current != '-') return '-';
+ /* else is a comment */
+ next(ls);
+ if (ls->current == '[') { /* long comment? */
+ int sep = skip_sep(ls);
+ luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */
+ if (sep >= 0) {
+ read_long_string(ls, NULL, sep); /* skip long comment */
+ luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */
+ break;
+ }
+ }
+ /* else short comment */
+ while (!currIsNewline(ls) && ls->current != EOZ)
+ next(ls); /* skip until end of line (or end of file) */
+ break;
+ }
+ case '[': { /* long string or simply '[' */
+ int sep = skip_sep(ls);
+ if (sep >= 0) {
+ read_long_string(ls, seminfo, sep);
+ return TK_STRING;
+ }
+ else if (sep == -1) return '[';
+ else lexerror(ls, "invalid long string delimiter", TK_STRING);
+ }
+ case '=': {
+ next(ls);
+ if (ls->current != '=') return '=';
+ else { next(ls); return TK_EQ; }
+ }
+ case '<': {
+ next(ls);
+ if (ls->current != '=') return '<';
+ else { next(ls); return TK_LE; }
+ }
+ case '>': {
+ next(ls);
+ if (ls->current != '=') return '>';
+ else { next(ls); return TK_GE; }
+ }
+ case '~': {
+ next(ls);
+ if (ls->current != '=') return '~';
+ else { next(ls); return TK_NE; }
+ }
+ case ':': {
+ next(ls);
+ if (ls->current != ':') return ':';
+ else { next(ls); return TK_DBCOLON; }
+ }
+ case '"': case '\'': { /* short literal strings */
+ read_string(ls, ls->current, seminfo);
+ return TK_STRING;
+ }
+ case '.': { /* '.', '..', '...', or number */
+ save_and_next(ls);
+ if (check_next(ls, ".")) {
+ if (check_next(ls, "."))
+ return TK_DOTS; /* '...' */
+ else return TK_CONCAT; /* '..' */
+ }
+ else if (!lisdigit(ls->current)) return '.';
+ /* else go through */
+ }
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9': {
+ read_numeral(ls, seminfo);
+ return TK_NUMBER;
+ }
+ case EOZ: {
+ return TK_EOS;
+ }
+ default: {
+ if (lislalpha(ls->current)) { /* identifier or reserved word? */
+ TString *ts;
+ do {
+ save_and_next(ls);
+ } while (lislalnum(ls->current));
+ ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
+ luaZ_bufflen(ls->buff));
+ seminfo->ts = ts;
+ if (isreserved(ts)) /* reserved word? */
+ return ts->tsv.extra - 1 + FIRST_RESERVED;
+ else {
+ return TK_NAME;
+ }
+ }
+ else { /* single-char tokens (+ - / ...) */
+ int c = ls->current;
+ next(ls);
+ return c;
+ }
+ }
+ }
+ }
+}
+
+
+void luaX_next (LexState *ls) {
+ ls->lastline = ls->linenumber;
+ if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */
+ ls->t = ls->lookahead; /* use this one */
+ ls->lookahead.token = TK_EOS; /* and discharge it */
+ }
+ else
+ ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */
+}
+
+
+int luaX_lookahead (LexState *ls) {
+ lua_assert(ls->lookahead.token == TK_EOS);
+ ls->lookahead.token = llex(ls, &ls->lookahead.seminfo);
+ return ls->lookahead.token;
+}
+
diff --git a/ext/lua/src/lmathlib.c b/ext/lua/src/lmathlib.c
new file mode 100644
index 0000000000..fe9fc5423d
--- /dev/null
+++ b/ext/lua/src/lmathlib.c
@@ -0,0 +1,279 @@
+/*
+** $Id: lmathlib.c,v 1.83.1.1 2013/04/12 18:48:47 roberto Exp $
+** Standard mathematical library
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+#include
+
+#define lmathlib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+#undef PI
+#define PI ((lua_Number)(3.1415926535897932384626433832795))
+#define RADIANS_PER_DEGREE ((lua_Number)(PI/180.0))
+
+
+
+static int math_abs (lua_State *L) {
+ lua_pushnumber(L, l_mathop(fabs)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_sin (lua_State *L) {
+ lua_pushnumber(L, l_mathop(sin)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_sinh (lua_State *L) {
+ lua_pushnumber(L, l_mathop(sinh)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_cos (lua_State *L) {
+ lua_pushnumber(L, l_mathop(cos)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_cosh (lua_State *L) {
+ lua_pushnumber(L, l_mathop(cosh)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_tan (lua_State *L) {
+ lua_pushnumber(L, l_mathop(tan)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_tanh (lua_State *L) {
+ lua_pushnumber(L, l_mathop(tanh)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_asin (lua_State *L) {
+ lua_pushnumber(L, l_mathop(asin)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_acos (lua_State *L) {
+ lua_pushnumber(L, l_mathop(acos)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_atan (lua_State *L) {
+ lua_pushnumber(L, l_mathop(atan)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_atan2 (lua_State *L) {
+ lua_pushnumber(L, l_mathop(atan2)(luaL_checknumber(L, 1),
+ luaL_checknumber(L, 2)));
+ return 1;
+}
+
+static int math_ceil (lua_State *L) {
+ lua_pushnumber(L, l_mathop(ceil)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_floor (lua_State *L) {
+ lua_pushnumber(L, l_mathop(floor)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_fmod (lua_State *L) {
+ lua_pushnumber(L, l_mathop(fmod)(luaL_checknumber(L, 1),
+ luaL_checknumber(L, 2)));
+ return 1;
+}
+
+static int math_modf (lua_State *L) {
+ lua_Number ip;
+ lua_Number fp = l_mathop(modf)(luaL_checknumber(L, 1), &ip);
+ lua_pushnumber(L, ip);
+ lua_pushnumber(L, fp);
+ return 2;
+}
+
+static int math_sqrt (lua_State *L) {
+ lua_pushnumber(L, l_mathop(sqrt)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_pow (lua_State *L) {
+ lua_Number x = luaL_checknumber(L, 1);
+ lua_Number y = luaL_checknumber(L, 2);
+ lua_pushnumber(L, l_mathop(pow)(x, y));
+ return 1;
+}
+
+static int math_log (lua_State *L) {
+ lua_Number x = luaL_checknumber(L, 1);
+ lua_Number res;
+ if (lua_isnoneornil(L, 2))
+ res = l_mathop(log)(x);
+ else {
+ lua_Number base = luaL_checknumber(L, 2);
+ if (base == (lua_Number)10.0) res = l_mathop(log10)(x);
+ else res = l_mathop(log)(x)/l_mathop(log)(base);
+ }
+ lua_pushnumber(L, res);
+ return 1;
+}
+
+#if defined(LUA_COMPAT_LOG10)
+static int math_log10 (lua_State *L) {
+ lua_pushnumber(L, l_mathop(log10)(luaL_checknumber(L, 1)));
+ return 1;
+}
+#endif
+
+static int math_exp (lua_State *L) {
+ lua_pushnumber(L, l_mathop(exp)(luaL_checknumber(L, 1)));
+ return 1;
+}
+
+static int math_deg (lua_State *L) {
+ lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE);
+ return 1;
+}
+
+static int math_rad (lua_State *L) {
+ lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE);
+ return 1;
+}
+
+static int math_frexp (lua_State *L) {
+ int e;
+ lua_pushnumber(L, l_mathop(frexp)(luaL_checknumber(L, 1), &e));
+ lua_pushinteger(L, e);
+ return 2;
+}
+
+static int math_ldexp (lua_State *L) {
+ lua_Number x = luaL_checknumber(L, 1);
+ int ep = luaL_checkint(L, 2);
+ lua_pushnumber(L, l_mathop(ldexp)(x, ep));
+ return 1;
+}
+
+
+
+static int math_min (lua_State *L) {
+ int n = lua_gettop(L); /* number of arguments */
+ lua_Number dmin = luaL_checknumber(L, 1);
+ int i;
+ for (i=2; i<=n; i++) {
+ lua_Number d = luaL_checknumber(L, i);
+ if (d < dmin)
+ dmin = d;
+ }
+ lua_pushnumber(L, dmin);
+ return 1;
+}
+
+
+static int math_max (lua_State *L) {
+ int n = lua_gettop(L); /* number of arguments */
+ lua_Number dmax = luaL_checknumber(L, 1);
+ int i;
+ for (i=2; i<=n; i++) {
+ lua_Number d = luaL_checknumber(L, i);
+ if (d > dmax)
+ dmax = d;
+ }
+ lua_pushnumber(L, dmax);
+ return 1;
+}
+
+
+static int math_random (lua_State *L) {
+ /* the `%' avoids the (rare) case of r==1, and is needed also because on
+ some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
+ lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX;
+ switch (lua_gettop(L)) { /* check number of arguments */
+ case 0: { /* no arguments */
+ lua_pushnumber(L, r); /* Number between 0 and 1 */
+ break;
+ }
+ case 1: { /* only upper limit */
+ lua_Number u = luaL_checknumber(L, 1);
+ luaL_argcheck(L, (lua_Number)1.0 <= u, 1, "interval is empty");
+ lua_pushnumber(L, l_mathop(floor)(r*u) + (lua_Number)(1.0)); /* [1, u] */
+ break;
+ }
+ case 2: { /* lower and upper limits */
+ lua_Number l = luaL_checknumber(L, 1);
+ lua_Number u = luaL_checknumber(L, 2);
+ luaL_argcheck(L, l <= u, 2, "interval is empty");
+ lua_pushnumber(L, l_mathop(floor)(r*(u-l+1)) + l); /* [l, u] */
+ break;
+ }
+ default: return luaL_error(L, "wrong number of arguments");
+ }
+ return 1;
+}
+
+
+static int math_randomseed (lua_State *L) {
+ srand(luaL_checkunsigned(L, 1));
+ (void)rand(); /* discard first value to avoid undesirable correlations */
+ return 0;
+}
+
+
+static const luaL_Reg mathlib[] = {
+ {"abs", math_abs},
+ {"acos", math_acos},
+ {"asin", math_asin},
+ {"atan2", math_atan2},
+ {"atan", math_atan},
+ {"ceil", math_ceil},
+ {"cosh", math_cosh},
+ {"cos", math_cos},
+ {"deg", math_deg},
+ {"exp", math_exp},
+ {"floor", math_floor},
+ {"fmod", math_fmod},
+ {"frexp", math_frexp},
+ {"ldexp", math_ldexp},
+#if defined(LUA_COMPAT_LOG10)
+ {"log10", math_log10},
+#endif
+ {"log", math_log},
+ {"max", math_max},
+ {"min", math_min},
+ {"modf", math_modf},
+ {"pow", math_pow},
+ {"rad", math_rad},
+ {"random", math_random},
+ {"randomseed", math_randomseed},
+ {"sinh", math_sinh},
+ {"sin", math_sin},
+ {"sqrt", math_sqrt},
+ {"tanh", math_tanh},
+ {"tan", math_tan},
+ {NULL, NULL}
+};
+
+
+/*
+** Open math library
+*/
+LUAMOD_API int luaopen_math (lua_State *L) {
+ luaL_newlib(L, mathlib);
+ lua_pushnumber(L, PI);
+ lua_setfield(L, -2, "pi");
+ lua_pushnumber(L, HUGE_VAL);
+ lua_setfield(L, -2, "huge");
+ return 1;
+}
+
diff --git a/ext/lua/src/lmem.c b/ext/lua/src/lmem.c
new file mode 100644
index 0000000000..ee343e3e03
--- /dev/null
+++ b/ext/lua/src/lmem.c
@@ -0,0 +1,99 @@
+/*
+** $Id: lmem.c,v 1.84.1.1 2013/04/12 18:48:47 roberto Exp $
+** Interface to Memory Manager
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+
+#define lmem_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldebug.h"
+#include "ldo.h"
+#include "lgc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+
+
+
+/*
+** About the realloc function:
+** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize);
+** (`osize' is the old size, `nsize' is the new size)
+**
+** * frealloc(ud, NULL, x, s) creates a new block of size `s' (no
+** matter 'x').
+**
+** * frealloc(ud, p, x, 0) frees the block `p'
+** (in this specific case, frealloc must return NULL);
+** particularly, frealloc(ud, NULL, 0, 0) does nothing
+** (which is equivalent to free(NULL) in ANSI C)
+**
+** frealloc returns NULL if it cannot create or reallocate the area
+** (any reallocation to an equal or smaller size cannot fail!)
+*/
+
+
+
+#define MINSIZEARRAY 4
+
+
+void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
+ int limit, const char *what) {
+ void *newblock;
+ int newsize;
+ if (*size >= limit/2) { /* cannot double it? */
+ if (*size >= limit) /* cannot grow even a little? */
+ luaG_runerror(L, "too many %s (limit is %d)", what, limit);
+ newsize = limit; /* still have at least one free place */
+ }
+ else {
+ newsize = (*size)*2;
+ if (newsize < MINSIZEARRAY)
+ newsize = MINSIZEARRAY; /* minimum size */
+ }
+ newblock = luaM_reallocv(L, block, *size, newsize, size_elems);
+ *size = newsize; /* update only when everything else is OK */
+ return newblock;
+}
+
+
+l_noret luaM_toobig (lua_State *L) {
+ luaG_runerror(L, "memory allocation error: block too big");
+}
+
+
+
+/*
+** generic allocation routine.
+*/
+void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
+ void *newblock;
+ global_State *g = G(L);
+ size_t realosize = (block) ? osize : 0;
+ lua_assert((realosize == 0) == (block == NULL));
+#if defined(HARDMEMTESTS)
+ if (nsize > realosize && g->gcrunning)
+ luaC_fullgc(L, 1); /* force a GC whenever possible */
+#endif
+ newblock = (*g->frealloc)(g->ud, block, osize, nsize);
+ if (newblock == NULL && nsize > 0) {
+ api_check(L, nsize > realosize,
+ "realloc cannot fail when shrinking a block");
+ if (g->gcrunning) {
+ luaC_fullgc(L, 1); /* try to free some memory... */
+ newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */
+ }
+ if (newblock == NULL)
+ luaD_throw(L, LUA_ERRMEM);
+ }
+ lua_assert((nsize == 0) == (newblock == NULL));
+ g->GCdebt = (g->GCdebt + nsize) - realosize;
+ return newblock;
+}
+
diff --git a/ext/lua/src/loadlib.c b/ext/lua/src/loadlib.c
new file mode 100644
index 0000000000..bedbea3e9a
--- /dev/null
+++ b/ext/lua/src/loadlib.c
@@ -0,0 +1,725 @@
+/*
+** $Id: loadlib.c,v 1.111.1.1 2013/04/12 18:48:47 roberto Exp $
+** Dynamic library loader for Lua
+** See Copyright Notice in lua.h
+**
+** This module contains an implementation of loadlib for Unix systems
+** that have dlfcn, an implementation for Windows, and a stub for other
+** systems.
+*/
+
+
+/*
+** if needed, includes windows header before everything else
+*/
+#if defined(_WIN32)
+#include
+#endif
+
+
+#include
+#include
+
+
+#define loadlib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+/*
+** LUA_PATH and LUA_CPATH are the names of the environment
+** variables that Lua check to set its paths.
+*/
+#if !defined(LUA_PATH)
+#define LUA_PATH "LUA_PATH"
+#endif
+
+#if !defined(LUA_CPATH)
+#define LUA_CPATH "LUA_CPATH"
+#endif
+
+#define LUA_PATHSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
+
+#define LUA_PATHVERSION LUA_PATH LUA_PATHSUFFIX
+#define LUA_CPATHVERSION LUA_CPATH LUA_PATHSUFFIX
+
+/*
+** LUA_PATH_SEP is the character that separates templates in a path.
+** LUA_PATH_MARK is the string that marks the substitution points in a
+** template.
+** LUA_EXEC_DIR in a Windows path is replaced by the executable's
+** directory.
+** LUA_IGMARK is a mark to ignore all before it when building the
+** luaopen_ function name.
+*/
+#if !defined (LUA_PATH_SEP)
+#define LUA_PATH_SEP ";"
+#endif
+#if !defined (LUA_PATH_MARK)
+#define LUA_PATH_MARK "?"
+#endif
+#if !defined (LUA_EXEC_DIR)
+#define LUA_EXEC_DIR "!"
+#endif
+#if !defined (LUA_IGMARK)
+#define LUA_IGMARK "-"
+#endif
+
+
+/*
+** LUA_CSUBSEP is the character that replaces dots in submodule names
+** when searching for a C loader.
+** LUA_LSUBSEP is the character that replaces dots in submodule names
+** when searching for a Lua loader.
+*/
+#if !defined(LUA_CSUBSEP)
+#define LUA_CSUBSEP LUA_DIRSEP
+#endif
+
+#if !defined(LUA_LSUBSEP)
+#define LUA_LSUBSEP LUA_DIRSEP
+#endif
+
+
+/* prefix for open functions in C libraries */
+#define LUA_POF "luaopen_"
+
+/* separator for open functions in C libraries */
+#define LUA_OFSEP "_"
+
+
+/* table (in the registry) that keeps handles for all loaded C libraries */
+#define CLIBS "_CLIBS"
+
+#define LIB_FAIL "open"
+
+
+/* error codes for ll_loadfunc */
+#define ERRLIB 1
+#define ERRFUNC 2
+
+#define setprogdir(L) ((void)0)
+
+
+/*
+** system-dependent functions
+*/
+static void ll_unloadlib (void *lib);
+static void *ll_load (lua_State *L, const char *path, int seeglb);
+static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym);
+
+
+
+#if defined(LUA_USE_DLOPEN)
+/*
+** {========================================================================
+** This is an implementation of loadlib based on the dlfcn interface.
+** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD,
+** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least
+** as an emulation layer on top of native functions.
+** =========================================================================
+*/
+
+#include
+
+static void ll_unloadlib (void *lib) {
+ dlclose(lib);
+}
+
+
+static void *ll_load (lua_State *L, const char *path, int seeglb) {
+ void *lib = dlopen(path, RTLD_NOW | (seeglb ? RTLD_GLOBAL : RTLD_LOCAL));
+ if (lib == NULL) lua_pushstring(L, dlerror());
+ return lib;
+}
+
+
+static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
+ lua_CFunction f = (lua_CFunction)dlsym(lib, sym);
+ if (f == NULL) lua_pushstring(L, dlerror());
+ return f;
+}
+
+/* }====================================================== */
+
+
+
+#elif defined(LUA_DL_DLL)
+/*
+** {======================================================================
+** This is an implementation of loadlib for Windows using native functions.
+** =======================================================================
+*/
+
+#undef setprogdir
+
+/*
+** optional flags for LoadLibraryEx
+*/
+#if !defined(LUA_LLE_FLAGS)
+#define LUA_LLE_FLAGS 0
+#endif
+
+
+static void setprogdir (lua_State *L) {
+ char buff[MAX_PATH + 1];
+ char *lb;
+ DWORD nsize = sizeof(buff)/sizeof(char);
+ DWORD n = GetModuleFileNameA(NULL, buff, nsize);
+ if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL)
+ luaL_error(L, "unable to get ModuleFileName");
+ else {
+ *lb = '\0';
+ luaL_gsub(L, lua_tostring(L, -1), LUA_EXEC_DIR, buff);
+ lua_remove(L, -2); /* remove original string */
+ }
+}
+
+
+static void pusherror (lua_State *L) {
+ int error = GetLastError();
+ char buffer[128];
+ if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL, error, 0, buffer, sizeof(buffer)/sizeof(char), NULL))
+ lua_pushstring(L, buffer);
+ else
+ lua_pushfstring(L, "system error %d\n", error);
+}
+
+static void ll_unloadlib (void *lib) {
+ FreeLibrary((HMODULE)lib);
+}
+
+
+static void *ll_load (lua_State *L, const char *path, int seeglb) {
+ HMODULE lib = LoadLibraryExA(path, NULL, LUA_LLE_FLAGS);
+ (void)(seeglb); /* not used: symbols are 'global' by default */
+ if (lib == NULL) pusherror(L);
+ return lib;
+}
+
+
+static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
+ lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym);
+ if (f == NULL) pusherror(L);
+ return f;
+}
+
+/* }====================================================== */
+
+
+#else
+/*
+** {======================================================
+** Fallback for other systems
+** =======================================================
+*/
+
+#undef LIB_FAIL
+#define LIB_FAIL "absent"
+
+
+#define DLMSG "dynamic libraries not enabled; check your Lua installation"
+
+
+static void ll_unloadlib (void *lib) {
+ (void)(lib); /* not used */
+}
+
+
+static void *ll_load (lua_State *L, const char *path, int seeglb) {
+ (void)(path); (void)(seeglb); /* not used */
+ lua_pushliteral(L, DLMSG);
+ return NULL;
+}
+
+
+static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
+ (void)(lib); (void)(sym); /* not used */
+ lua_pushliteral(L, DLMSG);
+ return NULL;
+}
+
+/* }====================================================== */
+#endif
+
+
+static void *ll_checkclib (lua_State *L, const char *path) {
+ void *plib;
+ lua_getfield(L, LUA_REGISTRYINDEX, CLIBS);
+ lua_getfield(L, -1, path);
+ plib = lua_touserdata(L, -1); /* plib = CLIBS[path] */
+ lua_pop(L, 2); /* pop CLIBS table and 'plib' */
+ return plib;
+}
+
+
+static void ll_addtoclib (lua_State *L, const char *path, void *plib) {
+ lua_getfield(L, LUA_REGISTRYINDEX, CLIBS);
+ lua_pushlightuserdata(L, plib);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -3, path); /* CLIBS[path] = plib */
+ lua_rawseti(L, -2, luaL_len(L, -2) + 1); /* CLIBS[#CLIBS + 1] = plib */
+ lua_pop(L, 1); /* pop CLIBS table */
+}
+
+
+/*
+** __gc tag method for CLIBS table: calls 'll_unloadlib' for all lib
+** handles in list CLIBS
+*/
+static int gctm (lua_State *L) {
+ int n = luaL_len(L, 1);
+ for (; n >= 1; n--) { /* for each handle, in reverse order */
+ lua_rawgeti(L, 1, n); /* get handle CLIBS[n] */
+ ll_unloadlib(lua_touserdata(L, -1));
+ lua_pop(L, 1); /* pop handle */
+ }
+ return 0;
+}
+
+
+static int ll_loadfunc (lua_State *L, const char *path, const char *sym) {
+ void *reg = ll_checkclib(L, path); /* check loaded C libraries */
+ if (reg == NULL) { /* must load library? */
+ reg = ll_load(L, path, *sym == '*');
+ if (reg == NULL) return ERRLIB; /* unable to load library */
+ ll_addtoclib(L, path, reg);
+ }
+ if (*sym == '*') { /* loading only library (no function)? */
+ lua_pushboolean(L, 1); /* return 'true' */
+ return 0; /* no errors */
+ }
+ else {
+ lua_CFunction f = ll_sym(L, reg, sym);
+ if (f == NULL)
+ return ERRFUNC; /* unable to find function */
+ lua_pushcfunction(L, f); /* else create new function */
+ return 0; /* no errors */
+ }
+}
+
+
+static int ll_loadlib (lua_State *L) {
+ const char *path = luaL_checkstring(L, 1);
+ const char *init = luaL_checkstring(L, 2);
+ int stat = ll_loadfunc(L, path, init);
+ if (stat == 0) /* no errors? */
+ return 1; /* return the loaded function */
+ else { /* error; error message is on stack top */
+ lua_pushnil(L);
+ lua_insert(L, -2);
+ lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init");
+ return 3; /* return nil, error message, and where */
+ }
+}
+
+
+
+/*
+** {======================================================
+** 'require' function
+** =======================================================
+*/
+
+
+static int readable (const char *filename) {
+ FILE *f = fopen(filename, "r"); /* try to open file */
+ if (f == NULL) return 0; /* open failed */
+ fclose(f);
+ return 1;
+}
+
+
+static const char *pushnexttemplate (lua_State *L, const char *path) {
+ const char *l;
+ while (*path == *LUA_PATH_SEP) path++; /* skip separators */
+ if (*path == '\0') return NULL; /* no more templates */
+ l = strchr(path, *LUA_PATH_SEP); /* find next separator */
+ if (l == NULL) l = path + strlen(path);
+ lua_pushlstring(L, path, l - path); /* template */
+ return l;
+}
+
+
+static const char *searchpath (lua_State *L, const char *name,
+ const char *path,
+ const char *sep,
+ const char *dirsep) {
+ luaL_Buffer msg; /* to build error message */
+ luaL_buffinit(L, &msg);
+ if (*sep != '\0') /* non-empty separator? */
+ name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */
+ while ((path = pushnexttemplate(L, path)) != NULL) {
+ const char *filename = luaL_gsub(L, lua_tostring(L, -1),
+ LUA_PATH_MARK, name);
+ lua_remove(L, -2); /* remove path template */
+ if (readable(filename)) /* does file exist and is readable? */
+ return filename; /* return that file name */
+ lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
+ lua_remove(L, -2); /* remove file name */
+ luaL_addvalue(&msg); /* concatenate error msg. entry */
+ }
+ luaL_pushresult(&msg); /* create error message */
+ return NULL; /* not found */
+}
+
+
+static int ll_searchpath (lua_State *L) {
+ const char *f = searchpath(L, luaL_checkstring(L, 1),
+ luaL_checkstring(L, 2),
+ luaL_optstring(L, 3, "."),
+ luaL_optstring(L, 4, LUA_DIRSEP));
+ if (f != NULL) return 1;
+ else { /* error message is on top of the stack */
+ lua_pushnil(L);
+ lua_insert(L, -2);
+ return 2; /* return nil + error message */
+ }
+}
+
+
+static const char *findfile (lua_State *L, const char *name,
+ const char *pname,
+ const char *dirsep) {
+ const char *path;
+ lua_getfield(L, lua_upvalueindex(1), pname);
+ path = lua_tostring(L, -1);
+ if (path == NULL)
+ luaL_error(L, LUA_QL("package.%s") " must be a string", pname);
+ return searchpath(L, name, path, ".", dirsep);
+}
+
+
+static int checkload (lua_State *L, int stat, const char *filename) {
+ if (stat) { /* module loaded successfully? */
+ lua_pushstring(L, filename); /* will be 2nd argument to module */
+ return 2; /* return open function and file name */
+ }
+ else
+ return luaL_error(L, "error loading module " LUA_QS
+ " from file " LUA_QS ":\n\t%s",
+ lua_tostring(L, 1), filename, lua_tostring(L, -1));
+}
+
+
+static int searcher_Lua (lua_State *L) {
+ const char *filename;
+ const char *name = luaL_checkstring(L, 1);
+ filename = findfile(L, name, "path", LUA_LSUBSEP);
+ if (filename == NULL) return 1; /* module not found in this path */
+ return checkload(L, (luaL_loadfile(L, filename) == LUA_OK), filename);
+}
+
+
+static int loadfunc (lua_State *L, const char *filename, const char *modname) {
+ const char *funcname;
+ const char *mark;
+ modname = luaL_gsub(L, modname, ".", LUA_OFSEP);
+ mark = strchr(modname, *LUA_IGMARK);
+ if (mark) {
+ int stat;
+ funcname = lua_pushlstring(L, modname, mark - modname);
+ funcname = lua_pushfstring(L, LUA_POF"%s", funcname);
+ stat = ll_loadfunc(L, filename, funcname);
+ if (stat != ERRFUNC) return stat;
+ modname = mark + 1; /* else go ahead and try old-style name */
+ }
+ funcname = lua_pushfstring(L, LUA_POF"%s", modname);
+ return ll_loadfunc(L, filename, funcname);
+}
+
+
+static int searcher_C (lua_State *L) {
+ const char *name = luaL_checkstring(L, 1);
+ const char *filename = findfile(L, name, "cpath", LUA_CSUBSEP);
+ if (filename == NULL) return 1; /* module not found in this path */
+ return checkload(L, (loadfunc(L, filename, name) == 0), filename);
+}
+
+
+static int searcher_Croot (lua_State *L) {
+ const char *filename;
+ const char *name = luaL_checkstring(L, 1);
+ const char *p = strchr(name, '.');
+ int stat;
+ if (p == NULL) return 0; /* is root */
+ lua_pushlstring(L, name, p - name);
+ filename = findfile(L, lua_tostring(L, -1), "cpath", LUA_CSUBSEP);
+ if (filename == NULL) return 1; /* root not found */
+ if ((stat = loadfunc(L, filename, name)) != 0) {
+ if (stat != ERRFUNC)
+ return checkload(L, 0, filename); /* real error */
+ else { /* open function not found */
+ lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,
+ name, filename);
+ return 1;
+ }
+ }
+ lua_pushstring(L, filename); /* will be 2nd argument to module */
+ return 2;
+}
+
+
+static int searcher_preload (lua_State *L) {
+ const char *name = luaL_checkstring(L, 1);
+ lua_getfield(L, LUA_REGISTRYINDEX, "_PRELOAD");
+ lua_getfield(L, -1, name);
+ if (lua_isnil(L, -1)) /* not found? */
+ lua_pushfstring(L, "\n\tno field package.preload['%s']", name);
+ return 1;
+}
+
+
+static void findloader (lua_State *L, const char *name) {
+ int i;
+ luaL_Buffer msg; /* to build error message */
+ luaL_buffinit(L, &msg);
+ lua_getfield(L, lua_upvalueindex(1), "searchers"); /* will be at index 3 */
+ if (!lua_istable(L, 3))
+ luaL_error(L, LUA_QL("package.searchers") " must be a table");
+ /* iterate over available searchers to find a loader */
+ for (i = 1; ; i++) {
+ lua_rawgeti(L, 3, i); /* get a searcher */
+ if (lua_isnil(L, -1)) { /* no more searchers? */
+ lua_pop(L, 1); /* remove nil */
+ luaL_pushresult(&msg); /* create error message */
+ luaL_error(L, "module " LUA_QS " not found:%s",
+ name, lua_tostring(L, -1));
+ }
+ lua_pushstring(L, name);
+ lua_call(L, 1, 2); /* call it */
+ if (lua_isfunction(L, -2)) /* did it find a loader? */
+ return; /* module loader found */
+ else if (lua_isstring(L, -2)) { /* searcher returned error message? */
+ lua_pop(L, 1); /* remove extra return */
+ luaL_addvalue(&msg); /* concatenate error message */
+ }
+ else
+ lua_pop(L, 2); /* remove both returns */
+ }
+}
+
+
+static int ll_require (lua_State *L) {
+ const char *name = luaL_checkstring(L, 1);
+ lua_settop(L, 1); /* _LOADED table will be at index 2 */
+ lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
+ lua_getfield(L, 2, name); /* _LOADED[name] */
+ if (lua_toboolean(L, -1)) /* is it there? */
+ return 1; /* package is already loaded */
+ /* else must load package */
+ lua_pop(L, 1); /* remove 'getfield' result */
+ findloader(L, name);
+ lua_pushstring(L, name); /* pass name as argument to module loader */
+ lua_insert(L, -2); /* name is 1st argument (before search data) */
+ lua_call(L, 2, 1); /* run loader to load module */
+ if (!lua_isnil(L, -1)) /* non-nil return? */
+ lua_setfield(L, 2, name); /* _LOADED[name] = returned value */
+ lua_getfield(L, 2, name);
+ if (lua_isnil(L, -1)) { /* module did not set a value? */
+ lua_pushboolean(L, 1); /* use true as result */
+ lua_pushvalue(L, -1); /* extra copy to be returned */
+ lua_setfield(L, 2, name); /* _LOADED[name] = true */
+ }
+ return 1;
+}
+
+/* }====================================================== */
+
+
+
+/*
+** {======================================================
+** 'module' function
+** =======================================================
+*/
+#if defined(LUA_COMPAT_MODULE)
+
+/*
+** changes the environment variable of calling function
+*/
+static void set_env (lua_State *L) {
+ lua_Debug ar;
+ if (lua_getstack(L, 1, &ar) == 0 ||
+ lua_getinfo(L, "f", &ar) == 0 || /* get calling function */
+ lua_iscfunction(L, -1))
+ luaL_error(L, LUA_QL("module") " not called from a Lua function");
+ lua_pushvalue(L, -2); /* copy new environment table to top */
+ lua_setupvalue(L, -2, 1);
+ lua_pop(L, 1); /* remove function */
+}
+
+
+static void dooptions (lua_State *L, int n) {
+ int i;
+ for (i = 2; i <= n; i++) {
+ if (lua_isfunction(L, i)) { /* avoid 'calling' extra info. */
+ lua_pushvalue(L, i); /* get option (a function) */
+ lua_pushvalue(L, -2); /* module */
+ lua_call(L, 1, 0);
+ }
+ }
+}
+
+
+static void modinit (lua_State *L, const char *modname) {
+ const char *dot;
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -2, "_M"); /* module._M = module */
+ lua_pushstring(L, modname);
+ lua_setfield(L, -2, "_NAME");
+ dot = strrchr(modname, '.'); /* look for last dot in module name */
+ if (dot == NULL) dot = modname;
+ else dot++;
+ /* set _PACKAGE as package name (full module name minus last part) */
+ lua_pushlstring(L, modname, dot - modname);
+ lua_setfield(L, -2, "_PACKAGE");
+}
+
+
+static int ll_module (lua_State *L) {
+ const char *modname = luaL_checkstring(L, 1);
+ int lastarg = lua_gettop(L); /* last parameter */
+ luaL_pushmodule(L, modname, 1); /* get/create module table */
+ /* check whether table already has a _NAME field */
+ lua_getfield(L, -1, "_NAME");
+ if (!lua_isnil(L, -1)) /* is table an initialized module? */
+ lua_pop(L, 1);
+ else { /* no; initialize it */
+ lua_pop(L, 1);
+ modinit(L, modname);
+ }
+ lua_pushvalue(L, -1);
+ set_env(L);
+ dooptions(L, lastarg);
+ return 1;
+}
+
+
+static int ll_seeall (lua_State *L) {
+ luaL_checktype(L, 1, LUA_TTABLE);
+ if (!lua_getmetatable(L, 1)) {
+ lua_createtable(L, 0, 1); /* create new metatable */
+ lua_pushvalue(L, -1);
+ lua_setmetatable(L, 1);
+ }
+ lua_pushglobaltable(L);
+ lua_setfield(L, -2, "__index"); /* mt.__index = _G */
+ return 0;
+}
+
+#endif
+/* }====================================================== */
+
+
+
+/* auxiliary mark (for internal use) */
+#define AUXMARK "\1"
+
+
+/*
+** return registry.LUA_NOENV as a boolean
+*/
+static int noenv (lua_State *L) {
+ int b;
+ lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
+ b = lua_toboolean(L, -1);
+ lua_pop(L, 1); /* remove value */
+ return b;
+}
+
+
+static void setpath (lua_State *L, const char *fieldname, const char *envname1,
+ const char *envname2, const char *def) {
+ const char *path = getenv(envname1);
+ if (path == NULL) /* no environment variable? */
+ path = getenv(envname2); /* try alternative name */
+ if (path == NULL || noenv(L)) /* no environment variable? */
+ lua_pushstring(L, def); /* use default */
+ else {
+ /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
+ path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP,
+ LUA_PATH_SEP AUXMARK LUA_PATH_SEP);
+ luaL_gsub(L, path, AUXMARK, def);
+ lua_remove(L, -2);
+ }
+ setprogdir(L);
+ lua_setfield(L, -2, fieldname);
+}
+
+
+static const luaL_Reg pk_funcs[] = {
+ {"loadlib", ll_loadlib},
+ {"searchpath", ll_searchpath},
+#if defined(LUA_COMPAT_MODULE)
+ {"seeall", ll_seeall},
+#endif
+ {NULL, NULL}
+};
+
+
+static const luaL_Reg ll_funcs[] = {
+#if defined(LUA_COMPAT_MODULE)
+ {"module", ll_module},
+#endif
+ {"require", ll_require},
+ {NULL, NULL}
+};
+
+
+static void createsearcherstable (lua_State *L) {
+ static const lua_CFunction searchers[] =
+ {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL};
+ int i;
+ /* create 'searchers' table */
+ lua_createtable(L, sizeof(searchers)/sizeof(searchers[0]) - 1, 0);
+ /* fill it with pre-defined searchers */
+ for (i=0; searchers[i] != NULL; i++) {
+ lua_pushvalue(L, -2); /* set 'package' as upvalue for all searchers */
+ lua_pushcclosure(L, searchers[i], 1);
+ lua_rawseti(L, -2, i+1);
+ }
+}
+
+
+LUAMOD_API int luaopen_package (lua_State *L) {
+ /* create table CLIBS to keep track of loaded C libraries */
+ luaL_getsubtable(L, LUA_REGISTRYINDEX, CLIBS);
+ lua_createtable(L, 0, 1); /* metatable for CLIBS */
+ lua_pushcfunction(L, gctm);
+ lua_setfield(L, -2, "__gc"); /* set finalizer for CLIBS table */
+ lua_setmetatable(L, -2);
+ /* create `package' table */
+ luaL_newlib(L, pk_funcs);
+ createsearcherstable(L);
+#if defined(LUA_COMPAT_LOADERS)
+ lua_pushvalue(L, -1); /* make a copy of 'searchers' table */
+ lua_setfield(L, -3, "loaders"); /* put it in field `loaders' */
+#endif
+ lua_setfield(L, -2, "searchers"); /* put it in field 'searchers' */
+ /* set field 'path' */
+ setpath(L, "path", LUA_PATHVERSION, LUA_PATH, LUA_PATH_DEFAULT);
+ /* set field 'cpath' */
+ setpath(L, "cpath", LUA_CPATHVERSION, LUA_CPATH, LUA_CPATH_DEFAULT);
+ /* store config information */
+ lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
+ LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
+ lua_setfield(L, -2, "config");
+ /* set field `loaded' */
+ luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
+ lua_setfield(L, -2, "loaded");
+ /* set field `preload' */
+ luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
+ lua_setfield(L, -2, "preload");
+ lua_pushglobaltable(L);
+ lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */
+ luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */
+ lua_pop(L, 1); /* pop global table */
+ return 1; /* return 'package' table */
+}
+
diff --git a/ext/lua/src/lobject.c b/ext/lua/src/lobject.c
new file mode 100644
index 0000000000..882d994d41
--- /dev/null
+++ b/ext/lua/src/lobject.c
@@ -0,0 +1,287 @@
+/*
+** $Id: lobject.c,v 2.58.1.1 2013/04/12 18:48:47 roberto Exp $
+** Some generic functions over Lua objects
+** See Copyright Notice in lua.h
+*/
+
+#include
+#include
+#include
+#include
+
+#define lobject_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lctype.h"
+#include "ldebug.h"
+#include "ldo.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "lvm.h"
+
+
+
+LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT};
+
+
+/*
+** converts an integer to a "floating point byte", represented as
+** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
+** eeeee != 0 and (xxx) otherwise.
+*/
+int luaO_int2fb (unsigned int x) {
+ int e = 0; /* exponent */
+ if (x < 8) return x;
+ while (x >= 0x10) {
+ x = (x+1) >> 1;
+ e++;
+ }
+ return ((e+1) << 3) | (cast_int(x) - 8);
+}
+
+
+/* converts back */
+int luaO_fb2int (int x) {
+ int e = (x >> 3) & 0x1f;
+ if (e == 0) return x;
+ else return ((x & 7) + 8) << (e - 1);
+}
+
+
+int luaO_ceillog2 (unsigned int x) {
+ static const lu_byte log_2[256] = {
+ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
+ };
+ int l = 0;
+ x--;
+ while (x >= 256) { l += 8; x >>= 8; }
+ return l + log_2[x];
+}
+
+
+lua_Number luaO_arith (int op, lua_Number v1, lua_Number v2) {
+ switch (op) {
+ case LUA_OPADD: return luai_numadd(NULL, v1, v2);
+ case LUA_OPSUB: return luai_numsub(NULL, v1, v2);
+ case LUA_OPMUL: return luai_nummul(NULL, v1, v2);
+ case LUA_OPDIV: return luai_numdiv(NULL, v1, v2);
+ case LUA_OPMOD: return luai_nummod(NULL, v1, v2);
+ case LUA_OPPOW: return luai_numpow(NULL, v1, v2);
+ case LUA_OPUNM: return luai_numunm(NULL, v1);
+ default: lua_assert(0); return 0;
+ }
+}
+
+
+int luaO_hexavalue (int c) {
+ if (lisdigit(c)) return c - '0';
+ else return ltolower(c) - 'a' + 10;
+}
+
+
+#if !defined(lua_strx2number)
+
+#include
+
+
+static int isneg (const char **s) {
+ if (**s == '-') { (*s)++; return 1; }
+ else if (**s == '+') (*s)++;
+ return 0;
+}
+
+
+static lua_Number readhexa (const char **s, lua_Number r, int *count) {
+ for (; lisxdigit(cast_uchar(**s)); (*s)++) { /* read integer part */
+ r = (r * cast_num(16.0)) + cast_num(luaO_hexavalue(cast_uchar(**s)));
+ (*count)++;
+ }
+ return r;
+}
+
+
+/*
+** convert an hexadecimal numeric string to a number, following
+** C99 specification for 'strtod'
+*/
+static lua_Number lua_strx2number (const char *s, char **endptr) {
+ lua_Number r = 0.0;
+ int e = 0, i = 0;
+ int neg = 0; /* 1 if number is negative */
+ *endptr = cast(char *, s); /* nothing is valid yet */
+ while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */
+ neg = isneg(&s); /* check signal */
+ if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */
+ return 0.0; /* invalid format (no '0x') */
+ s += 2; /* skip '0x' */
+ r = readhexa(&s, r, &i); /* read integer part */
+ if (*s == '.') {
+ s++; /* skip dot */
+ r = readhexa(&s, r, &e); /* read fractional part */
+ }
+ if (i == 0 && e == 0)
+ return 0.0; /* invalid format (no digit) */
+ e *= -4; /* each fractional digit divides value by 2^-4 */
+ *endptr = cast(char *, s); /* valid up to here */
+ if (*s == 'p' || *s == 'P') { /* exponent part? */
+ int exp1 = 0;
+ int neg1;
+ s++; /* skip 'p' */
+ neg1 = isneg(&s); /* signal */
+ if (!lisdigit(cast_uchar(*s)))
+ goto ret; /* must have at least one digit */
+ while (lisdigit(cast_uchar(*s))) /* read exponent */
+ exp1 = exp1 * 10 + *(s++) - '0';
+ if (neg1) exp1 = -exp1;
+ e += exp1;
+ }
+ *endptr = cast(char *, s); /* valid up to here */
+ ret:
+ if (neg) r = -r;
+ return l_mathop(ldexp)(r, e);
+}
+
+#endif
+
+
+int luaO_str2d (const char *s, size_t len, lua_Number *result) {
+ char *endptr;
+ if (strpbrk(s, "nN")) /* reject 'inf' and 'nan' */
+ return 0;
+ else if (strpbrk(s, "xX")) /* hexa? */
+ *result = lua_strx2number(s, &endptr);
+ else
+ *result = lua_str2number(s, &endptr);
+ if (endptr == s) return 0; /* nothing recognized */
+ while (lisspace(cast_uchar(*endptr))) endptr++;
+ return (endptr == s + len); /* OK if no trailing characters */
+}
+
+
+
+static void pushstr (lua_State *L, const char *str, size_t l) {
+ setsvalue2s(L, L->top++, luaS_newlstr(L, str, l));
+}
+
+
+/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
+const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
+ int n = 0;
+ for (;;) {
+ const char *e = strchr(fmt, '%');
+ if (e == NULL) break;
+ luaD_checkstack(L, 2); /* fmt + item */
+ pushstr(L, fmt, e - fmt);
+ switch (*(e+1)) {
+ case 's': {
+ const char *s = va_arg(argp, char *);
+ if (s == NULL) s = "(null)";
+ pushstr(L, s, strlen(s));
+ break;
+ }
+ case 'c': {
+ char buff;
+ buff = cast(char, va_arg(argp, int));
+ pushstr(L, &buff, 1);
+ break;
+ }
+ case 'd': {
+ setnvalue(L->top++, cast_num(va_arg(argp, int)));
+ break;
+ }
+ case 'f': {
+ setnvalue(L->top++, cast_num(va_arg(argp, l_uacNumber)));
+ break;
+ }
+ case 'p': {
+ char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
+ int l = sprintf(buff, "%p", va_arg(argp, void *));
+ pushstr(L, buff, l);
+ break;
+ }
+ case '%': {
+ pushstr(L, "%", 1);
+ break;
+ }
+ default: {
+ luaG_runerror(L,
+ "invalid option " LUA_QL("%%%c") " to " LUA_QL("lua_pushfstring"),
+ *(e + 1));
+ }
+ }
+ n += 2;
+ fmt = e+2;
+ }
+ luaD_checkstack(L, 1);
+ pushstr(L, fmt, strlen(fmt));
+ if (n > 0) luaV_concat(L, n + 1);
+ return svalue(L->top - 1);
+}
+
+
+const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
+ const char *msg;
+ va_list argp;
+ va_start(argp, fmt);
+ msg = luaO_pushvfstring(L, fmt, argp);
+ va_end(argp);
+ return msg;
+}
+
+
+/* number of chars of a literal string without the ending \0 */
+#define LL(x) (sizeof(x)/sizeof(char) - 1)
+
+#define RETS "..."
+#define PRE "[string \""
+#define POS "\"]"
+
+#define addstr(a,b,l) ( memcpy(a,b,(l) * sizeof(char)), a += (l) )
+
+void luaO_chunkid (char *out, const char *source, size_t bufflen) {
+ size_t l = strlen(source);
+ if (*source == '=') { /* 'literal' source */
+ if (l <= bufflen) /* small enough? */
+ memcpy(out, source + 1, l * sizeof(char));
+ else { /* truncate it */
+ addstr(out, source + 1, bufflen - 1);
+ *out = '\0';
+ }
+ }
+ else if (*source == '@') { /* file name */
+ if (l <= bufflen) /* small enough? */
+ memcpy(out, source + 1, l * sizeof(char));
+ else { /* add '...' before rest of name */
+ addstr(out, RETS, LL(RETS));
+ bufflen -= LL(RETS);
+ memcpy(out, source + 1 + l - bufflen, bufflen * sizeof(char));
+ }
+ }
+ else { /* string; format as [string "source"] */
+ const char *nl = strchr(source, '\n'); /* find first new line (if any) */
+ addstr(out, PRE, LL(PRE)); /* add prefix */
+ bufflen -= LL(PRE RETS POS) + 1; /* save space for prefix+suffix+'\0' */
+ if (l < bufflen && nl == NULL) { /* small one-line source? */
+ addstr(out, source, l); /* keep it */
+ }
+ else {
+ if (nl != NULL) l = nl - source; /* stop at first newline */
+ if (l > bufflen) l = bufflen;
+ addstr(out, source, l);
+ addstr(out, RETS, LL(RETS));
+ }
+ memcpy(out, POS, (LL(POS) + 1) * sizeof(char));
+ }
+}
+
diff --git a/ext/lua/src/lopcodes.c b/ext/lua/src/lopcodes.c
new file mode 100644
index 0000000000..4190dc7624
--- /dev/null
+++ b/ext/lua/src/lopcodes.c
@@ -0,0 +1,107 @@
+/*
+** $Id: lopcodes.c,v 1.49.1.1 2013/04/12 18:48:47 roberto Exp $
+** Opcodes for Lua virtual machine
+** See Copyright Notice in lua.h
+*/
+
+
+#define lopcodes_c
+#define LUA_CORE
+
+
+#include "lopcodes.h"
+
+
+/* ORDER OP */
+
+LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
+ "MOVE",
+ "LOADK",
+ "LOADKX",
+ "LOADBOOL",
+ "LOADNIL",
+ "GETUPVAL",
+ "GETTABUP",
+ "GETTABLE",
+ "SETTABUP",
+ "SETUPVAL",
+ "SETTABLE",
+ "NEWTABLE",
+ "SELF",
+ "ADD",
+ "SUB",
+ "MUL",
+ "DIV",
+ "MOD",
+ "POW",
+ "UNM",
+ "NOT",
+ "LEN",
+ "CONCAT",
+ "JMP",
+ "EQ",
+ "LT",
+ "LE",
+ "TEST",
+ "TESTSET",
+ "CALL",
+ "TAILCALL",
+ "RETURN",
+ "FORLOOP",
+ "FORPREP",
+ "TFORCALL",
+ "TFORLOOP",
+ "SETLIST",
+ "CLOSURE",
+ "VARARG",
+ "EXTRAARG",
+ NULL
+};
+
+
+#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
+
+LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
+/* T A B C mode opcode */
+ opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */
+ ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */
+ ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */
+ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */
+ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */
+ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */
+ ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */
+ ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */
+ ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */
+ ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */
+ ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */
+ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */
+ ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */
+ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */
+ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */
+ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */
+ ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */
+ ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */
+ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */
+ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */
+ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */
+ ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */
+ ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */
+ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */
+ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */
+ ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */
+ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */
+ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */
+ ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */
+ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */
+ ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */
+ ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */
+ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
+ ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */
+};
+
diff --git a/ext/lua/src/loslib.c b/ext/lua/src/loslib.c
new file mode 100644
index 0000000000..052ba17441
--- /dev/null
+++ b/ext/lua/src/loslib.c
@@ -0,0 +1,323 @@
+/*
+** $Id: loslib.c,v 1.40.1.1 2013/04/12 18:48:47 roberto Exp $
+** Standard Operating System library
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+#include
+#include
+#include
+#include
+
+#define loslib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+/*
+** list of valid conversion specifiers for the 'strftime' function
+*/
+#if !defined(LUA_STRFTIMEOPTIONS)
+
+#if !defined(LUA_USE_POSIX)
+#define LUA_STRFTIMEOPTIONS { "aAbBcdHIjmMpSUwWxXyYz%", "" }
+#else
+#define LUA_STRFTIMEOPTIONS \
+ { "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%", "" \
+ "", "E", "cCxXyY", \
+ "O", "deHImMSuUVwWy" }
+#endif
+
+#endif
+
+
+
+/*
+** By default, Lua uses tmpnam except when POSIX is available, where it
+** uses mkstemp.
+*/
+#if defined(LUA_USE_MKSTEMP)
+#include
+#define LUA_TMPNAMBUFSIZE 32
+#define lua_tmpnam(b,e) { \
+ strcpy(b, "/tmp/lua_XXXXXX"); \
+ e = mkstemp(b); \
+ if (e != -1) close(e); \
+ e = (e == -1); }
+
+#elif !defined(lua_tmpnam)
+
+#define LUA_TMPNAMBUFSIZE L_tmpnam
+#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
+
+#endif
+
+
+/*
+** By default, Lua uses gmtime/localtime, except when POSIX is available,
+** where it uses gmtime_r/localtime_r
+*/
+#if defined(LUA_USE_GMTIME_R)
+
+#define l_gmtime(t,r) gmtime_r(t,r)
+#define l_localtime(t,r) localtime_r(t,r)
+
+#elif !defined(l_gmtime)
+
+#define l_gmtime(t,r) ((void)r, gmtime(t))
+#define l_localtime(t,r) ((void)r, localtime(t))
+
+#endif
+
+
+
+static int os_execute (lua_State *L) {
+ const char *cmd = luaL_optstring(L, 1, NULL);
+ int stat = system(cmd);
+ if (cmd != NULL)
+ return luaL_execresult(L, stat);
+ else {
+ lua_pushboolean(L, stat); /* true if there is a shell */
+ return 1;
+ }
+}
+
+
+static int os_remove (lua_State *L) {
+ const char *filename = luaL_checkstring(L, 1);
+ return luaL_fileresult(L, remove(filename) == 0, filename);
+}
+
+
+static int os_rename (lua_State *L) {
+ const char *fromname = luaL_checkstring(L, 1);
+ const char *toname = luaL_checkstring(L, 2);
+ return luaL_fileresult(L, rename(fromname, toname) == 0, NULL);
+}
+
+
+static int os_tmpname (lua_State *L) {
+ char buff[LUA_TMPNAMBUFSIZE];
+ int err;
+ lua_tmpnam(buff, err);
+ if (err)
+ return luaL_error(L, "unable to generate a unique filename");
+ lua_pushstring(L, buff);
+ return 1;
+}
+
+
+static int os_getenv (lua_State *L) {
+ lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */
+ return 1;
+}
+
+
+static int os_clock (lua_State *L) {
+ lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC);
+ return 1;
+}
+
+
+/*
+** {======================================================
+** Time/Date operations
+** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S,
+** wday=%w+1, yday=%j, isdst=? }
+** =======================================================
+*/
+
+static void setfield (lua_State *L, const char *key, int value) {
+ lua_pushinteger(L, value);
+ lua_setfield(L, -2, key);
+}
+
+static void setboolfield (lua_State *L, const char *key, int value) {
+ if (value < 0) /* undefined? */
+ return; /* does not set field */
+ lua_pushboolean(L, value);
+ lua_setfield(L, -2, key);
+}
+
+static int getboolfield (lua_State *L, const char *key) {
+ int res;
+ lua_getfield(L, -1, key);
+ res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1);
+ lua_pop(L, 1);
+ return res;
+}
+
+
+static int getfield (lua_State *L, const char *key, int d) {
+ int res, isnum;
+ lua_getfield(L, -1, key);
+ res = (int)lua_tointegerx(L, -1, &isnum);
+ if (!isnum) {
+ if (d < 0)
+ return luaL_error(L, "field " LUA_QS " missing in date table", key);
+ res = d;
+ }
+ lua_pop(L, 1);
+ return res;
+}
+
+
+static const char *checkoption (lua_State *L, const char *conv, char *buff) {
+ static const char *const options[] = LUA_STRFTIMEOPTIONS;
+ unsigned int i;
+ for (i = 0; i < sizeof(options)/sizeof(options[0]); i += 2) {
+ if (*conv != '\0' && strchr(options[i], *conv) != NULL) {
+ buff[1] = *conv;
+ if (*options[i + 1] == '\0') { /* one-char conversion specifier? */
+ buff[2] = '\0'; /* end buffer */
+ return conv + 1;
+ }
+ else if (*(conv + 1) != '\0' &&
+ strchr(options[i + 1], *(conv + 1)) != NULL) {
+ buff[2] = *(conv + 1); /* valid two-char conversion specifier */
+ buff[3] = '\0'; /* end buffer */
+ return conv + 2;
+ }
+ }
+ }
+ luaL_argerror(L, 1,
+ lua_pushfstring(L, "invalid conversion specifier '%%%s'", conv));
+ return conv; /* to avoid warnings */
+}
+
+
+static int os_date (lua_State *L) {
+ const char *s = luaL_optstring(L, 1, "%c");
+ time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL));
+ struct tm tmr, *stm;
+ if (*s == '!') { /* UTC? */
+ stm = l_gmtime(&t, &tmr);
+ s++; /* skip `!' */
+ }
+ else
+ stm = l_localtime(&t, &tmr);
+ if (stm == NULL) /* invalid date? */
+ lua_pushnil(L);
+ else if (strcmp(s, "*t") == 0) {
+ lua_createtable(L, 0, 9); /* 9 = number of fields */
+ setfield(L, "sec", stm->tm_sec);
+ setfield(L, "min", stm->tm_min);
+ setfield(L, "hour", stm->tm_hour);
+ setfield(L, "day", stm->tm_mday);
+ setfield(L, "month", stm->tm_mon+1);
+ setfield(L, "year", stm->tm_year+1900);
+ setfield(L, "wday", stm->tm_wday+1);
+ setfield(L, "yday", stm->tm_yday+1);
+ setboolfield(L, "isdst", stm->tm_isdst);
+ }
+ else {
+ char cc[4];
+ luaL_Buffer b;
+ cc[0] = '%';
+ luaL_buffinit(L, &b);
+ while (*s) {
+ if (*s != '%') /* no conversion specifier? */
+ luaL_addchar(&b, *s++);
+ else {
+ size_t reslen;
+ char buff[200]; /* should be big enough for any conversion result */
+ s = checkoption(L, s + 1, cc);
+ reslen = strftime(buff, sizeof(buff), cc, stm);
+ luaL_addlstring(&b, buff, reslen);
+ }
+ }
+ luaL_pushresult(&b);
+ }
+ return 1;
+}
+
+
+static int os_time (lua_State *L) {
+ time_t t;
+ if (lua_isnoneornil(L, 1)) /* called without args? */
+ t = time(NULL); /* get current time */
+ else {
+ struct tm ts;
+ luaL_checktype(L, 1, LUA_TTABLE);
+ lua_settop(L, 1); /* make sure table is at the top */
+ ts.tm_sec = getfield(L, "sec", 0);
+ ts.tm_min = getfield(L, "min", 0);
+ ts.tm_hour = getfield(L, "hour", 12);
+ ts.tm_mday = getfield(L, "day", -1);
+ ts.tm_mon = getfield(L, "month", -1) - 1;
+ ts.tm_year = getfield(L, "year", -1) - 1900;
+ ts.tm_isdst = getboolfield(L, "isdst");
+ t = mktime(&ts);
+ }
+ if (t == (time_t)(-1))
+ lua_pushnil(L);
+ else
+ lua_pushnumber(L, (lua_Number)t);
+ return 1;
+}
+
+
+static int os_difftime (lua_State *L) {
+ lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
+ (time_t)(luaL_optnumber(L, 2, 0))));
+ return 1;
+}
+
+/* }====================================================== */
+
+
+static int os_setlocale (lua_State *L) {
+ static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY,
+ LC_NUMERIC, LC_TIME};
+ static const char *const catnames[] = {"all", "collate", "ctype", "monetary",
+ "numeric", "time", NULL};
+ const char *l = luaL_optstring(L, 1, NULL);
+ int op = luaL_checkoption(L, 2, "all", catnames);
+ lua_pushstring(L, setlocale(cat[op], l));
+ return 1;
+}
+
+
+static int os_exit (lua_State *L) {
+ int status;
+ if (lua_isboolean(L, 1))
+ status = (lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE);
+ else
+ status = luaL_optint(L, 1, EXIT_SUCCESS);
+ if (lua_toboolean(L, 2))
+ lua_close(L);
+ if (L) exit(status); /* 'if' to avoid warnings for unreachable 'return' */
+ return 0;
+}
+
+
+static const luaL_Reg syslib[] = {
+ {"clock", os_clock},
+ {"date", os_date},
+ {"difftime", os_difftime},
+ {"execute", os_execute},
+ {"exit", os_exit},
+ {"getenv", os_getenv},
+ {"remove", os_remove},
+ {"rename", os_rename},
+ {"setlocale", os_setlocale},
+ {"time", os_time},
+ {"tmpname", os_tmpname},
+ {NULL, NULL}
+};
+
+/* }====================================================== */
+
+
+
+LUAMOD_API int luaopen_os (lua_State *L) {
+ luaL_newlib(L, syslib);
+ return 1;
+}
+
diff --git a/ext/lua/src/lparser.c b/ext/lua/src/lparser.c
new file mode 100644
index 0000000000..9e1a9ca2cf
--- /dev/null
+++ b/ext/lua/src/lparser.c
@@ -0,0 +1,1638 @@
+/*
+** $Id: lparser.c,v 2.130.1.1 2013/04/12 18:48:47 roberto Exp $
+** Lua Parser
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+
+#define lparser_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lcode.h"
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "llex.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lopcodes.h"
+#include "lparser.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+
+
+
+/* maximum number of local variables per function (must be smaller
+ than 250, due to the bytecode format) */
+#define MAXVARS 200
+
+
+#define hasmultret(k) ((k) == VCALL || (k) == VVARARG)
+
+
+
+/*
+** nodes for block list (list of active blocks)
+*/
+typedef struct BlockCnt {
+ struct BlockCnt *previous; /* chain */
+ short firstlabel; /* index of first label in this block */
+ short firstgoto; /* index of first pending goto in this block */
+ lu_byte nactvar; /* # active locals outside the block */
+ lu_byte upval; /* true if some variable in the block is an upvalue */
+ lu_byte isloop; /* true if `block' is a loop */
+} BlockCnt;
+
+
+
+/*
+** prototypes for recursive non-terminal functions
+*/
+static void statement (LexState *ls);
+static void expr (LexState *ls, expdesc *v);
+
+
+static void anchor_token (LexState *ls) {
+ /* last token from outer function must be EOS */
+ lua_assert(ls->fs != NULL || ls->t.token == TK_EOS);
+ if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) {
+ TString *ts = ls->t.seminfo.ts;
+ luaX_newstring(ls, getstr(ts), ts->tsv.len);
+ }
+}
+
+
+/* semantic error */
+static l_noret semerror (LexState *ls, const char *msg) {
+ ls->t.token = 0; /* remove 'near to' from final message */
+ luaX_syntaxerror(ls, msg);
+}
+
+
+static l_noret error_expected (LexState *ls, int token) {
+ luaX_syntaxerror(ls,
+ luaO_pushfstring(ls->L, "%s expected", luaX_token2str(ls, token)));
+}
+
+
+static l_noret errorlimit (FuncState *fs, int limit, const char *what) {
+ lua_State *L = fs->ls->L;
+ const char *msg;
+ int line = fs->f->linedefined;
+ const char *where = (line == 0)
+ ? "main function"
+ : luaO_pushfstring(L, "function at line %d", line);
+ msg = luaO_pushfstring(L, "too many %s (limit is %d) in %s",
+ what, limit, where);
+ luaX_syntaxerror(fs->ls, msg);
+}
+
+
+static void checklimit (FuncState *fs, int v, int l, const char *what) {
+ if (v > l) errorlimit(fs, l, what);
+}
+
+
+static int testnext (LexState *ls, int c) {
+ if (ls->t.token == c) {
+ luaX_next(ls);
+ return 1;
+ }
+ else return 0;
+}
+
+
+static void check (LexState *ls, int c) {
+ if (ls->t.token != c)
+ error_expected(ls, c);
+}
+
+
+static void checknext (LexState *ls, int c) {
+ check(ls, c);
+ luaX_next(ls);
+}
+
+
+#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); }
+
+
+
+static void check_match (LexState *ls, int what, int who, int where) {
+ if (!testnext(ls, what)) {
+ if (where == ls->linenumber)
+ error_expected(ls, what);
+ else {
+ luaX_syntaxerror(ls, luaO_pushfstring(ls->L,
+ "%s expected (to close %s at line %d)",
+ luaX_token2str(ls, what), luaX_token2str(ls, who), where));
+ }
+ }
+}
+
+
+static TString *str_checkname (LexState *ls) {
+ TString *ts;
+ check(ls, TK_NAME);
+ ts = ls->t.seminfo.ts;
+ luaX_next(ls);
+ return ts;
+}
+
+
+static void init_exp (expdesc *e, expkind k, int i) {
+ e->f = e->t = NO_JUMP;
+ e->k = k;
+ e->u.info = i;
+}
+
+
+static void codestring (LexState *ls, expdesc *e, TString *s) {
+ init_exp(e, VK, luaK_stringK(ls->fs, s));
+}
+
+
+static void checkname (LexState *ls, expdesc *e) {
+ codestring(ls, e, str_checkname(ls));
+}
+
+
+static int registerlocalvar (LexState *ls, TString *varname) {
+ FuncState *fs = ls->fs;
+ Proto *f = fs->f;
+ int oldsize = f->sizelocvars;
+ luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
+ LocVar, SHRT_MAX, "local variables");
+ while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL;
+ f->locvars[fs->nlocvars].varname = varname;
+ luaC_objbarrier(ls->L, f, varname);
+ return fs->nlocvars++;
+}
+
+
+static void new_localvar (LexState *ls, TString *name) {
+ FuncState *fs = ls->fs;
+ Dyndata *dyd = ls->dyd;
+ int reg = registerlocalvar(ls, name);
+ checklimit(fs, dyd->actvar.n + 1 - fs->firstlocal,
+ MAXVARS, "local variables");
+ luaM_growvector(ls->L, dyd->actvar.arr, dyd->actvar.n + 1,
+ dyd->actvar.size, Vardesc, MAX_INT, "local variables");
+ dyd->actvar.arr[dyd->actvar.n++].idx = cast(short, reg);
+}
+
+
+static void new_localvarliteral_ (LexState *ls, const char *name, size_t sz) {
+ new_localvar(ls, luaX_newstring(ls, name, sz));
+}
+
+#define new_localvarliteral(ls,v) \
+ new_localvarliteral_(ls, "" v, (sizeof(v)/sizeof(char))-1)
+
+
+static LocVar *getlocvar (FuncState *fs, int i) {
+ int idx = fs->ls->dyd->actvar.arr[fs->firstlocal + i].idx;
+ lua_assert(idx < fs->nlocvars);
+ return &fs->f->locvars[idx];
+}
+
+
+static void adjustlocalvars (LexState *ls, int nvars) {
+ FuncState *fs = ls->fs;
+ fs->nactvar = cast_byte(fs->nactvar + nvars);
+ for (; nvars; nvars--) {
+ getlocvar(fs, fs->nactvar - nvars)->startpc = fs->pc;
+ }
+}
+
+
+static void removevars (FuncState *fs, int tolevel) {
+ fs->ls->dyd->actvar.n -= (fs->nactvar - tolevel);
+ while (fs->nactvar > tolevel)
+ getlocvar(fs, --fs->nactvar)->endpc = fs->pc;
+}
+
+
+static int searchupvalue (FuncState *fs, TString *name) {
+ int i;
+ Upvaldesc *up = fs->f->upvalues;
+ for (i = 0; i < fs->nups; i++) {
+ if (luaS_eqstr(up[i].name, name)) return i;
+ }
+ return -1; /* not found */
+}
+
+
+static int newupvalue (FuncState *fs, TString *name, expdesc *v) {
+ Proto *f = fs->f;
+ int oldsize = f->sizeupvalues;
+ checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues");
+ luaM_growvector(fs->ls->L, f->upvalues, fs->nups, f->sizeupvalues,
+ Upvaldesc, MAXUPVAL, "upvalues");
+ while (oldsize < f->sizeupvalues) f->upvalues[oldsize++].name = NULL;
+ f->upvalues[fs->nups].instack = (v->k == VLOCAL);
+ f->upvalues[fs->nups].idx = cast_byte(v->u.info);
+ f->upvalues[fs->nups].name = name;
+ luaC_objbarrier(fs->ls->L, f, name);
+ return fs->nups++;
+}
+
+
+static int searchvar (FuncState *fs, TString *n) {
+ int i;
+ for (i = cast_int(fs->nactvar) - 1; i >= 0; i--) {
+ if (luaS_eqstr(n, getlocvar(fs, i)->varname))
+ return i;
+ }
+ return -1; /* not found */
+}
+
+
+/*
+ Mark block where variable at given level was defined
+ (to emit close instructions later).
+*/
+static void markupval (FuncState *fs, int level) {
+ BlockCnt *bl = fs->bl;
+ while (bl->nactvar > level) bl = bl->previous;
+ bl->upval = 1;
+}
+
+
+/*
+ Find variable with given name 'n'. If it is an upvalue, add this
+ upvalue into all intermediate functions.
+*/
+static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
+ if (fs == NULL) /* no more levels? */
+ return VVOID; /* default is global */
+ else {
+ int v = searchvar(fs, n); /* look up locals at current level */
+ if (v >= 0) { /* found? */
+ init_exp(var, VLOCAL, v); /* variable is local */
+ if (!base)
+ markupval(fs, v); /* local will be used as an upval */
+ return VLOCAL;
+ }
+ else { /* not found as local at current level; try upvalues */
+ int idx = searchupvalue(fs, n); /* try existing upvalues */
+ if (idx < 0) { /* not found? */
+ if (singlevaraux(fs->prev, n, var, 0) == VVOID) /* try upper levels */
+ return VVOID; /* not found; is a global */
+ /* else was LOCAL or UPVAL */
+ idx = newupvalue(fs, n, var); /* will be a new upvalue */
+ }
+ init_exp(var, VUPVAL, idx);
+ return VUPVAL;
+ }
+ }
+}
+
+
+static void singlevar (LexState *ls, expdesc *var) {
+ TString *varname = str_checkname(ls);
+ FuncState *fs = ls->fs;
+ if (singlevaraux(fs, varname, var, 1) == VVOID) { /* global name? */
+ expdesc key;
+ singlevaraux(fs, ls->envn, var, 1); /* get environment variable */
+ lua_assert(var->k == VLOCAL || var->k == VUPVAL);
+ codestring(ls, &key, varname); /* key is variable name */
+ luaK_indexed(fs, var, &key); /* env[varname] */
+ }
+}
+
+
+static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
+ FuncState *fs = ls->fs;
+ int extra = nvars - nexps;
+ if (hasmultret(e->k)) {
+ extra++; /* includes call itself */
+ if (extra < 0) extra = 0;
+ luaK_setreturns(fs, e, extra); /* last exp. provides the difference */
+ if (extra > 1) luaK_reserveregs(fs, extra-1);
+ }
+ else {
+ if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */
+ if (extra > 0) {
+ int reg = fs->freereg;
+ luaK_reserveregs(fs, extra);
+ luaK_nil(fs, reg, extra);
+ }
+ }
+}
+
+
+static void enterlevel (LexState *ls) {
+ lua_State *L = ls->L;
+ ++L->nCcalls;
+ checklimit(ls->fs, L->nCcalls, LUAI_MAXCCALLS, "C levels");
+}
+
+
+#define leavelevel(ls) ((ls)->L->nCcalls--)
+
+
+static void closegoto (LexState *ls, int g, Labeldesc *label) {
+ int i;
+ FuncState *fs = ls->fs;
+ Labellist *gl = &ls->dyd->gt;
+ Labeldesc *gt = &gl->arr[g];
+ lua_assert(luaS_eqstr(gt->name, label->name));
+ if (gt->nactvar < label->nactvar) {
+ TString *vname = getlocvar(fs, gt->nactvar)->varname;
+ const char *msg = luaO_pushfstring(ls->L,
+ " at line %d jumps into the scope of local " LUA_QS,
+ getstr(gt->name), gt->line, getstr(vname));
+ semerror(ls, msg);
+ }
+ luaK_patchlist(fs, gt->pc, label->pc);
+ /* remove goto from pending list */
+ for (i = g; i < gl->n - 1; i++)
+ gl->arr[i] = gl->arr[i + 1];
+ gl->n--;
+}
+
+
+/*
+** try to close a goto with existing labels; this solves backward jumps
+*/
+static int findlabel (LexState *ls, int g) {
+ int i;
+ BlockCnt *bl = ls->fs->bl;
+ Dyndata *dyd = ls->dyd;
+ Labeldesc *gt = &dyd->gt.arr[g];
+ /* check labels in current block for a match */
+ for (i = bl->firstlabel; i < dyd->label.n; i++) {
+ Labeldesc *lb = &dyd->label.arr[i];
+ if (luaS_eqstr(lb->name, gt->name)) { /* correct label? */
+ if (gt->nactvar > lb->nactvar &&
+ (bl->upval || dyd->label.n > bl->firstlabel))
+ luaK_patchclose(ls->fs, gt->pc, lb->nactvar);
+ closegoto(ls, g, lb); /* close it */
+ return 1;
+ }
+ }
+ return 0; /* label not found; cannot close goto */
+}
+
+
+static int newlabelentry (LexState *ls, Labellist *l, TString *name,
+ int line, int pc) {
+ int n = l->n;
+ luaM_growvector(ls->L, l->arr, n, l->size,
+ Labeldesc, SHRT_MAX, "labels/gotos");
+ l->arr[n].name = name;
+ l->arr[n].line = line;
+ l->arr[n].nactvar = ls->fs->nactvar;
+ l->arr[n].pc = pc;
+ l->n++;
+ return n;
+}
+
+
+/*
+** check whether new label 'lb' matches any pending gotos in current
+** block; solves forward jumps
+*/
+static void findgotos (LexState *ls, Labeldesc *lb) {
+ Labellist *gl = &ls->dyd->gt;
+ int i = ls->fs->bl->firstgoto;
+ while (i < gl->n) {
+ if (luaS_eqstr(gl->arr[i].name, lb->name))
+ closegoto(ls, i, lb);
+ else
+ i++;
+ }
+}
+
+
+/*
+** "export" pending gotos to outer level, to check them against
+** outer labels; if the block being exited has upvalues, and
+** the goto exits the scope of any variable (which can be the
+** upvalue), close those variables being exited.
+*/
+static void movegotosout (FuncState *fs, BlockCnt *bl) {
+ int i = bl->firstgoto;
+ Labellist *gl = &fs->ls->dyd->gt;
+ /* correct pending gotos to current block and try to close it
+ with visible labels */
+ while (i < gl->n) {
+ Labeldesc *gt = &gl->arr[i];
+ if (gt->nactvar > bl->nactvar) {
+ if (bl->upval)
+ luaK_patchclose(fs, gt->pc, bl->nactvar);
+ gt->nactvar = bl->nactvar;
+ }
+ if (!findlabel(fs->ls, i))
+ i++; /* move to next one */
+ }
+}
+
+
+static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isloop) {
+ bl->isloop = isloop;
+ bl->nactvar = fs->nactvar;
+ bl->firstlabel = fs->ls->dyd->label.n;
+ bl->firstgoto = fs->ls->dyd->gt.n;
+ bl->upval = 0;
+ bl->previous = fs->bl;
+ fs->bl = bl;
+ lua_assert(fs->freereg == fs->nactvar);
+}
+
+
+/*
+** create a label named "break" to resolve break statements
+*/
+static void breaklabel (LexState *ls) {
+ TString *n = luaS_new(ls->L, "break");
+ int l = newlabelentry(ls, &ls->dyd->label, n, 0, ls->fs->pc);
+ findgotos(ls, &ls->dyd->label.arr[l]);
+}
+
+/*
+** generates an error for an undefined 'goto'; choose appropriate
+** message when label name is a reserved word (which can only be 'break')
+*/
+static l_noret undefgoto (LexState *ls, Labeldesc *gt) {
+ const char *msg = isreserved(gt->name)
+ ? "<%s> at line %d not inside a loop"
+ : "no visible label " LUA_QS " for at line %d";
+ msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line);
+ semerror(ls, msg);
+}
+
+
+static void leaveblock (FuncState *fs) {
+ BlockCnt *bl = fs->bl;
+ LexState *ls = fs->ls;
+ if (bl->previous && bl->upval) {
+ /* create a 'jump to here' to close upvalues */
+ int j = luaK_jump(fs);
+ luaK_patchclose(fs, j, bl->nactvar);
+ luaK_patchtohere(fs, j);
+ }
+ if (bl->isloop)
+ breaklabel(ls); /* close pending breaks */
+ fs->bl = bl->previous;
+ removevars(fs, bl->nactvar);
+ lua_assert(bl->nactvar == fs->nactvar);
+ fs->freereg = fs->nactvar; /* free registers */
+ ls->dyd->label.n = bl->firstlabel; /* remove local labels */
+ if (bl->previous) /* inner block? */
+ movegotosout(fs, bl); /* update pending gotos to outer block */
+ else if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */
+ undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */
+}
+
+
+/*
+** adds a new prototype into list of prototypes
+*/
+static Proto *addprototype (LexState *ls) {
+ Proto *clp;
+ lua_State *L = ls->L;
+ FuncState *fs = ls->fs;
+ Proto *f = fs->f; /* prototype of current function */
+ if (fs->np >= f->sizep) {
+ int oldsize = f->sizep;
+ luaM_growvector(L, f->p, fs->np, f->sizep, Proto *, MAXARG_Bx, "functions");
+ while (oldsize < f->sizep) f->p[oldsize++] = NULL;
+ }
+ f->p[fs->np++] = clp = luaF_newproto(L);
+ luaC_objbarrier(L, f, clp);
+ return clp;
+}
+
+
+/*
+** codes instruction to create new closure in parent function.
+** The OP_CLOSURE instruction must use the last available register,
+** so that, if it invokes the GC, the GC knows which registers
+** are in use at that time.
+*/
+static void codeclosure (LexState *ls, expdesc *v) {
+ FuncState *fs = ls->fs->prev;
+ init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1));
+ luaK_exp2nextreg(fs, v); /* fix it at the last register */
+}
+
+
+static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) {
+ lua_State *L = ls->L;
+ Proto *f;
+ fs->prev = ls->fs; /* linked list of funcstates */
+ fs->ls = ls;
+ ls->fs = fs;
+ fs->pc = 0;
+ fs->lasttarget = 0;
+ fs->jpc = NO_JUMP;
+ fs->freereg = 0;
+ fs->nk = 0;
+ fs->np = 0;
+ fs->nups = 0;
+ fs->nlocvars = 0;
+ fs->nactvar = 0;
+ fs->firstlocal = ls->dyd->actvar.n;
+ fs->bl = NULL;
+ f = fs->f;
+ f->source = ls->source;
+ f->maxstacksize = 2; /* registers 0/1 are always valid */
+ fs->h = luaH_new(L);
+ /* anchor table of constants (to avoid being collected) */
+ sethvalue2s(L, L->top, fs->h);
+ incr_top(L);
+ enterblock(fs, bl, 0);
+}
+
+
+static void close_func (LexState *ls) {
+ lua_State *L = ls->L;
+ FuncState *fs = ls->fs;
+ Proto *f = fs->f;
+ luaK_ret(fs, 0, 0); /* final return */
+ leaveblock(fs);
+ luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction);
+ f->sizecode = fs->pc;
+ luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int);
+ f->sizelineinfo = fs->pc;
+ luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue);
+ f->sizek = fs->nk;
+ luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *);
+ f->sizep = fs->np;
+ luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar);
+ f->sizelocvars = fs->nlocvars;
+ luaM_reallocvector(L, f->upvalues, f->sizeupvalues, fs->nups, Upvaldesc);
+ f->sizeupvalues = fs->nups;
+ lua_assert(fs->bl == NULL);
+ ls->fs = fs->prev;
+ /* last token read was anchored in defunct function; must re-anchor it */
+ anchor_token(ls);
+ L->top--; /* pop table of constants */
+ luaC_checkGC(L);
+}
+
+
+
+/*============================================================*/
+/* GRAMMAR RULES */
+/*============================================================*/
+
+
+/*
+** check whether current token is in the follow set of a block.
+** 'until' closes syntactical blocks, but do not close scope,
+** so it handled in separate.
+*/
+static int block_follow (LexState *ls, int withuntil) {
+ switch (ls->t.token) {
+ case TK_ELSE: case TK_ELSEIF:
+ case TK_END: case TK_EOS:
+ return 1;
+ case TK_UNTIL: return withuntil;
+ default: return 0;
+ }
+}
+
+
+static void statlist (LexState *ls) {
+ /* statlist -> { stat [`;'] } */
+ while (!block_follow(ls, 1)) {
+ if (ls->t.token == TK_RETURN) {
+ statement(ls);
+ return; /* 'return' must be last statement */
+ }
+ statement(ls);
+ }
+}
+
+
+static void fieldsel (LexState *ls, expdesc *v) {
+ /* fieldsel -> ['.' | ':'] NAME */
+ FuncState *fs = ls->fs;
+ expdesc key;
+ luaK_exp2anyregup(fs, v);
+ luaX_next(ls); /* skip the dot or colon */
+ checkname(ls, &key);
+ luaK_indexed(fs, v, &key);
+}
+
+
+static void yindex (LexState *ls, expdesc *v) {
+ /* index -> '[' expr ']' */
+ luaX_next(ls); /* skip the '[' */
+ expr(ls, v);
+ luaK_exp2val(ls->fs, v);
+ checknext(ls, ']');
+}
+
+
+/*
+** {======================================================================
+** Rules for Constructors
+** =======================================================================
+*/
+
+
+struct ConsControl {
+ expdesc v; /* last list item read */
+ expdesc *t; /* table descriptor */
+ int nh; /* total number of `record' elements */
+ int na; /* total number of array elements */
+ int tostore; /* number of array elements pending to be stored */
+};
+
+
+static void recfield (LexState *ls, struct ConsControl *cc) {
+ /* recfield -> (NAME | `['exp1`]') = exp1 */
+ FuncState *fs = ls->fs;
+ int reg = ls->fs->freereg;
+ expdesc key, val;
+ int rkkey;
+ if (ls->t.token == TK_NAME) {
+ checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
+ checkname(ls, &key);
+ }
+ else /* ls->t.token == '[' */
+ yindex(ls, &key);
+ cc->nh++;
+ checknext(ls, '=');
+ rkkey = luaK_exp2RK(fs, &key);
+ expr(ls, &val);
+ luaK_codeABC(fs, OP_SETTABLE, cc->t->u.info, rkkey, luaK_exp2RK(fs, &val));
+ fs->freereg = reg; /* free registers */
+}
+
+
+static void closelistfield (FuncState *fs, struct ConsControl *cc) {
+ if (cc->v.k == VVOID) return; /* there is no list item */
+ luaK_exp2nextreg(fs, &cc->v);
+ cc->v.k = VVOID;
+ if (cc->tostore == LFIELDS_PER_FLUSH) {
+ luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); /* flush */
+ cc->tostore = 0; /* no more items pending */
+ }
+}
+
+
+static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
+ if (cc->tostore == 0) return;
+ if (hasmultret(cc->v.k)) {
+ luaK_setmultret(fs, &cc->v);
+ luaK_setlist(fs, cc->t->u.info, cc->na, LUA_MULTRET);
+ cc->na--; /* do not count last expression (unknown number of elements) */
+ }
+ else {
+ if (cc->v.k != VVOID)
+ luaK_exp2nextreg(fs, &cc->v);
+ luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore);
+ }
+}
+
+
+static void listfield (LexState *ls, struct ConsControl *cc) {
+ /* listfield -> exp */
+ expr(ls, &cc->v);
+ checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
+ cc->na++;
+ cc->tostore++;
+}
+
+
+static void field (LexState *ls, struct ConsControl *cc) {
+ /* field -> listfield | recfield */
+ switch(ls->t.token) {
+ case TK_NAME: { /* may be 'listfield' or 'recfield' */
+ if (luaX_lookahead(ls) != '=') /* expression? */
+ listfield(ls, cc);
+ else
+ recfield(ls, cc);
+ break;
+ }
+ case '[': {
+ recfield(ls, cc);
+ break;
+ }
+ default: {
+ listfield(ls, cc);
+ break;
+ }
+ }
+}
+
+
+static void constructor (LexState *ls, expdesc *t) {
+ /* constructor -> '{' [ field { sep field } [sep] ] '}'
+ sep -> ',' | ';' */
+ FuncState *fs = ls->fs;
+ int line = ls->linenumber;
+ int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
+ struct ConsControl cc;
+ cc.na = cc.nh = cc.tostore = 0;
+ cc.t = t;
+ init_exp(t, VRELOCABLE, pc);
+ init_exp(&cc.v, VVOID, 0); /* no value (yet) */
+ luaK_exp2nextreg(ls->fs, t); /* fix it at stack top */
+ checknext(ls, '{');
+ do {
+ lua_assert(cc.v.k == VVOID || cc.tostore > 0);
+ if (ls->t.token == '}') break;
+ closelistfield(fs, &cc);
+ field(ls, &cc);
+ } while (testnext(ls, ',') || testnext(ls, ';'));
+ check_match(ls, '}', '{', line);
+ lastlistfield(fs, &cc);
+ SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */
+ SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */
+}
+
+/* }====================================================================== */
+
+
+
+static void parlist (LexState *ls) {
+ /* parlist -> [ param { `,' param } ] */
+ FuncState *fs = ls->fs;
+ Proto *f = fs->f;
+ int nparams = 0;
+ f->is_vararg = 0;
+ if (ls->t.token != ')') { /* is `parlist' not empty? */
+ do {
+ switch (ls->t.token) {
+ case TK_NAME: { /* param -> NAME */
+ new_localvar(ls, str_checkname(ls));
+ nparams++;
+ break;
+ }
+ case TK_DOTS: { /* param -> `...' */
+ luaX_next(ls);
+ f->is_vararg = 1;
+ break;
+ }
+ default: luaX_syntaxerror(ls, " or " LUA_QL("...") " expected");
+ }
+ } while (!f->is_vararg && testnext(ls, ','));
+ }
+ adjustlocalvars(ls, nparams);
+ f->numparams = cast_byte(fs->nactvar);
+ luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */
+}
+
+
+static void body (LexState *ls, expdesc *e, int ismethod, int line) {
+ /* body -> `(' parlist `)' block END */
+ FuncState new_fs;
+ BlockCnt bl;
+ new_fs.f = addprototype(ls);
+ new_fs.f->linedefined = line;
+ open_func(ls, &new_fs, &bl);
+ checknext(ls, '(');
+ if (ismethod) {
+ new_localvarliteral(ls, "self"); /* create 'self' parameter */
+ adjustlocalvars(ls, 1);
+ }
+ parlist(ls);
+ checknext(ls, ')');
+ statlist(ls);
+ new_fs.f->lastlinedefined = ls->linenumber;
+ check_match(ls, TK_END, TK_FUNCTION, line);
+ codeclosure(ls, e);
+ close_func(ls);
+}
+
+
+static int explist (LexState *ls, expdesc *v) {
+ /* explist -> expr { `,' expr } */
+ int n = 1; /* at least one expression */
+ expr(ls, v);
+ while (testnext(ls, ',')) {
+ luaK_exp2nextreg(ls->fs, v);
+ expr(ls, v);
+ n++;
+ }
+ return n;
+}
+
+
+static void funcargs (LexState *ls, expdesc *f, int line) {
+ FuncState *fs = ls->fs;
+ expdesc args;
+ int base, nparams;
+ switch (ls->t.token) {
+ case '(': { /* funcargs -> `(' [ explist ] `)' */
+ luaX_next(ls);
+ if (ls->t.token == ')') /* arg list is empty? */
+ args.k = VVOID;
+ else {
+ explist(ls, &args);
+ luaK_setmultret(fs, &args);
+ }
+ check_match(ls, ')', '(', line);
+ break;
+ }
+ case '{': { /* funcargs -> constructor */
+ constructor(ls, &args);
+ break;
+ }
+ case TK_STRING: { /* funcargs -> STRING */
+ codestring(ls, &args, ls->t.seminfo.ts);
+ luaX_next(ls); /* must use `seminfo' before `next' */
+ break;
+ }
+ default: {
+ luaX_syntaxerror(ls, "function arguments expected");
+ }
+ }
+ lua_assert(f->k == VNONRELOC);
+ base = f->u.info; /* base register for call */
+ if (hasmultret(args.k))
+ nparams = LUA_MULTRET; /* open call */
+ else {
+ if (args.k != VVOID)
+ luaK_exp2nextreg(fs, &args); /* close last argument */
+ nparams = fs->freereg - (base+1);
+ }
+ init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
+ luaK_fixline(fs, line);
+ fs->freereg = base+1; /* call remove function and arguments and leaves
+ (unless changed) one result */
+}
+
+
+
+
+/*
+** {======================================================================
+** Expression parsing
+** =======================================================================
+*/
+
+
+static void primaryexp (LexState *ls, expdesc *v) {
+ /* primaryexp -> NAME | '(' expr ')' */
+ switch (ls->t.token) {
+ case '(': {
+ int line = ls->linenumber;
+ luaX_next(ls);
+ expr(ls, v);
+ check_match(ls, ')', '(', line);
+ luaK_dischargevars(ls->fs, v);
+ return;
+ }
+ case TK_NAME: {
+ singlevar(ls, v);
+ return;
+ }
+ default: {
+ luaX_syntaxerror(ls, "unexpected symbol");
+ }
+ }
+}
+
+
+static void suffixedexp (LexState *ls, expdesc *v) {
+ /* suffixedexp ->
+ primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */
+ FuncState *fs = ls->fs;
+ int line = ls->linenumber;
+ primaryexp(ls, v);
+ for (;;) {
+ switch (ls->t.token) {
+ case '.': { /* fieldsel */
+ fieldsel(ls, v);
+ break;
+ }
+ case '[': { /* `[' exp1 `]' */
+ expdesc key;
+ luaK_exp2anyregup(fs, v);
+ yindex(ls, &key);
+ luaK_indexed(fs, v, &key);
+ break;
+ }
+ case ':': { /* `:' NAME funcargs */
+ expdesc key;
+ luaX_next(ls);
+ checkname(ls, &key);
+ luaK_self(fs, v, &key);
+ funcargs(ls, v, line);
+ break;
+ }
+ case '(': case TK_STRING: case '{': { /* funcargs */
+ luaK_exp2nextreg(fs, v);
+ funcargs(ls, v, line);
+ break;
+ }
+ default: return;
+ }
+ }
+}
+
+
+static void simpleexp (LexState *ls, expdesc *v) {
+ /* simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | ... |
+ constructor | FUNCTION body | suffixedexp */
+ switch (ls->t.token) {
+ case TK_NUMBER: {
+ init_exp(v, VKNUM, 0);
+ v->u.nval = ls->t.seminfo.r;
+ break;
+ }
+ case TK_STRING: {
+ codestring(ls, v, ls->t.seminfo.ts);
+ break;
+ }
+ case TK_NIL: {
+ init_exp(v, VNIL, 0);
+ break;
+ }
+ case TK_TRUE: {
+ init_exp(v, VTRUE, 0);
+ break;
+ }
+ case TK_FALSE: {
+ init_exp(v, VFALSE, 0);
+ break;
+ }
+ case TK_DOTS: { /* vararg */
+ FuncState *fs = ls->fs;
+ check_condition(ls, fs->f->is_vararg,
+ "cannot use " LUA_QL("...") " outside a vararg function");
+ init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
+ break;
+ }
+ case '{': { /* constructor */
+ constructor(ls, v);
+ return;
+ }
+ case TK_FUNCTION: {
+ luaX_next(ls);
+ body(ls, v, 0, ls->linenumber);
+ return;
+ }
+ default: {
+ suffixedexp(ls, v);
+ return;
+ }
+ }
+ luaX_next(ls);
+}
+
+
+static UnOpr getunopr (int op) {
+ switch (op) {
+ case TK_NOT: return OPR_NOT;
+ case '-': return OPR_MINUS;
+ case '#': return OPR_LEN;
+ default: return OPR_NOUNOPR;
+ }
+}
+
+
+static BinOpr getbinopr (int op) {
+ switch (op) {
+ case '+': return OPR_ADD;
+ case '-': return OPR_SUB;
+ case '*': return OPR_MUL;
+ case '/': return OPR_DIV;
+ case '%': return OPR_MOD;
+ case '^': return OPR_POW;
+ case TK_CONCAT: return OPR_CONCAT;
+ case TK_NE: return OPR_NE;
+ case TK_EQ: return OPR_EQ;
+ case '<': return OPR_LT;
+ case TK_LE: return OPR_LE;
+ case '>': return OPR_GT;
+ case TK_GE: return OPR_GE;
+ case TK_AND: return OPR_AND;
+ case TK_OR: return OPR_OR;
+ default: return OPR_NOBINOPR;
+ }
+}
+
+
+static const struct {
+ lu_byte left; /* left priority for each binary operator */
+ lu_byte right; /* right priority */
+} priority[] = { /* ORDER OPR */
+ {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `*' `/' `%' */
+ {10, 9}, {5, 4}, /* ^, .. (right associative) */
+ {3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */
+ {3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */
+ {2, 2}, {1, 1} /* and, or */
+};
+
+#define UNARY_PRIORITY 8 /* priority for unary operators */
+
+
+/*
+** subexpr -> (simpleexp | unop subexpr) { binop subexpr }
+** where `binop' is any binary operator with a priority higher than `limit'
+*/
+static BinOpr subexpr (LexState *ls, expdesc *v, int limit) {
+ BinOpr op;
+ UnOpr uop;
+ enterlevel(ls);
+ uop = getunopr(ls->t.token);
+ if (uop != OPR_NOUNOPR) {
+ int line = ls->linenumber;
+ luaX_next(ls);
+ subexpr(ls, v, UNARY_PRIORITY);
+ luaK_prefix(ls->fs, uop, v, line);
+ }
+ else simpleexp(ls, v);
+ /* expand while operators have priorities higher than `limit' */
+ op = getbinopr(ls->t.token);
+ while (op != OPR_NOBINOPR && priority[op].left > limit) {
+ expdesc v2;
+ BinOpr nextop;
+ int line = ls->linenumber;
+ luaX_next(ls);
+ luaK_infix(ls->fs, op, v);
+ /* read sub-expression with higher priority */
+ nextop = subexpr(ls, &v2, priority[op].right);
+ luaK_posfix(ls->fs, op, v, &v2, line);
+ op = nextop;
+ }
+ leavelevel(ls);
+ return op; /* return first untreated operator */
+}
+
+
+static void expr (LexState *ls, expdesc *v) {
+ subexpr(ls, v, 0);
+}
+
+/* }==================================================================== */
+
+
+
+/*
+** {======================================================================
+** Rules for Statements
+** =======================================================================
+*/
+
+
+static void block (LexState *ls) {
+ /* block -> statlist */
+ FuncState *fs = ls->fs;
+ BlockCnt bl;
+ enterblock(fs, &bl, 0);
+ statlist(ls);
+ leaveblock(fs);
+}
+
+
+/*
+** structure to chain all variables in the left-hand side of an
+** assignment
+*/
+struct LHS_assign {
+ struct LHS_assign *prev;
+ expdesc v; /* variable (global, local, upvalue, or indexed) */
+};
+
+
+/*
+** check whether, in an assignment to an upvalue/local variable, the
+** upvalue/local variable is begin used in a previous assignment to a
+** table. If so, save original upvalue/local value in a safe place and
+** use this safe copy in the previous assignment.
+*/
+static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
+ FuncState *fs = ls->fs;
+ int extra = fs->freereg; /* eventual position to save local variable */
+ int conflict = 0;
+ for (; lh; lh = lh->prev) { /* check all previous assignments */
+ if (lh->v.k == VINDEXED) { /* assigning to a table? */
+ /* table is the upvalue/local being assigned now? */
+ if (lh->v.u.ind.vt == v->k && lh->v.u.ind.t == v->u.info) {
+ conflict = 1;
+ lh->v.u.ind.vt = VLOCAL;
+ lh->v.u.ind.t = extra; /* previous assignment will use safe copy */
+ }
+ /* index is the local being assigned? (index cannot be upvalue) */
+ if (v->k == VLOCAL && lh->v.u.ind.idx == v->u.info) {
+ conflict = 1;
+ lh->v.u.ind.idx = extra; /* previous assignment will use safe copy */
+ }
+ }
+ }
+ if (conflict) {
+ /* copy upvalue/local value to a temporary (in position 'extra') */
+ OpCode op = (v->k == VLOCAL) ? OP_MOVE : OP_GETUPVAL;
+ luaK_codeABC(fs, op, extra, v->u.info, 0);
+ luaK_reserveregs(fs, 1);
+ }
+}
+
+
+static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
+ expdesc e;
+ check_condition(ls, vkisvar(lh->v.k), "syntax error");
+ if (testnext(ls, ',')) { /* assignment -> ',' suffixedexp assignment */
+ struct LHS_assign nv;
+ nv.prev = lh;
+ suffixedexp(ls, &nv.v);
+ if (nv.v.k != VINDEXED)
+ check_conflict(ls, lh, &nv.v);
+ checklimit(ls->fs, nvars + ls->L->nCcalls, LUAI_MAXCCALLS,
+ "C levels");
+ assignment(ls, &nv, nvars+1);
+ }
+ else { /* assignment -> `=' explist */
+ int nexps;
+ checknext(ls, '=');
+ nexps = explist(ls, &e);
+ if (nexps != nvars) {
+ adjust_assign(ls, nvars, nexps, &e);
+ if (nexps > nvars)
+ ls->fs->freereg -= nexps - nvars; /* remove extra values */
+ }
+ else {
+ luaK_setoneret(ls->fs, &e); /* close last expression */
+ luaK_storevar(ls->fs, &lh->v, &e);
+ return; /* avoid default */
+ }
+ }
+ init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */
+ luaK_storevar(ls->fs, &lh->v, &e);
+}
+
+
+static int cond (LexState *ls) {
+ /* cond -> exp */
+ expdesc v;
+ expr(ls, &v); /* read condition */
+ if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */
+ luaK_goiftrue(ls->fs, &v);
+ return v.f;
+}
+
+
+static void gotostat (LexState *ls, int pc) {
+ int line = ls->linenumber;
+ TString *label;
+ int g;
+ if (testnext(ls, TK_GOTO))
+ label = str_checkname(ls);
+ else {
+ luaX_next(ls); /* skip break */
+ label = luaS_new(ls->L, "break");
+ }
+ g = newlabelentry(ls, &ls->dyd->gt, label, line, pc);
+ findlabel(ls, g); /* close it if label already defined */
+}
+
+
+/* check for repeated labels on the same block */
+static void checkrepeated (FuncState *fs, Labellist *ll, TString *label) {
+ int i;
+ for (i = fs->bl->firstlabel; i < ll->n; i++) {
+ if (luaS_eqstr(label, ll->arr[i].name)) {
+ const char *msg = luaO_pushfstring(fs->ls->L,
+ "label " LUA_QS " already defined on line %d",
+ getstr(label), ll->arr[i].line);
+ semerror(fs->ls, msg);
+ }
+ }
+}
+
+
+/* skip no-op statements */
+static void skipnoopstat (LexState *ls) {
+ while (ls->t.token == ';' || ls->t.token == TK_DBCOLON)
+ statement(ls);
+}
+
+
+static void labelstat (LexState *ls, TString *label, int line) {
+ /* label -> '::' NAME '::' */
+ FuncState *fs = ls->fs;
+ Labellist *ll = &ls->dyd->label;
+ int l; /* index of new label being created */
+ checkrepeated(fs, ll, label); /* check for repeated labels */
+ checknext(ls, TK_DBCOLON); /* skip double colon */
+ /* create new entry for this label */
+ l = newlabelentry(ls, ll, label, line, fs->pc);
+ skipnoopstat(ls); /* skip other no-op statements */
+ if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */
+ /* assume that locals are already out of scope */
+ ll->arr[l].nactvar = fs->bl->nactvar;
+ }
+ findgotos(ls, &ll->arr[l]);
+}
+
+
+static void whilestat (LexState *ls, int line) {
+ /* whilestat -> WHILE cond DO block END */
+ FuncState *fs = ls->fs;
+ int whileinit;
+ int condexit;
+ BlockCnt bl;
+ luaX_next(ls); /* skip WHILE */
+ whileinit = luaK_getlabel(fs);
+ condexit = cond(ls);
+ enterblock(fs, &bl, 1);
+ checknext(ls, TK_DO);
+ block(ls);
+ luaK_jumpto(fs, whileinit);
+ check_match(ls, TK_END, TK_WHILE, line);
+ leaveblock(fs);
+ luaK_patchtohere(fs, condexit); /* false conditions finish the loop */
+}
+
+
+static void repeatstat (LexState *ls, int line) {
+ /* repeatstat -> REPEAT block UNTIL cond */
+ int condexit;
+ FuncState *fs = ls->fs;
+ int repeat_init = luaK_getlabel(fs);
+ BlockCnt bl1, bl2;
+ enterblock(fs, &bl1, 1); /* loop block */
+ enterblock(fs, &bl2, 0); /* scope block */
+ luaX_next(ls); /* skip REPEAT */
+ statlist(ls);
+ check_match(ls, TK_UNTIL, TK_REPEAT, line);
+ condexit = cond(ls); /* read condition (inside scope block) */
+ if (bl2.upval) /* upvalues? */
+ luaK_patchclose(fs, condexit, bl2.nactvar);
+ leaveblock(fs); /* finish scope */
+ luaK_patchlist(fs, condexit, repeat_init); /* close the loop */
+ leaveblock(fs); /* finish loop */
+}
+
+
+static int exp1 (LexState *ls) {
+ expdesc e;
+ int reg;
+ expr(ls, &e);
+ luaK_exp2nextreg(ls->fs, &e);
+ lua_assert(e.k == VNONRELOC);
+ reg = e.u.info;
+ return reg;
+}
+
+
+static void forbody (LexState *ls, int base, int line, int nvars, int isnum) {
+ /* forbody -> DO block */
+ BlockCnt bl;
+ FuncState *fs = ls->fs;
+ int prep, endfor;
+ adjustlocalvars(ls, 3); /* control variables */
+ checknext(ls, TK_DO);
+ prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs);
+ enterblock(fs, &bl, 0); /* scope for declared variables */
+ adjustlocalvars(ls, nvars);
+ luaK_reserveregs(fs, nvars);
+ block(ls);
+ leaveblock(fs); /* end of scope for declared variables */
+ luaK_patchtohere(fs, prep);
+ if (isnum) /* numeric for? */
+ endfor = luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP);
+ else { /* generic for */
+ luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars);
+ luaK_fixline(fs, line);
+ endfor = luaK_codeAsBx(fs, OP_TFORLOOP, base + 2, NO_JUMP);
+ }
+ luaK_patchlist(fs, endfor, prep + 1);
+ luaK_fixline(fs, line);
+}
+
+
+static void fornum (LexState *ls, TString *varname, int line) {
+ /* fornum -> NAME = exp1,exp1[,exp1] forbody */
+ FuncState *fs = ls->fs;
+ int base = fs->freereg;
+ new_localvarliteral(ls, "(for index)");
+ new_localvarliteral(ls, "(for limit)");
+ new_localvarliteral(ls, "(for step)");
+ new_localvar(ls, varname);
+ checknext(ls, '=');
+ exp1(ls); /* initial value */
+ checknext(ls, ',');
+ exp1(ls); /* limit */
+ if (testnext(ls, ','))
+ exp1(ls); /* optional step */
+ else { /* default step = 1 */
+ luaK_codek(fs, fs->freereg, luaK_numberK(fs, 1));
+ luaK_reserveregs(fs, 1);
+ }
+ forbody(ls, base, line, 1, 1);
+}
+
+
+static void forlist (LexState *ls, TString *indexname) {
+ /* forlist -> NAME {,NAME} IN explist forbody */
+ FuncState *fs = ls->fs;
+ expdesc e;
+ int nvars = 4; /* gen, state, control, plus at least one declared var */
+ int line;
+ int base = fs->freereg;
+ /* create control variables */
+ new_localvarliteral(ls, "(for generator)");
+ new_localvarliteral(ls, "(for state)");
+ new_localvarliteral(ls, "(for control)");
+ /* create declared variables */
+ new_localvar(ls, indexname);
+ while (testnext(ls, ',')) {
+ new_localvar(ls, str_checkname(ls));
+ nvars++;
+ }
+ checknext(ls, TK_IN);
+ line = ls->linenumber;
+ adjust_assign(ls, 3, explist(ls, &e), &e);
+ luaK_checkstack(fs, 3); /* extra space to call generator */
+ forbody(ls, base, line, nvars - 3, 0);
+}
+
+
+static void forstat (LexState *ls, int line) {
+ /* forstat -> FOR (fornum | forlist) END */
+ FuncState *fs = ls->fs;
+ TString *varname;
+ BlockCnt bl;
+ enterblock(fs, &bl, 1); /* scope for loop and control variables */
+ luaX_next(ls); /* skip `for' */
+ varname = str_checkname(ls); /* first variable name */
+ switch (ls->t.token) {
+ case '=': fornum(ls, varname, line); break;
+ case ',': case TK_IN: forlist(ls, varname); break;
+ default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected");
+ }
+ check_match(ls, TK_END, TK_FOR, line);
+ leaveblock(fs); /* loop scope (`break' jumps to this point) */
+}
+
+
+static void test_then_block (LexState *ls, int *escapelist) {
+ /* test_then_block -> [IF | ELSEIF] cond THEN block */
+ BlockCnt bl;
+ FuncState *fs = ls->fs;
+ expdesc v;
+ int jf; /* instruction to skip 'then' code (if condition is false) */
+ luaX_next(ls); /* skip IF or ELSEIF */
+ expr(ls, &v); /* read condition */
+ checknext(ls, TK_THEN);
+ if (ls->t.token == TK_GOTO || ls->t.token == TK_BREAK) {
+ luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */
+ enterblock(fs, &bl, 0); /* must enter block before 'goto' */
+ gotostat(ls, v.t); /* handle goto/break */
+ skipnoopstat(ls); /* skip other no-op statements */
+ if (block_follow(ls, 0)) { /* 'goto' is the entire block? */
+ leaveblock(fs);
+ return; /* and that is it */
+ }
+ else /* must skip over 'then' part if condition is false */
+ jf = luaK_jump(fs);
+ }
+ else { /* regular case (not goto/break) */
+ luaK_goiftrue(ls->fs, &v); /* skip over block if condition is false */
+ enterblock(fs, &bl, 0);
+ jf = v.f;
+ }
+ statlist(ls); /* `then' part */
+ leaveblock(fs);
+ if (ls->t.token == TK_ELSE ||
+ ls->t.token == TK_ELSEIF) /* followed by 'else'/'elseif'? */
+ luaK_concat(fs, escapelist, luaK_jump(fs)); /* must jump over it */
+ luaK_patchtohere(fs, jf);
+}
+
+
+static void ifstat (LexState *ls, int line) {
+ /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
+ FuncState *fs = ls->fs;
+ int escapelist = NO_JUMP; /* exit list for finished parts */
+ test_then_block(ls, &escapelist); /* IF cond THEN block */
+ while (ls->t.token == TK_ELSEIF)
+ test_then_block(ls, &escapelist); /* ELSEIF cond THEN block */
+ if (testnext(ls, TK_ELSE))
+ block(ls); /* `else' part */
+ check_match(ls, TK_END, TK_IF, line);
+ luaK_patchtohere(fs, escapelist); /* patch escape list to 'if' end */
+}
+
+
+static void localfunc (LexState *ls) {
+ expdesc b;
+ FuncState *fs = ls->fs;
+ new_localvar(ls, str_checkname(ls)); /* new local variable */
+ adjustlocalvars(ls, 1); /* enter its scope */
+ body(ls, &b, 0, ls->linenumber); /* function created in next register */
+ /* debug information will only see the variable after this point! */
+ getlocvar(fs, b.u.info)->startpc = fs->pc;
+}
+
+
+static void localstat (LexState *ls) {
+ /* stat -> LOCAL NAME {`,' NAME} [`=' explist] */
+ int nvars = 0;
+ int nexps;
+ expdesc e;
+ do {
+ new_localvar(ls, str_checkname(ls));
+ nvars++;
+ } while (testnext(ls, ','));
+ if (testnext(ls, '='))
+ nexps = explist(ls, &e);
+ else {
+ e.k = VVOID;
+ nexps = 0;
+ }
+ adjust_assign(ls, nvars, nexps, &e);
+ adjustlocalvars(ls, nvars);
+}
+
+
+static int funcname (LexState *ls, expdesc *v) {
+ /* funcname -> NAME {fieldsel} [`:' NAME] */
+ int ismethod = 0;
+ singlevar(ls, v);
+ while (ls->t.token == '.')
+ fieldsel(ls, v);
+ if (ls->t.token == ':') {
+ ismethod = 1;
+ fieldsel(ls, v);
+ }
+ return ismethod;
+}
+
+
+static void funcstat (LexState *ls, int line) {
+ /* funcstat -> FUNCTION funcname body */
+ int ismethod;
+ expdesc v, b;
+ luaX_next(ls); /* skip FUNCTION */
+ ismethod = funcname(ls, &v);
+ body(ls, &b, ismethod, line);
+ luaK_storevar(ls->fs, &v, &b);
+ luaK_fixline(ls->fs, line); /* definition `happens' in the first line */
+}
+
+
+static void exprstat (LexState *ls) {
+ /* stat -> func | assignment */
+ FuncState *fs = ls->fs;
+ struct LHS_assign v;
+ suffixedexp(ls, &v.v);
+ if (ls->t.token == '=' || ls->t.token == ',') { /* stat -> assignment ? */
+ v.prev = NULL;
+ assignment(ls, &v, 1);
+ }
+ else { /* stat -> func */
+ check_condition(ls, v.v.k == VCALL, "syntax error");
+ SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */
+ }
+}
+
+
+static void retstat (LexState *ls) {
+ /* stat -> RETURN [explist] [';'] */
+ FuncState *fs = ls->fs;
+ expdesc e;
+ int first, nret; /* registers with returned values */
+ if (block_follow(ls, 1) || ls->t.token == ';')
+ first = nret = 0; /* return no values */
+ else {
+ nret = explist(ls, &e); /* optional return values */
+ if (hasmultret(e.k)) {
+ luaK_setmultret(fs, &e);
+ if (e.k == VCALL && nret == 1) { /* tail call? */
+ SET_OPCODE(getcode(fs,&e), OP_TAILCALL);
+ lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar);
+ }
+ first = fs->nactvar;
+ nret = LUA_MULTRET; /* return all values */
+ }
+ else {
+ if (nret == 1) /* only one single value? */
+ first = luaK_exp2anyreg(fs, &e);
+ else {
+ luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */
+ first = fs->nactvar; /* return all `active' values */
+ lua_assert(nret == fs->freereg - first);
+ }
+ }
+ }
+ luaK_ret(fs, first, nret);
+ testnext(ls, ';'); /* skip optional semicolon */
+}
+
+
+static void statement (LexState *ls) {
+ int line = ls->linenumber; /* may be needed for error messages */
+ enterlevel(ls);
+ switch (ls->t.token) {
+ case ';': { /* stat -> ';' (empty statement) */
+ luaX_next(ls); /* skip ';' */
+ break;
+ }
+ case TK_IF: { /* stat -> ifstat */
+ ifstat(ls, line);
+ break;
+ }
+ case TK_WHILE: { /* stat -> whilestat */
+ whilestat(ls, line);
+ break;
+ }
+ case TK_DO: { /* stat -> DO block END */
+ luaX_next(ls); /* skip DO */
+ block(ls);
+ check_match(ls, TK_END, TK_DO, line);
+ break;
+ }
+ case TK_FOR: { /* stat -> forstat */
+ forstat(ls, line);
+ break;
+ }
+ case TK_REPEAT: { /* stat -> repeatstat */
+ repeatstat(ls, line);
+ break;
+ }
+ case TK_FUNCTION: { /* stat -> funcstat */
+ funcstat(ls, line);
+ break;
+ }
+ case TK_LOCAL: { /* stat -> localstat */
+ luaX_next(ls); /* skip LOCAL */
+ if (testnext(ls, TK_FUNCTION)) /* local function? */
+ localfunc(ls);
+ else
+ localstat(ls);
+ break;
+ }
+ case TK_DBCOLON: { /* stat -> label */
+ luaX_next(ls); /* skip double colon */
+ labelstat(ls, str_checkname(ls), line);
+ break;
+ }
+ case TK_RETURN: { /* stat -> retstat */
+ luaX_next(ls); /* skip RETURN */
+ retstat(ls);
+ break;
+ }
+ case TK_BREAK: /* stat -> breakstat */
+ case TK_GOTO: { /* stat -> 'goto' NAME */
+ gotostat(ls, luaK_jump(ls->fs));
+ break;
+ }
+ default: { /* stat -> func | assignment */
+ exprstat(ls);
+ break;
+ }
+ }
+ lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg &&
+ ls->fs->freereg >= ls->fs->nactvar);
+ ls->fs->freereg = ls->fs->nactvar; /* free registers */
+ leavelevel(ls);
+}
+
+/* }====================================================================== */
+
+
+/*
+** compiles the main function, which is a regular vararg function with an
+** upvalue named LUA_ENV
+*/
+static void mainfunc (LexState *ls, FuncState *fs) {
+ BlockCnt bl;
+ expdesc v;
+ open_func(ls, fs, &bl);
+ fs->f->is_vararg = 1; /* main function is always vararg */
+ init_exp(&v, VLOCAL, 0); /* create and... */
+ newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */
+ luaX_next(ls); /* read first token */
+ statlist(ls); /* parse main body */
+ check(ls, TK_EOS);
+ close_func(ls);
+}
+
+
+Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
+ Dyndata *dyd, const char *name, int firstchar) {
+ LexState lexstate;
+ FuncState funcstate;
+ Closure *cl = luaF_newLclosure(L, 1); /* create main closure */
+ /* anchor closure (to avoid being collected) */
+ setclLvalue(L, L->top, cl);
+ incr_top(L);
+ funcstate.f = cl->l.p = luaF_newproto(L);
+ funcstate.f->source = luaS_new(L, name); /* create and anchor TString */
+ lexstate.buff = buff;
+ lexstate.dyd = dyd;
+ dyd->actvar.n = dyd->gt.n = dyd->label.n = 0;
+ luaX_setinput(L, &lexstate, z, funcstate.f->source, firstchar);
+ mainfunc(&lexstate, &funcstate);
+ lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs);
+ /* all scopes should be correctly finished */
+ lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0);
+ return cl; /* it's on the stack too */
+}
+
diff --git a/ext/lua/src/lstate.c b/ext/lua/src/lstate.c
new file mode 100644
index 0000000000..c7f2672be7
--- /dev/null
+++ b/ext/lua/src/lstate.c
@@ -0,0 +1,323 @@
+/*
+** $Id: lstate.c,v 2.99.1.2 2013/11/08 17:45:31 roberto Exp $
+** Global State
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+#include
+
+#define lstate_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lapi.h"
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lgc.h"
+#include "llex.h"
+#include "lmem.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+
+
+#if !defined(LUAI_GCPAUSE)
+#define LUAI_GCPAUSE 200 /* 200% */
+#endif
+
+#if !defined(LUAI_GCMAJOR)
+#define LUAI_GCMAJOR 200 /* 200% */
+#endif
+
+#if !defined(LUAI_GCMUL)
+#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */
+#endif
+
+
+#define MEMERRMSG "not enough memory"
+
+
+/*
+** a macro to help the creation of a unique random seed when a state is
+** created; the seed is used to randomize hashes.
+*/
+#if !defined(luai_makeseed)
+#include
+#define luai_makeseed() cast(unsigned int, time(NULL))
+#endif
+
+
+
+/*
+** thread state + extra space
+*/
+typedef struct LX {
+#if defined(LUAI_EXTRASPACE)
+ char buff[LUAI_EXTRASPACE];
+#endif
+ lua_State l;
+} LX;
+
+
+/*
+** Main thread combines a thread state and the global state
+*/
+typedef struct LG {
+ LX l;
+ global_State g;
+} LG;
+
+
+
+#define fromstate(L) (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l)))
+
+
+/*
+** Compute an initial seed as random as possible. In ANSI, rely on
+** Address Space Layout Randomization (if present) to increase
+** randomness..
+*/
+#define addbuff(b,p,e) \
+ { size_t t = cast(size_t, e); \
+ memcpy(buff + p, &t, sizeof(t)); p += sizeof(t); }
+
+static unsigned int makeseed (lua_State *L) {
+ char buff[4 * sizeof(size_t)];
+ unsigned int h = luai_makeseed();
+ int p = 0;
+ addbuff(buff, p, L); /* heap variable */
+ addbuff(buff, p, &h); /* local variable */
+ addbuff(buff, p, luaO_nilobject); /* global variable */
+ addbuff(buff, p, &lua_newstate); /* public function */
+ lua_assert(p == sizeof(buff));
+ return luaS_hash(buff, p, h);
+}
+
+
+/*
+** set GCdebt to a new value keeping the value (totalbytes + GCdebt)
+** invariant
+*/
+void luaE_setdebt (global_State *g, l_mem debt) {
+ g->totalbytes -= (debt - g->GCdebt);
+ g->GCdebt = debt;
+}
+
+
+CallInfo *luaE_extendCI (lua_State *L) {
+ CallInfo *ci = luaM_new(L, CallInfo);
+ lua_assert(L->ci->next == NULL);
+ L->ci->next = ci;
+ ci->previous = L->ci;
+ ci->next = NULL;
+ return ci;
+}
+
+
+void luaE_freeCI (lua_State *L) {
+ CallInfo *ci = L->ci;
+ CallInfo *next = ci->next;
+ ci->next = NULL;
+ while ((ci = next) != NULL) {
+ next = ci->next;
+ luaM_free(L, ci);
+ }
+}
+
+
+static void stack_init (lua_State *L1, lua_State *L) {
+ int i; CallInfo *ci;
+ /* initialize stack array */
+ L1->stack = luaM_newvector(L, BASIC_STACK_SIZE, TValue);
+ L1->stacksize = BASIC_STACK_SIZE;
+ for (i = 0; i < BASIC_STACK_SIZE; i++)
+ setnilvalue(L1->stack + i); /* erase new stack */
+ L1->top = L1->stack;
+ L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK;
+ /* initialize first ci */
+ ci = &L1->base_ci;
+ ci->next = ci->previous = NULL;
+ ci->callstatus = 0;
+ ci->func = L1->top;
+ setnilvalue(L1->top++); /* 'function' entry for this 'ci' */
+ ci->top = L1->top + LUA_MINSTACK;
+ L1->ci = ci;
+}
+
+
+static void freestack (lua_State *L) {
+ if (L->stack == NULL)
+ return; /* stack not completely built yet */
+ L->ci = &L->base_ci; /* free the entire 'ci' list */
+ luaE_freeCI(L);
+ luaM_freearray(L, L->stack, L->stacksize); /* free stack array */
+}
+
+
+/*
+** Create registry table and its predefined values
+*/
+static void init_registry (lua_State *L, global_State *g) {
+ TValue mt;
+ /* create registry */
+ Table *registry = luaH_new(L);
+ sethvalue(L, &g->l_registry, registry);
+ luaH_resize(L, registry, LUA_RIDX_LAST, 0);
+ /* registry[LUA_RIDX_MAINTHREAD] = L */
+ setthvalue(L, &mt, L);
+ luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &mt);
+ /* registry[LUA_RIDX_GLOBALS] = table of globals */
+ sethvalue(L, &mt, luaH_new(L));
+ luaH_setint(L, registry, LUA_RIDX_GLOBALS, &mt);
+}
+
+
+/*
+** open parts of the state that may cause memory-allocation errors
+*/
+static void f_luaopen (lua_State *L, void *ud) {
+ global_State *g = G(L);
+ UNUSED(ud);
+ stack_init(L, L); /* init stack */
+ init_registry(L, g);
+ luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */
+ luaT_init(L);
+ luaX_init(L);
+ /* pre-create memory-error message */
+ g->memerrmsg = luaS_newliteral(L, MEMERRMSG);
+ luaS_fix(g->memerrmsg); /* it should never be collected */
+ g->gcrunning = 1; /* allow gc */
+ g->version = lua_version(NULL);
+ luai_userstateopen(L);
+}
+
+
+/*
+** preinitialize a state with consistent values without allocating
+** any memory (to avoid errors)
+*/
+static void preinit_state (lua_State *L, global_State *g) {
+ G(L) = g;
+ L->stack = NULL;
+ L->ci = NULL;
+ L->stacksize = 0;
+ L->errorJmp = NULL;
+ L->nCcalls = 0;
+ L->hook = NULL;
+ L->hookmask = 0;
+ L->basehookcount = 0;
+ L->allowhook = 1;
+ resethookcount(L);
+ L->openupval = NULL;
+ L->nny = 1;
+ L->status = LUA_OK;
+ L->errfunc = 0;
+}
+
+
+static void close_state (lua_State *L) {
+ global_State *g = G(L);
+ luaF_close(L, L->stack); /* close all upvalues for this thread */
+ luaC_freeallobjects(L); /* collect all objects */
+ if (g->version) /* closing a fully built state? */
+ luai_userstateclose(L);
+ luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size);
+ luaZ_freebuffer(L, &g->buff);
+ freestack(L);
+ lua_assert(gettotalbytes(g) == sizeof(LG));
+ (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */
+}
+
+
+LUA_API lua_State *lua_newthread (lua_State *L) {
+ lua_State *L1;
+ lua_lock(L);
+ luaC_checkGC(L);
+ L1 = &luaC_newobj(L, LUA_TTHREAD, sizeof(LX), NULL, offsetof(LX, l))->th;
+ setthvalue(L, L->top, L1);
+ api_incr_top(L);
+ preinit_state(L1, G(L));
+ L1->hookmask = L->hookmask;
+ L1->basehookcount = L->basehookcount;
+ L1->hook = L->hook;
+ resethookcount(L1);
+ luai_userstatethread(L, L1);
+ stack_init(L1, L); /* init stack */
+ lua_unlock(L);
+ return L1;
+}
+
+
+void luaE_freethread (lua_State *L, lua_State *L1) {
+ LX *l = fromstate(L1);
+ luaF_close(L1, L1->stack); /* close all upvalues for this thread */
+ lua_assert(L1->openupval == NULL);
+ luai_userstatefree(L, L1);
+ freestack(L1);
+ luaM_free(L, l);
+}
+
+
+LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
+ int i;
+ lua_State *L;
+ global_State *g;
+ LG *l = cast(LG *, (*f)(ud, NULL, LUA_TTHREAD, sizeof(LG)));
+ if (l == NULL) return NULL;
+ L = &l->l.l;
+ g = &l->g;
+ L->next = NULL;
+ L->tt = LUA_TTHREAD;
+ g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT);
+ L->marked = luaC_white(g);
+ g->gckind = KGC_NORMAL;
+ preinit_state(L, g);
+ g->frealloc = f;
+ g->ud = ud;
+ g->mainthread = L;
+ g->seed = makeseed(L);
+ g->uvhead.u.l.prev = &g->uvhead;
+ g->uvhead.u.l.next = &g->uvhead;
+ g->gcrunning = 0; /* no GC while building state */
+ g->GCestimate = 0;
+ g->strt.size = 0;
+ g->strt.nuse = 0;
+ g->strt.hash = NULL;
+ setnilvalue(&g->l_registry);
+ luaZ_initbuffer(L, &g->buff);
+ g->panic = NULL;
+ g->version = NULL;
+ g->gcstate = GCSpause;
+ g->allgc = NULL;
+ g->finobj = NULL;
+ g->tobefnz = NULL;
+ g->sweepgc = g->sweepfin = NULL;
+ g->gray = g->grayagain = NULL;
+ g->weak = g->ephemeron = g->allweak = NULL;
+ g->totalbytes = sizeof(LG);
+ g->GCdebt = 0;
+ g->gcpause = LUAI_GCPAUSE;
+ g->gcmajorinc = LUAI_GCMAJOR;
+ g->gcstepmul = LUAI_GCMUL;
+ for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL;
+ if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) {
+ /* memory allocation error: free partial state */
+ close_state(L);
+ L = NULL;
+ }
+ return L;
+}
+
+
+LUA_API void lua_close (lua_State *L) {
+ L = G(L)->mainthread; /* only the main thread can be closed */
+ lua_lock(L);
+ close_state(L);
+}
+
+
diff --git a/ext/lua/src/lstring.c b/ext/lua/src/lstring.c
new file mode 100644
index 0000000000..af96c89c18
--- /dev/null
+++ b/ext/lua/src/lstring.c
@@ -0,0 +1,185 @@
+/*
+** $Id: lstring.c,v 2.26.1.1 2013/04/12 18:48:47 roberto Exp $
+** String table (keeps all strings handled by Lua)
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+
+#define lstring_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+#include "lstring.h"
+
+
+/*
+** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to
+** compute its hash
+*/
+#if !defined(LUAI_HASHLIMIT)
+#define LUAI_HASHLIMIT 5
+#endif
+
+
+/*
+** equality for long strings
+*/
+int luaS_eqlngstr (TString *a, TString *b) {
+ size_t len = a->tsv.len;
+ lua_assert(a->tsv.tt == LUA_TLNGSTR && b->tsv.tt == LUA_TLNGSTR);
+ return (a == b) || /* same instance or... */
+ ((len == b->tsv.len) && /* equal length and ... */
+ (memcmp(getstr(a), getstr(b), len) == 0)); /* equal contents */
+}
+
+
+/*
+** equality for strings
+*/
+int luaS_eqstr (TString *a, TString *b) {
+ return (a->tsv.tt == b->tsv.tt) &&
+ (a->tsv.tt == LUA_TSHRSTR ? eqshrstr(a, b) : luaS_eqlngstr(a, b));
+}
+
+
+unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) {
+ unsigned int h = seed ^ cast(unsigned int, l);
+ size_t l1;
+ size_t step = (l >> LUAI_HASHLIMIT) + 1;
+ for (l1 = l; l1 >= step; l1 -= step)
+ h = h ^ ((h<<5) + (h>>2) + cast_byte(str[l1 - 1]));
+ return h;
+}
+
+
+/*
+** resizes the string table
+*/
+void luaS_resize (lua_State *L, int newsize) {
+ int i;
+ stringtable *tb = &G(L)->strt;
+ /* cannot resize while GC is traversing strings */
+ luaC_runtilstate(L, ~bitmask(GCSsweepstring));
+ if (newsize > tb->size) {
+ luaM_reallocvector(L, tb->hash, tb->size, newsize, GCObject *);
+ for (i = tb->size; i < newsize; i++) tb->hash[i] = NULL;
+ }
+ /* rehash */
+ for (i=0; isize; i++) {
+ GCObject *p = tb->hash[i];
+ tb->hash[i] = NULL;
+ while (p) { /* for each node in the list */
+ GCObject *next = gch(p)->next; /* save next */
+ unsigned int h = lmod(gco2ts(p)->hash, newsize); /* new position */
+ gch(p)->next = tb->hash[h]; /* chain it */
+ tb->hash[h] = p;
+ resetoldbit(p); /* see MOVE OLD rule */
+ p = next;
+ }
+ }
+ if (newsize < tb->size) {
+ /* shrinking slice must be empty */
+ lua_assert(tb->hash[newsize] == NULL && tb->hash[tb->size - 1] == NULL);
+ luaM_reallocvector(L, tb->hash, tb->size, newsize, GCObject *);
+ }
+ tb->size = newsize;
+}
+
+
+/*
+** creates a new string object
+*/
+static TString *createstrobj (lua_State *L, const char *str, size_t l,
+ int tag, unsigned int h, GCObject **list) {
+ TString *ts;
+ size_t totalsize; /* total size of TString object */
+ totalsize = sizeof(TString) + ((l + 1) * sizeof(char));
+ ts = &luaC_newobj(L, tag, totalsize, list, 0)->ts;
+ ts->tsv.len = l;
+ ts->tsv.hash = h;
+ ts->tsv.extra = 0;
+ memcpy(ts+1, str, l*sizeof(char));
+ ((char *)(ts+1))[l] = '\0'; /* ending 0 */
+ return ts;
+}
+
+
+/*
+** creates a new short string, inserting it into string table
+*/
+static TString *newshrstr (lua_State *L, const char *str, size_t l,
+ unsigned int h) {
+ GCObject **list; /* (pointer to) list where it will be inserted */
+ stringtable *tb = &G(L)->strt;
+ TString *s;
+ if (tb->nuse >= cast(lu_int32, tb->size) && tb->size <= MAX_INT/2)
+ luaS_resize(L, tb->size*2); /* too crowded */
+ list = &tb->hash[lmod(h, tb->size)];
+ s = createstrobj(L, str, l, LUA_TSHRSTR, h, list);
+ tb->nuse++;
+ return s;
+}
+
+
+/*
+** checks whether short string exists and reuses it or creates a new one
+*/
+static TString *internshrstr (lua_State *L, const char *str, size_t l) {
+ GCObject *o;
+ global_State *g = G(L);
+ unsigned int h = luaS_hash(str, l, g->seed);
+ for (o = g->strt.hash[lmod(h, g->strt.size)];
+ o != NULL;
+ o = gch(o)->next) {
+ TString *ts = rawgco2ts(o);
+ if (h == ts->tsv.hash &&
+ l == ts->tsv.len &&
+ (memcmp(str, getstr(ts), l * sizeof(char)) == 0)) {
+ if (isdead(G(L), o)) /* string is dead (but was not collected yet)? */
+ changewhite(o); /* resurrect it */
+ return ts;
+ }
+ }
+ return newshrstr(L, str, l, h); /* not found; create a new string */
+}
+
+
+/*
+** new string (with explicit length)
+*/
+TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
+ if (l <= LUAI_MAXSHORTLEN) /* short string? */
+ return internshrstr(L, str, l);
+ else {
+ if (l + 1 > (MAX_SIZET - sizeof(TString))/sizeof(char))
+ luaM_toobig(L);
+ return createstrobj(L, str, l, LUA_TLNGSTR, G(L)->seed, NULL);
+ }
+}
+
+
+/*
+** new zero-terminated string
+*/
+TString *luaS_new (lua_State *L, const char *str) {
+ return luaS_newlstr(L, str, strlen(str));
+}
+
+
+Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {
+ Udata *u;
+ if (s > MAX_SIZET - sizeof(Udata))
+ luaM_toobig(L);
+ u = &luaC_newobj(L, LUA_TUSERDATA, sizeof(Udata) + s, NULL, 0)->u;
+ u->uv.len = s;
+ u->uv.metatable = NULL;
+ u->uv.env = e;
+ return u;
+}
+
diff --git a/ext/lua/src/lstrlib.c b/ext/lua/src/lstrlib.c
new file mode 100644
index 0000000000..9261fd220d
--- /dev/null
+++ b/ext/lua/src/lstrlib.c
@@ -0,0 +1,1019 @@
+/*
+** $Id: lstrlib.c,v 1.178.1.1 2013/04/12 18:48:47 roberto Exp $
+** Standard library for string operations and pattern-matching
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+#include
+#include
+#include
+#include
+
+#define lstrlib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+/*
+** maximum number of captures that a pattern can do during
+** pattern-matching. This limit is arbitrary.
+*/
+#if !defined(LUA_MAXCAPTURES)
+#define LUA_MAXCAPTURES 32
+#endif
+
+
+/* macro to `unsign' a character */
+#define uchar(c) ((unsigned char)(c))
+
+
+
+static int str_len (lua_State *L) {
+ size_t l;
+ luaL_checklstring(L, 1, &l);
+ lua_pushinteger(L, (lua_Integer)l);
+ return 1;
+}
+
+
+/* translate a relative string position: negative means back from end */
+static size_t posrelat (ptrdiff_t pos, size_t len) {
+ if (pos >= 0) return (size_t)pos;
+ else if (0u - (size_t)pos > len) return 0;
+ else return len - ((size_t)-pos) + 1;
+}
+
+
+static int str_sub (lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t start = posrelat(luaL_checkinteger(L, 2), l);
+ size_t end = posrelat(luaL_optinteger(L, 3, -1), l);
+ if (start < 1) start = 1;
+ if (end > l) end = l;
+ if (start <= end)
+ lua_pushlstring(L, s + start - 1, end - start + 1);
+ else lua_pushliteral(L, "");
+ return 1;
+}
+
+
+static int str_reverse (lua_State *L) {
+ size_t l, i;
+ luaL_Buffer b;
+ const char *s = luaL_checklstring(L, 1, &l);
+ char *p = luaL_buffinitsize(L, &b, l);
+ for (i = 0; i < l; i++)
+ p[i] = s[l - i - 1];
+ luaL_pushresultsize(&b, l);
+ return 1;
+}
+
+
+static int str_lower (lua_State *L) {
+ size_t l;
+ size_t i;
+ luaL_Buffer b;
+ const char *s = luaL_checklstring(L, 1, &l);
+ char *p = luaL_buffinitsize(L, &b, l);
+ for (i=0; i> 1)
+
+static int str_rep (lua_State *L) {
+ size_t l, lsep;
+ const char *s = luaL_checklstring(L, 1, &l);
+ int n = luaL_checkint(L, 2);
+ const char *sep = luaL_optlstring(L, 3, "", &lsep);
+ if (n <= 0) lua_pushliteral(L, "");
+ else if (l + lsep < l || l + lsep >= MAXSIZE / n) /* may overflow? */
+ return luaL_error(L, "resulting string too large");
+ else {
+ size_t totallen = n * l + (n - 1) * lsep;
+ luaL_Buffer b;
+ char *p = luaL_buffinitsize(L, &b, totallen);
+ while (n-- > 1) { /* first n-1 copies (followed by separator) */
+ memcpy(p, s, l * sizeof(char)); p += l;
+ if (lsep > 0) { /* avoid empty 'memcpy' (may be expensive) */
+ memcpy(p, sep, lsep * sizeof(char)); p += lsep;
+ }
+ }
+ memcpy(p, s, l * sizeof(char)); /* last copy (not followed by separator) */
+ luaL_pushresultsize(&b, totallen);
+ }
+ return 1;
+}
+
+
+static int str_byte (lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
+ size_t pose = posrelat(luaL_optinteger(L, 3, posi), l);
+ int n, i;
+ if (posi < 1) posi = 1;
+ if (pose > l) pose = l;
+ if (posi > pose) return 0; /* empty interval; return no values */
+ n = (int)(pose - posi + 1);
+ if (posi + n <= pose) /* (size_t -> int) overflow? */
+ return luaL_error(L, "string slice too long");
+ luaL_checkstack(L, n, "string slice too long");
+ for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED)
+ return luaL_error(ms->L, "invalid capture index %%%d", l + 1);
+ return l;
+}
+
+
+static int capture_to_close (MatchState *ms) {
+ int level = ms->level;
+ for (level--; level>=0; level--)
+ if (ms->capture[level].len == CAP_UNFINISHED) return level;
+ return luaL_error(ms->L, "invalid pattern capture");
+}
+
+
+static const char *classend (MatchState *ms, const char *p) {
+ switch (*p++) {
+ case L_ESC: {
+ if (p == ms->p_end)
+ luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")");
+ return p+1;
+ }
+ case '[': {
+ if (*p == '^') p++;
+ do { /* look for a `]' */
+ if (p == ms->p_end)
+ luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")");
+ if (*(p++) == L_ESC && p < ms->p_end)
+ p++; /* skip escapes (e.g. `%]') */
+ } while (*p != ']');
+ return p+1;
+ }
+ default: {
+ return p;
+ }
+ }
+}
+
+
+static int match_class (int c, int cl) {
+ int res;
+ switch (tolower(cl)) {
+ case 'a' : res = isalpha(c); break;
+ case 'c' : res = iscntrl(c); break;
+ case 'd' : res = isdigit(c); break;
+ case 'g' : res = isgraph(c); break;
+ case 'l' : res = islower(c); break;
+ case 'p' : res = ispunct(c); break;
+ case 's' : res = isspace(c); break;
+ case 'u' : res = isupper(c); break;
+ case 'w' : res = isalnum(c); break;
+ case 'x' : res = isxdigit(c); break;
+ case 'z' : res = (c == 0); break; /* deprecated option */
+ default: return (cl == c);
+ }
+ return (islower(cl) ? res : !res);
+}
+
+
+static int matchbracketclass (int c, const char *p, const char *ec) {
+ int sig = 1;
+ if (*(p+1) == '^') {
+ sig = 0;
+ p++; /* skip the `^' */
+ }
+ while (++p < ec) {
+ if (*p == L_ESC) {
+ p++;
+ if (match_class(c, uchar(*p)))
+ return sig;
+ }
+ else if ((*(p+1) == '-') && (p+2 < ec)) {
+ p+=2;
+ if (uchar(*(p-2)) <= c && c <= uchar(*p))
+ return sig;
+ }
+ else if (uchar(*p) == c) return sig;
+ }
+ return !sig;
+}
+
+
+static int singlematch (MatchState *ms, const char *s, const char *p,
+ const char *ep) {
+ if (s >= ms->src_end)
+ return 0;
+ else {
+ int c = uchar(*s);
+ switch (*p) {
+ case '.': return 1; /* matches any char */
+ case L_ESC: return match_class(c, uchar(*(p+1)));
+ case '[': return matchbracketclass(c, p, ep-1);
+ default: return (uchar(*p) == c);
+ }
+ }
+}
+
+
+static const char *matchbalance (MatchState *ms, const char *s,
+ const char *p) {
+ if (p >= ms->p_end - 1)
+ luaL_error(ms->L, "malformed pattern "
+ "(missing arguments to " LUA_QL("%%b") ")");
+ if (*s != *p) return NULL;
+ else {
+ int b = *p;
+ int e = *(p+1);
+ int cont = 1;
+ while (++s < ms->src_end) {
+ if (*s == e) {
+ if (--cont == 0) return s+1;
+ }
+ else if (*s == b) cont++;
+ }
+ }
+ return NULL; /* string ends out of balance */
+}
+
+
+static const char *max_expand (MatchState *ms, const char *s,
+ const char *p, const char *ep) {
+ ptrdiff_t i = 0; /* counts maximum expand for item */
+ while (singlematch(ms, s + i, p, ep))
+ i++;
+ /* keeps trying to match with the maximum repetitions */
+ while (i>=0) {
+ const char *res = match(ms, (s+i), ep+1);
+ if (res) return res;
+ i--; /* else didn't match; reduce 1 repetition to try again */
+ }
+ return NULL;
+}
+
+
+static const char *min_expand (MatchState *ms, const char *s,
+ const char *p, const char *ep) {
+ for (;;) {
+ const char *res = match(ms, s, ep+1);
+ if (res != NULL)
+ return res;
+ else if (singlematch(ms, s, p, ep))
+ s++; /* try with one more repetition */
+ else return NULL;
+ }
+}
+
+
+static const char *start_capture (MatchState *ms, const char *s,
+ const char *p, int what) {
+ const char *res;
+ int level = ms->level;
+ if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures");
+ ms->capture[level].init = s;
+ ms->capture[level].len = what;
+ ms->level = level+1;
+ if ((res=match(ms, s, p)) == NULL) /* match failed? */
+ ms->level--; /* undo capture */
+ return res;
+}
+
+
+static const char *end_capture (MatchState *ms, const char *s,
+ const char *p) {
+ int l = capture_to_close(ms);
+ const char *res;
+ ms->capture[l].len = s - ms->capture[l].init; /* close capture */
+ if ((res = match(ms, s, p)) == NULL) /* match failed? */
+ ms->capture[l].len = CAP_UNFINISHED; /* undo capture */
+ return res;
+}
+
+
+static const char *match_capture (MatchState *ms, const char *s, int l) {
+ size_t len;
+ l = check_capture(ms, l);
+ len = ms->capture[l].len;
+ if ((size_t)(ms->src_end-s) >= len &&
+ memcmp(ms->capture[l].init, s, len) == 0)
+ return s+len;
+ else return NULL;
+}
+
+
+static const char *match (MatchState *ms, const char *s, const char *p) {
+ if (ms->matchdepth-- == 0)
+ luaL_error(ms->L, "pattern too complex");
+ init: /* using goto's to optimize tail recursion */
+ if (p != ms->p_end) { /* end of pattern? */
+ switch (*p) {
+ case '(': { /* start capture */
+ if (*(p + 1) == ')') /* position capture? */
+ s = start_capture(ms, s, p + 2, CAP_POSITION);
+ else
+ s = start_capture(ms, s, p + 1, CAP_UNFINISHED);
+ break;
+ }
+ case ')': { /* end capture */
+ s = end_capture(ms, s, p + 1);
+ break;
+ }
+ case '$': {
+ if ((p + 1) != ms->p_end) /* is the `$' the last char in pattern? */
+ goto dflt; /* no; go to default */
+ s = (s == ms->src_end) ? s : NULL; /* check end of string */
+ break;
+ }
+ case L_ESC: { /* escaped sequences not in the format class[*+?-]? */
+ switch (*(p + 1)) {
+ case 'b': { /* balanced string? */
+ s = matchbalance(ms, s, p + 2);
+ if (s != NULL) {
+ p += 4; goto init; /* return match(ms, s, p + 4); */
+ } /* else fail (s == NULL) */
+ break;
+ }
+ case 'f': { /* frontier? */
+ const char *ep; char previous;
+ p += 2;
+ if (*p != '[')
+ luaL_error(ms->L, "missing " LUA_QL("[") " after "
+ LUA_QL("%%f") " in pattern");
+ ep = classend(ms, p); /* points to what is next */
+ previous = (s == ms->src_init) ? '\0' : *(s - 1);
+ if (!matchbracketclass(uchar(previous), p, ep - 1) &&
+ matchbracketclass(uchar(*s), p, ep - 1)) {
+ p = ep; goto init; /* return match(ms, s, ep); */
+ }
+ s = NULL; /* match failed */
+ break;
+ }
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9': { /* capture results (%0-%9)? */
+ s = match_capture(ms, s, uchar(*(p + 1)));
+ if (s != NULL) {
+ p += 2; goto init; /* return match(ms, s, p + 2) */
+ }
+ break;
+ }
+ default: goto dflt;
+ }
+ break;
+ }
+ default: dflt: { /* pattern class plus optional suffix */
+ const char *ep = classend(ms, p); /* points to optional suffix */
+ /* does not match at least once? */
+ if (!singlematch(ms, s, p, ep)) {
+ if (*ep == '*' || *ep == '?' || *ep == '-') { /* accept empty? */
+ p = ep + 1; goto init; /* return match(ms, s, ep + 1); */
+ }
+ else /* '+' or no suffix */
+ s = NULL; /* fail */
+ }
+ else { /* matched once */
+ switch (*ep) { /* handle optional suffix */
+ case '?': { /* optional */
+ const char *res;
+ if ((res = match(ms, s + 1, ep + 1)) != NULL)
+ s = res;
+ else {
+ p = ep + 1; goto init; /* else return match(ms, s, ep + 1); */
+ }
+ break;
+ }
+ case '+': /* 1 or more repetitions */
+ s++; /* 1 match already done */
+ /* go through */
+ case '*': /* 0 or more repetitions */
+ s = max_expand(ms, s, p, ep);
+ break;
+ case '-': /* 0 or more repetitions (minimum) */
+ s = min_expand(ms, s, p, ep);
+ break;
+ default: /* no suffix */
+ s++; p = ep; goto init; /* return match(ms, s + 1, ep); */
+ }
+ }
+ break;
+ }
+ }
+ }
+ ms->matchdepth++;
+ return s;
+}
+
+
+
+static const char *lmemfind (const char *s1, size_t l1,
+ const char *s2, size_t l2) {
+ if (l2 == 0) return s1; /* empty strings are everywhere */
+ else if (l2 > l1) return NULL; /* avoids a negative `l1' */
+ else {
+ const char *init; /* to search for a `*s2' inside `s1' */
+ l2--; /* 1st char will be checked by `memchr' */
+ l1 = l1-l2; /* `s2' cannot be found after that */
+ while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) {
+ init++; /* 1st char is already checked */
+ if (memcmp(init, s2+1, l2) == 0)
+ return init-1;
+ else { /* correct `l1' and `s1' to try again */
+ l1 -= init-s1;
+ s1 = init;
+ }
+ }
+ return NULL; /* not found */
+ }
+}
+
+
+static void push_onecapture (MatchState *ms, int i, const char *s,
+ const char *e) {
+ if (i >= ms->level) {
+ if (i == 0) /* ms->level == 0, too */
+ lua_pushlstring(ms->L, s, e - s); /* add whole match */
+ else
+ luaL_error(ms->L, "invalid capture index");
+ }
+ else {
+ ptrdiff_t l = ms->capture[i].len;
+ if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture");
+ if (l == CAP_POSITION)
+ lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1);
+ else
+ lua_pushlstring(ms->L, ms->capture[i].init, l);
+ }
+}
+
+
+static int push_captures (MatchState *ms, const char *s, const char *e) {
+ int i;
+ int nlevels = (ms->level == 0 && s) ? 1 : ms->level;
+ luaL_checkstack(ms->L, nlevels, "too many captures");
+ for (i = 0; i < nlevels; i++)
+ push_onecapture(ms, i, s, e);
+ return nlevels; /* number of strings pushed */
+}
+
+
+/* check whether pattern has no special characters */
+static int nospecials (const char *p, size_t l) {
+ size_t upto = 0;
+ do {
+ if (strpbrk(p + upto, SPECIALS))
+ return 0; /* pattern has a special character */
+ upto += strlen(p + upto) + 1; /* may have more after \0 */
+ } while (upto <= l);
+ return 1; /* no special chars found */
+}
+
+
+static int str_find_aux (lua_State *L, int find) {
+ size_t ls, lp;
+ const char *s = luaL_checklstring(L, 1, &ls);
+ const char *p = luaL_checklstring(L, 2, &lp);
+ size_t init = posrelat(luaL_optinteger(L, 3, 1), ls);
+ if (init < 1) init = 1;
+ else if (init > ls + 1) { /* start after string's end? */
+ lua_pushnil(L); /* cannot find anything */
+ return 1;
+ }
+ /* explicit request or no special characters? */
+ if (find && (lua_toboolean(L, 4) || nospecials(p, lp))) {
+ /* do a plain search */
+ const char *s2 = lmemfind(s + init - 1, ls - init + 1, p, lp);
+ if (s2) {
+ lua_pushinteger(L, s2 - s + 1);
+ lua_pushinteger(L, s2 - s + lp);
+ return 2;
+ }
+ }
+ else {
+ MatchState ms;
+ const char *s1 = s + init - 1;
+ int anchor = (*p == '^');
+ if (anchor) {
+ p++; lp--; /* skip anchor character */
+ }
+ ms.L = L;
+ ms.matchdepth = MAXCCALLS;
+ ms.src_init = s;
+ ms.src_end = s + ls;
+ ms.p_end = p + lp;
+ do {
+ const char *res;
+ ms.level = 0;
+ lua_assert(ms.matchdepth == MAXCCALLS);
+ if ((res=match(&ms, s1, p)) != NULL) {
+ if (find) {
+ lua_pushinteger(L, s1 - s + 1); /* start */
+ lua_pushinteger(L, res - s); /* end */
+ return push_captures(&ms, NULL, 0) + 2;
+ }
+ else
+ return push_captures(&ms, s1, res);
+ }
+ } while (s1++ < ms.src_end && !anchor);
+ }
+ lua_pushnil(L); /* not found */
+ return 1;
+}
+
+
+static int str_find (lua_State *L) {
+ return str_find_aux(L, 1);
+}
+
+
+static int str_match (lua_State *L) {
+ return str_find_aux(L, 0);
+}
+
+
+static int gmatch_aux (lua_State *L) {
+ MatchState ms;
+ size_t ls, lp;
+ const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls);
+ const char *p = lua_tolstring(L, lua_upvalueindex(2), &lp);
+ const char *src;
+ ms.L = L;
+ ms.matchdepth = MAXCCALLS;
+ ms.src_init = s;
+ ms.src_end = s+ls;
+ ms.p_end = p + lp;
+ for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3));
+ src <= ms.src_end;
+ src++) {
+ const char *e;
+ ms.level = 0;
+ lua_assert(ms.matchdepth == MAXCCALLS);
+ if ((e = match(&ms, src, p)) != NULL) {
+ lua_Integer newstart = e-s;
+ if (e == src) newstart++; /* empty match? go at least one position */
+ lua_pushinteger(L, newstart);
+ lua_replace(L, lua_upvalueindex(3));
+ return push_captures(&ms, src, e);
+ }
+ }
+ return 0; /* not found */
+}
+
+
+static int gmatch (lua_State *L) {
+ luaL_checkstring(L, 1);
+ luaL_checkstring(L, 2);
+ lua_settop(L, 2);
+ lua_pushinteger(L, 0);
+ lua_pushcclosure(L, gmatch_aux, 3);
+ return 1;
+}
+
+
+static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
+ const char *e) {
+ size_t l, i;
+ const char *news = lua_tolstring(ms->L, 3, &l);
+ for (i = 0; i < l; i++) {
+ if (news[i] != L_ESC)
+ luaL_addchar(b, news[i]);
+ else {
+ i++; /* skip ESC */
+ if (!isdigit(uchar(news[i]))) {
+ if (news[i] != L_ESC)
+ luaL_error(ms->L, "invalid use of " LUA_QL("%c")
+ " in replacement string", L_ESC);
+ luaL_addchar(b, news[i]);
+ }
+ else if (news[i] == '0')
+ luaL_addlstring(b, s, e - s);
+ else {
+ push_onecapture(ms, news[i] - '1', s, e);
+ luaL_addvalue(b); /* add capture to accumulated result */
+ }
+ }
+ }
+}
+
+
+static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
+ const char *e, int tr) {
+ lua_State *L = ms->L;
+ switch (tr) {
+ case LUA_TFUNCTION: {
+ int n;
+ lua_pushvalue(L, 3);
+ n = push_captures(ms, s, e);
+ lua_call(L, n, 1);
+ break;
+ }
+ case LUA_TTABLE: {
+ push_onecapture(ms, 0, s, e);
+ lua_gettable(L, 3);
+ break;
+ }
+ default: { /* LUA_TNUMBER or LUA_TSTRING */
+ add_s(ms, b, s, e);
+ return;
+ }
+ }
+ if (!lua_toboolean(L, -1)) { /* nil or false? */
+ lua_pop(L, 1);
+ lua_pushlstring(L, s, e - s); /* keep original text */
+ }
+ else if (!lua_isstring(L, -1))
+ luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
+ luaL_addvalue(b); /* add result to accumulator */
+}
+
+
+static int str_gsub (lua_State *L) {
+ size_t srcl, lp;
+ const char *src = luaL_checklstring(L, 1, &srcl);
+ const char *p = luaL_checklstring(L, 2, &lp);
+ int tr = lua_type(L, 3);
+ size_t max_s = luaL_optinteger(L, 4, srcl+1);
+ int anchor = (*p == '^');
+ size_t n = 0;
+ MatchState ms;
+ luaL_Buffer b;
+ luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
+ tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
+ "string/function/table expected");
+ luaL_buffinit(L, &b);
+ if (anchor) {
+ p++; lp--; /* skip anchor character */
+ }
+ ms.L = L;
+ ms.matchdepth = MAXCCALLS;
+ ms.src_init = src;
+ ms.src_end = src+srcl;
+ ms.p_end = p + lp;
+ while (n < max_s) {
+ const char *e;
+ ms.level = 0;
+ lua_assert(ms.matchdepth == MAXCCALLS);
+ e = match(&ms, src, p);
+ if (e) {
+ n++;
+ add_value(&ms, &b, src, e, tr);
+ }
+ if (e && e>src) /* non empty match? */
+ src = e; /* skip it */
+ else if (src < ms.src_end)
+ luaL_addchar(&b, *src++);
+ else break;
+ if (anchor) break;
+ }
+ luaL_addlstring(&b, src, ms.src_end-src);
+ luaL_pushresult(&b);
+ lua_pushinteger(L, n); /* number of substitutions */
+ return 2;
+}
+
+/* }====================================================== */
+
+
+
+/*
+** {======================================================
+** STRING FORMAT
+** =======================================================
+*/
+
+/*
+** LUA_INTFRMLEN is the length modifier for integer conversions in
+** 'string.format'; LUA_INTFRM_T is the integer type corresponding to
+** the previous length
+*/
+#if !defined(LUA_INTFRMLEN) /* { */
+#if defined(LUA_USE_LONGLONG)
+
+#define LUA_INTFRMLEN "ll"
+#define LUA_INTFRM_T long long
+
+#else
+
+#define LUA_INTFRMLEN "l"
+#define LUA_INTFRM_T long
+
+#endif
+#endif /* } */
+
+
+/*
+** LUA_FLTFRMLEN is the length modifier for float conversions in
+** 'string.format'; LUA_FLTFRM_T is the float type corresponding to
+** the previous length
+*/
+#if !defined(LUA_FLTFRMLEN)
+
+#define LUA_FLTFRMLEN ""
+#define LUA_FLTFRM_T double
+
+#endif
+
+
+/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */
+#define MAX_ITEM 512
+/* valid flags in a format specification */
+#define FLAGS "-+ #0"
+/*
+** maximum size of each format specification (such as '%-099.99d')
+** (+10 accounts for %99.99x plus margin of error)
+*/
+#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
+
+
+static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
+ size_t l;
+ const char *s = luaL_checklstring(L, arg, &l);
+ luaL_addchar(b, '"');
+ while (l--) {
+ if (*s == '"' || *s == '\\' || *s == '\n') {
+ luaL_addchar(b, '\\');
+ luaL_addchar(b, *s);
+ }
+ else if (*s == '\0' || iscntrl(uchar(*s))) {
+ char buff[10];
+ if (!isdigit(uchar(*(s+1))))
+ sprintf(buff, "\\%d", (int)uchar(*s));
+ else
+ sprintf(buff, "\\%03d", (int)uchar(*s));
+ luaL_addstring(b, buff);
+ }
+ else
+ luaL_addchar(b, *s);
+ s++;
+ }
+ luaL_addchar(b, '"');
+}
+
+static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
+ const char *p = strfrmt;
+ while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
+ if ((size_t)(p - strfrmt) >= sizeof(FLAGS)/sizeof(char))
+ luaL_error(L, "invalid format (repeated flags)");
+ if (isdigit(uchar(*p))) p++; /* skip width */
+ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
+ if (*p == '.') {
+ p++;
+ if (isdigit(uchar(*p))) p++; /* skip precision */
+ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
+ }
+ if (isdigit(uchar(*p)))
+ luaL_error(L, "invalid format (width or precision too long)");
+ *(form++) = '%';
+ memcpy(form, strfrmt, (p - strfrmt + 1) * sizeof(char));
+ form += p - strfrmt + 1;
+ *form = '\0';
+ return p;
+}
+
+
+/*
+** add length modifier into formats
+*/
+static void addlenmod (char *form, const char *lenmod) {
+ size_t l = strlen(form);
+ size_t lm = strlen(lenmod);
+ char spec = form[l - 1];
+ strcpy(form + l - 1, lenmod);
+ form[l + lm - 1] = spec;
+ form[l + lm] = '\0';
+}
+
+
+static int str_format (lua_State *L) {
+ int top = lua_gettop(L);
+ int arg = 1;
+ size_t sfl;
+ const char *strfrmt = luaL_checklstring(L, arg, &sfl);
+ const char *strfrmt_end = strfrmt+sfl;
+ luaL_Buffer b;
+ luaL_buffinit(L, &b);
+ while (strfrmt < strfrmt_end) {
+ if (*strfrmt != L_ESC)
+ luaL_addchar(&b, *strfrmt++);
+ else if (*++strfrmt == L_ESC)
+ luaL_addchar(&b, *strfrmt++); /* %% */
+ else { /* format item */
+ char form[MAX_FORMAT]; /* to store the format (`%...') */
+ char *buff = luaL_prepbuffsize(&b, MAX_ITEM); /* to put formatted item */
+ int nb = 0; /* number of bytes in added item */
+ if (++arg > top)
+ luaL_argerror(L, arg, "no value");
+ strfrmt = scanformat(L, strfrmt, form);
+ switch (*strfrmt++) {
+ case 'c': {
+ nb = sprintf(buff, form, luaL_checkint(L, arg));
+ break;
+ }
+ case 'd': case 'i': {
+ lua_Number n = luaL_checknumber(L, arg);
+ LUA_INTFRM_T ni = (LUA_INTFRM_T)n;
+ lua_Number diff = n - (lua_Number)ni;
+ luaL_argcheck(L, -1 < diff && diff < 1, arg,
+ "not a number in proper range");
+ addlenmod(form, LUA_INTFRMLEN);
+ nb = sprintf(buff, form, ni);
+ break;
+ }
+ case 'o': case 'u': case 'x': case 'X': {
+ lua_Number n = luaL_checknumber(L, arg);
+ unsigned LUA_INTFRM_T ni = (unsigned LUA_INTFRM_T)n;
+ lua_Number diff = n - (lua_Number)ni;
+ luaL_argcheck(L, -1 < diff && diff < 1, arg,
+ "not a non-negative number in proper range");
+ addlenmod(form, LUA_INTFRMLEN);
+ nb = sprintf(buff, form, ni);
+ break;
+ }
+ case 'e': case 'E': case 'f':
+#if defined(LUA_USE_AFORMAT)
+ case 'a': case 'A':
+#endif
+ case 'g': case 'G': {
+ addlenmod(form, LUA_FLTFRMLEN);
+ nb = sprintf(buff, form, (LUA_FLTFRM_T)luaL_checknumber(L, arg));
+ break;
+ }
+ case 'q': {
+ addquoted(L, &b, arg);
+ break;
+ }
+ case 's': {
+ size_t l;
+ const char *s = luaL_tolstring(L, arg, &l);
+ if (!strchr(form, '.') && l >= 100) {
+ /* no precision and string is too long to be formatted;
+ keep original string */
+ luaL_addvalue(&b);
+ break;
+ }
+ else {
+ nb = sprintf(buff, form, s);
+ lua_pop(L, 1); /* remove result from 'luaL_tolstring' */
+ break;
+ }
+ }
+ default: { /* also treat cases `pnLlh' */
+ return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
+ LUA_QL("format"), *(strfrmt - 1));
+ }
+ }
+ luaL_addsize(&b, nb);
+ }
+ }
+ luaL_pushresult(&b);
+ return 1;
+}
+
+/* }====================================================== */
+
+
+static const luaL_Reg strlib[] = {
+ {"byte", str_byte},
+ {"char", str_char},
+ {"dump", str_dump},
+ {"find", str_find},
+ {"format", str_format},
+ {"gmatch", gmatch},
+ {"gsub", str_gsub},
+ {"len", str_len},
+ {"lower", str_lower},
+ {"match", str_match},
+ {"rep", str_rep},
+ {"reverse", str_reverse},
+ {"sub", str_sub},
+ {"upper", str_upper},
+ {NULL, NULL}
+};
+
+
+static void createmetatable (lua_State *L) {
+ lua_createtable(L, 0, 1); /* table to be metatable for strings */
+ lua_pushliteral(L, ""); /* dummy string */
+ lua_pushvalue(L, -2); /* copy table */
+ lua_setmetatable(L, -2); /* set table as metatable for strings */
+ lua_pop(L, 1); /* pop dummy string */
+ lua_pushvalue(L, -2); /* get string library */
+ lua_setfield(L, -2, "__index"); /* metatable.__index = string */
+ lua_pop(L, 1); /* pop metatable */
+}
+
+
+/*
+** Open string library
+*/
+LUAMOD_API int luaopen_string (lua_State *L) {
+ luaL_newlib(L, strlib);
+ createmetatable(L);
+ return 1;
+}
+
diff --git a/ext/lua/src/ltable.c b/ext/lua/src/ltable.c
new file mode 100644
index 0000000000..5d76f97ec3
--- /dev/null
+++ b/ext/lua/src/ltable.c
@@ -0,0 +1,588 @@
+/*
+** $Id: ltable.c,v 2.72.1.1 2013/04/12 18:48:47 roberto Exp $
+** Lua tables (hash)
+** See Copyright Notice in lua.h
+*/
+
+
+/*
+** Implementation of tables (aka arrays, objects, or hash tables).
+** Tables keep its elements in two parts: an array part and a hash part.
+** Non-negative integer keys are all candidates to be kept in the array
+** part. The actual size of the array is the largest `n' such that at
+** least half the slots between 0 and n are in use.
+** Hash uses a mix of chained scatter table with Brent's variation.
+** A main invariant of these tables is that, if an element is not
+** in its main position (i.e. the `original' position that its hash gives
+** to it), then the colliding element is in its own main position.
+** Hence even when the load factor reaches 100%, performance remains good.
+*/
+
+#include
+
+#define ltable_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldebug.h"
+#include "ldo.h"
+#include "lgc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "lvm.h"
+
+
+/*
+** max size of array part is 2^MAXBITS
+*/
+#if LUAI_BITSINT >= 32
+#define MAXBITS 30
+#else
+#define MAXBITS (LUAI_BITSINT-2)
+#endif
+
+#define MAXASIZE (1 << MAXBITS)
+
+
+#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t))))
+
+#define hashstr(t,str) hashpow2(t, (str)->tsv.hash)
+#define hashboolean(t,p) hashpow2(t, p)
+
+
+/*
+** for some types, it is better to avoid modulus by power of 2, as
+** they tend to have many 2 factors.
+*/
+#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1))))
+
+
+#define hashpointer(t,p) hashmod(t, IntPoint(p))
+
+
+#define dummynode (&dummynode_)
+
+#define isdummy(n) ((n) == dummynode)
+
+static const Node dummynode_ = {
+ {NILCONSTANT}, /* value */
+ {{NILCONSTANT, NULL}} /* key */
+};
+
+
+/*
+** hash for lua_Numbers
+*/
+static Node *hashnum (const Table *t, lua_Number n) {
+ int i;
+ luai_hashnum(i, n);
+ if (i < 0) {
+ if (cast(unsigned int, i) == 0u - i) /* use unsigned to avoid overflows */
+ i = 0; /* handle INT_MIN */
+ i = -i; /* must be a positive value */
+ }
+ return hashmod(t, i);
+}
+
+
+
+/*
+** returns the `main' position of an element in a table (that is, the index
+** of its hash value)
+*/
+static Node *mainposition (const Table *t, const TValue *key) {
+ switch (ttype(key)) {
+ case LUA_TNUMBER:
+ return hashnum(t, nvalue(key));
+ case LUA_TLNGSTR: {
+ TString *s = rawtsvalue(key);
+ if (s->tsv.extra == 0) { /* no hash? */
+ s->tsv.hash = luaS_hash(getstr(s), s->tsv.len, s->tsv.hash);
+ s->tsv.extra = 1; /* now it has its hash */
+ }
+ return hashstr(t, rawtsvalue(key));
+ }
+ case LUA_TSHRSTR:
+ return hashstr(t, rawtsvalue(key));
+ case LUA_TBOOLEAN:
+ return hashboolean(t, bvalue(key));
+ case LUA_TLIGHTUSERDATA:
+ return hashpointer(t, pvalue(key));
+ case LUA_TLCF:
+ return hashpointer(t, fvalue(key));
+ default:
+ return hashpointer(t, gcvalue(key));
+ }
+}
+
+
+/*
+** returns the index for `key' if `key' is an appropriate key to live in
+** the array part of the table, -1 otherwise.
+*/
+static int arrayindex (const TValue *key) {
+ if (ttisnumber(key)) {
+ lua_Number n = nvalue(key);
+ int k;
+ lua_number2int(k, n);
+ if (luai_numeq(cast_num(k), n))
+ return k;
+ }
+ return -1; /* `key' did not match some condition */
+}
+
+
+/*
+** returns the index of a `key' for table traversals. First goes all
+** elements in the array part, then elements in the hash part. The
+** beginning of a traversal is signaled by -1.
+*/
+static int findindex (lua_State *L, Table *t, StkId key) {
+ int i;
+ if (ttisnil(key)) return -1; /* first iteration */
+ i = arrayindex(key);
+ if (0 < i && i <= t->sizearray) /* is `key' inside array part? */
+ return i-1; /* yes; that's the index (corrected to C) */
+ else {
+ Node *n = mainposition(t, key);
+ for (;;) { /* check whether `key' is somewhere in the chain */
+ /* key may be dead already, but it is ok to use it in `next' */
+ if (luaV_rawequalobj(gkey(n), key) ||
+ (ttisdeadkey(gkey(n)) && iscollectable(key) &&
+ deadvalue(gkey(n)) == gcvalue(key))) {
+ i = cast_int(n - gnode(t, 0)); /* key index in hash table */
+ /* hash elements are numbered after array ones */
+ return i + t->sizearray;
+ }
+ else n = gnext(n);
+ if (n == NULL)
+ luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */
+ }
+ }
+}
+
+
+int luaH_next (lua_State *L, Table *t, StkId key) {
+ int i = findindex(L, t, key); /* find original element */
+ for (i++; i < t->sizearray; i++) { /* try first array part */
+ if (!ttisnil(&t->array[i])) { /* a non-nil value? */
+ setnvalue(key, cast_num(i+1));
+ setobj2s(L, key+1, &t->array[i]);
+ return 1;
+ }
+ }
+ for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */
+ if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */
+ setobj2s(L, key, gkey(gnode(t, i)));
+ setobj2s(L, key+1, gval(gnode(t, i)));
+ return 1;
+ }
+ }
+ return 0; /* no more elements */
+}
+
+
+/*
+** {=============================================================
+** Rehash
+** ==============================================================
+*/
+
+
+static int computesizes (int nums[], int *narray) {
+ int i;
+ int twotoi; /* 2^i */
+ int a = 0; /* number of elements smaller than 2^i */
+ int na = 0; /* number of elements to go to array part */
+ int n = 0; /* optimal size for array part */
+ for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) {
+ if (nums[i] > 0) {
+ a += nums[i];
+ if (a > twotoi/2) { /* more than half elements present? */
+ n = twotoi; /* optimal size (till now) */
+ na = a; /* all elements smaller than n will go to array part */
+ }
+ }
+ if (a == *narray) break; /* all elements already counted */
+ }
+ *narray = n;
+ lua_assert(*narray/2 <= na && na <= *narray);
+ return na;
+}
+
+
+static int countint (const TValue *key, int *nums) {
+ int k = arrayindex(key);
+ if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
+ nums[luaO_ceillog2(k)]++; /* count as such */
+ return 1;
+ }
+ else
+ return 0;
+}
+
+
+static int numusearray (const Table *t, int *nums) {
+ int lg;
+ int ttlg; /* 2^lg */
+ int ause = 0; /* summation of `nums' */
+ int i = 1; /* count to traverse all array keys */
+ for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */
+ int lc = 0; /* counter */
+ int lim = ttlg;
+ if (lim > t->sizearray) {
+ lim = t->sizearray; /* adjust upper limit */
+ if (i > lim)
+ break; /* no more elements to count */
+ }
+ /* count elements in range (2^(lg-1), 2^lg] */
+ for (; i <= lim; i++) {
+ if (!ttisnil(&t->array[i-1]))
+ lc++;
+ }
+ nums[lg] += lc;
+ ause += lc;
+ }
+ return ause;
+}
+
+
+static int numusehash (const Table *t, int *nums, int *pnasize) {
+ int totaluse = 0; /* total number of elements */
+ int ause = 0; /* summation of `nums' */
+ int i = sizenode(t);
+ while (i--) {
+ Node *n = &t->node[i];
+ if (!ttisnil(gval(n))) {
+ ause += countint(gkey(n), nums);
+ totaluse++;
+ }
+ }
+ *pnasize += ause;
+ return totaluse;
+}
+
+
+static void setarrayvector (lua_State *L, Table *t, int size) {
+ int i;
+ luaM_reallocvector(L, t->array, t->sizearray, size, TValue);
+ for (i=t->sizearray; iarray[i]);
+ t->sizearray = size;
+}
+
+
+static void setnodevector (lua_State *L, Table *t, int size) {
+ int lsize;
+ if (size == 0) { /* no elements to hash part? */
+ t->node = cast(Node *, dummynode); /* use common `dummynode' */
+ lsize = 0;
+ }
+ else {
+ int i;
+ lsize = luaO_ceillog2(size);
+ if (lsize > MAXBITS)
+ luaG_runerror(L, "table overflow");
+ size = twoto(lsize);
+ t->node = luaM_newvector(L, size, Node);
+ for (i=0; ilsizenode = cast_byte(lsize);
+ t->lastfree = gnode(t, size); /* all positions are free */
+}
+
+
+void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) {
+ int i;
+ int oldasize = t->sizearray;
+ int oldhsize = t->lsizenode;
+ Node *nold = t->node; /* save old hash ... */
+ if (nasize > oldasize) /* array part must grow? */
+ setarrayvector(L, t, nasize);
+ /* create new hash part with appropriate size */
+ setnodevector(L, t, nhsize);
+ if (nasize < oldasize) { /* array part must shrink? */
+ t->sizearray = nasize;
+ /* re-insert elements from vanishing slice */
+ for (i=nasize; iarray[i]))
+ luaH_setint(L, t, i + 1, &t->array[i]);
+ }
+ /* shrink array */
+ luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
+ }
+ /* re-insert elements from hash part */
+ for (i = twoto(oldhsize) - 1; i >= 0; i--) {
+ Node *old = nold+i;
+ if (!ttisnil(gval(old))) {
+ /* doesn't need barrier/invalidate cache, as entry was
+ already present in the table */
+ setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old));
+ }
+ }
+ if (!isdummy(nold))
+ luaM_freearray(L, nold, cast(size_t, twoto(oldhsize))); /* free old array */
+}
+
+
+void luaH_resizearray (lua_State *L, Table *t, int nasize) {
+ int nsize = isdummy(t->node) ? 0 : sizenode(t);
+ luaH_resize(L, t, nasize, nsize);
+}
+
+
+static void rehash (lua_State *L, Table *t, const TValue *ek) {
+ int nasize, na;
+ int nums[MAXBITS+1]; /* nums[i] = number of keys with 2^(i-1) < k <= 2^i */
+ int i;
+ int totaluse;
+ for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */
+ nasize = numusearray(t, nums); /* count keys in array part */
+ totaluse = nasize; /* all those keys are integer keys */
+ totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */
+ /* count extra key */
+ nasize += countint(ek, nums);
+ totaluse++;
+ /* compute new size for array part */
+ na = computesizes(nums, &nasize);
+ /* resize the table to new computed sizes */
+ luaH_resize(L, t, nasize, totaluse - na);
+}
+
+
+
+/*
+** }=============================================================
+*/
+
+
+Table *luaH_new (lua_State *L) {
+ Table *t = &luaC_newobj(L, LUA_TTABLE, sizeof(Table), NULL, 0)->h;
+ t->metatable = NULL;
+ t->flags = cast_byte(~0);
+ t->array = NULL;
+ t->sizearray = 0;
+ setnodevector(L, t, 0);
+ return t;
+}
+
+
+void luaH_free (lua_State *L, Table *t) {
+ if (!isdummy(t->node))
+ luaM_freearray(L, t->node, cast(size_t, sizenode(t)));
+ luaM_freearray(L, t->array, t->sizearray);
+ luaM_free(L, t);
+}
+
+
+static Node *getfreepos (Table *t) {
+ while (t->lastfree > t->node) {
+ t->lastfree--;
+ if (ttisnil(gkey(t->lastfree)))
+ return t->lastfree;
+ }
+ return NULL; /* could not find a free place */
+}
+
+
+
+/*
+** inserts a new key into a hash table; first, check whether key's main
+** position is free. If not, check whether colliding node is in its main
+** position or not: if it is not, move colliding node to an empty place and
+** put new key in its main position; otherwise (colliding node is in its main
+** position), new key goes to an empty position.
+*/
+TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
+ Node *mp;
+ if (ttisnil(key)) luaG_runerror(L, "table index is nil");
+ else if (ttisnumber(key) && luai_numisnan(L, nvalue(key)))
+ luaG_runerror(L, "table index is NaN");
+ mp = mainposition(t, key);
+ if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */
+ Node *othern;
+ Node *n = getfreepos(t); /* get a free place */
+ if (n == NULL) { /* cannot find a free place? */
+ rehash(L, t, key); /* grow table */
+ /* whatever called 'newkey' take care of TM cache and GC barrier */
+ return luaH_set(L, t, key); /* insert key into grown table */
+ }
+ lua_assert(!isdummy(n));
+ othern = mainposition(t, gkey(mp));
+ if (othern != mp) { /* is colliding node out of its main position? */
+ /* yes; move colliding node into free position */
+ while (gnext(othern) != mp) othern = gnext(othern); /* find previous */
+ gnext(othern) = n; /* redo the chain with `n' in place of `mp' */
+ *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
+ gnext(mp) = NULL; /* now `mp' is free */
+ setnilvalue(gval(mp));
+ }
+ else { /* colliding node is in its own main position */
+ /* new node will go into free position */
+ gnext(n) = gnext(mp); /* chain new position */
+ gnext(mp) = n;
+ mp = n;
+ }
+ }
+ setobj2t(L, gkey(mp), key);
+ luaC_barrierback(L, obj2gco(t), key);
+ lua_assert(ttisnil(gval(mp)));
+ return gval(mp);
+}
+
+
+/*
+** search function for integers
+*/
+const TValue *luaH_getint (Table *t, int key) {
+ /* (1 <= key && key <= t->sizearray) */
+ if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
+ return &t->array[key-1];
+ else {
+ lua_Number nk = cast_num(key);
+ Node *n = hashnum(t, nk);
+ do { /* check whether `key' is somewhere in the chain */
+ if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk))
+ return gval(n); /* that's it */
+ else n = gnext(n);
+ } while (n);
+ return luaO_nilobject;
+ }
+}
+
+
+/*
+** search function for short strings
+*/
+const TValue *luaH_getstr (Table *t, TString *key) {
+ Node *n = hashstr(t, key);
+ lua_assert(key->tsv.tt == LUA_TSHRSTR);
+ do { /* check whether `key' is somewhere in the chain */
+ if (ttisshrstring(gkey(n)) && eqshrstr(rawtsvalue(gkey(n)), key))
+ return gval(n); /* that's it */
+ else n = gnext(n);
+ } while (n);
+ return luaO_nilobject;
+}
+
+
+/*
+** main search function
+*/
+const TValue *luaH_get (Table *t, const TValue *key) {
+ switch (ttype(key)) {
+ case LUA_TSHRSTR: return luaH_getstr(t, rawtsvalue(key));
+ case LUA_TNIL: return luaO_nilobject;
+ case LUA_TNUMBER: {
+ int k;
+ lua_Number n = nvalue(key);
+ lua_number2int(k, n);
+ if (luai_numeq(cast_num(k), n)) /* index is int? */
+ return luaH_getint(t, k); /* use specialized version */
+ /* else go through */
+ }
+ default: {
+ Node *n = mainposition(t, key);
+ do { /* check whether `key' is somewhere in the chain */
+ if (luaV_rawequalobj(gkey(n), key))
+ return gval(n); /* that's it */
+ else n = gnext(n);
+ } while (n);
+ return luaO_nilobject;
+ }
+ }
+}
+
+
+/*
+** beware: when using this function you probably need to check a GC
+** barrier and invalidate the TM cache.
+*/
+TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
+ const TValue *p = luaH_get(t, key);
+ if (p != luaO_nilobject)
+ return cast(TValue *, p);
+ else return luaH_newkey(L, t, key);
+}
+
+
+void luaH_setint (lua_State *L, Table *t, int key, TValue *value) {
+ const TValue *p = luaH_getint(t, key);
+ TValue *cell;
+ if (p != luaO_nilobject)
+ cell = cast(TValue *, p);
+ else {
+ TValue k;
+ setnvalue(&k, cast_num(key));
+ cell = luaH_newkey(L, t, &k);
+ }
+ setobj2t(L, cell, value);
+}
+
+
+static int unbound_search (Table *t, unsigned int j) {
+ unsigned int i = j; /* i is zero or a present index */
+ j++;
+ /* find `i' and `j' such that i is present and j is not */
+ while (!ttisnil(luaH_getint(t, j))) {
+ i = j;
+ j *= 2;
+ if (j > cast(unsigned int, MAX_INT)) { /* overflow? */
+ /* table was built with bad purposes: resort to linear search */
+ i = 1;
+ while (!ttisnil(luaH_getint(t, i))) i++;
+ return i - 1;
+ }
+ }
+ /* now do a binary search between them */
+ while (j - i > 1) {
+ unsigned int m = (i+j)/2;
+ if (ttisnil(luaH_getint(t, m))) j = m;
+ else i = m;
+ }
+ return i;
+}
+
+
+/*
+** Try to find a boundary in table `t'. A `boundary' is an integer index
+** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
+*/
+int luaH_getn (Table *t) {
+ unsigned int j = t->sizearray;
+ if (j > 0 && ttisnil(&t->array[j - 1])) {
+ /* there is a boundary in the array part: (binary) search for it */
+ unsigned int i = 0;
+ while (j - i > 1) {
+ unsigned int m = (i+j)/2;
+ if (ttisnil(&t->array[m - 1])) j = m;
+ else i = m;
+ }
+ return i;
+ }
+ /* else must find a boundary in hash part */
+ else if (isdummy(t->node)) /* hash part is empty? */
+ return j; /* that is easy... */
+ else return unbound_search(t, j);
+}
+
+
+
+#if defined(LUA_DEBUG)
+
+Node *luaH_mainposition (const Table *t, const TValue *key) {
+ return mainposition(t, key);
+}
+
+int luaH_isdummy (Node *n) { return isdummy(n); }
+
+#endif
diff --git a/ext/lua/src/ltablib.c b/ext/lua/src/ltablib.c
new file mode 100644
index 0000000000..6001224e39
--- /dev/null
+++ b/ext/lua/src/ltablib.c
@@ -0,0 +1,283 @@
+/*
+** $Id: ltablib.c,v 1.65.1.1 2013/04/12 18:48:47 roberto Exp $
+** Library for Table Manipulation
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+
+#define ltablib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_len(L, n))
+
+
+
+#if defined(LUA_COMPAT_MAXN)
+static int maxn (lua_State *L) {
+ lua_Number max = 0;
+ luaL_checktype(L, 1, LUA_TTABLE);
+ lua_pushnil(L); /* first key */
+ while (lua_next(L, 1)) {
+ lua_pop(L, 1); /* remove value */
+ if (lua_type(L, -1) == LUA_TNUMBER) {
+ lua_Number v = lua_tonumber(L, -1);
+ if (v > max) max = v;
+ }
+ }
+ lua_pushnumber(L, max);
+ return 1;
+}
+#endif
+
+
+static int tinsert (lua_State *L) {
+ int e = aux_getn(L, 1) + 1; /* first empty element */
+ int pos; /* where to insert new element */
+ switch (lua_gettop(L)) {
+ case 2: { /* called with only 2 arguments */
+ pos = e; /* insert new element at the end */
+ break;
+ }
+ case 3: {
+ int i;
+ pos = luaL_checkint(L, 2); /* 2nd argument is the position */
+ luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds");
+ for (i = e; i > pos; i--) { /* move up elements */
+ lua_rawgeti(L, 1, i-1);
+ lua_rawseti(L, 1, i); /* t[i] = t[i-1] */
+ }
+ break;
+ }
+ default: {
+ return luaL_error(L, "wrong number of arguments to " LUA_QL("insert"));
+ }
+ }
+ lua_rawseti(L, 1, pos); /* t[pos] = v */
+ return 0;
+}
+
+
+static int tremove (lua_State *L) {
+ int size = aux_getn(L, 1);
+ int pos = luaL_optint(L, 2, size);
+ if (pos != size) /* validate 'pos' if given */
+ luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds");
+ lua_rawgeti(L, 1, pos); /* result = t[pos] */
+ for ( ; pos < size; pos++) {
+ lua_rawgeti(L, 1, pos+1);
+ lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */
+ }
+ lua_pushnil(L);
+ lua_rawseti(L, 1, pos); /* t[pos] = nil */
+ return 1;
+}
+
+
+static void addfield (lua_State *L, luaL_Buffer *b, int i) {
+ lua_rawgeti(L, 1, i);
+ if (!lua_isstring(L, -1))
+ luaL_error(L, "invalid value (%s) at index %d in table for "
+ LUA_QL("concat"), luaL_typename(L, -1), i);
+ luaL_addvalue(b);
+}
+
+
+static int tconcat (lua_State *L) {
+ luaL_Buffer b;
+ size_t lsep;
+ int i, last;
+ const char *sep = luaL_optlstring(L, 2, "", &lsep);
+ luaL_checktype(L, 1, LUA_TTABLE);
+ i = luaL_optint(L, 3, 1);
+ last = luaL_opt(L, luaL_checkint, 4, luaL_len(L, 1));
+ luaL_buffinit(L, &b);
+ for (; i < last; i++) {
+ addfield(L, &b, i);
+ luaL_addlstring(&b, sep, lsep);
+ }
+ if (i == last) /* add last value (if interval was not empty) */
+ addfield(L, &b, i);
+ luaL_pushresult(&b);
+ return 1;
+}
+
+
+/*
+** {======================================================
+** Pack/unpack
+** =======================================================
+*/
+
+static int pack (lua_State *L) {
+ int n = lua_gettop(L); /* number of elements to pack */
+ lua_createtable(L, n, 1); /* create result table */
+ lua_pushinteger(L, n);
+ lua_setfield(L, -2, "n"); /* t.n = number of elements */
+ if (n > 0) { /* at least one element? */
+ int i;
+ lua_pushvalue(L, 1);
+ lua_rawseti(L, -2, 1); /* insert first element */
+ lua_replace(L, 1); /* move table into index 1 */
+ for (i = n; i >= 2; i--) /* assign other elements */
+ lua_rawseti(L, 1, i);
+ }
+ return 1; /* return table */
+}
+
+
+static int unpack (lua_State *L) {
+ int i, e, n;
+ luaL_checktype(L, 1, LUA_TTABLE);
+ i = luaL_optint(L, 2, 1);
+ e = luaL_opt(L, luaL_checkint, 3, luaL_len(L, 1));
+ if (i > e) return 0; /* empty range */
+ n = e - i + 1; /* number of elements */
+ if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */
+ return luaL_error(L, "too many results to unpack");
+ lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */
+ while (i++ < e) /* push arg[i + 1...e] */
+ lua_rawgeti(L, 1, i);
+ return n;
+}
+
+/* }====================================================== */
+
+
+
+/*
+** {======================================================
+** Quicksort
+** (based on `Algorithms in MODULA-3', Robert Sedgewick;
+** Addison-Wesley, 1993.)
+** =======================================================
+*/
+
+
+static void set2 (lua_State *L, int i, int j) {
+ lua_rawseti(L, 1, i);
+ lua_rawseti(L, 1, j);
+}
+
+static int sort_comp (lua_State *L, int a, int b) {
+ if (!lua_isnil(L, 2)) { /* function? */
+ int res;
+ lua_pushvalue(L, 2);
+ lua_pushvalue(L, a-1); /* -1 to compensate function */
+ lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */
+ lua_call(L, 2, 1);
+ res = lua_toboolean(L, -1);
+ lua_pop(L, 1);
+ return res;
+ }
+ else /* a < b? */
+ return lua_compare(L, a, b, LUA_OPLT);
+}
+
+static void auxsort (lua_State *L, int l, int u) {
+ while (l < u) { /* for tail recursion */
+ int i, j;
+ /* sort elements a[l], a[(l+u)/2] and a[u] */
+ lua_rawgeti(L, 1, l);
+ lua_rawgeti(L, 1, u);
+ if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */
+ set2(L, l, u); /* swap a[l] - a[u] */
+ else
+ lua_pop(L, 2);
+ if (u-l == 1) break; /* only 2 elements */
+ i = (l+u)/2;
+ lua_rawgeti(L, 1, i);
+ lua_rawgeti(L, 1, l);
+ if (sort_comp(L, -2, -1)) /* a[i]= P */
+ while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
+ if (i>=u) luaL_error(L, "invalid order function for sorting");
+ lua_pop(L, 1); /* remove a[i] */
+ }
+ /* repeat --j until a[j] <= P */
+ while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
+ if (j<=l) luaL_error(L, "invalid order function for sorting");
+ lua_pop(L, 1); /* remove a[j] */
+ }
+ if (j
+
+#define ltm_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lobject.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+
+
+static const char udatatypename[] = "userdata";
+
+LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = {
+ "no value",
+ "nil", "boolean", udatatypename, "number",
+ "string", "table", "function", udatatypename, "thread",
+ "proto", "upval" /* these last two cases are used for tests only */
+};
+
+
+void luaT_init (lua_State *L) {
+ static const char *const luaT_eventname[] = { /* ORDER TM */
+ "__index", "__newindex",
+ "__gc", "__mode", "__len", "__eq",
+ "__add", "__sub", "__mul", "__div", "__mod",
+ "__pow", "__unm", "__lt", "__le",
+ "__concat", "__call"
+ };
+ int i;
+ for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]);
+ luaS_fix(G(L)->tmname[i]); /* never collect these names */
+ }
+}
+
+
+/*
+** function to be used with macro "fasttm": optimized for absence of
+** tag methods
+*/
+const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
+ const TValue *tm = luaH_getstr(events, ename);
+ lua_assert(event <= TM_EQ);
+ if (ttisnil(tm)) { /* no tag method? */
+ events->flags |= cast_byte(1u<metatable;
+ break;
+ case LUA_TUSERDATA:
+ mt = uvalue(o)->metatable;
+ break;
+ default:
+ mt = G(L)->mt[ttypenv(o)];
+ }
+ return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject);
+}
+
diff --git a/ext/lua/src/lundump.c b/ext/lua/src/lundump.c
new file mode 100644
index 0000000000..4163cb5d3b
--- /dev/null
+++ b/ext/lua/src/lundump.c
@@ -0,0 +1,258 @@
+/*
+** $Id: lundump.c,v 2.22.1.1 2013/04/12 18:48:47 roberto Exp $
+** load precompiled Lua chunks
+** See Copyright Notice in lua.h
+*/
+
+#include
+
+#define lundump_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstring.h"
+#include "lundump.h"
+#include "lzio.h"
+
+typedef struct {
+ lua_State* L;
+ ZIO* Z;
+ Mbuffer* b;
+ const char* name;
+} LoadState;
+
+static l_noret error(LoadState* S, const char* why)
+{
+ luaO_pushfstring(S->L,"%s: %s precompiled chunk",S->name,why);
+ luaD_throw(S->L,LUA_ERRSYNTAX);
+}
+
+#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
+#define LoadByte(S) (lu_byte)LoadChar(S)
+#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
+#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
+
+#if !defined(luai_verifycode)
+#define luai_verifycode(L,b,f) /* empty */
+#endif
+
+static void LoadBlock(LoadState* S, void* b, size_t size)
+{
+ if (luaZ_read(S->Z,b,size)!=0) error(S,"truncated");
+}
+
+static int LoadChar(LoadState* S)
+{
+ char x;
+ LoadVar(S,x);
+ return x;
+}
+
+static int LoadInt(LoadState* S)
+{
+ int x;
+ LoadVar(S,x);
+ if (x<0) error(S,"corrupted");
+ return x;
+}
+
+static lua_Number LoadNumber(LoadState* S)
+{
+ lua_Number x;
+ LoadVar(S,x);
+ return x;
+}
+
+static TString* LoadString(LoadState* S)
+{
+ size_t size;
+ LoadVar(S,size);
+ if (size==0)
+ return NULL;
+ else
+ {
+ char* s=luaZ_openspace(S->L,S->b,size);
+ LoadBlock(S,s,size*sizeof(char));
+ return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */
+ }
+}
+
+static void LoadCode(LoadState* S, Proto* f)
+{
+ int n=LoadInt(S);
+ f->code=luaM_newvector(S->L,n,Instruction);
+ f->sizecode=n;
+ LoadVector(S,f->code,n,sizeof(Instruction));
+}
+
+static void LoadFunction(LoadState* S, Proto* f);
+
+static void LoadConstants(LoadState* S, Proto* f)
+{
+ int i,n;
+ n=LoadInt(S);
+ f->k=luaM_newvector(S->L,n,TValue);
+ f->sizek=n;
+ for (i=0; ik[i]);
+ for (i=0; ik[i];
+ int t=LoadChar(S);
+ switch (t)
+ {
+ case LUA_TNIL:
+ setnilvalue(o);
+ break;
+ case LUA_TBOOLEAN:
+ setbvalue(o,LoadChar(S));
+ break;
+ case LUA_TNUMBER:
+ setnvalue(o,LoadNumber(S));
+ break;
+ case LUA_TSTRING:
+ setsvalue2n(S->L,o,LoadString(S));
+ break;
+ default: lua_assert(0);
+ }
+ }
+ n=LoadInt(S);
+ f->p=luaM_newvector(S->L,n,Proto*);
+ f->sizep=n;
+ for (i=0; ip[i]=NULL;
+ for (i=0; ip[i]=luaF_newproto(S->L);
+ LoadFunction(S,f->p[i]);
+ }
+}
+
+static void LoadUpvalues(LoadState* S, Proto* f)
+{
+ int i,n;
+ n=LoadInt(S);
+ f->upvalues=luaM_newvector(S->L,n,Upvaldesc);
+ f->sizeupvalues=n;
+ for (i=0; iupvalues[i].name=NULL;
+ for (i=0; iupvalues[i].instack=LoadByte(S);
+ f->upvalues[i].idx=LoadByte(S);
+ }
+}
+
+static void LoadDebug(LoadState* S, Proto* f)
+{
+ int i,n;
+ f->source=LoadString(S);
+ n=LoadInt(S);
+ f->lineinfo=luaM_newvector(S->L,n,int);
+ f->sizelineinfo=n;
+ LoadVector(S,f->lineinfo,n,sizeof(int));
+ n=LoadInt(S);
+ f->locvars=luaM_newvector(S->L,n,LocVar);
+ f->sizelocvars=n;
+ for (i=0; ilocvars[i].varname=NULL;
+ for (i=0; ilocvars[i].varname=LoadString(S);
+ f->locvars[i].startpc=LoadInt(S);
+ f->locvars[i].endpc=LoadInt(S);
+ }
+ n=LoadInt(S);
+ for (i=0; iupvalues[i].name=LoadString(S);
+}
+
+static void LoadFunction(LoadState* S, Proto* f)
+{
+ f->linedefined=LoadInt(S);
+ f->lastlinedefined=LoadInt(S);
+ f->numparams=LoadByte(S);
+ f->is_vararg=LoadByte(S);
+ f->maxstacksize=LoadByte(S);
+ LoadCode(S,f);
+ LoadConstants(S,f);
+ LoadUpvalues(S,f);
+ LoadDebug(S,f);
+}
+
+/* the code below must be consistent with the code in luaU_header */
+#define N0 LUAC_HEADERSIZE
+#define N1 (sizeof(LUA_SIGNATURE)-sizeof(char))
+#define N2 N1+2
+#define N3 N2+6
+
+static void LoadHeader(LoadState* S)
+{
+ lu_byte h[LUAC_HEADERSIZE];
+ lu_byte s[LUAC_HEADERSIZE];
+ luaU_header(h);
+ memcpy(s,h,sizeof(char)); /* first char already read */
+ LoadBlock(S,s+sizeof(char),LUAC_HEADERSIZE-sizeof(char));
+ if (memcmp(h,s,N0)==0) return;
+ if (memcmp(h,s,N1)!=0) error(S,"not a");
+ if (memcmp(h,s,N2)!=0) error(S,"version mismatch in");
+ if (memcmp(h,s,N3)!=0) error(S,"incompatible"); else error(S,"corrupted");
+}
+
+/*
+** load precompiled chunk
+*/
+Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
+{
+ LoadState S;
+ Closure* cl;
+ if (*name=='@' || *name=='=')
+ S.name=name+1;
+ else if (*name==LUA_SIGNATURE[0])
+ S.name="binary string";
+ else
+ S.name=name;
+ S.L=L;
+ S.Z=Z;
+ S.b=buff;
+ LoadHeader(&S);
+ cl=luaF_newLclosure(L,1);
+ setclLvalue(L,L->top,cl); incr_top(L);
+ cl->l.p=luaF_newproto(L);
+ LoadFunction(&S,cl->l.p);
+ if (cl->l.p->sizeupvalues != 1)
+ {
+ Proto* p=cl->l.p;
+ cl=luaF_newLclosure(L,cl->l.p->sizeupvalues);
+ cl->l.p=p;
+ setclLvalue(L,L->top-1,cl);
+ }
+ luai_verifycode(L,buff,cl->l.p);
+ return cl;
+}
+
+#define MYINT(s) (s[0]-'0')
+#define VERSION MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)
+#define FORMAT 0 /* this is the official format */
+
+/*
+* make header for precompiled chunks
+* if you change the code below be sure to update LoadHeader and FORMAT above
+* and LUAC_HEADERSIZE in lundump.h
+*/
+void luaU_header (lu_byte* h)
+{
+ int x=1;
+ memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-sizeof(char));
+ h+=sizeof(LUA_SIGNATURE)-sizeof(char);
+ *h++=cast_byte(VERSION);
+ *h++=cast_byte(FORMAT);
+ *h++=cast_byte(*(char*)&x); /* endianness */
+ *h++=cast_byte(sizeof(int));
+ *h++=cast_byte(sizeof(size_t));
+ *h++=cast_byte(sizeof(Instruction));
+ *h++=cast_byte(sizeof(lua_Number));
+ *h++=cast_byte(((lua_Number)0.5)==0); /* is lua_Number integral? */
+ memcpy(h,LUAC_TAIL,sizeof(LUAC_TAIL)-sizeof(char));
+}
diff --git a/ext/lua/src/lvm.c b/ext/lua/src/lvm.c
new file mode 100644
index 0000000000..141b9fd19c
--- /dev/null
+++ b/ext/lua/src/lvm.c
@@ -0,0 +1,867 @@
+/*
+** $Id: lvm.c,v 2.155.1.1 2013/04/12 18:48:47 roberto Exp $
+** Lua virtual machine
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+#include
+#include
+
+#define lvm_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lgc.h"
+#include "lobject.h"
+#include "lopcodes.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+#include "lvm.h"
+
+
+
+/* limit for table tag-method chains (to avoid loops) */
+#define MAXTAGLOOP 100
+
+
+const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
+ lua_Number num;
+ if (ttisnumber(obj)) return obj;
+ if (ttisstring(obj) && luaO_str2d(svalue(obj), tsvalue(obj)->len, &num)) {
+ setnvalue(n, num);
+ return n;
+ }
+ else
+ return NULL;
+}
+
+
+int luaV_tostring (lua_State *L, StkId obj) {
+ if (!ttisnumber(obj))
+ return 0;
+ else {
+ char s[LUAI_MAXNUMBER2STR];
+ lua_Number n = nvalue(obj);
+ int l = lua_number2str(s, n);
+ setsvalue2s(L, obj, luaS_newlstr(L, s, l));
+ return 1;
+ }
+}
+
+
+static void traceexec (lua_State *L) {
+ CallInfo *ci = L->ci;
+ lu_byte mask = L->hookmask;
+ int counthook = ((mask & LUA_MASKCOUNT) && L->hookcount == 0);
+ if (counthook)
+ resethookcount(L); /* reset count */
+ if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */
+ ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */
+ return; /* do not call hook again (VM yielded, so it did not move) */
+ }
+ if (counthook)
+ luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */
+ if (mask & LUA_MASKLINE) {
+ Proto *p = ci_func(ci)->p;
+ int npc = pcRel(ci->u.l.savedpc, p);
+ int newline = getfuncline(p, npc);
+ if (npc == 0 || /* call linehook when enter a new function, */
+ ci->u.l.savedpc <= L->oldpc || /* when jump back (loop), or when */
+ newline != getfuncline(p, pcRel(L->oldpc, p))) /* enter a new line */
+ luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */
+ }
+ L->oldpc = ci->u.l.savedpc;
+ if (L->status == LUA_YIELD) { /* did hook yield? */
+ if (counthook)
+ L->hookcount = 1; /* undo decrement to zero */
+ ci->u.l.savedpc--; /* undo increment (resume will increment it again) */
+ ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */
+ ci->func = L->top - 1; /* protect stack below results */
+ luaD_throw(L, LUA_YIELD);
+ }
+}
+
+
+static void callTM (lua_State *L, const TValue *f, const TValue *p1,
+ const TValue *p2, TValue *p3, int hasres) {
+ ptrdiff_t result = savestack(L, p3);
+ setobj2s(L, L->top++, f); /* push function */
+ setobj2s(L, L->top++, p1); /* 1st argument */
+ setobj2s(L, L->top++, p2); /* 2nd argument */
+ if (!hasres) /* no result? 'p3' is third argument */
+ setobj2s(L, L->top++, p3); /* 3rd argument */
+ /* metamethod may yield only when called from Lua code */
+ luaD_call(L, L->top - (4 - hasres), hasres, isLua(L->ci));
+ if (hasres) { /* if has result, move it to its place */
+ p3 = restorestack(L, result);
+ setobjs2s(L, p3, --L->top);
+ }
+}
+
+
+void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
+ int loop;
+ for (loop = 0; loop < MAXTAGLOOP; loop++) {
+ const TValue *tm;
+ if (ttistable(t)) { /* `t' is a table? */
+ Table *h = hvalue(t);
+ const TValue *res = luaH_get(h, key); /* do a primitive get */
+ if (!ttisnil(res) || /* result is not nil? */
+ (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
+ setobj2s(L, val, res);
+ return;
+ }
+ /* else will try the tag method */
+ }
+ else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
+ luaG_typeerror(L, t, "index");
+ if (ttisfunction(tm)) {
+ callTM(L, tm, t, key, val, 1);
+ return;
+ }
+ t = tm; /* else repeat with 'tm' */
+ }
+ luaG_runerror(L, "loop in gettable");
+}
+
+
+void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
+ int loop;
+ for (loop = 0; loop < MAXTAGLOOP; loop++) {
+ const TValue *tm;
+ if (ttistable(t)) { /* `t' is a table? */
+ Table *h = hvalue(t);
+ TValue *oldval = cast(TValue *, luaH_get(h, key));
+ /* if previous value is not nil, there must be a previous entry
+ in the table; moreover, a metamethod has no relevance */
+ if (!ttisnil(oldval) ||
+ /* previous value is nil; must check the metamethod */
+ ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL &&
+ /* no metamethod; is there a previous entry in the table? */
+ (oldval != luaO_nilobject ||
+ /* no previous entry; must create one. (The next test is
+ always true; we only need the assignment.) */
+ (oldval = luaH_newkey(L, h, key), 1)))) {
+ /* no metamethod and (now) there is an entry with given key */
+ setobj2t(L, oldval, val); /* assign new value to that entry */
+ invalidateTMcache(h);
+ luaC_barrierback(L, obj2gco(h), val);
+ return;
+ }
+ /* else will try the metamethod */
+ }
+ else /* not a table; check metamethod */
+ if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
+ luaG_typeerror(L, t, "index");
+ /* there is a metamethod */
+ if (ttisfunction(tm)) {
+ callTM(L, tm, t, key, val, 0);
+ return;
+ }
+ t = tm; /* else repeat with 'tm' */
+ }
+ luaG_runerror(L, "loop in settable");
+}
+
+
+static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
+ StkId res, TMS event) {
+ const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */
+ if (ttisnil(tm))
+ tm = luaT_gettmbyobj(L, p2, event); /* try second operand */
+ if (ttisnil(tm)) return 0;
+ callTM(L, tm, p1, p2, res, 1);
+ return 1;
+}
+
+
+static const TValue *get_equalTM (lua_State *L, Table *mt1, Table *mt2,
+ TMS event) {
+ const TValue *tm1 = fasttm(L, mt1, event);
+ const TValue *tm2;
+ if (tm1 == NULL) return NULL; /* no metamethod */
+ if (mt1 == mt2) return tm1; /* same metatables => same metamethods */
+ tm2 = fasttm(L, mt2, event);
+ if (tm2 == NULL) return NULL; /* no metamethod */
+ if (luaV_rawequalobj(tm1, tm2)) /* same metamethods? */
+ return tm1;
+ return NULL;
+}
+
+
+static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
+ TMS event) {
+ if (!call_binTM(L, p1, p2, L->top, event))
+ return -1; /* no metamethod */
+ else
+ return !l_isfalse(L->top);
+}
+
+
+static int l_strcmp (const TString *ls, const TString *rs) {
+ const char *l = getstr(ls);
+ size_t ll = ls->tsv.len;
+ const char *r = getstr(rs);
+ size_t lr = rs->tsv.len;
+ for (;;) {
+ int temp = strcoll(l, r);
+ if (temp != 0) return temp;
+ else { /* strings are equal up to a `\0' */
+ size_t len = strlen(l); /* index of first `\0' in both strings */
+ if (len == lr) /* r is finished? */
+ return (len == ll) ? 0 : 1;
+ else if (len == ll) /* l is finished? */
+ return -1; /* l is smaller than r (because r is not finished) */
+ /* both strings longer than `len'; go on comparing (after the `\0') */
+ len++;
+ l += len; ll -= len; r += len; lr -= len;
+ }
+ }
+}
+
+
+int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
+ int res;
+ if (ttisnumber(l) && ttisnumber(r))
+ return luai_numlt(L, nvalue(l), nvalue(r));
+ else if (ttisstring(l) && ttisstring(r))
+ return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
+ else if ((res = call_orderTM(L, l, r, TM_LT)) < 0)
+ luaG_ordererror(L, l, r);
+ return res;
+}
+
+
+int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) {
+ int res;
+ if (ttisnumber(l) && ttisnumber(r))
+ return luai_numle(L, nvalue(l), nvalue(r));
+ else if (ttisstring(l) && ttisstring(r))
+ return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
+ else if ((res = call_orderTM(L, l, r, TM_LE)) >= 0) /* first try `le' */
+ return res;
+ else if ((res = call_orderTM(L, r, l, TM_LT)) < 0) /* else try `lt' */
+ luaG_ordererror(L, l, r);
+ return !res;
+}
+
+
+/*
+** equality of Lua values. L == NULL means raw equality (no metamethods)
+*/
+int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2) {
+ const TValue *tm;
+ lua_assert(ttisequal(t1, t2));
+ switch (ttype(t1)) {
+ case LUA_TNIL: return 1;
+ case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
+ case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
+ case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
+ case LUA_TLCF: return fvalue(t1) == fvalue(t2);
+ case LUA_TSHRSTR: return eqshrstr(rawtsvalue(t1), rawtsvalue(t2));
+ case LUA_TLNGSTR: return luaS_eqlngstr(rawtsvalue(t1), rawtsvalue(t2));
+ case LUA_TUSERDATA: {
+ if (uvalue(t1) == uvalue(t2)) return 1;
+ else if (L == NULL) return 0;
+ tm = get_equalTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, TM_EQ);
+ break; /* will try TM */
+ }
+ case LUA_TTABLE: {
+ if (hvalue(t1) == hvalue(t2)) return 1;
+ else if (L == NULL) return 0;
+ tm = get_equalTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
+ break; /* will try TM */
+ }
+ default:
+ lua_assert(iscollectable(t1));
+ return gcvalue(t1) == gcvalue(t2);
+ }
+ if (tm == NULL) return 0; /* no TM? */
+ callTM(L, tm, t1, t2, L->top, 1); /* call TM */
+ return !l_isfalse(L->top);
+}
+
+
+void luaV_concat (lua_State *L, int total) {
+ lua_assert(total >= 2);
+ do {
+ StkId top = L->top;
+ int n = 2; /* number of elements handled in this pass (at least 2) */
+ if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {
+ if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
+ luaG_concaterror(L, top-2, top-1);
+ }
+ else if (tsvalue(top-1)->len == 0) /* second operand is empty? */
+ (void)tostring(L, top - 2); /* result is first operand */
+ else if (ttisstring(top-2) && tsvalue(top-2)->len == 0) {
+ setobjs2s(L, top - 2, top - 1); /* result is second op. */
+ }
+ else {
+ /* at least two non-empty string values; get as many as possible */
+ size_t tl = tsvalue(top-1)->len;
+ char *buffer;
+ int i;
+ /* collect total length */
+ for (i = 1; i < total && tostring(L, top-i-1); i++) {
+ size_t l = tsvalue(top-i-1)->len;
+ if (l >= (MAX_SIZET/sizeof(char)) - tl)
+ luaG_runerror(L, "string length overflow");
+ tl += l;
+ }
+ buffer = luaZ_openspace(L, &G(L)->buff, tl);
+ tl = 0;
+ n = i;
+ do { /* concat all strings */
+ size_t l = tsvalue(top-i)->len;
+ memcpy(buffer+tl, svalue(top-i), l * sizeof(char));
+ tl += l;
+ } while (--i > 0);
+ setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));
+ }
+ total -= n-1; /* got 'n' strings to create 1 new */
+ L->top -= n-1; /* popped 'n' strings and pushed one */
+ } while (total > 1); /* repeat until only 1 result left */
+}
+
+
+void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {
+ const TValue *tm;
+ switch (ttypenv(rb)) {
+ case LUA_TTABLE: {
+ Table *h = hvalue(rb);
+ tm = fasttm(L, h->metatable, TM_LEN);
+ if (tm) break; /* metamethod? break switch to call it */
+ setnvalue(ra, cast_num(luaH_getn(h))); /* else primitive len */
+ return;
+ }
+ case LUA_TSTRING: {
+ setnvalue(ra, cast_num(tsvalue(rb)->len));
+ return;
+ }
+ default: { /* try metamethod */
+ tm = luaT_gettmbyobj(L, rb, TM_LEN);
+ if (ttisnil(tm)) /* no metamethod? */
+ luaG_typeerror(L, rb, "get length of");
+ break;
+ }
+ }
+ callTM(L, tm, rb, rb, ra, 1);
+}
+
+
+void luaV_arith (lua_State *L, StkId ra, const TValue *rb,
+ const TValue *rc, TMS op) {
+ TValue tempb, tempc;
+ const TValue *b, *c;
+ if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
+ (c = luaV_tonumber(rc, &tempc)) != NULL) {
+ lua_Number res = luaO_arith(op - TM_ADD + LUA_OPADD, nvalue(b), nvalue(c));
+ setnvalue(ra, res);
+ }
+ else if (!call_binTM(L, rb, rc, ra, op))
+ luaG_aritherror(L, rb, rc);
+}
+
+
+/*
+** check whether cached closure in prototype 'p' may be reused, that is,
+** whether there is a cached closure with the same upvalues needed by
+** new closure to be created.
+*/
+static Closure *getcached (Proto *p, UpVal **encup, StkId base) {
+ Closure *c = p->cache;
+ if (c != NULL) { /* is there a cached closure? */
+ int nup = p->sizeupvalues;
+ Upvaldesc *uv = p->upvalues;
+ int i;
+ for (i = 0; i < nup; i++) { /* check whether it has right upvalues */
+ TValue *v = uv[i].instack ? base + uv[i].idx : encup[uv[i].idx]->v;
+ if (c->l.upvals[i]->v != v)
+ return NULL; /* wrong upvalue; cannot reuse closure */
+ }
+ }
+ return c; /* return cached closure (or NULL if no cached closure) */
+}
+
+
+/*
+** create a new Lua closure, push it in the stack, and initialize
+** its upvalues. Note that the call to 'luaC_barrierproto' must come
+** before the assignment to 'p->cache', as the function needs the
+** original value of that field.
+*/
+static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
+ StkId ra) {
+ int nup = p->sizeupvalues;
+ Upvaldesc *uv = p->upvalues;
+ int i;
+ Closure *ncl = luaF_newLclosure(L, nup);
+ ncl->l.p = p;
+ setclLvalue(L, ra, ncl); /* anchor new closure in stack */
+ for (i = 0; i < nup; i++) { /* fill in its upvalues */
+ if (uv[i].instack) /* upvalue refers to local variable? */
+ ncl->l.upvals[i] = luaF_findupval(L, base + uv[i].idx);
+ else /* get upvalue from enclosing function */
+ ncl->l.upvals[i] = encup[uv[i].idx];
+ }
+ luaC_barrierproto(L, p, ncl);
+ p->cache = ncl; /* save it on cache for reuse */
+}
+
+
+/*
+** finish execution of an opcode interrupted by an yield
+*/
+void luaV_finishOp (lua_State *L) {
+ CallInfo *ci = L->ci;
+ StkId base = ci->u.l.base;
+ Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */
+ OpCode op = GET_OPCODE(inst);
+ switch (op) { /* finish its execution */
+ case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV:
+ case OP_MOD: case OP_POW: case OP_UNM: case OP_LEN:
+ case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: {
+ setobjs2s(L, base + GETARG_A(inst), --L->top);
+ break;
+ }
+ case OP_LE: case OP_LT: case OP_EQ: {
+ int res = !l_isfalse(L->top - 1);
+ L->top--;
+ /* metamethod should not be called when operand is K */
+ lua_assert(!ISK(GETARG_B(inst)));
+ if (op == OP_LE && /* "<=" using "<" instead? */
+ ttisnil(luaT_gettmbyobj(L, base + GETARG_B(inst), TM_LE)))
+ res = !res; /* invert result */
+ lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP);
+ if (res != GETARG_A(inst)) /* condition failed? */
+ ci->u.l.savedpc++; /* skip jump instruction */
+ break;
+ }
+ case OP_CONCAT: {
+ StkId top = L->top - 1; /* top when 'call_binTM' was called */
+ int b = GETARG_B(inst); /* first element to concatenate */
+ int total = cast_int(top - 1 - (base + b)); /* yet to concatenate */
+ setobj2s(L, top - 2, top); /* put TM result in proper position */
+ if (total > 1) { /* are there elements to concat? */
+ L->top = top - 1; /* top is one after last element (at top-2) */
+ luaV_concat(L, total); /* concat them (may yield again) */
+ }
+ /* move final result to final position */
+ setobj2s(L, ci->u.l.base + GETARG_A(inst), L->top - 1);
+ L->top = ci->top; /* restore top */
+ break;
+ }
+ case OP_TFORCALL: {
+ lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_TFORLOOP);
+ L->top = ci->top; /* correct top */
+ break;
+ }
+ case OP_CALL: {
+ if (GETARG_C(inst) - 1 >= 0) /* nresults >= 0? */
+ L->top = ci->top; /* adjust results */
+ break;
+ }
+ case OP_TAILCALL: case OP_SETTABUP: case OP_SETTABLE:
+ break;
+ default: lua_assert(0);
+ }
+}
+
+
+
+/*
+** some macros for common tasks in `luaV_execute'
+*/
+
+#if !defined luai_runtimecheck
+#define luai_runtimecheck(L, c) /* void */
+#endif
+
+
+#define RA(i) (base+GETARG_A(i))
+/* to be used after possible stack reallocation */
+#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))
+#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))
+#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \
+ ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i))
+#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \
+ ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i))
+#define KBx(i) \
+ (k + (GETARG_Bx(i) != 0 ? GETARG_Bx(i) - 1 : GETARG_Ax(*ci->u.l.savedpc++)))
+
+
+/* execute a jump instruction */
+#define dojump(ci,i,e) \
+ { int a = GETARG_A(i); \
+ if (a > 0) luaF_close(L, ci->u.l.base + a - 1); \
+ ci->u.l.savedpc += GETARG_sBx(i) + e; }
+
+/* for test instructions, execute the jump instruction that follows it */
+#define donextjump(ci) { i = *ci->u.l.savedpc; dojump(ci, i, 1); }
+
+
+#define Protect(x) { {x;}; base = ci->u.l.base; }
+
+#define checkGC(L,c) \
+ Protect( luaC_condGC(L,{L->top = (c); /* limit of live values */ \
+ luaC_step(L); \
+ L->top = ci->top;}) /* restore top */ \
+ luai_threadyield(L); )
+
+
+#define arith_op(op,tm) { \
+ TValue *rb = RKB(i); \
+ TValue *rc = RKC(i); \
+ if (ttisnumber(rb) && ttisnumber(rc)) { \
+ lua_Number nb = nvalue(rb), nc = nvalue(rc); \
+ setnvalue(ra, op(L, nb, nc)); \
+ } \
+ else { Protect(luaV_arith(L, ra, rb, rc, tm)); } }
+
+
+#define vmdispatch(o) switch(o)
+#define vmcase(l,b) case l: {b} break;
+#define vmcasenb(l,b) case l: {b} /* nb = no break */
+
+void luaV_execute (lua_State *L) {
+ CallInfo *ci = L->ci;
+ LClosure *cl;
+ TValue *k;
+ StkId base;
+ newframe: /* reentry point when frame changes (call/return) */
+ lua_assert(ci == L->ci);
+ cl = clLvalue(ci->func);
+ k = cl->p->k;
+ base = ci->u.l.base;
+ /* main loop of interpreter */
+ for (;;) {
+ Instruction i = *(ci->u.l.savedpc++);
+ StkId ra;
+ if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
+ (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
+ Protect(traceexec(L));
+ }
+ /* WARNING: several calls may realloc the stack and invalidate `ra' */
+ ra = RA(i);
+ lua_assert(base == ci->u.l.base);
+ lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
+ vmdispatch (GET_OPCODE(i)) {
+ vmcase(OP_MOVE,
+ setobjs2s(L, ra, RB(i));
+ )
+ vmcase(OP_LOADK,
+ TValue *rb = k + GETARG_Bx(i);
+ setobj2s(L, ra, rb);
+ )
+ vmcase(OP_LOADKX,
+ TValue *rb;
+ lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG);
+ rb = k + GETARG_Ax(*ci->u.l.savedpc++);
+ setobj2s(L, ra, rb);
+ )
+ vmcase(OP_LOADBOOL,
+ setbvalue(ra, GETARG_B(i));
+ if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */
+ )
+ vmcase(OP_LOADNIL,
+ int b = GETARG_B(i);
+ do {
+ setnilvalue(ra++);
+ } while (b--);
+ )
+ vmcase(OP_GETUPVAL,
+ int b = GETARG_B(i);
+ setobj2s(L, ra, cl->upvals[b]->v);
+ )
+ vmcase(OP_GETTABUP,
+ int b = GETARG_B(i);
+ Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra));
+ )
+ vmcase(OP_GETTABLE,
+ Protect(luaV_gettable(L, RB(i), RKC(i), ra));
+ )
+ vmcase(OP_SETTABUP,
+ int a = GETARG_A(i);
+ Protect(luaV_settable(L, cl->upvals[a]->v, RKB(i), RKC(i)));
+ )
+ vmcase(OP_SETUPVAL,
+ UpVal *uv = cl->upvals[GETARG_B(i)];
+ setobj(L, uv->v, ra);
+ luaC_barrier(L, uv, ra);
+ )
+ vmcase(OP_SETTABLE,
+ Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
+ )
+ vmcase(OP_NEWTABLE,
+ int b = GETARG_B(i);
+ int c = GETARG_C(i);
+ Table *t = luaH_new(L);
+ sethvalue(L, ra, t);
+ if (b != 0 || c != 0)
+ luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c));
+ checkGC(L, ra + 1);
+ )
+ vmcase(OP_SELF,
+ StkId rb = RB(i);
+ setobjs2s(L, ra+1, rb);
+ Protect(luaV_gettable(L, rb, RKC(i), ra));
+ )
+ vmcase(OP_ADD,
+ arith_op(luai_numadd, TM_ADD);
+ )
+ vmcase(OP_SUB,
+ arith_op(luai_numsub, TM_SUB);
+ )
+ vmcase(OP_MUL,
+ arith_op(luai_nummul, TM_MUL);
+ )
+ vmcase(OP_DIV,
+ arith_op(luai_numdiv, TM_DIV);
+ )
+ vmcase(OP_MOD,
+ arith_op(luai_nummod, TM_MOD);
+ )
+ vmcase(OP_POW,
+ arith_op(luai_numpow, TM_POW);
+ )
+ vmcase(OP_UNM,
+ TValue *rb = RB(i);
+ if (ttisnumber(rb)) {
+ lua_Number nb = nvalue(rb);
+ setnvalue(ra, luai_numunm(L, nb));
+ }
+ else {
+ Protect(luaV_arith(L, ra, rb, rb, TM_UNM));
+ }
+ )
+ vmcase(OP_NOT,
+ TValue *rb = RB(i);
+ int res = l_isfalse(rb); /* next assignment may change this value */
+ setbvalue(ra, res);
+ )
+ vmcase(OP_LEN,
+ Protect(luaV_objlen(L, ra, RB(i)));
+ )
+ vmcase(OP_CONCAT,
+ int b = GETARG_B(i);
+ int c = GETARG_C(i);
+ StkId rb;
+ L->top = base + c + 1; /* mark the end of concat operands */
+ Protect(luaV_concat(L, c - b + 1));
+ ra = RA(i); /* 'luav_concat' may invoke TMs and move the stack */
+ rb = b + base;
+ setobjs2s(L, ra, rb);
+ checkGC(L, (ra >= rb ? ra + 1 : rb));
+ L->top = ci->top; /* restore top */
+ )
+ vmcase(OP_JMP,
+ dojump(ci, i, 0);
+ )
+ vmcase(OP_EQ,
+ TValue *rb = RKB(i);
+ TValue *rc = RKC(i);
+ Protect(
+ if (cast_int(equalobj(L, rb, rc)) != GETARG_A(i))
+ ci->u.l.savedpc++;
+ else
+ donextjump(ci);
+ )
+ )
+ vmcase(OP_LT,
+ Protect(
+ if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i))
+ ci->u.l.savedpc++;
+ else
+ donextjump(ci);
+ )
+ )
+ vmcase(OP_LE,
+ Protect(
+ if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i))
+ ci->u.l.savedpc++;
+ else
+ donextjump(ci);
+ )
+ )
+ vmcase(OP_TEST,
+ if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra))
+ ci->u.l.savedpc++;
+ else
+ donextjump(ci);
+ )
+ vmcase(OP_TESTSET,
+ TValue *rb = RB(i);
+ if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb))
+ ci->u.l.savedpc++;
+ else {
+ setobjs2s(L, ra, rb);
+ donextjump(ci);
+ }
+ )
+ vmcase(OP_CALL,
+ int b = GETARG_B(i);
+ int nresults = GETARG_C(i) - 1;
+ if (b != 0) L->top = ra+b; /* else previous instruction set top */
+ if (luaD_precall(L, ra, nresults)) { /* C function? */
+ if (nresults >= 0) L->top = ci->top; /* adjust results */
+ base = ci->u.l.base;
+ }
+ else { /* Lua function */
+ ci = L->ci;
+ ci->callstatus |= CIST_REENTRY;
+ goto newframe; /* restart luaV_execute over new Lua function */
+ }
+ )
+ vmcase(OP_TAILCALL,
+ int b = GETARG_B(i);
+ if (b != 0) L->top = ra+b; /* else previous instruction set top */
+ lua_assert(GETARG_C(i) - 1 == LUA_MULTRET);
+ if (luaD_precall(L, ra, LUA_MULTRET)) /* C function? */
+ base = ci->u.l.base;
+ else {
+ /* tail call: put called frame (n) in place of caller one (o) */
+ CallInfo *nci = L->ci; /* called frame */
+ CallInfo *oci = nci->previous; /* caller frame */
+ StkId nfunc = nci->func; /* called function */
+ StkId ofunc = oci->func; /* caller function */
+ /* last stack slot filled by 'precall' */
+ StkId lim = nci->u.l.base + getproto(nfunc)->numparams;
+ int aux;
+ /* close all upvalues from previous call */
+ if (cl->p->sizep > 0) luaF_close(L, oci->u.l.base);
+ /* move new frame into old one */
+ for (aux = 0; nfunc + aux < lim; aux++)
+ setobjs2s(L, ofunc + aux, nfunc + aux);
+ oci->u.l.base = ofunc + (nci->u.l.base - nfunc); /* correct base */
+ oci->top = L->top = ofunc + (L->top - nfunc); /* correct top */
+ oci->u.l.savedpc = nci->u.l.savedpc;
+ oci->callstatus |= CIST_TAIL; /* function was tail called */
+ ci = L->ci = oci; /* remove new frame */
+ lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize);
+ goto newframe; /* restart luaV_execute over new Lua function */
+ }
+ )
+ vmcasenb(OP_RETURN,
+ int b = GETARG_B(i);
+ if (b != 0) L->top = ra+b-1;
+ if (cl->p->sizep > 0) luaF_close(L, base);
+ b = luaD_poscall(L, ra);
+ if (!(ci->callstatus & CIST_REENTRY)) /* 'ci' still the called one */
+ return; /* external invocation: return */
+ else { /* invocation via reentry: continue execution */
+ ci = L->ci;
+ if (b) L->top = ci->top;
+ lua_assert(isLua(ci));
+ lua_assert(GET_OPCODE(*((ci)->u.l.savedpc - 1)) == OP_CALL);
+ goto newframe; /* restart luaV_execute over new Lua function */
+ }
+ )
+ vmcase(OP_FORLOOP,
+ lua_Number step = nvalue(ra+2);
+ lua_Number idx = luai_numadd(L, nvalue(ra), step); /* increment index */
+ lua_Number limit = nvalue(ra+1);
+ if (luai_numlt(L, 0, step) ? luai_numle(L, idx, limit)
+ : luai_numle(L, limit, idx)) {
+ ci->u.l.savedpc += GETARG_sBx(i); /* jump back */
+ setnvalue(ra, idx); /* update internal index... */
+ setnvalue(ra+3, idx); /* ...and external index */
+ }
+ )
+ vmcase(OP_FORPREP,
+ const TValue *init = ra;
+ const TValue *plimit = ra+1;
+ const TValue *pstep = ra+2;
+ if (!tonumber(init, ra))
+ luaG_runerror(L, LUA_QL("for") " initial value must be a number");
+ else if (!tonumber(plimit, ra+1))
+ luaG_runerror(L, LUA_QL("for") " limit must be a number");
+ else if (!tonumber(pstep, ra+2))
+ luaG_runerror(L, LUA_QL("for") " step must be a number");
+ setnvalue(ra, luai_numsub(L, nvalue(ra), nvalue(pstep)));
+ ci->u.l.savedpc += GETARG_sBx(i);
+ )
+ vmcasenb(OP_TFORCALL,
+ StkId cb = ra + 3; /* call base */
+ setobjs2s(L, cb+2, ra+2);
+ setobjs2s(L, cb+1, ra+1);
+ setobjs2s(L, cb, ra);
+ L->top = cb + 3; /* func. + 2 args (state and index) */
+ Protect(luaD_call(L, cb, GETARG_C(i), 1));
+ L->top = ci->top;
+ i = *(ci->u.l.savedpc++); /* go to next instruction */
+ ra = RA(i);
+ lua_assert(GET_OPCODE(i) == OP_TFORLOOP);
+ goto l_tforloop;
+ )
+ vmcase(OP_TFORLOOP,
+ l_tforloop:
+ if (!ttisnil(ra + 1)) { /* continue loop? */
+ setobjs2s(L, ra, ra + 1); /* save control variable */
+ ci->u.l.savedpc += GETARG_sBx(i); /* jump back */
+ }
+ )
+ vmcase(OP_SETLIST,
+ int n = GETARG_B(i);
+ int c = GETARG_C(i);
+ int last;
+ Table *h;
+ if (n == 0) n = cast_int(L->top - ra) - 1;
+ if (c == 0) {
+ lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG);
+ c = GETARG_Ax(*ci->u.l.savedpc++);
+ }
+ luai_runtimecheck(L, ttistable(ra));
+ h = hvalue(ra);
+ last = ((c-1)*LFIELDS_PER_FLUSH) + n;
+ if (last > h->sizearray) /* needs more space? */
+ luaH_resizearray(L, h, last); /* pre-allocate it at once */
+ for (; n > 0; n--) {
+ TValue *val = ra+n;
+ luaH_setint(L, h, last--, val);
+ luaC_barrierback(L, obj2gco(h), val);
+ }
+ L->top = ci->top; /* correct top (in case of previous open call) */
+ )
+ vmcase(OP_CLOSURE,
+ Proto *p = cl->p->p[GETARG_Bx(i)];
+ Closure *ncl = getcached(p, cl->upvals, base); /* cached closure */
+ if (ncl == NULL) /* no match? */
+ pushclosure(L, p, cl->upvals, base, ra); /* create a new one */
+ else
+ setclLvalue(L, ra, ncl); /* push cashed closure */
+ checkGC(L, ra + 1);
+ )
+ vmcase(OP_VARARG,
+ int b = GETARG_B(i) - 1;
+ int j;
+ int n = cast_int(base - ci->func) - cl->p->numparams - 1;
+ if (b < 0) { /* B == 0? */
+ b = n; /* get all var. arguments */
+ Protect(luaD_checkstack(L, n));
+ ra = RA(i); /* previous call may change the stack */
+ L->top = ra + n;
+ }
+ for (j = 0; j < b; j++) {
+ if (j < n) {
+ setobjs2s(L, ra + j, base - n + j);
+ }
+ else {
+ setnilvalue(ra + j);
+ }
+ }
+ )
+ vmcase(OP_EXTRAARG,
+ lua_assert(0);
+ )
+ }
+ }
+}
+
diff --git a/ext/lua/src/lzio.c b/ext/lua/src/lzio.c
new file mode 100644
index 0000000000..20efea9830
--- /dev/null
+++ b/ext/lua/src/lzio.c
@@ -0,0 +1,76 @@
+/*
+** $Id: lzio.c,v 1.35.1.1 2013/04/12 18:48:47 roberto Exp $
+** Buffered streams
+** See Copyright Notice in lua.h
+*/
+
+
+#include
+
+#define lzio_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "llimits.h"
+#include "lmem.h"
+#include "lstate.h"
+#include "lzio.h"
+
+
+int luaZ_fill (ZIO *z) {
+ size_t size;
+ lua_State *L = z->L;
+ const char *buff;
+ lua_unlock(L);
+ buff = z->reader(L, z->data, &size);
+ lua_lock(L);
+ if (buff == NULL || size == 0)
+ return EOZ;
+ z->n = size - 1; /* discount char being returned */
+ z->p = buff;
+ return cast_uchar(*(z->p++));
+}
+
+
+void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
+ z->L = L;
+ z->reader = reader;
+ z->data = data;
+ z->n = 0;
+ z->p = NULL;
+}
+
+
+/* --------------------------------------------------------------- read --- */
+size_t luaZ_read (ZIO *z, void *b, size_t n) {
+ while (n) {
+ size_t m;
+ if (z->n == 0) { /* no bytes in buffer? */
+ if (luaZ_fill(z) == EOZ) /* try to read more */
+ return n; /* no more input; return number of missing bytes */
+ else {
+ z->n++; /* luaZ_fill consumed first byte; put it back */
+ z->p--;
+ }
+ }
+ m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
+ memcpy(b, z->p, m);
+ z->n -= m;
+ z->p += m;
+ b = (char *)b + m;
+ n -= m;
+ }
+ return 0;
+}
+
+/* ------------------------------------------------------------------------ */
+char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
+ if (n > buff->buffsize) {
+ if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
+ luaZ_resizebuffer(L, buff, n);
+ }
+ return buff->buffer;
+}
+
+
diff --git a/ext/spice/CMakeLists.txt b/ext/spice/CMakeLists.txt
new file mode 100644
index 0000000000..1ef4c3a90a
--- /dev/null
+++ b/ext/spice/CMakeLists.txt
@@ -0,0 +1,28 @@
+cmake_minimum_required (VERSION 2.8)
+
+project (Spice)
+
+if (NOT SPICE_ROOT_DIR)
+ set(SPICE_ROOT_DIR ${PROJECT_SOURCE_DIR})
+endif ()
+
+file(GLOB cspice_SRC
+ "src/cspice/*.c"
+)
+file(GLOB csupport_SRC
+ "src/csupport/*.c"
+)
+
+include_directories ("${SPICE_ROOT_DIR}/include")
+
+add_definitions( -DKR_headers )
+
+if(MSVC)
+add_definitions( -DMSDOS )
+endif(MSVC)
+
+#add_library( Spice ${cspice_SRC} ${csupport_SRC} )
+add_library( Spice ${cspice_SRC} )
+
+#SET_TARGET_PROPERTIES(cspice PROPERTIES LINKER_LANGUAGE C)
+#SET_TARGET_PROPERTIES(csupport PROPERTIES LINKER_LANGUAGE C)
diff --git a/ext/spice/include/SpiceCK.h b/ext/spice/include/SpiceCK.h
new file mode 100644
index 0000000000..894d4e9a6c
--- /dev/null
+++ b/ext/spice/include/SpiceCK.h
@@ -0,0 +1,155 @@
+/*
+
+-Header_File SpiceCK.h ( CSPICE CK definitions )
+
+-Abstract
+
+ Perform CSPICE definitions to support CK wrapper interfaces.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header defines types that may be referenced in
+ application code that calls CSPICE CK functions.
+
+ Typedef
+ =======
+
+ Name Description
+ ---- ----------
+
+ SpiceCK05Subtype Typedef for enum indicating the
+ mathematical representation used
+ in an CK type 05 segment. Possible
+ values and meanings are:
+
+ C05TP0:
+
+ Hermite interpolation, 8-
+ element packets containing
+
+ q0, q1, q2, q3,
+ dq0/dt, dq1/dt, dq2/dt dq3/dt
+
+ where q0, q1, q2, q3 represent
+ quaternion components and dq0/dt,
+ dq1/dt, dq2/dt, dq3/dt represent
+ quaternion time derivative components.
+
+ Quaternions are unitless. Quaternion
+ time derivatives have units of
+ 1/second.
+
+
+ C05TP1:
+
+ Lagrange interpolation, 4-
+ element packets containing
+
+ q0, q1, q2, q3,
+
+ where q0, q1, q2, q3 represent
+ quaternion components. Quaternion
+ derivatives are obtained by
+ differentiating interpolating
+ polynomials.
+
+
+ C05TP2:
+
+ Hermite interpolation, 14-
+ element packets containing
+
+ q0, q1, q2, q3,
+ dq0/dt, dq1/dt, dq2/dt dq3/dt,
+ av0, av1, av2,
+ dav0/dt, dav1/dt, dav2/dt
+
+ where q0, q1, q2, q3 represent
+ quaternion components and dq0/dt,
+ dq1/dt, dq2/dt, dq3/dt represent
+ quaternion time derivative components,
+ av0, av1, av2 represent angular
+ velocity components, and
+ dav0/dt, dav1/dt, dav2/dt represent
+ angular acceleration components.
+
+
+ C05TP3:
+
+ Lagrange interpolation, 7-
+ element packets containing
+
+ q0, q1, q2, q3,
+ av0, av1, av2
+
+ where q0, q1, q2, q3 represent
+ quaternion components and
+ av0, av1, av2 represent angular
+ velocity components.
+
+
+
+Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 20-AUG-2002 (NJB)
+
+*/
+
+#ifndef HAVE_SPICE_CK_H
+
+ #define HAVE_SPICE_CK_H
+
+
+
+ /*
+ CK type 05 subtype codes:
+ */
+
+ enum _SpiceCK05Subtype { C05TP0, C05TP1, C05TP2, C05TP3 };
+
+
+ typedef enum _SpiceCK05Subtype SpiceCK05Subtype;
+
+#endif
+
diff --git a/ext/spice/include/SpiceCel.h b/ext/spice/include/SpiceCel.h
new file mode 100644
index 0000000000..7b0537e9ee
--- /dev/null
+++ b/ext/spice/include/SpiceCel.h
@@ -0,0 +1,441 @@
+/*
+
+-Header_File SpiceCel.h ( CSPICE Cell definitions )
+
+-Abstract
+
+ Perform CSPICE definitions for the SpiceCell data type.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CELLS
+
+-Particulars
+
+ This header defines structures, macros, and enumerated types that
+ may be referenced in application code that calls CSPICE cell
+ functions.
+
+ CSPICE cells are data structures that implement functionality
+ parallel to that of the cell abstract data type in SPICELIB. In
+ CSPICE, a cell is a C structure containing bookkeeping information,
+ including a pointer to an associated data array.
+
+ For numeric data types, the data array is simply a SPICELIB-style
+ cell, including a valid control area. For character cells, the data
+ array has the same number of elements as the corresponding
+ SPICELIB-style cell, but the contents of the control area are not
+ maintained, and the data elements are null-terminated C-style
+ strings.
+
+ CSPICE cells should be declared using the declaration macros
+ provided in this header file. See the table of macros below.
+
+
+ Structures
+ ==========
+
+ Name Description
+ ---- ----------
+
+ SpiceCell Structure containing CSPICE cell metadata.
+
+ The members are:
+
+ dtype: Data type of cell: character,
+ integer, or double precision.
+
+ dtype has type
+ SpiceCellDataType.
+
+ length: For character cells, the
+ declared length of the
+ cell's string array.
+
+ size: The maximum number of data
+ items that can be stored in
+ the cell's data array.
+
+ card: The cell's "cardinality": the
+ number of data items currently
+ present in the cell.
+
+ isSet: Boolean flag indicating whether
+ the cell is a CSPICE set.
+ Sets have no duplicate data
+ items, and their data items are
+ stored in increasing order.
+
+ adjust: Boolean flag indicating whether
+ the cell's data area has
+ adjustable size. Adjustable
+ size cell data areas are not
+ currently implemented.
+
+ init: Boolean flag indicating whether
+ the cell has been initialized.
+
+ base: is a void pointer to the
+ associated data array. base
+ points to the start of the
+ control area of this array.
+
+ data: is a void pointer to the
+ first data slot in the
+ associated data array. This
+ slot is the element following
+ the control area.
+
+
+ ConstSpiceCell A const SpiceCell.
+
+
+
+
+ Declaration Macros
+ ==================
+
+ Name Description
+ ---- ----------
+
+ SPICECHAR_CELL ( name, size, length ) Declare a
+ character CSPICE
+ cell having cell
+ name name,
+ maximum cell
+ cardinality size,
+ and string length
+ length. The
+ macro declares
+ both the cell and
+ the associated
+ data array. The
+ name of the data
+ array begins with
+ "SPICE_".
+
+
+ SPICEDOUBLE_CELL ( name, size ) Like SPICECHAR_CELL,
+ but declares a
+ double precision
+ cell.
+
+
+ SPICEINT_CELL ( name, size ) Like
+ SPICECHAR_CELL,
+ but declares an
+ integer cell.
+
+ Assignment Macros
+ =================
+
+ Name Description
+ ---- ----------
+ SPICE_CELL_SET_C( item, i, cell ) Assign the ith
+ element of a
+ character cell.
+ Arguments cell
+ and item are
+ pointers.
+
+ SPICE_CELL_SET_D( item, i, cell ) Assign the ith
+ element of a
+ double precision
+ cell. Argument
+ cell is a
+ pointer.
+
+ SPICE_CELL_SET_I( item, i, cell ) Assign the ith
+ element of an
+ integer cell.
+ Argument cell is
+ a pointer.
+
+
+ Fetch Macros
+ ==============
+
+ Name Description
+ ---- ----------
+ SPICE_CELL_GET_C( cell, i, lenout, item ) Fetch the ith
+ element from a
+ character cell.
+ Arguments cell
+ and item are
+ pointers.
+ Argument lenout
+ is the available
+ space in item.
+
+ SPICE_CELL_GET_D( cell, i, item ) Fetch the ith
+ element from a
+ double precision
+ cell. Arguments
+ cell and item are
+ pointers.
+
+ SPICE_CELL_GET_I( cell, i, item ) Fetch the ith
+ element from an
+ integer cell.
+ Arguments cell
+ and item are
+ pointers.
+ Element Pointer Macros
+ ======================
+
+ Name Description
+ ---- ----------
+ SPICE_CELL_ELEM_C( cell, i ) Macro evaluates
+ to a SpiceChar
+ pointer to the
+ ith data element
+ of a character
+ cell. Argument
+ cell is a
+ pointer.
+
+ SPICE_CELL_ELEM_D( cell, i ) Macro evaluates
+ to a SpiceDouble
+ pointer to the
+ ith data element
+ of a double
+ precision cell.
+ Argument cell is
+ a pointer.
+
+ SPICE_CELL_ELEM_I( cell, i ) Macro evaluates
+ to a SpiceInt
+ pointer to the
+ ith data element
+ of an integer
+ cell. Argument
+ cell is a
+ pointer.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 22-AUG-2002 (NJB)
+
+*/
+#ifndef HAVE_SPICE_CELLS_H
+
+ #define HAVE_SPICE_CELLS_H
+
+
+ /*
+ Data type codes:
+ */
+ typedef enum _SpiceDataType SpiceCellDataType;
+
+
+ /*
+ Cell structure:
+ */
+ struct _SpiceCell
+
+ { SpiceCellDataType dtype;
+ SpiceInt length;
+ SpiceInt size;
+ SpiceInt card;
+ SpiceBoolean isSet;
+ SpiceBoolean adjust;
+ SpiceBoolean init;
+ void * base;
+ void * data; };
+
+ typedef struct _SpiceCell SpiceCell;
+
+ typedef const SpiceCell ConstSpiceCell;
+
+
+ /*
+ SpiceCell control area size:
+ */
+ #define SPICE_CELL_CTRLSZ 6
+
+
+ /*
+ Declaration macros:
+ */
+
+ #define SPICECHAR_CELL( name, size, length ) \
+ \
+ static SpiceChar SPICE_CELL_##name[SPICE_CELL_CTRLSZ + size][length]; \
+ \
+ static SpiceCell name = \
+ \
+ { SPICE_CHR, \
+ length, \
+ size, \
+ 0, \
+ SPICETRUE, \
+ SPICEFALSE, \
+ SPICEFALSE, \
+ (void *) &(SPICE_CELL_##name), \
+ (void *) &(SPICE_CELL_##name[SPICE_CELL_CTRLSZ]) }
+
+
+ #define SPICEDOUBLE_CELL( name, size ) \
+ \
+ static SpiceDouble SPICE_CELL_##name [SPICE_CELL_CTRLSZ + size]; \
+ \
+ static SpiceCell name = \
+ \
+ { SPICE_DP, \
+ 0, \
+ size, \
+ 0, \
+ SPICETRUE, \
+ SPICEFALSE, \
+ SPICEFALSE, \
+ (void *) &(SPICE_CELL_##name), \
+ (void *) &(SPICE_CELL_##name[SPICE_CELL_CTRLSZ]) }
+
+
+ #define SPICEINT_CELL( name, size ) \
+ \
+ static SpiceInt SPICE_CELL_##name [SPICE_CELL_CTRLSZ + size]; \
+ \
+ static SpiceCell name = \
+ \
+ { SPICE_INT, \
+ 0, \
+ size, \
+ 0, \
+ SPICETRUE, \
+ SPICEFALSE, \
+ SPICEFALSE, \
+ (void *) &(SPICE_CELL_##name), \
+ (void *) &(SPICE_CELL_##name[SPICE_CELL_CTRLSZ]) }
+
+
+ /*
+ Access macros for individual elements:
+ */
+
+ /*
+ Data element pointer macros:
+ */
+
+ #define SPICE_CELL_ELEM_C( cell, i ) \
+ \
+ ( ( (SpiceChar *) (cell)->data ) + (i)*( (cell)->length ) )
+
+
+ #define SPICE_CELL_ELEM_D( cell, i ) \
+ \
+ ( ( (SpiceDouble *) (cell)->data )[(i)] )
+
+
+ #define SPICE_CELL_ELEM_I( cell, i ) \
+ \
+ ( ( (SpiceInt *) (cell)->data )[(i)] )
+
+
+ /*
+ "Fetch" macros:
+ */
+
+ #define SPICE_CELL_GET_C( cell, i, lenout, item ) \
+ \
+ { \
+ SpiceInt nBytes; \
+ \
+ nBytes = brckti_c ( (cell)->length, 0, (lenout-1) ) \
+ * sizeof ( SpiceChar ); \
+ \
+ memmove ( (item), SPICE_CELL_ELEM_C((cell), (i)), nBytes ); \
+ \
+ item[nBytes] = NULLCHAR; \
+ }
+
+
+ #define SPICE_CELL_GET_D( cell, i, item ) \
+ \
+ ( (*item) = ( (SpiceDouble *) (cell)->data)[i] )
+
+
+ #define SPICE_CELL_GET_I( cell, i, item ) \
+ \
+ ( (*item) = ( (SpiceInt *) (cell)->data)[i] )
+
+
+ /*
+ Assignment macros:
+ */
+
+ #define SPICE_CELL_SET_C( item, i, cell ) \
+ \
+ { \
+ SpiceChar * sPtr; \
+ SpiceInt nBytes; \
+ \
+ nBytes = brckti_c ( strlen(item), 0, (cell)->length - 1 ) \
+ * sizeof ( SpiceChar ); \
+ \
+ sPtr = SPICE_CELL_ELEM_C((cell), (i)); \
+ \
+ memmove ( sPtr, (item), nBytes ); \
+ \
+ sPtr[nBytes] = NULLCHAR; \
+ }
+
+
+ #define SPICE_CELL_SET_D( item, i, cell ) \
+ \
+ ( ( (SpiceDouble *) (cell)->data)[i] = (item) )
+
+
+ #define SPICE_CELL_SET_I( item, i, cell ) \
+ \
+ ( ( (SpiceInt *) (cell)->data)[i] = (item) )
+
+
+ /*
+ The enum SpiceTransDir is used to indicate language translation
+ direction: C to Fortran or vice versa.
+ */
+ enum _SpiceTransDir { C2F = 0, F2C = 1 };
+
+ typedef enum _SpiceTransDir SpiceTransDir;
+
+
+#endif
+
diff --git a/ext/spice/include/SpiceEK.h b/ext/spice/include/SpiceEK.h
new file mode 100644
index 0000000000..cbe213fb01
--- /dev/null
+++ b/ext/spice/include/SpiceEK.h
@@ -0,0 +1,448 @@
+/*
+
+-Header_File SpiceEK.h ( CSPICE EK-specific definitions )
+
+-Abstract
+
+ Perform CSPICE EK-specific definitions, including macros and user-
+ defined types.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header defines macros, enumerated types, structures, and
+ typedefs that may be referenced in application code that calls CSPICE
+ EK functions.
+
+
+ Macros
+ ======
+
+ General limits
+ --------------
+
+ Name Description
+ ---- ----------
+ SPICE_EK_MXCLSG Maximum number of columns per segment.
+
+ SPICE_EK_TYPLEN Maximum length of a short string
+ indicating a data type (one of
+ {"CHR", "DP", "INT", "TIME"}). Such
+ strings are returned by some of the
+ Fortran SPICELIB EK routines, hence also
+ by their f2c'd counterparts.
+
+ Sizes of EK objects
+ -------------------
+
+ Name Description
+ ---- ----------
+
+ SPICE_EK_CNAMSZ Maximum length of column name.
+ SPICE_EK_CSTRLN Length of string required to hold column
+ name.
+ SPICE_EK_TNAMSZ Maximum length of table name.
+ SPICE_EK_TSTRLN Length of string required to hold table
+ name.
+
+
+ Query-related limits
+ --------------------
+
+ Name Description
+ ---- ----------
+
+ SPICE_EK_MAXQRY Maximum length of an input query. This
+ value is currently equivalent to
+ twenty-five 80-character lines.
+
+ SPICE_EK_MAXQSEL Maximum number of columns that may be
+ listed in the `SELECT clause' of a query.
+
+ SPICE_EK_MAXQTAB Maximum number of tables that may be
+ listed in the `FROM clause' of a query.
+
+ SPICE_EK_MAXQCON Maximum number of relational expressions
+ that may be listed in the `constraint
+ clause' of a query.
+
+ This limit applies to a query when it is
+ represented in `normalized form': that
+ is, the constraints have been expressed
+ as a disjunction of conjunctions of
+ relational expressions. The number of
+ relational expressions in a query that
+ has been expanded in this fashion may be
+ greater than the number of relations in
+ the query as orginally written. For
+ example, the expression
+
+ ( ( A LT 1 ) OR ( B GT 2 ) )
+ AND
+ ( ( C NE 3 ) OR ( D EQ 4 ) )
+
+ which contains 4 relational expressions,
+ expands to the equivalent normalized
+ constraint
+
+ ( ( A LT 1 ) AND ( C NE 3 ) )
+ OR
+ ( ( A LT 1 ) AND ( D EQ 4 ) )
+ OR
+ ( ( B GT 2 ) AND ( C NE 3 ) )
+ OR
+ ( ( B GT 2 ) AND ( D EQ 4 ) )
+
+ which contains eight relational
+ expressions.
+
+
+
+ SPICE_EK_MAXQJOIN Maximum number of tables that can be
+ joined.
+
+ SPICE_EK_MAXQJCON Maximum number of join constraints
+ allowed.
+
+ SPICE_EK_MAXQORD Maximum number of columns that may be
+ used in the `order-by clause' of a query.
+
+ SPICE_EK_MAXQTOK Maximum number of tokens in a query.
+ Tokens
+ are reserved words, column names,
+ parentheses, and values. Literal strings
+ and time values count as single tokens.
+
+ SPICE_EK_MAXQNUM Maximum number of numeric tokens in a
+ query.
+
+ SPICE_EK_MAXQCLN Maximum total length of character tokens
+ in a query.
+
+ SPICE_EK_MAXQSTR Maximum length of literal string values
+ allowed in queries.
+
+
+ Codes
+ -----
+
+ Name Description
+ ---- ----------
+
+ SPICE_EK_VARSIZ Code used to indicate variable-size
+ objects. Usually this is used in a
+ context where a non-negative integer
+ indicates the size of a fixed-size object
+ and the presence of this code indicates a
+ variable-size object.
+
+ The value of this constant must match the
+ parameter IFALSE used in the Fortran
+ library SPICELIB.
+
+
+ Enumerated Types
+ ================
+
+ Enumerated code values
+ ----------------------
+
+ Name Description
+ ---- ----------
+ SpiceEKDataType Codes for data types used in the EK
+ interface: character, double precision,
+ integer, and "time."
+
+ The values are:
+
+ { SPICE_CHR = 0,
+ SPICE_DP = 1,
+ SPICE_INT = 2,
+ SPICE_TIME = 3 }
+
+
+
+ SpiceEKExprClass Codes for types of expressions that may
+ appear in the SELECT clause of EK
+ queries. Values and meanings are:
+
+
+ SPICE_EK_EXP_COL Selected item was a
+ column. The column
+ may qualified by a
+ table name.
+
+ SPICE_EK_EXP_FUNC Selected item was
+ a simple function
+ invocation of the
+ form
+
+ F ( )
+
+ or else was
+
+ COUNT(*)
+
+ SPICE_EK_EXP_EXPR Selected item was a
+ more general
+ expression than
+ those shown above.
+
+
+ Numeric values are:
+
+ { SPICE_EK_EXP_COL = 0,
+ SPICE_EK_EXP_FUNC = 1,
+ SPICE_EK_EXP_EXPR = 2 }
+
+
+ Structures
+ ==========
+
+ EK API structures
+ -----------------
+
+ Name Description
+ ---- ----------
+
+ SpiceEKAttDsc EK column attribute descriptor. Note
+ that this object is distinct from the EK
+ column descriptors used internally in
+ the EK routines; those descriptors
+ contain pointers as well as attribute
+ information.
+
+ The members are:
+
+ cclass: Column class code.
+
+ dtype: Data type code: has type
+ SpiceEKDataType.
+
+ strlen: String length. Applies to
+ SPICE_CHR type. Value is
+ SPICE_EK_VARSIZ for
+ variable-length strings.
+
+ size: Column entry size; this is
+ the number of array
+ elements in a column
+ entry. The value is
+ SPICE_EK_VARSIZ for
+ variable-size columns.
+
+ indexd: Index flag; value is
+ SPICETRUE if the column is
+ indexed, SPICEFALSE
+ otherwise.
+
+ nullok: Null flag; value is
+ SPICETRUE if the column
+ may contain null values,
+ SPICEFALSE otherwise.
+
+
+
+ SpiceEKSegSum EK segment summary. This structure
+ contains user interface level descriptive
+ information. The structure contains the
+ following members:
+
+ tabnam The name of the table to
+ which the segment belongs.
+
+ nrows The number of rows in the
+ segment.
+
+ ncols The number of columns in
+ the segment.
+
+ cnames An array of names of
+ columns in the segment.
+ Column names may contain
+ as many as SPICE_EK_CNAMSZ
+ characters. The array
+ contains room for
+ SPICE_EK_MXCLSG column
+ names.
+
+ cdescrs An array of column
+ attribute descriptors of
+ type SpiceEKAttDsc.
+ The array contains room
+ for SPICE_EK_MXCLSG
+ descriptors. The Ith
+ descriptor corresponds to
+ the column whose name is
+ the Ith element of the
+ array cnames.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 2.0.0 27-JUL-2002 (NJB)
+
+ Defined SpiceEKDataType using SpiceDataType. Removed declaration
+ of enum _SpiceEKDataType.
+
+ -CSPICE Version 1.0.0, 05-JUL-1999 (NJB)
+
+ Renamed _SpiceEKAttDsc member "class" to "cclass." The
+ former name is a reserved word in C++.
+
+
+ -CSPICE Version 1.0.0, 24-FEB-1999 (NJB)
+
+*/
+
+#ifndef HAVE_SPICE_EK_H
+
+ #define HAVE_SPICE_EK_H
+
+
+
+ /*
+ Constants
+ */
+
+ /*
+ Sizes of EK objects:
+ */
+
+ #define SPICE_EK_CNAMSZ 32
+ #define SPICE_EK_CSTRLN ( SPICE_EK_CNAMSZ + 1 )
+ #define SPICE_EK_TNAMSZ 64
+ #define SPICE_EK_TSTRLN ( SPICE_EK_TNAMSZ + 1 )
+
+
+
+ /*
+ Maximum number of columns per segment:
+ */
+
+ #define SPICE_EK_MXCLSG 100
+
+
+ /*
+ Maximum length of string indicating data type:
+ */
+
+ #define SPICE_EK_TYPLEN 4
+
+
+ /*
+ Query-related limits (see header for details):
+ */
+
+ #define SPICE_EK_MAXQRY 2000
+ #define SPICE_EK_MAXQSEL 50
+ #define SPICE_EK_MAXQTAB 10
+ #define SPICE_EK_MAXQCON 1000
+ #define SPICE_EK_MAXQJOIN 10
+ #define SPICE_EK_MAXQJCON 100
+ #define SPICE_EK_MAXQORD 10
+ #define SPICE_EK_MAXQTOK 500
+ #define SPICE_EK_MAXQNUM 100
+ #define SPICE_EK_MAXQCLN SPICE_EK_MAXQRY
+ #define SPICE_EK_MAXQSTR 1024
+
+
+
+ /*
+ Code indicating "variable size":
+ */
+ #define SPICE_EK_VARSIZ (-1)
+
+
+
+ /*
+ Data type codes:
+ */
+ typedef SpiceDataType SpiceEKDataType;
+
+
+
+ /*
+ SELECT clause expression type codes:
+ */
+ enum _SpiceEKExprClass{ SPICE_EK_EXP_COL = 0,
+ SPICE_EK_EXP_FUNC = 1,
+ SPICE_EK_EXP_EXPR = 2 };
+
+ typedef enum _SpiceEKExprClass SpiceEKExprClass;
+
+
+
+ /*
+ EK column attribute descriptor:
+ */
+
+ struct _SpiceEKAttDsc
+
+ { SpiceInt cclass;
+ SpiceEKDataType dtype;
+ SpiceInt strlen;
+ SpiceInt size;
+ SpiceBoolean indexd;
+ SpiceBoolean nullok; };
+
+ typedef struct _SpiceEKAttDsc SpiceEKAttDsc;
+
+
+
+ /*
+ EK segment summary:
+ */
+
+ struct _SpiceEKSegSum
+
+ { SpiceChar tabnam [SPICE_EK_TSTRLN];
+ SpiceInt nrows;
+ SpiceInt ncols;
+ SpiceChar cnames [SPICE_EK_MXCLSG][SPICE_EK_CSTRLN];
+ SpiceEKAttDsc cdescrs[SPICE_EK_MXCLSG]; };
+
+ typedef struct _SpiceEKSegSum SpiceEKSegSum;
+
+
+#endif
+
diff --git a/ext/spice/include/SpiceEll.h b/ext/spice/include/SpiceEll.h
new file mode 100644
index 0000000000..d0c123ab06
--- /dev/null
+++ b/ext/spice/include/SpiceEll.h
@@ -0,0 +1,115 @@
+/*
+
+-Header_File SpiceEll.h ( CSPICE Ellipse definitions )
+
+-Abstract
+
+ Perform CSPICE definitions for the SpiceEllipse data type.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header defines structures and typedefs that may be referenced in
+ application code that calls CSPICE Ellipse functions.
+
+
+ Structures
+ ==========
+
+ Name Description
+ ---- ----------
+
+ SpiceEllipse Structure representing an ellipse in 3-
+ dimensional space.
+
+ The members are:
+
+ center: Vector defining ellipse's
+ center.
+
+ semiMajor: Vector defining ellipse's
+ semi-major axis.
+
+ semiMinor: Vector defining ellipse's
+ semi-minor axis.
+
+ The ellipse is the set of points
+
+ {X: X = center
+ + cos(theta) * semiMajor
+ + sin(theta) * semiMinor,
+
+ theta in [0, 2*Pi) }
+
+
+ ConstSpiceEllipse A const SpiceEllipse.
+
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 04-MAR-1999 (NJB)
+
+*/
+
+#ifndef HAVE_SPICE_ELLIPSES
+
+ #define HAVE_SPICE_ELLIPSES
+
+
+
+ /*
+ Ellipse structure:
+ */
+
+ struct _SpiceEllipse
+
+ { SpiceDouble center [3];
+ SpiceDouble semiMajor [3];
+ SpiceDouble semiMinor [3]; };
+
+ typedef struct _SpiceEllipse SpiceEllipse;
+
+ typedef const SpiceEllipse ConstSpiceEllipse;
+
+#endif
+
diff --git a/ext/spice/include/SpiceGF.h b/ext/spice/include/SpiceGF.h
new file mode 100644
index 0000000000..14d10de2fd
--- /dev/null
+++ b/ext/spice/include/SpiceGF.h
@@ -0,0 +1,319 @@
+/*
+
+-Header_File SpiceGF.h ( CSPICE GF-specific definitions )
+
+-Abstract
+
+ Perform CSPICE GF-specific definitions.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ GF
+
+-Keywords
+
+ GEOMETRY
+ SEARCH
+
+-Exceptions
+
+ None
+
+-Files
+
+ None
+
+-Particulars
+
+ This header defines macros that may be referenced in application
+ code that calls CSPICE GF functions.
+
+
+ Macros
+ ======
+
+ Workspace parameters
+ --------------------
+
+ CSPICE applications normally don't declare workspace arguments
+ and therefore don't directly reference workspace size parameters.
+ However, CSPICE GF APIs dealing with numeric constraints
+ dynamically allocate workspace memory; the amount allocated
+ depends on the number of intervals the workspace windows can
+ hold. This amount is an input argument to the GF numeric quantity
+ APIs.
+
+ The parameters below are used to calculate the amount of memory
+ required. Each workspace window contains 6 double precision
+ numbers in its control area and 2 double precision numbers for
+ each interval it can hold.
+
+
+ Name Description
+ ---- ----------
+ SPICE_GF_NWMAX Maximum number of windows required for
+ a user-defined workspace array.
+
+ SPICE_GF_NWDIST Number of workspace windows used by
+ gfdist_c and the underlying SPICELIB
+ routine GFDIST.
+
+ SPICE_GF_NWSEP Number of workspace windows used by
+ gfsep_c and the underlying SPICELIB
+ routine GFSEP.
+
+
+
+ Field of view (FOV) parameters
+ ------------------------------
+
+ Name Description
+ ---- ----------
+ SPICE_GF_MAXVRT Maximum allowed number of boundary
+ vectors for a polygonal FOV.
+
+ SPICE_GF_CIRFOV Parameter identifying a circular FOV.
+
+ SPICE_GF_ELLFOV Parameter identifying a elliptical FOV.
+
+ SPICE_GF_POLFOV Parameter identifying a polygonal FOV.
+
+ SPICE_GF_RECFOV Parameter identifying a rectangular FOV.
+
+ SPICE_GF_SHPLEN Parameter specifying maximum length of
+ a FOV shape name.
+
+ SPICE_GF_MARGIN is a small positive number used to
+ constrain the orientation of the
+ boundary vectors of polygonal FOVs. Such
+ FOVs must satisfy the following
+ constraints:
+
+ 1) The boundary vectors must be
+ contained within a right circular
+ cone of angular radius less than
+ than (pi/2) - MARGIN radians; in
+ other words, there must be a vector
+ A such that all boundary vectors
+ have angular separation from A of
+ less than (pi/2)-MARGIN radians.
+
+ 2) There must be a pair of boundary
+ vectors U, V such that all other
+ boundary vectors lie in the same
+ half space bounded by the plane
+ containing U and V. Furthermore, all
+ other boundary vectors must have
+ orthogonal projections onto a plane
+ normal to this plane such that the
+ projections have angular separation
+ of at least 2*MARGIN radians from
+ the plane spanned by U and V.
+
+ MARGIN is currently set to 1.D-12.
+
+
+ Occultation parameters
+ ----------------------
+
+ SPICE_GF_ANNULR Parameter identifying an "annular
+ occultation." This geometric condition
+ is more commonly known as a "transit."
+ The limb of the background object must
+ not be blocked by the foreground object
+ in order for an occultation to be
+ "annular."
+
+ SPICE_GF_ANY Parameter identifying any type of
+ occultation or transit.
+
+ SPICE_GF_FULL Parameter identifying a full
+ occultation: the foreground body
+ entirely blocks the background body.
+
+ SPICE_GF_PARTL Parameter identifying an "partial
+ occultation." This is an occultation in
+ which the foreground body blocks part,
+ but not all, of the limb of the
+ background body.
+
+
+
+ Target shape parameters
+ -----------------------
+
+ SPICE_GF_EDSHAP Parameter indicating a target object's
+ shape is modeled as an ellipsoid.
+
+ SPICE_GF_PTSHAP Parameter indicating a target object's
+ shape is modeled as a point.
+
+ SPICE_GF_RYSHAP Parameter indicating a target object's
+ "shape" is modeled as a ray emanating
+ from an observer's location. This model
+ may be used in visibility computations
+ for targets whose direction, but not
+ position, relative to an observer is
+ known.
+
+ SPICE_GF_SPSHAP Parameter indicating a target object's
+ shape is modeled as a point.
+
+
+
+ Search parameters
+ -----------------
+
+ These parameters affect the manner in which GF searches are
+ performed.
+
+ SPICE_GF_ADDWIN is a parameter used in numeric quantity
+ searches that use an equality
+ constraint. This parameter is used to
+ expand the confinement window (the
+ window over which the search is
+ performed) by a small amount at both
+ ends. This expansion accommodates the
+ case where a geometric quantity is equal
+ to a reference value at a boundary point
+ of the original confinement window.
+
+ SPICE_GF_CNVTOL is the default convergence tolerance
+ used by GF routines that don't support a
+ user-supplied tolerance value. GF
+ searches for roots will terminate when a
+ root is bracketed by times separated by
+ no more than this tolerance. Units are
+ seconds.
+
+ Configuration parameter
+ -----------------------
+
+ SPICE_GFEVNT_MAXPAR Parameter indicating the maximum number of
+ elements needed for the 'qnames' and 'q*pars'
+ arrays used in gfevnt_c.
+
+ SpiceChar qcpars[SPICE_GFEVNT_MAXPAR][LNSIZE];
+ SpiceDouble qdpars[SPICE_GFEVNT_MAXPAR];
+ SpiceInt qipars[SPICE_GFEVNT_MAXPAR];
+ SpiceBoolean qlpars[SPICE_GFEVNT_MAXPAR];
+
+-Examples
+
+ None
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ L.S. Elson (JPL)
+
+-Version
+
+ -CSPICE Version 2.0.0, 23-JUN-2009 (NJB)
+
+ Added parameter for maximum length of FOV shape string.
+
+ -CSPICE Version 1.0.0, 11-MAR-2009 (NJB)
+
+*/
+
+
+#ifndef HAVE_SPICE_GF_H
+
+ #define HAVE_SPICE_GF_H
+
+
+ /*
+ See the Particulars section above for parameter descriptions.
+ */
+
+ /*
+ Workspace parameters
+ */
+ #define SPICE_GF_NWMAX 15
+ #define SPICE_GF_NWDIST 5
+ #define SPICE_GF_NWSEP 5
+
+
+ /*
+ Field of view (FOV) parameters
+ */
+ #define SPICE_GF_MAXVRT 10000
+ #define SPICE_GF_CIRFOV "CIRCLE"
+ #define SPICE_GF_ELLFOV "ELLIPSE"
+ #define SPICE_GF_POLFOV "POLYGON"
+ #define SPICE_GF_RECFOV "RECTANGLE"
+ #define SPICE_GF_SHPLEN 10
+ #define SPICE_GF_MARGIN ( 1.e-12 )
+
+
+ /*
+ Occultation parameters
+ */
+ #define SPICE_GF_ANNULR "ANNULAR"
+ #define SPICE_GF_ANY "ANY"
+ #define SPICE_GF_FULL "FULL"
+ #define SPICE_GF_PARTL "PARTIAL"
+
+
+ /*
+ Target shape parameters
+ */
+ #define SPICE_GF_EDSHAP "ELLIPSOID"
+ #define SPICE_GF_PTSHAP "POINT"
+ #define SPICE_GF_RYSHAP "RAY"
+ #define SPICE_GF_SPSHAP "SPHERE"
+
+
+ /*
+ Search parameters
+ */
+ #define SPICE_GF_ADDWIN 1.0
+ #define SPICE_GF_CNVTOL 1.e-6
+
+
+ /*
+ Configuration parameters.
+ */
+ #define SPICE_GFEVNT_MAXPAR 10
+
+
+#endif
+
+
+/*
+ End of header file SpiceGF.h
+*/
diff --git a/ext/spice/include/SpicePln.h b/ext/spice/include/SpicePln.h
new file mode 100644
index 0000000000..839fb15606
--- /dev/null
+++ b/ext/spice/include/SpicePln.h
@@ -0,0 +1,106 @@
+/*
+
+-Header_File SpicePln.h ( CSPICE Plane definitions )
+
+-Abstract
+
+ Perform CSPICE definitions for the SpicePlane data type.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header defines structures and typedefs that may be referenced in
+ application code that calls CSPICE Plane functions.
+
+
+ Structures
+ ==========
+
+ Name Description
+ ---- ----------
+
+ SpicePlane Structure representing a plane in 3-
+ dimensional space.
+
+ The members are:
+
+ normal: Vector normal to plane.
+
+ constant: Constant of plane equation
+
+ Plane =
+
+ {X: = constant}
+
+
+
+ ConstSpicePlane A const SpicePlane.
+
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 04-MAR-1999 (NJB)
+
+*/
+
+#ifndef HAVE_SPICE_PLANES
+
+ #define HAVE_SPICE_PLANES
+
+
+
+ /*
+ Plane structure:
+ */
+
+ struct _SpicePlane
+
+ { SpiceDouble normal [3];
+ SpiceDouble constant; };
+
+ typedef struct _SpicePlane SpicePlane;
+
+ typedef const SpicePlane ConstSpicePlane;
+
+#endif
+
diff --git a/ext/spice/include/SpiceSPK.h b/ext/spice/include/SpiceSPK.h
new file mode 100644
index 0000000000..a4c8eac5f7
--- /dev/null
+++ b/ext/spice/include/SpiceSPK.h
@@ -0,0 +1,128 @@
+/*
+
+-Header_File SpiceSPK.h ( CSPICE SPK definitions )
+
+-Abstract
+
+ Perform CSPICE definitions to support SPK wrapper interfaces.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header defines types that may be referenced in
+ application code that calls CSPICE SPK functions.
+
+ Typedef
+ =======
+
+ Name Description
+ ---- ----------
+
+ SpiceSPK18Subtype Typedef for enum indicating the
+ mathematical representation used
+ in an SPK type 18 segment. Possible
+ values and meanings are:
+
+ S18TP0:
+
+ Hermite interpolation, 12-
+ element packets containing
+
+ x, y, z, dx/dt, dy/dt, dz/dt,
+ vx, vy, vz, dvx/dt, dvy/dt, dvz/dt
+
+ where x, y, z represent Cartesian
+ position components and vx, vy, vz
+ represent Cartesian velocity
+ components. Note well: vx, vy, and
+ vz *are not necessarily equal* to the
+ time derivatives of x, y, and z.
+ This packet structure mimics that of
+ the Rosetta/MEX orbit file from which
+ the data are taken.
+
+ Position units are kilometers,
+ velocity units are kilometers per
+ second, and acceleration units are
+ kilometers per second per second.
+
+
+ S18TP1:
+
+ Lagrange interpolation, 6-
+ element packets containing
+
+ x, y, z, dx/dt, dy/dt, dz/dt
+
+ where x, y, z represent Cartesian
+ position components and vx, vy, vz
+ represent Cartesian velocity
+ components.
+
+ Position units are kilometers;
+ velocity units are kilometers per
+ second.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 16-AUG-2002 (NJB)
+
+*/
+
+#ifndef HAVE_SPICE_SPK_H
+
+ #define HAVE_SPICE_SPK_H
+
+
+
+ /*
+ SPK type 18 subtype codes:
+ */
+
+ enum _SpiceSPK18Subtype { S18TP0, S18TP1 };
+
+
+ typedef enum _SpiceSPK18Subtype SpiceSPK18Subtype;
+
+#endif
+
diff --git a/ext/spice/include/SpiceUsr.h b/ext/spice/include/SpiceUsr.h
new file mode 100644
index 0000000000..83038e32a3
--- /dev/null
+++ b/ext/spice/include/SpiceUsr.h
@@ -0,0 +1,217 @@
+/*
+
+-Header_File SpiceUsr.h ( CSPICE user interface definitions )
+
+-Abstract
+
+ Perform CSPICE user interface declarations, including type
+ definitions and function prototype declarations.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This file is an umbrella header that includes all header files
+ required to support the CSPICE application programming interface
+ (API). Users' application code that calls CSPICE need include only
+ this single header file. This file includes function prototypes for
+ the entire set of CSPICE routines. Typedef statements used to create
+ SPICE data types are also included.
+
+
+ About SPICE data types
+ ======================
+
+ To assist with long-term maintainability of CSPICE, NAIF has elected
+ to use typedefs to represent data types occurring in argument lists
+ and as return values of CSPICE functions. These are:
+
+ SpiceBoolean
+ SpiceChar
+ SpiceDouble
+ SpiceInt
+ ConstSpiceBoolean
+ ConstSpiceChar
+ ConstSpiceDouble
+ ConstSpiceInt
+
+ The SPICE typedefs map in an arguably natural way to ANSI C types:
+
+ SpiceBoolean -> enum { SPICEFALSE = 0, SPICETRUE = 1 }
+ SpiceChar -> char
+ SpiceDouble -> double
+ SpiceInt -> int or long
+ ConstX -> const X (X = any of the above types)
+
+ The type SpiceInt is a special case: the corresponding type is picked
+ so as to be half the size of a double. On all currently supported
+ platforms, type double occupies 8 bytes and type int occupies 4
+ bytes. Other platforms may require a SpiceInt to map to type long.
+
+ While other data types may be used internally in CSPICE, no other
+ types appear in the API.
+
+
+ About CSPICE function prototypes
+ ================================
+
+ Because CSPICE function prototypes enable substantial
+ compile-time error checking, we recommend that user
+ applications always reference them. Including the header
+ file SpiceUsr.h in any module that calls CSPICE will
+ automatically make the prototypes available.
+
+
+ About CSPICE C style
+ ====================
+
+ CSPICE is written in ANSI C. No attempt has been made to support K&R
+ conventions or restrictions.
+
+
+ About C++ compatibility
+ =======================
+
+ The preprocessor directive -D__cplusplus should be used when
+ compiling C++ source code that includes this header file. This
+ directive will suppress mangling of CSPICE names, permitting linkage
+ to a CSPICE object library built from object modules produced by
+ an ANSI C compiler.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ E.D. Wright (JPL)
+
+-Restrictions
+
+ The #include statements contained in this file are not part of
+ the CSPICE API. The set of files included may change without notice.
+ Users should not include these files directly in their own
+ application code.
+
+-Version
+
+ -CSPICE Version 4.0.0, 30-SEP-2008 (NJB)
+
+ Updated to include header file
+
+ SpiceGF.h
+
+ -CSPICE Version 3.0.0, 19-AUG-2002 (NJB)
+
+ Updated to include header files
+
+ SpiceCel.h
+ SpiceCK.h
+ SpiceSPK.h
+
+ -CSPICE Version 3.0.0, 17-FEB-1999 (NJB)
+
+ Updated to support suppression of name mangling when included in
+ C++ source code. Also now interface macros to intercept function
+ calls and perform automatic type casting.
+
+ Now includes platform macro definition header file.
+
+ References to types SpiceVoid and ConstSpiceVoid were removed.
+
+ -CSPICE Version 2.0.0, 06-MAY-1998 (NJB) (EDW)
+
+*/
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+#ifndef HAVE_SPICE_USER
+
+ #define HAVE_SPICE_USER
+
+
+ /*
+ Include CSPICE platform macro definitions.
+ */
+ #include "SpiceZpl.h"
+
+ /*
+ Include CSPICE data type definitions.
+ */
+ #include "SpiceZdf.h"
+
+ /*
+ Include the CSPICE EK interface definitions.
+ */
+ #include "SpiceEK.h"
+
+ /*
+ Include the CSPICE Cell interface definitions.
+ */
+ #include "SpiceCel.h"
+
+ /*
+ Include the CSPICE CK interface definitions.
+ */
+ #include "SpiceCK.h"
+
+ /*
+ Include the CSPICE SPK interface definitions.
+ */
+ #include "SpiceSPK.h"
+
+ /*
+ Include the CSPICE GF interface definitions.
+ */
+ #include "SpiceGF.h"
+
+ /*
+ Include CSPICE prototypes.
+ */
+ #include "SpiceZpr.h"
+
+ /*
+ Define the CSPICE function interface macros.
+ */
+ #include "SpiceZim.h"
+
+
+
+#endif
+
+
+#ifdef __cplusplus
+ }
+#endif
+
diff --git a/ext/spice/include/SpiceZad.h b/ext/spice/include/SpiceZad.h
new file mode 100644
index 0000000000..f838e7f31c
--- /dev/null
+++ b/ext/spice/include/SpiceZad.h
@@ -0,0 +1,205 @@
+/*
+
+-Header_File SpiceZad.h ( CSPICE adapter definitions )
+
+-Abstract
+
+ Perform CSPICE declarations to support passed-in function
+ adapters used in wrapper interfaces.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header file contains declarations used by the CSPICE
+ passed-in function adapter ("PFA") system. This system enables
+ CSPICE wrapper functions to support passed-in function
+ arguments whose prototypes are C-style, even when these
+ functions are to be called from f2c'd Fortran routines
+ expecting f2c-style interfaces.
+
+ This header declares:
+
+ - The prototype for the passed-in function argument
+ pointer storage and fetch routines
+
+ zzadsave_c
+ zzadget_c
+
+ - Prototypes for CSPICE adapter functions. Each passed-in
+ function argument in a CSPICE wrapper has a corresponding
+ adapter function. The adapter functions have interfaces
+ that match those of their f2c'd counterparts; this allows
+ the adapters to be called by f2c'd SPICELIB code. The
+ adapters look up saved function pointers for routines
+ passed in by the wrapper's caller and call these functions.
+
+ - Values for the enumerated type SpicePassedInFunc. These
+ values are used to map function pointers to the
+ functions they represent, enabling adapters to call
+ the correct passed-in functions.
+
+Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 2.1.0, 21-DEC-2009 (EDW)
+
+ Updated to support the user defined scalar function capability.
+
+ -CSPICE Version 2.0.0, 29-JAN-2009 (NJB)
+
+ Now conditionally includes SpiceZfc.h.
+
+ Updated to reflect new calling sequence of f2c'd
+ routine gfrefn_. Some header updates were made
+ as well.
+
+ -CSPICE Version 1.0.0, 29-MAR-2008 (NJB)
+
+*/
+
+
+/*
+ This file has dependencies defined in SpiceZfc.h. Include that
+ file if it hasn't already been included.
+*/
+#ifndef HAVE_SPICEF2C_H
+ #include "SpiceZfc.h"
+#endif
+
+
+
+#ifndef HAVE_SPICE_ZAD_H
+
+ #define HAVE_SPICE_ZAD_H
+
+
+
+ /*
+ Prototypes for GF adapters:
+ */
+
+ logical zzadbail_c ( void );
+
+
+ int zzadstep_c ( doublereal * et,
+ doublereal * step );
+
+
+ int zzadrefn_c ( doublereal * t1,
+ doublereal * t2,
+ logical * s1,
+ logical * s2,
+ doublereal * t );
+
+
+ int zzadrepf_c ( void );
+
+
+ int zzadrepi_c ( doublereal * cnfine,
+ char * srcpre,
+ char * srcsuf,
+ ftnlen srcprelen,
+ ftnlen srcsuflen );
+
+
+ int zzadrepu_c ( doublereal * ivbeg,
+ doublereal * ivend,
+ doublereal * et );
+
+
+ int zzadfunc_c ( doublereal * et,
+ doublereal * value );
+
+
+ int zzadqdec_c ( U_fp udfunc,
+ doublereal * et,
+ logical * xbool );
+
+ /*
+ Define the enumerated type
+
+ SpicePassedInFunc
+
+ for names of passed-in functions. Using this type gives
+ us compile-time checking and avoids string comparisons.
+ */
+ enum _SpicePassedInFunc {
+ UDBAIL,
+ UDREFN,
+ UDREPF,
+ UDREPI,
+ UDREPU,
+ UDSTEP,
+ UDFUNC,
+ UDQDEC,
+ };
+
+ typedef enum _SpicePassedInFunc SpicePassedInFunc;
+
+ /*
+ SPICE_N_PASSED_IN_FUNC is the count of SpicePassedInFunc values.
+ */
+ #define SPICE_N_PASSED_IN_FUNC 8
+
+
+ /*
+ CSPICE wrappers supporting passed-in function arguments call
+ the adapter setup interface function once per each such argument;
+ these calls save the function pointers for later use within the
+ f2c'd code that calls passed-in functions. The saved pointers
+ will be used in calls by the adapter functions whose prototypes
+ are declared above.
+
+ Prototypes for adapter setup interface:
+ */
+ void zzadsave_c ( SpicePassedInFunc functionID,
+ void * functionPtr );
+
+ void * zzadget_c ( SpicePassedInFunc functionID );
+
+
+#endif
+
+/*
+End of header file SpiceZad.h
+*/
+
diff --git a/ext/spice/include/SpiceZdf.h b/ext/spice/include/SpiceZdf.h
new file mode 100644
index 0000000000..36276051d6
--- /dev/null
+++ b/ext/spice/include/SpiceZdf.h
@@ -0,0 +1,246 @@
+/*
+
+-Header_File SpiceZdf.h ( CSPICE definitions )
+
+-Abstract
+
+ Define CSPICE data types via typedefs; also define some user-visible
+ enumerated types.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ CSPICE data types
+ =================
+
+ To assist with long-term maintainability of CSPICE, NAIF has elected
+ to use typedefs to represent data types occurring in argument lists
+ and as return values of CSPICE functions. These are:
+
+ SpiceBoolean
+ SpiceChar
+ SpiceDouble
+ SpiceInt
+ ConstSpiceBoolean
+ ConstSpiceChar
+ ConstSpiceDouble
+ ConstSpiceInt
+
+ The SPICE typedefs map in an arguably natural way to ANSI C types:
+
+ SpiceBoolean -> int
+ SpiceChar -> char
+ SpiceDouble -> double
+ SpiceInt -> int or long
+ ConstX -> const X (X = any of the above types)
+
+ The type SpiceInt is a special case: the corresponding type is picked
+ so as to be half the size of a double. On most currently supported
+ platforms, type double occupies 8 bytes and type long occupies 4
+ bytes. Other platforms may require a SpiceInt to map to type int.
+ The Alpha/Digital Unix platform is an example of the latter case.
+
+ While other data types may be used internally in CSPICE, no other
+ types appear in the API.
+
+
+ CSPICE enumerated types
+ =======================
+
+ These are provided to enhance readability of the code.
+
+ Type name Value set
+ --------- ---------
+
+ _Spicestatus { SPICEFAILURE = -1, SPICESUCCESS = 0 }
+
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ B.V. Semenov (JPL)
+ E.D. Wright (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 6.1.0, 14-MAY-2010 (EDW)(BVS)
+
+ Updated for:
+
+ MAC-OSX-64BIT-INTEL_C
+ SUN-SOLARIS-64BIT-NATIVE_C
+ SUN-SOLARIS-INTEL-64BIT-CC_C
+
+ environments. Added the corresponding tags:
+
+ CSPICE_MAC_OSX_INTEL_64BIT_GCC
+ CSPICE_SUN_SOLARIS_64BIT_NATIVE
+ CSPICE_SUN_SOLARIS_INTEL_64BIT_CC
+
+ tag to the #ifdefs set.
+
+ -CSPICE Version 6.0.0, 21-FEB-2006 (NJB)
+
+ Updated to support the PC Linux 64 bit mode/gcc platform.
+
+ -CSPICE Version 5.0.0, 27-JAN-2003 (NJB)
+
+ Updated to support the Sun Solaris 64 bit mode/gcc platform.
+
+ -CSPICE Version 4.0.0 27-JUL-2002 (NJB)
+
+ Added definition of SpiceDataType.
+
+ -CSPICE Version 3.0.0 18-SEP-1999 (NJB)
+
+ SpiceBoolean implementation changed from enumerated type to
+ typedef mapping to int.
+
+ -CSPICE Version 2.0.0 29-JAN-1999 (NJB)
+
+ Made definition of SpiceInt and ConstSpiceInt platform
+ dependent to accommodate the Alpha/Digital Unix platform.
+
+ Removed definitions of SpiceVoid and ConstSpiceVoid.
+
+ -CSPICE Version 1.0.0 25-OCT-1997 (KRG) (NJB) (EDW)
+*/
+
+ #ifndef HAVE_SPICEDEFS_H
+ #define HAVE_SPICEDEFS_H
+
+ /*
+ Include platform definitions, if they haven't been executed already.
+ */
+ #ifndef HAVE_PLATFORM_MACROS_H
+ #include "SpiceZpl.h"
+ #endif
+
+ /*
+ Basic data types. These are defined to be compatible with the
+ types used by f2c, and so they follow the Fortran notion of what
+ these things are. See the f2c documentation for the details
+ about the choices for the sizes of these types.
+ */
+ typedef char SpiceChar;
+ typedef double SpiceDouble;
+ typedef float SpiceFloat;
+
+
+
+ #if ( defined(CSPICE_ALPHA_DIGITAL_UNIX ) \
+ || defined(CSPICE_SUN_SOLARIS_64BIT_NATIVE) \
+ || defined(CSPICE_SUN_SOLARIS_64BIT_GCC ) \
+ || defined(CSPICE_MAC_OSX_INTEL_64BIT_GCC ) \
+ || defined(CSPICE_SUN_SOLARIS_INTEL_64BIT_CC ) \
+ || defined(CSPICE_PC_LINUX_64BIT_GCC ) )
+
+ typedef int SpiceInt;
+ #else
+ typedef long SpiceInt;
+ #endif
+
+
+ typedef const char ConstSpiceChar;
+ typedef const double ConstSpiceDouble;
+ typedef const float ConstSpiceFloat;
+
+
+ #if ( defined(CSPICE_ALPHA_DIGITAL_UNIX ) \
+ || defined(CSPICE_SUN_SOLARIS_64BIT_NATIVE) \
+ || defined(CSPICE_SUN_SOLARIS_64BIT_GCC ) \
+ || defined(CSPICE_MAC_OSX_INTEL_64BIT_GCC ) \
+ || defined(CSPICE_SUN_SOLARIS_INTEL_64BIT_CC ) \
+ || defined(CSPICE_PC_LINUX_64BIT_GCC ) )
+
+ typedef const int ConstSpiceInt;
+ #else
+ typedef const long ConstSpiceInt;
+ #endif
+
+
+ /*
+ More basic data types. These give mnemonics for some other data
+ types in C that are not used in Fortran written by NAIF or
+ supported by ANSI Fortran 77. These are for use in C functions
+ but should not be passed to any C SPICE wrappers, ``*_c.c''
+ since they are not Fortran compatible.
+ */
+ typedef long SpiceLong;
+ typedef short SpiceShort;
+
+ /*
+ Unsigned data types
+ */
+ typedef unsigned char SpiceUChar;
+ typedef unsigned int SpiceUInt;
+ typedef unsigned long SpiceULong;
+ typedef unsigned short SpiceUShort;
+
+ /*
+ Signed data types
+ */
+ typedef signed char SpiceSChar;
+
+ /*
+ Other basic types
+ */
+ typedef int SpiceBoolean;
+ typedef const int ConstSpiceBoolean;
+
+ #define SPICETRUE 1
+ #define SPICEFALSE 0
+
+
+ enum _Spicestatus { SPICEFAILURE = -1, SPICESUCCESS = 0 };
+
+ typedef enum _Spicestatus SpiceStatus;
+
+
+ enum _SpiceDataType { SPICE_CHR = 0,
+ SPICE_DP = 1,
+ SPICE_INT = 2,
+ SPICE_TIME = 3,
+ SPICE_BOOL = 4 };
+
+
+ typedef enum _SpiceDataType SpiceDataType;
+
+
+#endif
diff --git a/ext/spice/include/SpiceZfc.h b/ext/spice/include/SpiceZfc.h
new file mode 100644
index 0000000000..33f541770b
--- /dev/null
+++ b/ext/spice/include/SpiceZfc.h
@@ -0,0 +1,13228 @@
+/*
+
+-Header_File SpiceZfc.h ( f2c'd SPICELIB prototypes )
+
+-Abstract
+
+ Define prototypes for functions produced by converting Fortran
+ SPICELIB routines to C using f2c.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ B.V. Semenov (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ - CSPICE Version 6.1.0, 14-MAY-2010 (EDW)(BVS)
+
+ Updated for:
+
+ MAC-OSX-64BIT-INTEL_C
+ SUN-SOLARIS-64BIT-NATIVE_C
+ SUN-SOLARIS-INTEL-64BIT-CC_C
+
+ environments. Added the corresponding tags:
+
+ CSPICE_MAC_OSX_INTEL_64BIT_GCC
+ CSPICE_SUN_SOLARIS_64BIT_NATIVE
+ CSPICE_SUN_SOLARIS_INTEL_64BIT_CC
+
+ tag to the #ifdefs set.
+
+ - CSPICE Version 6.0.0, 21-FEB-2006 (NJB)
+
+ Added typedefs for the PC-LINUX-64BIT-GCC_C
+ environment (these are identical to those for the
+ ALPHA-DIGITAL-UNIX_C environment).
+
+ - C-SPICELIB Version 5.0.0, 06-MAR-2005 (NJB)
+
+ Added typedefs for pointers to functions. This change was
+ made to support CSPICE wrappers for geometry finder routines.
+
+ Added typedefs for the SUN-SOLARIS-64BIT-GCC_C
+ environment (these are identical to those for the
+ ALPHA-DIGITAL-UNIX_C environment).
+
+ - C-SPICELIB Version 4.1.0, 24-MAY-2001 (WLT)
+
+ Moved the #ifdef __cplusplus so that it appears after the
+ typedefs. This allows us to more easily wrap CSPICE in a
+ namespace for C++.
+
+ - C-SPICELIB Version 4.0.0, 09-FEB-1999 (NJB)
+
+ Updated to accommodate the Alpha/Digital Unix platform.
+ Also updated to support inclusion in C++ code.
+
+ - C-SPICELIB Version 3.0.0, 02-NOV-1998 (NJB)
+
+ Updated for SPICELIB version N0049.
+
+ - C-SPICELIB Version 2.0.0, 15-SEP-1997 (NJB)
+
+ Changed variable name "typid" to "typid" in prototype
+ for zzfdat_. This was done to enable compilation under
+ Borland C++.
+
+ - C-SPICELIB Version 1.0.0, 15-SEP-1997 (NJB) (KRG)
+
+-Index_Entries
+
+ prototypes of f2c'd SPICELIB functions
+
+*/
+
+
+#ifndef HAVE_SPICEF2C_H
+#define HAVE_SPICEF2C_H
+
+
+
+/*
+ Include Files:
+
+ Many of the prototypes below use data types defined by f2c. We
+ copy here the f2c definitions that occur in prototypes of functions
+ produced by running f2c on Fortran SPICELIB routines.
+
+ The reason we don't simply conditionally include f2c.h itself here
+ is that f2c.h defines macros that conflict with stdlib.h on some
+ systems. It's simpler to just replicate the few typedefs we need.
+*/
+
+#if ( defined( CSPICE_ALPHA_DIGITAL_UNIX ) \
+ || defined( CSPICE_PC_LINUX_64BIT_GCC ) \
+ || defined( CSPICE_MAC_OSX_INTEL_64BIT_GCC ) \
+ || defined( CSPICE_SUN_SOLARIS_INTEL_64BIT_CC ) \
+ || defined( CSPICE_SUN_SOLARIS_64BIT_NATIVE) \
+ || defined( CSPICE_SUN_SOLARIS_64BIT_GCC ) )
+
+ #define VOID void
+
+ typedef VOID H_f;
+ typedef int integer;
+ typedef double doublereal;
+ typedef int logical;
+ typedef int ftnlen;
+
+
+ /*
+ Type H_fp is used for character return type.
+ Type S_fp is used for subroutines.
+ Type U_fp is used for functions of unknown type.
+ */
+ typedef VOID (*H_fp)();
+ typedef doublereal (*D_fp)();
+ typedef doublereal (*E_fp)();
+ typedef int (*S_fp)();
+ typedef int (*U_fp)();
+ typedef integer (*I_fp)();
+ typedef logical (*L_fp)();
+
+#else
+
+ #define VOID void
+
+ typedef VOID H_f;
+ typedef long integer;
+ typedef double doublereal;
+ typedef long logical;
+ typedef long ftnlen;
+
+ /*
+ Type H_fp is used for character return type.
+ Type S_fp is used for subroutines.
+ Type U_fp is used for functions of unknown type.
+ */
+ typedef VOID (*H_fp)();
+ typedef doublereal (*D_fp)();
+ typedef doublereal (*E_fp)();
+ typedef int (*S_fp)();
+ typedef int (*U_fp)();
+ typedef integer (*I_fp)();
+ typedef logical (*L_fp)();
+
+#endif
+
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+/*
+ Function prototypes for functions created by f2c are listed below.
+ See the headers of the Fortran routines for descriptions of the
+ routines' interfaces.
+
+ The functions listed below are those expected to be called by
+ C-SPICELIB wrappers. Prototypes are not currently provided for other
+ f2c'd functions.
+
+*/
+
+/*
+-Prototypes
+*/
+
+extern logical accept_(logical *ok);
+extern logical allowd_(void);
+
+extern logical alltru_(logical *logcls, integer *n);
+
+extern H_f ana_(char *ret_val, ftnlen ret_val_len, char *word, char *case__, ftnlen word_len, ftnlen case_len);
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: replch_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+
+extern int appndc_(char *item, char *cell, ftnlen item_len, ftnlen cell_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int appndd_(doublereal *item, doublereal *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int appndi_(integer *item, integer *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical approx_(doublereal *x, doublereal *y, doublereal *tol);
+
+extern int astrip_(char *instr, char *asciib, char *asciie, char *outstr, ftnlen instr_len, ftnlen asciib_len, ftnlen asciie_len, ftnlen outstr_len);
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int axisar_(doublereal *axis, doublereal *angle, doublereal *r__);
+/*:ref: ident_ 14 1 7 */
+/*:ref: vrotv_ 14 4 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern doublereal b1900_(void);
+
+extern doublereal b1950_(void);
+
+extern logical badkpv_(char *caller, char *name__, char *comp, integer *size, integer *divby, char *type__, ftnlen caller_len, ftnlen name_len, ftnlen comp_len, ftnlen type_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: eqchr_ 12 4 13 13 124 124 */
+
+extern logical bedec_(char *string, ftnlen string_len);
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+/*:ref: beint_ 12 2 13 124 */
+/*:ref: beuns_ 12 2 13 124 */
+
+extern logical beint_(char *string, ftnlen string_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: beuns_ 12 2 13 124 */
+
+extern logical benum_(char *string, ftnlen string_len);
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+/*:ref: bedec_ 12 2 13 124 */
+/*:ref: beint_ 12 2 13 124 */
+
+extern logical beuns_(char *string, ftnlen string_len);
+/*:ref: frstnb_ 4 2 13 124 */
+
+extern int bodc2n_(integer *code, char *name__, logical *found, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzbodc2n_ 14 4 4 13 12 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int bodc2s_(integer *code, char *name__, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzbodc2n_ 14 4 4 13 12 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+
+extern int boddef_(char *name__, integer *code, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzboddef_ 14 3 13 4 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int bodeul_(integer *body, doublereal *et, doublereal *ra, doublereal *dec, doublereal *w, doublereal *lambda);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: pckeul_ 14 6 4 7 12 13 7 124 */
+/*:ref: bodfnd_ 12 3 4 13 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: rpd_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: zzbodbry_ 4 1 4 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: spd_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: m2eul_ 14 7 7 4 4 4 7 7 7 */
+
+extern logical bodfnd_(integer *body, char *item, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int bodmat_(integer *body, doublereal *et, doublereal *tipm);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: pckmat_ 14 5 4 7 4 7 12 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: ccifrm_ 14 7 4 4 4 13 4 12 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzbodbry_ 4 1 4 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: spd_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: bodfnd_ 12 3 4 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: rpd_ 7 0 */
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: twopi_ 7 0 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int bodn2c_(char *name__, integer *code, logical *found, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzbodn2c_ 14 4 13 4 12 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int bods2c_(char *name__, integer *code, logical *found, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzbodn2c_ 14 4 13 4 12 124 */
+/*:ref: beint_ 12 2 13 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int bodvar_(integer *body, char *item, integer *dim, doublereal *values, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: rtpool_ 14 5 13 4 7 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int bodvcd_(integer *bodyid, char *item, integer *maxn, integer *dim, doublereal *values, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+
+extern int bodvrd_(char *bodynm, char *item, integer *maxn, integer *dim, doublereal *values, ftnlen bodynm_len, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+
+extern doublereal brcktd_(doublereal *number, doublereal *end1, doublereal *end2);
+
+extern integer brckti_(integer *number, integer *end1, integer *end2);
+
+extern integer bschoc_(char *value, integer *ndim, char *array, integer *order, ftnlen value_len, ftnlen array_len);
+
+extern integer bschoi_(integer *value, integer *ndim, integer *array, integer *order);
+
+extern integer bsrchc_(char *value, integer *ndim, char *array, ftnlen value_len, ftnlen array_len);
+
+extern integer bsrchd_(doublereal *value, integer *ndim, doublereal *array);
+
+extern integer bsrchi_(integer *value, integer *ndim, integer *array);
+
+extern integer cardc_(char *cell, ftnlen cell_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dechar_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer cardd_(doublereal *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer cardi_(integer *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int cgv2el_(doublereal *center, doublereal *vec1, doublereal *vec2, doublereal *ellips);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: saelgv_ 14 4 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer chbase_(void);
+
+extern int chbder_(doublereal *cp, integer *degp, doublereal *x2s, doublereal *x, integer *nderiv, doublereal *partdp, doublereal *dpdxs);
+
+extern int chbint_(doublereal *cp, integer *degp, doublereal *x2s, doublereal *x, doublereal *p, doublereal *dpdx);
+
+extern int chbval_(doublereal *cp, integer *degp, doublereal *x2s, doublereal *x, doublereal *p);
+
+extern int chckid_(char *class__, integer *maxlen, char *id, ftnlen class_len, ftnlen id_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int chgirf_(integer *refa, integer *refb, doublereal *rotab, char *name__, integer *index, ftnlen name_len);
+extern int irfrot_(integer *refa, integer *refb, doublereal *rotab);
+extern int irfnum_(char *name__, integer *index, ftnlen name_len);
+extern int irfnam_(integer *index, char *name__, ftnlen name_len);
+extern int irfdef_(integer *index);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rotate_ 14 3 7 4 7 */
+/*:ref: wdcnt_ 4 2 13 124 */
+/*:ref: nthwd_ 14 6 13 4 13 4 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: rotmat_ 14 4 7 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: mxmt_ 14 3 7 7 7 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: esrchc_ 4 5 13 4 13 124 124 */
+
+extern int ckbsr_(char *fname, integer *handle, integer *inst, doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *descr, char *segid, logical *found, ftnlen fname_len, ftnlen segid_len);
+extern int cklpf_(char *fname, integer *handle, ftnlen fname_len);
+extern int ckupf_(integer *handle);
+extern int ckbss_(integer *inst, doublereal *sclkdp, doublereal *tol, logical *needav);
+extern int cksns_(integer *handle, doublereal *descr, char *segid, logical *found, ftnlen segid_len);
+extern int ckhave_(logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnktl_ 4 2 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: lnkprv_ 4 2 4 4 */
+/*:ref: dpmin_ 7 0 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafbbs_ 14 1 4 */
+/*:ref: daffpa_ 14 1 12 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: dafgn_ 14 2 13 124 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+
+extern int ckcls_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int ckcov_(char *ck, integer *idcode, logical *needav, char *level, doublereal *tol, char *timsys, doublereal *cover, ftnlen ck_len, ftnlen level_len, ftnlen timsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: ckmeta_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+/*:ref: zzckcv01_ 14 8 4 4 4 4 7 13 7 124 */
+/*:ref: zzckcv02_ 14 8 4 4 4 4 7 13 7 124 */
+/*:ref: zzckcv03_ 14 8 4 4 4 4 7 13 7 124 */
+/*:ref: zzckcv04_ 14 8 4 4 4 4 7 13 7 124 */
+/*:ref: zzckcv05_ 14 9 4 4 4 4 7 7 13 7 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int cke01_(logical *needav, doublereal *record, doublereal *cmat, doublereal *av, doublereal *clkout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: q2m_ 14 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int cke02_(logical *needav, doublereal *record, doublereal *cmat, doublereal *av, doublereal *clkout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vequg_ 14 3 7 4 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: axisar_ 14 3 7 7 7 */
+/*:ref: q2m_ 14 2 7 7 */
+/*:ref: mxmt_ 14 3 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int cke03_(logical *needav, doublereal *record, doublereal *cmat, doublereal *av, doublereal *clkout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: q2m_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: mtxm_ 14 3 7 7 7 */
+/*:ref: raxisa_ 14 3 7 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: axisar_ 14 3 7 7 7 */
+/*:ref: mxmt_ 14 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int cke04_(logical *needav, doublereal *record, doublereal *cmat, doublereal *av, doublereal *clkout);
+/*:ref: chbval_ 14 5 7 4 7 7 7 */
+/*:ref: vhatg_ 14 3 7 4 7 */
+/*:ref: q2m_ 14 2 7 7 */
+
+extern int cke05_(logical *needav, doublereal *record, doublereal *cmat, doublereal *av, doublereal *clkout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vminug_ 14 3 7 4 7 */
+/*:ref: vdistg_ 7 3 7 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: xpsgip_ 14 3 4 4 7 */
+/*:ref: lgrind_ 14 7 4 7 7 7 7 7 7 */
+/*:ref: vnormg_ 7 2 7 4 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vsclg_ 14 4 7 7 4 7 */
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: qdq2av_ 14 3 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: lgrint_ 7 5 4 7 7 7 7 */
+/*:ref: vhatg_ 14 3 7 4 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: hrmint_ 14 7 4 7 7 7 7 7 7 */
+/*:ref: q2m_ 14 2 7 7 */
+
+extern int ckfrot_(integer *inst, doublereal *et, doublereal *rotate, integer *ref, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ckhave_ 14 1 12 */
+/*:ref: ckmeta_ 14 4 4 13 4 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzsclk_ 12 2 4 4 */
+/*:ref: sce2c_ 14 3 4 7 7 */
+/*:ref: ckbss_ 14 4 4 7 7 12 */
+/*:ref: cksns_ 14 5 4 7 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckpfs_ 14 9 4 7 7 7 12 7 7 7 12 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: xpose_ 14 2 7 7 */
+
+extern int ckfxfm_(integer *inst, doublereal *et, doublereal *xform, integer *ref, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ckmeta_ 14 4 4 13 4 124 */
+/*:ref: ckhave_ 14 1 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzsclk_ 12 2 4 4 */
+/*:ref: sce2c_ 14 3 4 7 7 */
+/*:ref: ckbss_ 14 4 4 7 7 12 */
+/*:ref: cksns_ 14 5 4 7 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckpfs_ 14 9 4 7 7 7 12 7 7 7 12 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: rav2xf_ 14 3 7 7 7 */
+/*:ref: invstm_ 14 2 7 7 */
+
+extern int ckgp_(integer *inst, doublereal *sclkdp, doublereal *tol, char *ref, doublereal *cmat, doublereal *clkout, logical *found, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ckbss_ 14 4 4 7 7 12 */
+/*:ref: cksns_ 14 5 4 7 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckpfs_ 14 9 4 7 7 7 12 7 7 7 12 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: ckmeta_ 14 4 4 13 4 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: refchg_ 14 4 4 4 7 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int ckgpav_(integer *inst, doublereal *sclkdp, doublereal *tol, char *ref, doublereal *cmat, doublereal *av, doublereal *clkout, logical *found, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ckbss_ 14 4 4 7 7 12 */
+/*:ref: cksns_ 14 5 4 7 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckpfs_ 14 9 4 7 7 7 12 7 7 7 12 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: ckmeta_ 14 4 4 13 4 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: frmchg_ 14 4 4 4 7 7 */
+/*:ref: xf2rav_ 14 3 7 7 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+
+extern int ckgr01_(integer *handle, doublereal *descr, integer *recno, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int ckgr02_(integer *handle, doublereal *descr, integer *recno, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cknr02_ 14 3 4 7 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int ckgr03_(integer *handle, doublereal *descr, integer *recno, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int ckgr04_(integer *handle, doublereal *descr, integer *recno, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cknr04_ 14 3 4 7 4 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+/*:ref: zzck4d2i_ 14 4 7 4 7 4 */
+
+extern int ckgr05_(integer *handle, doublereal *descr, integer *recno, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int ckmeta_(integer *ckid, char *meta, integer *idcode, ftnlen meta_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: bschoi_ 4 4 4 4 4 4 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: orderi_ 14 3 4 4 4 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int cknr01_(integer *handle, doublereal *descr, integer *nrec);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int cknr02_(integer *handle, doublereal *descr, integer *nrec);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int cknr03_(integer *handle, doublereal *descr, integer *nrec);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int cknr04_(integer *handle, doublereal *descr, integer *nrec);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+
+extern int cknr05_(integer *handle, doublereal *descr, integer *nrec);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int ckobj_(char *ck, integer *ids, ftnlen ck_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int ckopn_(char *name__, char *ifname, integer *ncomch, integer *handle, ftnlen name_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafonw_ 14 10 13 13 4 4 13 4 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ckpfs_(integer *handle, doublereal *descr, doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *cmat, doublereal *av, doublereal *clkout, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: ckr01_ 14 7 4 7 7 7 12 7 12 */
+/*:ref: cke01_ 14 5 12 7 7 7 7 */
+/*:ref: ckr02_ 14 6 4 7 7 7 7 12 */
+/*:ref: cke02_ 14 5 12 7 7 7 7 */
+/*:ref: ckr03_ 14 7 4 7 7 7 12 7 12 */
+/*:ref: cke03_ 14 5 12 7 7 7 7 */
+/*:ref: ckr04_ 14 7 4 7 7 7 12 7 12 */
+/*:ref: cke04_ 14 5 12 7 7 7 7 */
+/*:ref: ckr05_ 14 7 4 7 7 7 12 7 12 */
+/*:ref: cke05_ 14 5 12 7 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ckr01_(integer *handle, doublereal *descr, doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *record, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: lstcld_ 4 3 7 4 7 */
+
+extern int ckr02_(integer *handle, doublereal *descr, doublereal *sclkdp, doublereal *tol, doublereal *record, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: vequg_ 14 3 7 4 7 */
+
+extern int ckr03_(integer *handle, doublereal *descr, doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *record, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: dpmax_ 7 0 */
+
+extern int ckr04_(integer *handle, doublereal *descr, doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *record, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cknr04_ 14 3 4 7 4 */
+/*:ref: sgfrvi_ 14 6 4 7 7 7 4 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+/*:ref: zzck4d2i_ 14 4 7 4 7 4 */
+
+extern int ckr05_(integer *handle, doublereal *descr, doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *record, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int ckw01_(integer *handle, doublereal *begtim, doublereal *endtim, integer *inst, char *ref, logical *avflag, char *segid, integer *nrec, doublereal *sclkdp, doublereal *quats, doublereal *avvs, ftnlen ref_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: vzerog_ 12 2 7 4 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int ckw02_(integer *handle, doublereal *begtim, doublereal *endtim, integer *inst, char *ref, char *segid, integer *nrec, doublereal *start, doublereal *stop, doublereal *quats, doublereal *avvs, doublereal *rates, ftnlen ref_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: vzerog_ 12 2 7 4 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int ckw03_(integer *handle, doublereal *begtim, doublereal *endtim, integer *inst, char *ref, logical *avflag, char *segid, integer *nrec, doublereal *sclkdp, doublereal *quats, doublereal *avvs, integer *nints, doublereal *starts, ftnlen ref_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: vzerog_ 12 2 7 4 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int ckw04a_(integer *handle, integer *npkts, integer *pktsiz, doublereal *pktdat, doublereal *sclkdp);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzck4i2d_ 14 4 4 4 7 7 */
+/*:ref: sgwvpk_ 14 6 4 4 4 7 4 7 */
+
+extern int ckw04b_(integer *handle, doublereal *begtim, integer *inst, char *ref, logical *avflag, char *segid, ftnlen ref_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: sgbwvs_ 14 7 4 7 13 4 7 4 124 */
+
+extern int ckw04e_(integer *handle, doublereal *endtim);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgwes_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafbbs_ 14 1 4 */
+/*:ref: daffpa_ 14 1 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafrs_ 14 1 7 */
+
+extern int ckw05_(integer *handle, integer *subtyp, integer *degree, doublereal *begtim, doublereal *endtim, integer *inst, char *ref, logical *avflag, char *segid, integer *n, doublereal *sclkdp, doublereal *packts, doublereal *rate, integer *nints, doublereal *starts, ftnlen ref_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: bsrchd_ 4 3 7 4 7 */
+/*:ref: vzerog_ 12 2 7 4 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int clearc_(integer *ndim, char *array, ftnlen array_len);
+
+extern int cleard_(integer *ndim, doublereal *array);
+
+extern int cleari_(integer *ndim, integer *array);
+
+extern doublereal clight_(void);
+
+extern int cmprss_(char *delim, integer *n, char *input, char *output, ftnlen delim_len, ftnlen input_len, ftnlen output_len);
+
+extern int conics_(doublereal *elts, doublereal *et, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: prop2b_ 14 4 7 7 7 7 */
+
+extern int convrt_(doublereal *x, char *in, char *out, doublereal *y, ftnlen in_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dpr_ 7 0 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int copyc_(char *cell, char *copy, ftnlen cell_len, ftnlen copy_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: lastpc_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int copyd_(doublereal *cell, doublereal *copy);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int copyi_(integer *cell, integer *copy);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer countc_(integer *unit, integer *bline, integer *eline, char *line, ftnlen line_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: astrip_ 14 8 13 13 13 13 124 124 124 124 */
+
+extern integer cpos_(char *str, char *chars, integer *start, ftnlen str_len, ftnlen chars_len);
+
+extern integer cposr_(char *str, char *chars, integer *start, ftnlen str_len, ftnlen chars_len);
+
+extern int cyacip_(integer *nelt, char *dir, integer *ncycle, char *array, ftnlen dir_len, ftnlen array_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: nbwid_ 4 3 13 4 124 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyadip_(integer *nelt, char *dir, integer *ncycle, doublereal *array, ftnlen dir_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyaiip_(integer *nelt, char *dir, integer *ncycle, integer *array, ftnlen dir_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyclac_(char *array, integer *nelt, char *dir, integer *ncycle, char *out, ftnlen array_len, ftnlen dir_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+/*:ref: nbwid_ 4 3 13 4 124 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyclad_(doublereal *array, integer *nelt, char *dir, integer *ncycle, doublereal *out, ftnlen dir_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyclai_(integer *array, integer *nelt, char *dir, integer *ncycle, integer *out, ftnlen dir_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyclec_(char *instr, char *dir, integer *ncycle, char *outstr, ftnlen instr_len, ftnlen dir_len, ftnlen outstr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyllat_(doublereal *r__, doublereal *longc, doublereal *z__, doublereal *radius, doublereal *long__, doublereal *lat);
+
+extern int cylrec_(doublereal *r__, doublereal *long__, doublereal *z__, doublereal *rectan);
+
+extern int cylsph_(doublereal *r__, doublereal *longc, doublereal *z__, doublereal *radius, doublereal *colat, doublereal *long__);
+
+extern doublereal dacosh_(doublereal *x);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern doublereal dacosn_(doublereal *arg, doublereal *tol);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dafa2b_(char *ascii, char *binary, integer *resv, ftnlen ascii_len, ftnlen binary_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: txtopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: daft2b_ 14 4 4 13 4 124 */
+
+extern int dafac_(integer *handle, integer *n, char *buffer, ftnlen buffer_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+/*:ref: ncpos_ 4 5 13 13 4 124 124 */
+/*:ref: dafarr_ 14 2 4 4 */
+
+extern int dafah_(char *fname, char *ftype, integer *nd, integer *ni, char *ifname, integer *resv, integer *handle, integer *unit, integer *fhset, char *access, ftnlen fname_len, ftnlen ftype_len, ftnlen ifname_len, ftnlen access_len);
+extern int dafopr_(char *fname, integer *handle, ftnlen fname_len);
+extern int dafopw_(char *fname, integer *handle, ftnlen fname_len);
+extern int dafonw_(char *fname, char *ftype, integer *nd, integer *ni, char *ifname, integer *resv, integer *handle, ftnlen fname_len, ftnlen ftype_len, ftnlen ifname_len);
+extern int dafopn_(char *fname, integer *nd, integer *ni, char *ifname, integer *resv, integer *handle, ftnlen fname_len, ftnlen ifname_len);
+extern int dafcls_(integer *handle);
+extern int dafhsf_(integer *handle, integer *nd, integer *ni);
+extern int dafhlu_(integer *handle, integer *unit);
+extern int dafluh_(integer *unit, integer *handle);
+extern int dafhfn_(integer *handle, char *fname, ftnlen fname_len);
+extern int daffnh_(char *fname, integer *handle, ftnlen fname_len);
+extern int dafhof_(integer *fhset);
+extern int dafsih_(integer *handle, char *access, ftnlen access_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: zzddhopn_ 14 7 13 13 13 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zzdafgfr_ 14 11 4 13 4 4 13 4 4 4 12 124 124 */
+/*:ref: zzddhcls_ 14 4 4 13 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: dafrwa_ 14 3 4 4 4 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: zzdafnfr_ 14 12 4 13 4 4 13 4 4 4 13 124 124 124 */
+/*:ref: removi_ 14 2 4 4 */
+/*:ref: zzddhluh_ 14 3 4 4 12 */
+/*:ref: zzddhnfo_ 14 7 4 13 4 4 4 12 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: zzddhfnh_ 14 4 13 4 12 124 */
+/*:ref: copyi_ 14 2 4 4 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: elemi_ 12 2 4 4 */
+
+extern int dafana_(integer *handle, doublereal *sum, char *name__, doublereal *data, integer *n, ftnlen name_len);
+extern int dafbna_(integer *handle, doublereal *sum, char *name__, ftnlen name_len);
+extern int dafada_(doublereal *data, integer *n);
+extern int dafena_(void);
+extern int dafcad_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafhof_ 14 1 4 */
+/*:ref: elemi_ 12 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafhsf_ 14 3 4 4 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: dafhfn_ 14 3 4 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafwda_ 14 4 4 4 4 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafrdr_ 14 6 4 4 4 4 7 12 */
+/*:ref: dafrcr_ 14 4 4 4 13 124 */
+/*:ref: dafwdr_ 14 3 4 4 7 */
+/*:ref: dafwcr_ 14 4 4 4 13 124 */
+/*:ref: dafarw_ 14 3 4 4 4 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: dafrwa_ 14 3 4 4 4 */
+/*:ref: dafwfr_ 14 8 4 4 4 13 4 4 4 124 */
+
+extern int dafarr_(integer *handle, integer *resv);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafarw_ 14 3 4 4 4 */
+/*:ref: dafwdr_ 14 3 4 4 7 */
+/*:ref: dafrdr_ 14 6 4 4 4 4 7 12 */
+/*:ref: dafrcr_ 14 4 4 4 13 124 */
+/*:ref: dafwcr_ 14 4 4 4 13 124 */
+/*:ref: dafwfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafws_ 14 1 7 */
+
+extern int dafb2a_(char *binary, char *ascii, ftnlen binary_len, ftnlen ascii_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: txtopn_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafb2t_ 14 3 13 4 124 */
+
+extern int dafb2t_(char *binary, integer *text, ftnlen binary_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafcls_ 14 1 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafgn_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int dafbt_(char *binfil, integer *xfrlun, ftnlen binfil_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: wrenci_ 14 3 4 4 4 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafgn_ 14 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: wrencd_ 14 3 4 4 7 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int dafdc_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafrrr_ 14 2 4 4 */
+
+extern int dafec_(integer *handle, integer *bufsiz, integer *n, char *buffer, logical *done, ftnlen buffer_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+/*:ref: ncpos_ 4 5 13 13 4 124 124 */
+
+extern int daffa_(integer *handle, doublereal *sum, char *name__, logical *found, ftnlen name_len);
+extern int dafbfs_(integer *handle);
+extern int daffna_(logical *found);
+extern int dafbbs_(integer *handle);
+extern int daffpa_(logical *found);
+extern int dafgs_(doublereal *sum);
+extern int dafgn_(char *name__, ftnlen name_len);
+extern int dafgh_(integer *handle);
+extern int dafrs_(doublereal *sum);
+extern int dafrn_(char *name__, ftnlen name_len);
+extern int dafws_(doublereal *sum);
+extern int dafcs_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: dafhof_ 14 1 4 */
+/*:ref: elemi_ 12 2 4 4 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafgsr_ 14 6 4 4 4 4 7 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: dafhfn_ 14 3 4 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafhsf_ 14 3 4 4 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: dafrcr_ 14 4 4 4 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafwdr_ 14 3 4 4 7 */
+/*:ref: dafwcr_ 14 4 4 4 13 124 */
+
+extern int dafgda_(integer *handle, integer *begin, integer *end, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafarw_ 14 3 4 4 4 */
+/*:ref: dafgdr_ 14 6 4 4 4 4 7 12 */
+/*:ref: cleard_ 14 2 4 7 */
+
+extern int dafps_(integer *nd, integer *ni, doublereal *dc, integer *ic, doublereal *sum);
+extern int dafus_(doublereal *sum, integer *nd, integer *ni, doublereal *dc, integer *ic);
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: movei_ 14 3 4 4 4 */
+
+extern int dafra_(integer *handle, integer *iorder, integer *n);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: isordv_ 12 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafgn_ 14 2 13 124 */
+/*:ref: dafws_ 14 1 7 */
+/*:ref: dafrn_ 14 2 13 124 */
+
+extern int dafrcr_(integer *handle, integer *recno, char *crec, ftnlen crec_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+
+extern int dafrda_(integer *handle, integer *begin, integer *end, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: zzddhisn_ 14 3 4 12 12 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafarw_ 14 3 4 4 4 */
+/*:ref: dafrdr_ 14 6 4 4 4 4 7 12 */
+/*:ref: cleard_ 14 2 4 7 */
+
+extern int dafrfr_(integer *handle, integer *nd, integer *ni, char *ifname, integer *fward, integer *bward, integer *free, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzdafgfr_ 14 11 4 13 4 4 13 4 4 4 12 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int dafrrr_(integer *handle, integer *resv);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafrdr_ 14 6 4 4 4 4 7 12 */
+/*:ref: dafarw_ 14 3 4 4 4 */
+/*:ref: dafwdr_ 14 3 4 4 7 */
+/*:ref: dafrcr_ 14 4 4 4 13 124 */
+/*:ref: dafwcr_ 14 4 4 4 13 124 */
+/*:ref: dafwfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafws_ 14 1 7 */
+
+extern int dafrwa_(integer *recno, integer *wordno, integer *addr__);
+extern int dafarw_(integer *addr__, integer *recno, integer *wordno);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dafrwd_(integer *handle, integer *recno, integer *begin, integer *end, doublereal *drec, doublereal *data, logical *found, integer *reads, integer *reqs);
+extern int dafgdr_(integer *handle, integer *recno, integer *begin, integer *end, doublereal *data, logical *found);
+extern int dafgsr_(integer *handle, integer *recno, integer *begin, integer *end, doublereal *data, logical *found);
+extern int dafrdr_(integer *handle, integer *recno, integer *begin, integer *end, doublereal *data, logical *found);
+extern int dafwdr_(integer *handle, integer *recno, doublereal *drec);
+extern int dafnrr_(integer *reads, integer *reqs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: minai_ 14 4 4 4 4 4 */
+/*:ref: zzdafgdr_ 14 4 4 4 7 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: zzddhrcm_ 14 3 4 4 4 */
+/*:ref: dafhsf_ 14 3 4 4 4 */
+/*:ref: zzdafgsr_ 14 6 4 4 4 4 7 12 */
+/*:ref: zzddhisn_ 14 3 4 12 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int daft2b_(integer *text, char *binary, integer *resv, ftnlen binary_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: idw2at_ 14 6 13 13 13 124 124 124 */
+/*:ref: dafopn_ 14 8 13 4 4 13 4 4 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafcls_ 14 1 4 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafena_ 14 0 */
+
+extern int daftb_(integer *xfrlun, char *binfil, ftnlen binfil_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: idw2at_ 14 6 13 13 13 124 124 124 */
+/*:ref: rdenci_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafonw_ 14 10 13 13 4 4 13 4 4 124 124 124 */
+/*:ref: dafopn_ 14 8 13 4 4 13 4 4 124 124 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: rdencd_ 14 3 4 4 7 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int dafwcr_(integer *handle, integer *recno, char *crec, ftnlen crec_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dafwda_(integer *handle, integer *begin, integer *end, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafarw_ 14 3 4 4 4 */
+/*:ref: dafrdr_ 14 6 4 4 4 4 7 12 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: dafwdr_ 14 3 4 4 7 */
+
+extern int dafwfr_(integer *handle, integer *nd, integer *ni, char *ifname, integer *fward, integer *bward, integer *free, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int dasa2l_(integer *handle, integer *type__, integer *addrss, integer *clbase, integer *clsize, integer *recno, integer *wordno);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: dasham_ 14 3 4 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasrri_ 14 5 4 4 4 4 4 */
+
+extern int dasac_(integer *handle, integer *n, char *buffer, ftnlen buffer_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: dasrfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+/*:ref: dasacr_ 14 2 4 4 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: daswfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+
+extern int dasacr_(integer *handle, integer *n);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: daswbr_ 14 1 4 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: maxai_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: dasioi_ 14 5 13 4 4 4 124 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: dasiod_ 14 5 13 4 4 7 124 */
+/*:ref: dasufs_ 14 9 4 4 4 4 4 4 4 4 4 */
+
+extern int dasacu_(integer *comlun, char *begmrk, char *endmrk, logical *insbln, integer *handle, ftnlen begmrk_len, ftnlen endmrk_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: readln_ 14 4 4 13 12 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: readla_ 14 6 4 4 4 13 12 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: writla_ 14 4 4 13 4 124 */
+/*:ref: dasac_ 14 4 4 4 13 124 */
+
+extern int dasadc_(integer *handle, integer *n, integer *bpos, integer *epos, char *data, ftnlen data_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: daswrc_ 14 4 4 4 13 124 */
+/*:ref: dasurc_ 14 6 4 4 4 4 13 124 */
+/*:ref: dascud_ 14 3 4 4 4 */
+
+extern int dasadd_(integer *handle, integer *n, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: daswrd_ 14 3 4 4 7 */
+/*:ref: dasurd_ 14 5 4 4 4 4 7 */
+/*:ref: dascud_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dasadi_(integer *handle, integer *n, integer *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: daswri_ 14 3 4 4 4 */
+/*:ref: dasuri_ 14 5 4 4 4 4 4 */
+/*:ref: dascud_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dasbt_(char *binfil, integer *xfrlun, ftnlen binfil_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dasopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: dascls_ 14 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: wrenci_ 14 3 4 4 4 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: wrencc_ 14 4 4 4 13 124 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: wrencd_ 14 3 4 4 7 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int dascls_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: dashof_ 14 1 4 */
+/*:ref: elemi_ 12 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasham_ 14 3 4 13 124 */
+/*:ref: daswbr_ 14 1 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dassdr_ 14 1 4 */
+/*:ref: dasllc_ 14 1 4 */
+
+extern int dascud_(integer *handle, integer *type__, integer *nwords);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: maxai_ 14 4 4 4 4 4 */
+/*:ref: dasuri_ 14 5 4 4 4 4 4 */
+/*:ref: dasufs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasrri_ 14 5 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: daswri_ 14 3 4 4 4 */
+
+extern int dasdc_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+/*:ref: dasrcr_ 14 2 4 4 */
+/*:ref: daswfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+
+extern int dasec_(integer *handle, integer *bufsiz, integer *n, char *buffer, logical *done, ftnlen buffer_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: dasrfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int dasecu_(integer *handle, integer *comlun, logical *comnts);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasec_ 14 6 4 4 4 13 12 124 */
+/*:ref: writla_ 14 4 4 13 4 124 */
+
+extern int dasfm_(char *fname, char *ftype, char *ifname, integer *handle, integer *unit, integer *free, integer *lastla, integer *lastrc, integer *lastwd, integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc, integer *fhset, char *access, ftnlen fname_len, ftnlen ftype_len, ftnlen ifname_len, ftnlen access_len);
+extern int dasopr_(char *fname, integer *handle, ftnlen fname_len);
+extern int dasopw_(char *fname, integer *handle, ftnlen fname_len);
+extern int dasonw_(char *fname, char *ftype, char *ifname, integer *ncomr, integer *handle, ftnlen fname_len, ftnlen ftype_len, ftnlen ifname_len);
+extern int dasopn_(char *fname, char *ifname, integer *handle, ftnlen fname_len, ftnlen ifname_len);
+extern int dasops_(integer *handle);
+extern int dasllc_(integer *handle);
+extern int dashfs_(integer *handle, integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc, integer *free, integer *lastla, integer *lastrc, integer *lastwd);
+extern int dasufs_(integer *handle, integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc, integer *free, integer *lastla, integer *lastrc, integer *lastwd);
+extern int dashlu_(integer *handle, integer *unit);
+extern int dasluh_(integer *unit, integer *handle);
+extern int dashfn_(integer *handle, char *fname, ftnlen fname_len);
+extern int dasfnh_(char *fname, integer *handle, ftnlen fname_len);
+extern int dashof_(integer *fhset);
+extern int dassih_(integer *handle, char *access, ftnlen access_len);
+extern int dasham_(integer *handle, char *access, ftnlen access_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: exists_ 12 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzddhppf_ 14 3 4 4 4 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: idw2at_ 14 6 13 13 13 124 124 124 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: dasioi_ 14 5 13 4 4 4 124 */
+/*:ref: maxai_ 14 4 4 4 4 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: zzdasnfr_ 14 11 4 13 13 4 4 4 4 13 124 124 124 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: removi_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: copyi_ 14 2 4 4 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: elemi_ 12 2 4 4 */
+
+extern doublereal dasine_(doublereal *arg, doublereal *tol);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dasioc_(char *action, integer *unit, integer *recno, char *record, ftnlen action_len, ftnlen record_len);
+/*:ref: return_ 12 0 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int dasiod_(char *action, integer *unit, integer *recno, doublereal *record, ftnlen action_len);
+/*:ref: return_ 12 0 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int dasioi_(char *action, integer *unit, integer *recno, integer *record, ftnlen action_len);
+/*:ref: return_ 12 0 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int daslla_(integer *handle, integer *lastc, integer *lastd, integer *lasti);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dasrcr_(integer *handle, integer *n);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: daswbr_ 14 1 4 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: maxai_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: dasioi_ 14 5 13 4 4 4 124 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: dasiod_ 14 5 13 4 4 7 124 */
+/*:ref: dasufs_ 14 9 4 4 4 4 4 4 4 4 4 */
+
+extern int dasrdc_(integer *handle, integer *first, integer *last, integer *bpos, integer *epos, char *data, ftnlen data_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasrrc_ 14 6 4 4 4 4 13 124 */
+
+extern int dasrdd_(integer *handle, integer *first, integer *last, doublereal *data);
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: dasrrd_ 14 5 4 4 4 4 7 */
+/*:ref: failed_ 12 0 */
+
+extern int dasrdi_(integer *handle, integer *first, integer *last, integer *data);
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: dasrri_ 14 5 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+
+extern int dasrfr_(integer *handle, char *idword, char *ifname, integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc, ftnlen idword_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int dasrwr_(integer *handle, integer *recno, char *recc, doublereal *recd, integer *reci, integer *first, integer *last, doublereal *datad, integer *datai, char *datac, ftnlen recc_len, ftnlen datac_len);
+extern int dasrrd_(integer *handle, integer *recno, integer *first, integer *last, doublereal *datad);
+extern int dasrri_(integer *handle, integer *recno, integer *first, integer *last, integer *datai);
+extern int dasrrc_(integer *handle, integer *recno, integer *first, integer *last, char *datac, ftnlen datac_len);
+extern int daswrd_(integer *handle, integer *recno, doublereal *recd);
+extern int daswri_(integer *handle, integer *recno, integer *reci);
+extern int daswrc_(integer *handle, integer *recno, char *recc, ftnlen recc_len);
+extern int dasurd_(integer *handle, integer *recno, integer *first, integer *last, doublereal *datad);
+extern int dasuri_(integer *handle, integer *recno, integer *first, integer *last, integer *datai);
+extern int dasurc_(integer *handle, integer *recno, integer *first, integer *last, char *datac, ftnlen datac_len);
+extern int daswbr_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: lnkxsl_ 14 3 4 4 4 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: lnktl_ 4 2 4 4 */
+/*:ref: dasiod_ 14 5 13 4 4 7 124 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: dasioi_ 14 5 13 4 4 4 124 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+
+extern int dassdr_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: daswbr_ 14 1 4 */
+/*:ref: dasops_ 14 1 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: maxai_ 14 4 4 4 4 4 */
+/*:ref: dasrri_ 14 5 4 4 4 4 4 */
+/*:ref: dasadi_ 14 3 4 4 4 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: dasiod_ 14 5 13 4 4 7 124 */
+/*:ref: dasioi_ 14 5 13 4 4 4 124 */
+/*:ref: dasufs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasllc_ 14 1 4 */
+
+extern int dastb_(integer *xfrlun, char *binfil, ftnlen binfil_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: idw2at_ 14 6 13 13 13 124 124 124 */
+/*:ref: dasonw_ 14 8 13 13 13 4 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: daswfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+/*:ref: dascls_ 14 1 4 */
+/*:ref: rdenci_ 14 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: dasacr_ 14 2 4 4 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: rdencc_ 14 4 4 4 13 124 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: dasadc_ 14 6 4 4 4 4 13 124 */
+/*:ref: rdencd_ 14 3 4 4 7 */
+/*:ref: dasadd_ 14 3 4 4 7 */
+/*:ref: dasadi_ 14 3 4 4 4 */
+
+extern int dasudc_(integer *handle, integer *first, integer *last, integer *bpos, integer *epos, char *data, ftnlen data_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasurc_ 14 6 4 4 4 4 13 124 */
+
+extern int dasudd_(integer *handle, integer *first, integer *last, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasurd_ 14 5 4 4 4 4 7 */
+
+extern int dasudi_(integer *handle, integer *first, integer *last, integer *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasuri_ 14 5 4 4 4 4 4 */
+
+extern int daswfr_(integer *handle, char *idword, char *ifname, integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc, ftnlen idword_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasufs_ 14 9 4 4 4 4 4 4 4 4 4 */
+
+extern doublereal datanh_(doublereal *x);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern doublereal dcbrt_(doublereal *x);
+
+extern int dcyldr_(doublereal *x, doublereal *y, doublereal *z__, doublereal *jacobi);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: reccyl_ 14 4 7 7 7 7 */
+/*:ref: drdcyl_ 14 4 7 7 7 7 */
+/*:ref: invort_ 14 2 7 7 */
+
+extern int delfil_(char *filnam, ftnlen filnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: getlun_ 14 1 4 */
+
+extern int deltet_(doublereal *epoch, char *eptype, doublereal *delta, ftnlen eptype_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern doublereal det_(doublereal *m1);
+
+extern int dgeodr_(doublereal *x, doublereal *y, doublereal *z__, doublereal *re, doublereal *f, doublereal *jacobi);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: recgeo_ 14 6 7 7 7 7 7 7 */
+/*:ref: drdgeo_ 14 6 7 7 7 7 7 7 */
+/*:ref: invort_ 14 2 7 7 */
+
+extern doublereal dhfa_(doublereal *state, doublereal *bodyr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+
+extern int diags2_(doublereal *symmat, doublereal *diag, doublereal *rotate);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rquad_ 14 5 7 7 7 7 7 */
+/*:ref: vhatg_ 14 3 7 4 7 */
+
+extern int diffc_(char *a, char *b, char *c__, ftnlen a_len, ftnlen b_len, ftnlen c_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: excess_ 14 3 4 13 124 */
+
+extern int diffd_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int diffi_(integer *a, integer *b, integer *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dlatdr_(doublereal *x, doublereal *y, doublereal *z__, doublereal *jacobi);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: reclat_ 14 4 7 7 7 7 */
+/*:ref: drdlat_ 14 4 7 7 7 7 */
+/*:ref: invort_ 14 2 7 7 */
+
+extern int dnearp_(doublereal *state, doublereal *a, doublereal *b, doublereal *c__, doublereal *dnear, doublereal *dalt, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vtmv_ 7 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int dp2hx_(doublereal *number, char *string, integer *length, ftnlen string_len);
+/*:ref: int2hx_ 14 4 4 13 4 124 */
+
+extern int dpfmt_(doublereal *x, char *pictur, char *str, ftnlen pictur_len, ftnlen str_len);
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzvststr_ 14 4 7 13 4 124 */
+/*:ref: dpstr_ 14 4 7 4 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: rjust_ 14 4 13 13 124 124 */
+/*:ref: zzvsbstr_ 14 6 4 4 12 13 12 124 */
+/*:ref: ncpos_ 4 5 13 13 4 124 124 */
+
+extern int dpgrdr_(char *body, doublereal *x, doublereal *y, doublereal *z__, doublereal *re, doublereal *f, doublereal *jacobi, ftnlen body_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: plnsns_ 4 1 4 */
+/*:ref: dgeodr_ 14 6 7 7 7 7 7 7 */
+
+extern doublereal dpr_(void);
+
+extern int dpspce_(doublereal *time, doublereal *geophs, doublereal *elems, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: twopi_ 7 0 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: zzdpinit_ 14 6 7 7 7 7 7 7 */
+/*:ref: zzdpper_ 14 6 7 7 7 7 7 7 */
+/*:ref: zzdpsec_ 14 9 7 7 7 7 7 7 7 7 7 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dpstr_(doublereal *x, integer *sigdig, char *string, ftnlen string_len);
+/*:ref: intstr_ 14 3 4 13 124 */
+
+extern int dpstrf_(doublereal *x, integer *sigdig, char *format, char *string, ftnlen format_len, ftnlen string_len);
+/*:ref: dpstr_ 14 4 7 4 13 124 */
+/*:ref: zzvststr_ 14 4 7 13 4 124 */
+/*:ref: zzvsbstr_ 14 6 4 4 12 13 12 124 */
+
+extern int drdcyl_(doublereal *r__, doublereal *long__, doublereal *z__, doublereal *jacobi);
+
+extern int drdgeo_(doublereal *long__, doublereal *lat, doublereal *alt, doublereal *re, doublereal *f, doublereal *jacobi);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int drdlat_(doublereal *r__, doublereal *long__, doublereal *lat, doublereal *jacobi);
+
+extern int drdpgr_(char *body, doublereal *lon, doublereal *lat, doublereal *alt, doublereal *re, doublereal *f, doublereal *jacobi, ftnlen body_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: plnsns_ 4 1 4 */
+/*:ref: drdgeo_ 14 6 7 7 7 7 7 7 */
+
+extern int drdsph_(doublereal *r__, doublereal *colat, doublereal *long__, doublereal *jacobi);
+
+extern int drotat_(doublereal *angle, integer *iaxis, doublereal *dmout);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dsphdr_(doublereal *x, doublereal *y, doublereal *z__, doublereal *jacobi);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: recsph_ 14 4 7 7 7 7 */
+/*:ref: drdsph_ 14 4 7 7 7 7 */
+/*:ref: invort_ 14 2 7 7 */
+
+extern int ducrss_(doublereal *s1, doublereal *s2, doublereal *sout);
+/*:ref: dvcrss_ 14 3 7 7 7 */
+/*:ref: dvhat_ 14 2 7 7 */
+
+extern int dvcrss_(doublereal *s1, doublereal *s2, doublereal *sout);
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+
+extern doublereal dvdot_(doublereal *s1, doublereal *s2);
+
+extern int dvhat_(doublereal *s1, doublereal *sout);
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+
+extern doublereal dvnorm_(doublereal *state);
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+
+extern doublereal dvsep_(doublereal *s1, doublereal *s2);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dvhat_ 14 2 7 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int dxtrct_(char *keywd, integer *maxwds, char *string, integer *nfound, integer *parsed, doublereal *values, ftnlen keywd_len, ftnlen string_len);
+/*:ref: wdindx_ 4 4 13 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: nblen_ 4 2 13 124 */
+/*:ref: fndnwd_ 14 5 13 4 4 4 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+
+extern int edlimb_(doublereal *a, doublereal *b, doublereal *c__, doublereal *viewpt, doublereal *limb);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: nvc2pl_ 14 3 7 7 7 */
+/*:ref: inedpl_ 14 6 7 7 7 7 7 12 */
+/*:ref: vsclg_ 14 4 7 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int edterm_(char *trmtyp, char *source, char *target, doublereal *et, char *fixfrm, char *abcorr, char *obsrvr, integer *npts, doublereal *trgepc, doublereal *obspos, doublereal *trmpts, ftnlen trmtyp_len, ftnlen source_len, ftnlen target_len, ftnlen fixfrm_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: bodvrd_ 14 7 13 13 4 4 7 124 124 */
+/*:ref: spkpos_ 14 11 13 7 13 13 13 7 7 124 124 124 124 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: zzedterm_ 14 9 13 7 7 7 7 7 4 7 124 */
+
+extern int ekacec_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, char *cvals, logical *isnull, ftnlen column_len, ftnlen cvals_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekad03_ 14 7 4 4 4 4 13 12 124 */
+/*:ref: zzekad06_ 14 8 4 4 4 4 4 13 12 124 */
+
+extern int ekaced_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, doublereal *dvals, logical *isnull, ftnlen column_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekad02_ 14 6 4 4 4 4 7 12 */
+/*:ref: zzekad05_ 14 7 4 4 4 4 4 7 12 */
+
+extern int ekacei_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, integer *ivals, logical *isnull, ftnlen column_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekad01_ 14 6 4 4 4 4 4 12 */
+/*:ref: zzekad04_ 14 7 4 4 4 4 4 4 12 */
+
+extern int ekaclc_(integer *handle, integer *segno, char *column, char *cvals, integer *entszs, logical *nlflgs, integer *rcptrs, integer *wkindx, ftnlen column_len, ftnlen cvals_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzekac03_ 14 8 4 4 4 13 12 4 4 124 */
+/*:ref: zzekac06_ 14 7 4 4 4 13 4 12 124 */
+/*:ref: zzekac09_ 14 7 4 4 4 13 12 4 124 */
+
+extern int ekacld_(integer *handle, integer *segno, char *column, doublereal *dvals, integer *entszs, logical *nlflgs, integer *rcptrs, integer *wkindx, ftnlen column_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzekac02_ 14 7 4 4 4 7 12 4 4 */
+/*:ref: zzekac05_ 14 6 4 4 4 7 4 12 */
+/*:ref: zzekac08_ 14 6 4 4 4 7 12 4 */
+
+extern int ekacli_(integer *handle, integer *segno, char *column, integer *ivals, integer *entszs, logical *nlflgs, integer *rcptrs, integer *wkindx, ftnlen column_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzekac01_ 14 7 4 4 4 4 12 4 4 */
+/*:ref: zzekac04_ 14 6 4 4 4 4 4 12 */
+/*:ref: zzekac07_ 14 6 4 4 4 4 12 4 */
+
+extern int ekappr_(integer *handle, integer *segno, integer *recno);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: ekinsr_ 14 3 4 4 4 */
+
+extern int ekbseg_(integer *handle, char *tabnam, integer *ncols, char *cnames, char *decls, integer *segno, ftnlen tabnam_len, ftnlen cnames_len, ftnlen decls_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: lxdfid_ 14 1 4 */
+/*:ref: chckid_ 14 5 13 4 13 124 124 */
+/*:ref: lxidnt_ 14 6 4 13 4 4 4 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekpdec_ 14 3 13 4 124 */
+/*:ref: zzekstyp_ 4 2 4 4 */
+/*:ref: zzekbs01_ 14 8 4 13 4 13 4 4 124 124 */
+/*:ref: zzekbs02_ 14 8 4 13 4 13 4 4 124 124 */
+
+extern int ekcls_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dascls_ 14 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ekdelr_(integer *handle, integer *segno, integer *recno);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekrbck_ 14 6 13 4 4 4 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekde01_ 14 4 4 4 4 4 */
+/*:ref: zzekde02_ 14 4 4 4 4 4 */
+/*:ref: zzekde03_ 14 4 4 4 4 4 */
+/*:ref: zzekde04_ 14 4 4 4 4 4 */
+/*:ref: zzekde05_ 14 4 4 4 4 4 */
+/*:ref: zzekde06_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: zzektrdl_ 14 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int ekffld_(integer *handle, integer *segno, integer *rcptrs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekff01_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ekfind_(char *query, integer *nmrows, logical *error, char *errmsg, ftnlen query_len, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekqini_ 14 6 4 4 4 13 7 124 */
+/*:ref: zzekscan_ 14 17 13 4 4 4 4 4 4 4 7 13 4 4 12 13 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpars_ 14 19 13 4 4 4 4 4 7 13 4 4 4 13 7 12 13 124 124 124 124 */
+/*:ref: zzeknres_ 14 9 13 4 13 12 13 4 124 124 124 */
+/*:ref: zzektres_ 14 10 13 4 13 7 12 13 4 124 124 124 */
+/*:ref: zzeksemc_ 14 9 13 4 13 12 13 4 124 124 124 */
+/*:ref: eksrch_ 14 8 4 13 7 4 12 13 124 124 */
+
+extern int ekifld_(integer *handle, char *tabnam, integer *ncols, integer *nrows, char *cnames, char *decls, integer *segno, integer *rcptrs, ftnlen tabnam_len, ftnlen cnames_len, ftnlen decls_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ekbseg_ 14 9 4 13 4 13 13 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekif01_ 14 3 4 4 4 */
+/*:ref: zzekif02_ 14 2 4 4 */
+
+extern int ekinsr_(integer *handle, integer *segno, integer *recno);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: filli_ 14 3 4 4 4 */
+/*:ref: ekshdw_ 14 2 4 12 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzektrin_ 14 4 4 4 4 4 */
+/*:ref: zzekrbck_ 14 6 13 4 4 4 4 124 */
+
+extern integer eknseg_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzektrsz_ 4 2 4 4 */
+
+extern int ekopn_(char *fname, char *ifname, integer *ncomch, integer *handle, ftnlen fname_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasonw_ 14 8 13 13 13 4 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekpgin_ 14 1 4 */
+/*:ref: zzekpgan_ 14 4 4 4 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int ekopr_(char *fname, integer *handle, ftnlen fname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dasopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+
+extern int ekops_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dasops_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgin_ 14 1 4 */
+/*:ref: zzekpgan_ 14 4 4 4 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int ekopw_(char *fname, integer *handle, ftnlen fname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dasopw_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+
+extern int ekpsel_(char *query, integer *n, integer *xbegs, integer *xends, char *xtypes, char *xclass, char *tabs, char *cols, logical *error, char *errmsg, ftnlen query_len, ftnlen xtypes_len, ftnlen xclass_len, ftnlen tabs_len, ftnlen cols_len, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekqini_ 14 6 4 4 4 13 7 124 */
+/*:ref: zzekencd_ 14 10 13 4 13 7 12 13 4 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: zzekqsel_ 14 12 4 13 4 4 4 13 4 13 4 124 124 124 */
+/*:ref: zzekqtab_ 14 8 4 13 4 13 13 124 124 124 */
+/*:ref: ekcii_ 14 6 13 4 13 4 124 124 */
+
+extern int ekqmgr_(integer *cindex, integer *elment, char *eqryc, doublereal *eqryd, integer *eqryi, char *fname, integer *row, integer *selidx, char *column, integer *handle, integer *n, char *table, integer *attdsc, integer *ccount, logical *found, integer *nelt, integer *nmrows, logical *semerr, char *errmsg, char *cdata, doublereal *ddata, integer *idata, logical *null, ftnlen eqryc_len, ftnlen fname_len, ftnlen column_len, ftnlen table_len, ftnlen errmsg_len, ftnlen cdata_len);
+extern int eklef_(char *fname, integer *handle, ftnlen fname_len);
+extern int ekuef_(integer *handle);
+extern int ekntab_(integer *n);
+extern int ektnam_(integer *n, char *table, ftnlen table_len);
+extern int ekccnt_(char *table, integer *ccount, ftnlen table_len);
+extern int ekcii_(char *table, integer *cindex, char *column, integer *attdsc, ftnlen table_len, ftnlen column_len);
+extern int eksrch_(integer *eqryi, char *eqryc, doublereal *eqryd, integer *nmrows, logical *semerr, char *errmsg, ftnlen eqryc_len, ftnlen errmsg_len);
+extern int eknelt_(integer *selidx, integer *row, integer *nelt);
+extern int ekgc_(integer *selidx, integer *row, integer *elment, char *cdata, logical *null, logical *found, ftnlen cdata_len);
+extern int ekgd_(integer *selidx, integer *row, integer *elment, doublereal *ddata, logical *null, logical *found);
+extern int ekgi_(integer *selidx, integer *row, integer *elment, integer *idata, logical *null, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: ekopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dascls_ 14 1 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: ekcls_ 14 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: eknseg_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: zzeksinf_ 14 8 4 4 13 4 13 4 124 124 */
+/*:ref: ssizec_ 14 3 4 13 124 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+/*:ref: validc_ 14 4 4 4 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: lnktl_ 4 2 4 4 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: zzekqtab_ 14 8 4 13 4 13 13 124 124 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: appndc_ 14 4 13 13 124 124 */
+/*:ref: appndi_ 14 2 4 4 */
+/*:ref: zzekstop_ 14 1 4 */
+/*:ref: zzeksdec_ 14 1 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekqcnj_ 14 3 4 4 4 */
+/*:ref: zzekqcon_ 14 24 4 13 7 4 4 13 4 13 4 4 13 4 13 4 4 4 4 7 4 124 124 124 124 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzeksupd_ 14 3 4 4 4 */
+/*:ref: zzekkey_ 14 20 4 4 4 4 4 4 4 4 13 4 4 7 4 12 4 4 4 4 12 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekrplk_ 14 4 4 4 4 4 */
+/*:ref: zzekrmch_ 12 15 4 12 4 4 4 4 4 4 4 13 4 4 7 4 124 */
+/*:ref: zzekvmch_ 12 13 4 12 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzekjsqz_ 14 1 4 */
+/*:ref: zzekjoin_ 14 18 4 4 4 12 4 4 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: zzekweed_ 14 3 4 4 4 */
+/*:ref: zzekvset_ 14 2 4 4 */
+/*:ref: zzekqsel_ 14 12 4 13 4 4 4 13 4 13 4 124 124 124 */
+/*:ref: zzekqord_ 14 11 4 13 4 13 4 13 4 4 124 124 124 */
+/*:ref: zzekjsrt_ 14 13 4 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzekvcal_ 14 3 4 4 4 */
+/*:ref: zzekesiz_ 4 4 4 4 4 4 */
+/*:ref: zzekrsc_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: zzekrsd_ 14 8 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrsi_ 14 8 4 4 4 4 4 4 12 12 */
+
+extern int ekrcec_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, char *cvals, logical *isnull, ftnlen column_len, ftnlen cvals_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekrd03_ 14 8 4 4 4 4 4 13 12 124 */
+/*:ref: zzekesiz_ 4 4 4 4 4 4 */
+/*:ref: zzekrd06_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: zzekrd09_ 14 8 4 4 4 4 4 13 12 124 */
+
+extern int ekrced_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, doublereal *dvals, logical *isnull, ftnlen column_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekrd02_ 14 6 4 4 4 4 7 12 */
+/*:ref: zzekesiz_ 4 4 4 4 4 4 */
+/*:ref: zzekrd05_ 14 9 4 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrd08_ 14 6 4 4 4 4 7 12 */
+
+extern int ekrcei_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, integer *ivals, logical *isnull, ftnlen column_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekrd01_ 14 6 4 4 4 4 4 12 */
+/*:ref: zzekesiz_ 4 4 4 4 4 4 */
+/*:ref: zzekrd04_ 14 9 4 4 4 4 4 4 4 12 12 */
+/*:ref: zzekrd07_ 14 6 4 4 4 4 4 12 */
+
+extern int ekshdw_(integer *handle, logical *isshad);
+
+extern int ekssum_(integer *handle, integer *segno, char *tabnam, integer *nrows, integer *ncols, char *cnames, char *dtypes, integer *sizes, integer *strlns, logical *indexd, logical *nullok, ftnlen tabnam_len, ftnlen cnames_len, ftnlen dtypes_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksinf_ 14 8 4 4 13 4 13 4 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ekucec_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, char *cvals, logical *isnull, ftnlen column_len, ftnlen cvals_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: ekshdw_ 14 2 4 12 */
+/*:ref: zzekrbck_ 14 6 13 4 4 4 4 124 */
+/*:ref: zzekue03_ 14 7 4 4 4 4 13 12 124 */
+/*:ref: zzekue06_ 14 8 4 4 4 4 4 13 12 124 */
+
+extern int ekuced_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, doublereal *dvals, logical *isnull, ftnlen column_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: ekshdw_ 14 2 4 12 */
+/*:ref: zzekrbck_ 14 6 13 4 4 4 4 124 */
+/*:ref: zzekue02_ 14 6 4 4 4 4 7 12 */
+/*:ref: zzekue05_ 14 7 4 4 4 4 4 7 12 */
+
+extern int ekucei_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, integer *ivals, logical *isnull, ftnlen column_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: ekshdw_ 14 2 4 12 */
+/*:ref: zzekrbck_ 14 6 13 4 4 4 4 124 */
+/*:ref: zzekue01_ 14 6 4 4 4 4 4 12 */
+/*:ref: zzekue04_ 14 7 4 4 4 4 4 4 12 */
+
+extern int el2cgv_(doublereal *ellips, doublereal *center, doublereal *smajor, doublereal *sminor);
+/*:ref: vequ_ 14 2 7 7 */
+
+extern logical elemc_(char *item, char *a, ftnlen item_len, ftnlen a_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical elemd_(doublereal *item, doublereal *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bsrchd_ 4 3 7 4 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical elemi_(integer *item, integer *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bsrchi_ 4 3 4 4 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int elltof_(doublereal *ma, doublereal *ecc, doublereal *e);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pi_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: dcbrt_ 7 1 7 */
+
+extern int enchar_(integer *number, char *string, ftnlen string_len);
+extern int dechar_(char *string, integer *number, ftnlen string_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: chbase_ 4 0 */
+
+extern logical eqchr_(char *a, char *b, ftnlen a_len, ftnlen b_len);
+extern logical nechr_(char *a, char *b, ftnlen a_len, ftnlen b_len);
+
+extern int eqncpv_(doublereal *et, doublereal *epoch, doublereal *eqel, doublereal *rapol, doublereal *decpol, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: twopi_ 7 0 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: kepleq_ 7 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vlcom3_ 14 7 7 7 7 7 7 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+
+extern logical eqstr_(char *a, char *b, ftnlen a_len, ftnlen b_len);
+
+extern int erract_(char *op, char *action, ftnlen op_len, ftnlen action_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: getact_ 14 1 4 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: putact_ 14 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int errch_(char *marker, char *string, ftnlen marker_len, ftnlen string_len);
+/*:ref: allowd_ 12 0 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: getlms_ 14 2 13 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: nblen_ 4 2 13 124 */
+/*:ref: putlms_ 14 2 13 124 */
+
+extern int errdev_(char *op, char *device, ftnlen op_len, ftnlen device_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: getdev_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: putdev_ 14 2 13 124 */
+
+extern int errdp_(char *marker, doublereal *dpnum, ftnlen marker_len);
+/*:ref: allowd_ 12 0 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: getlms_ 14 2 13 124 */
+/*:ref: dpstr_ 14 4 7 4 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: putlms_ 14 2 13 124 */
+
+extern int errfnm_(char *marker, integer *unit, ftnlen marker_len);
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int errhan_(char *marker, integer *handle, ftnlen marker_len);
+/*:ref: zzddhnfo_ 14 7 4 13 4 4 4 12 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int errint_(char *marker, integer *integr, ftnlen marker_len);
+/*:ref: allowd_ 12 0 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: getlms_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: putlms_ 14 2 13 124 */
+
+extern int errprt_(char *op, char *list, ftnlen op_len, ftnlen list_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: msgsel_ 12 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: lparse_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: setprt_ 12 5 12 12 12 12 12 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer esrchc_(char *value, integer *ndim, char *array, ftnlen value_len, ftnlen array_len);
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+
+extern int et2lst_(doublereal *et, integer *body, doublereal *long__, char *type__, integer *hr, integer *mn, integer *sc, char *time, char *ampm, ftnlen type_len, ftnlen time_len, ftnlen ampm_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: pgrrec_ 14 8 13 7 7 7 7 7 7 124 */
+/*:ref: reclat_ 14 4 7 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: rmaind_ 14 4 7 7 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: pi_ 7 0 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: dpfmt_ 14 5 7 13 13 124 124 */
+
+extern int et2utc_(doublereal *et, char *format, integer *prec, char *utcstr, ftnlen format_len, ftnlen utcstr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ttrans_ 14 5 13 13 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dpstrf_ 14 6 7 4 13 13 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: unitim_ 7 5 7 13 13 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int etcal_(doublereal *et, char *string, ftnlen string_len);
+/*:ref: spd_ 7 0 */
+/*:ref: intmax_ 4 0 */
+/*:ref: intmin_ 4 0 */
+/*:ref: lstlti_ 4 3 4 4 4 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: dpstrf_ 14 6 7 4 13 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+
+extern int eul2m_(doublereal *angle3, doublereal *angle2, doublereal *angle1, integer *axis3, integer *axis2, integer *axis1, doublereal *r__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rotate_ 14 3 7 4 7 */
+/*:ref: rotmat_ 14 4 7 7 4 7 */
+
+extern int ev2lin_(doublereal *et, doublereal *geophs, doublereal *elems, doublereal *state);
+/*:ref: twopi_ 7 0 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+
+extern logical even_(integer *i__);
+
+extern doublereal exact_(doublereal *number, doublereal *value, doublereal *tol);
+
+extern int excess_(integer *number, char *struct__, ftnlen struct_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical exists_(char *file, ftnlen file_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int expln_(char *msg, char *expl, ftnlen msg_len, ftnlen expl_len);
+
+extern integer fetchc_(integer *nth, char *set, ftnlen set_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer fetchd_(integer *nth, doublereal *set);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer fetchi_(integer *nth, integer *set);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int fillc_(char *value, integer *ndim, char *array, ftnlen value_len, ftnlen array_len);
+
+extern int filld_(doublereal *value, integer *ndim, doublereal *array);
+
+extern int filli_(integer *value, integer *ndim, integer *array);
+
+extern int fn2lun_(char *filnam, integer *lunit, ftnlen filnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int fndlun_(integer *unit);
+extern int reslun_(integer *unit);
+extern int frelun_(integer *unit);
+
+extern int fndnwd_(char *string, integer *start, integer *b, integer *e, ftnlen string_len);
+
+extern int frame_(doublereal *x, doublereal *y, doublereal *z__);
+/*:ref: vhatip_ 14 1 7 */
+
+extern int framex_(char *cname, char *frname, integer *frcode, integer *cent, integer *class__, integer *clssid, logical *found, ftnlen cname_len, ftnlen frname_len);
+extern int namfrm_(char *frname, integer *frcode, ftnlen frname_len);
+extern int frmnam_(integer *frcode, char *frname, ftnlen frname_len);
+extern int frinfo_(integer *frcode, integer *cent, integer *class__, integer *clssid, logical *found);
+extern int cidfrm_(integer *cent, integer *frcode, char *frname, logical *found, ftnlen frname_len);
+extern int cnmfrm_(char *cname, integer *frcode, char *frname, logical *found, ftnlen cname_len, ftnlen frname_len);
+extern int ccifrm_(integer *class__, integer *clssid, integer *frcode, char *frname, integer *cent, logical *found, ftnlen frname_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: zzfdat_ 14 10 4 13 4 4 4 4 4 4 4 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: bschoc_ 4 6 13 4 13 4 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+/*:ref: bschoi_ 4 4 4 4 4 4 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: zzdynbid_ 14 6 13 4 13 4 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzdynvai_ 14 8 13 4 13 4 4 4 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: bodn2c_ 14 4 13 4 12 124 */
+/*:ref: gnpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int frmchg_(integer *frame1, integer *frame2, doublereal *et, doublereal *xform);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: frmget_ 14 5 4 7 7 4 12 */
+/*:ref: zzmsxf_ 14 3 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zznofcon_ 14 7 7 4 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: invstm_ 14 2 7 7 */
+
+extern int frmget_(integer *infrm, doublereal *et, doublereal *xform, integer *outfrm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: tisbod_ 14 5 13 4 7 7 124 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: ckfxfm_ 14 5 4 7 7 4 12 */
+/*:ref: tkfram_ 14 4 4 7 4 12 */
+/*:ref: zzdynfrm_ 14 5 4 4 7 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+
+extern integer frstnb_(char *string, ftnlen string_len);
+
+extern integer frstnp_(char *string, ftnlen string_len);
+
+extern integer frstpc_(char *string, ftnlen string_len);
+
+extern integer gcd_(integer *a, integer *b);
+
+extern int georec_(doublereal *long__, doublereal *lat, doublereal *alt, doublereal *re, doublereal *f, doublereal *rectan);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: surfnm_ 14 5 7 7 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int getelm_(integer *frstyr, char *lines, doublereal *epoch, doublereal *elems, ftnlen lines_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzgetelm_ 14 8 4 13 7 7 12 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int getfat_(char *file, char *arch, char *kertyp, ftnlen file_len, ftnlen arch_len, ftnlen kertyp_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhfnh_ 14 4 13 4 12 124 */
+/*:ref: zzddhnfo_ 14 7 4 13 4 4 4 12 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: dashof_ 14 1 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+/*:ref: idw2at_ 14 6 13 13 13 124 124 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: zzckspk_ 14 3 4 13 124 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int getfov_(integer *instid, integer *room, char *shape, char *frame, doublereal *bsight, integer *n, doublereal *bounds, ftnlen shape_len, ftnlen frame_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: vrotv_ 14 4 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+
+extern int getlun_(integer *unit);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: fndlun_ 14 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int getmsg_(char *option, char *msg, ftnlen option_len, ftnlen msg_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: getsms_ 14 2 13 124 */
+/*:ref: expln_ 14 4 13 13 124 124 */
+/*:ref: getlms_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern logical gfbail_(void);
+
+extern int gfdist_(char *target, char *abcorr, char *obsrvr, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: gfevnt_ 14 28 200 200 13 4 13 13 7 4 12 13 7 7 7 7 12 200 200 200 4 4 7 12 212 7 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfevnt_(U_fp udstep, U_fp udrefn, char *gquant, integer *qnpars, char *qpnams, char *qcpars, doublereal *qdpars, integer *qipars, logical *qlpars, char *op, doublereal *refval, doublereal *tol, doublereal *adjust, doublereal *cnfine, logical *rpt, U_fp udrepi, U_fp udrepu, U_fp udrepf, integer *mw, integer *nw, doublereal *work, logical *bail, L_fp udbail, doublereal *result, ftnlen gquant_len, ftnlen qpnams_len, ftnlen qcpars_len, ftnlen op_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: zzgfspin_ 14 11 13 13 13 13 7 13 124 124 124 124 124 */
+/*:ref: zzgfrel_ 14 26 200 200 200 200 200 200 13 7 7 7 7 4 4 7 12 200 200 200 13 13 12 212 7 124 124 124 */
+/*:ref: zzgfdiin_ 14 7 13 13 13 7 124 124 124 */
+/*:ref: zzgfcslv_ 14 37 13 13 13 13 13 13 13 7 13 13 13 7 7 7 200 200 12 200 200 200 12 212 4 4 7 7 7 124 124 124 124 124 124 124 124 124 124 */
+/*:ref: zzgfrrin_ 14 8 13 13 13 7 7 124 124 124 */
+
+extern int gffove_(char *inst, char *tshape, doublereal *raydir, char *target, char *tframe, char *abcorr, char *obsrvr, doublereal *tol, U_fp udstep, U_fp udrefn, logical *rpt, S_fp udrepi, U_fp udrepu, S_fp udrepf, logical *bail, L_fp udbail, doublereal *cnfine, doublereal *result, ftnlen inst_len, ftnlen tshape_len, ftnlen target_len, ftnlen tframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: zzgffvin_ 14 13 13 13 7 13 13 13 13 124 124 124 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: wncard_ 4 1 7 */
+/*:ref: wnfetd_ 14 4 7 4 7 7 */
+/*:ref: zzgfsolv_ 14 13 200 200 200 12 212 12 7 7 7 7 12 200 7 */
+
+extern int gfocce_(char *occtyp, char *front, char *fshape, char *fframe, char *back, char *bshape, char *bframe, char *abcorr, char *obsrvr, doublereal *tol, U_fp udstep, U_fp udrefn, logical *rpt, S_fp udrepi, U_fp udrepu, S_fp udrepf, logical *bail, L_fp udbail, doublereal *cnfine, doublereal *result, ftnlen occtyp_len, ftnlen front_len, ftnlen fshape_len, ftnlen fframe_len, ftnlen back_len, ftnlen bshape_len, ftnlen bframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzgfocin_ 14 18 13 13 13 13 13 13 13 13 13 124 124 124 124 124 124 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: wncard_ 4 1 7 */
+/*:ref: wnfetd_ 14 4 7 4 7 7 */
+/*:ref: zzgfsolv_ 14 13 200 200 200 12 212 12 7 7 7 7 12 200 7 */
+
+extern int gfoclt_(char *occtyp, char *front, char *fshape, char *fframe, char *back, char *bshape, char *bframe, char *abcorr, char *obsrvr, doublereal *step, doublereal *cnfine, doublereal *result, ftnlen occtyp_len, ftnlen front_len, ftnlen fshape_len, ftnlen fframe_len, ftnlen back_len, ftnlen bshape_len, ftnlen bframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: gfocce_ 14 29 13 13 13 13 13 13 13 13 13 7 200 200 12 200 200 200 12 212 7 7 124 124 124 124 124 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfposc_(char *target, char *frame, char *abcorr, char *obsrvr, char *crdsys, char *coord, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen target_len, ftnlen frame_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen crdsys_len, ftnlen coord_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: gfevnt_ 14 28 200 200 13 4 13 13 7 4 12 13 7 7 7 7 12 200 200 200 4 4 7 12 212 7 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfrefn_(doublereal *t1, doublereal *t2, logical *s1, logical *s2, doublereal *t);
+/*:ref: brcktd_ 7 3 7 7 7 */
+
+extern int gfrfov_(char *inst, doublereal *raydir, char *rframe, char *abcorr, char *obsrvr, doublereal *step, doublereal *cnfine, doublereal *result, ftnlen inst_len, ftnlen rframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: gffove_ 14 24 13 13 7 13 13 13 13 7 200 200 12 200 200 200 12 212 7 7 124 124 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfrprt_(doublereal *window, char *begmss, char *endmss, doublereal *ivbeg, doublereal *ivend, doublereal *time, ftnlen begmss_len, ftnlen endmss_len);
+extern int gfrepi_(doublereal *window, char *begmss, char *endmss, ftnlen begmss_len, ftnlen endmss_len);
+extern int gfrepu_(doublereal *ivbeg, doublereal *ivend, doublereal *time);
+extern int gfrepf_(void);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: wnsumd_ 14 6 7 7 7 7 4 4 */
+/*:ref: zzgftswk_ 14 7 7 7 4 13 13 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: zzgfwkin_ 14 1 7 */
+/*:ref: zzgfwkad_ 14 6 7 4 13 13 124 124 */
+/*:ref: zzgfwkmo_ 14 9 4 7 7 4 13 13 7 124 124 */
+/*:ref: stdio_ 14 3 13 4 124 */
+/*:ref: zzgfdsps_ 14 6 4 13 13 4 124 124 */
+
+extern int gfrr_(char *target, char *abcorr, char *obsrvr, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: gfevnt_ 14 28 200 200 13 4 13 13 7 4 12 13 7 7 7 7 12 200 200 200 4 4 7 12 212 7 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfsep_(char *targ1, char *shape1, char *frame1, char *targ2, char *shape2, char *frame2, char *abcorr, char *obsrvr, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen targ1_len, ftnlen shape1_len, ftnlen frame1_len, ftnlen targ2_len, ftnlen shape2_len, ftnlen frame2_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: gfevnt_ 14 28 200 200 13 4 13 13 7 4 12 13 7 7 7 7 12 200 200 200 4 4 7 12 212 7 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfsntc_(char *target, char *fixref, char *method, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, char *crdsys, char *coord, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen target_len, ftnlen fixref_len, ftnlen method_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len, ftnlen crdsys_len, ftnlen coord_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: gfevnt_ 14 28 200 200 13 4 13 13 7 4 12 13 7 7 7 7 12 200 200 200 4 4 7 12 212 7 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfstep_(doublereal *time, doublereal *step);
+extern int gfsstp_(doublereal *step);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+
+extern int gfsubc_(char *target, char *fixref, char *method, char *abcorr, char *obsrvr, char *crdsys, char *coord, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen target_len, ftnlen fixref_len, ftnlen method_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen crdsys_len, ftnlen coord_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: gfevnt_ 14 28 200 200 13 4 13 13 7 4 12 13 7 7 7 7 12 200 200 200 4 4 7 12 212 7 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gftfov_(char *inst, char *target, char *tshape, char *tframe, char *abcorr, char *obsrvr, doublereal *step, doublereal *cnfine, doublereal *result, ftnlen inst_len, ftnlen target_len, ftnlen tshape_len, ftnlen tframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: gffove_ 14 24 13 13 7 13 13 13 13 7 200 200 12 200 200 200 12 212 7 7 124 124 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfuds_(U_fp udfunc, U_fp udqdec, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen relate_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: zzgfref_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: zzgfrelx_ 14 26 200 200 200 200 200 214 13 7 7 7 7 4 4 7 12 200 200 200 13 13 12 212 7 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern doublereal halfpi_(void);
+
+extern int hrmesp_(integer *n, doublereal *first, doublereal *step, doublereal *yvals, doublereal *x, doublereal *work, doublereal *f, doublereal *df);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int hrmint_(integer *n, doublereal *xvals, doublereal *yvals, doublereal *x, doublereal *work, doublereal *f, doublereal *df);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+
+extern int hx2dp_(char *string, doublereal *number, logical *error, char *errmsg, ftnlen string_len, ftnlen errmsg_len);
+/*:ref: dpmin_ 7 0 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: hx2int_ 14 6 13 4 12 13 124 124 */
+
+extern int hx2int_(char *string, integer *number, logical *error, char *errmsg, ftnlen string_len, ftnlen errmsg_len);
+/*:ref: intmin_ 4 0 */
+/*:ref: intmax_ 4 0 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+
+extern int hyptof_(doublereal *ma, doublereal *ecc, doublereal *f);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dcbrt_ 7 1 7 */
+
+extern int ident_(doublereal *matrix);
+
+extern int idw2at_(char *idword, char *arch, char *type__, ftnlen idword_len, ftnlen arch_len, ftnlen type_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+
+extern int illum_(char *target, doublereal *et, char *abcorr, char *obsrvr, doublereal *spoint, doublereal *phase, doublereal *solar, doublereal *emissn, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: surfnm_ 14 5 7 7 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+
+extern int ilumin_(char *method, char *target, doublereal *et, char *fixref, char *abcorr, char *obsrvr, doublereal *spoint, doublereal *trgepc, doublereal *srfvec, doublereal *phase, doublereal *solar, doublereal *emissn, ftnlen method_len, ftnlen target_len, ftnlen fixref_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: surfnm_ 14 5 7 7 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+
+extern int inedpl_(doublereal *a, doublereal *b, doublereal *c__, doublereal *plane, doublereal *ellips, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: pl2psv_ 14 4 7 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: psv2pl_ 14 4 7 7 7 7 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: cgv2el_ 14 4 7 7 7 7 */
+
+extern int inelpl_(doublereal *ellips, doublereal *plane, integer *nxpts, doublereal *xpt1, doublereal *xpt2);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: pl2nvp_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: nvp2pl_ 14 3 7 7 7 */
+/*:ref: vzerog_ 12 2 7 4 */
+/*:ref: vnormg_ 7 2 7 4 */
+/*:ref: vlcom3_ 14 7 7 7 7 7 7 7 7 */
+
+extern int inrypl_(doublereal *vertex, doublereal *dir, doublereal *plane, integer *nxpts, doublereal *xpt);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: smsgnd_ 12 2 7 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+
+extern int inslac_(char *elts, integer *ne, integer *loc, char *array, integer *na, ftnlen elts_len, ftnlen array_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int inslad_(doublereal *elts, integer *ne, integer *loc, doublereal *array, integer *na);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int inslai_(integer *elts, integer *ne, integer *loc, integer *array, integer *na);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int insrtc_(char *item, char *a, ftnlen item_len, ftnlen a_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int insrtd_(doublereal *item, doublereal *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int insrti_(integer *item, integer *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlei_ 4 3 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int inssub_(char *in, char *sub, integer *loc, char *out, ftnlen in_len, ftnlen sub_len, ftnlen out_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int int2hx_(integer *number, char *string, integer *length, ftnlen string_len);
+
+extern int interc_(char *a, char *b, char *c__, ftnlen a_len, ftnlen b_len, ftnlen c_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: excess_ 14 3 4 13 124 */
+
+extern int interd_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int interi_(integer *a, integer *b, integer *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int intord_(integer *n, char *string, ftnlen string_len);
+/*:ref: inttxt_ 14 3 4 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int intstr_(integer *number, char *string, ftnlen string_len);
+
+extern int inttxt_(integer *n, char *string, ftnlen string_len);
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int invert_(doublereal *m1, doublereal *mout);
+/*:ref: det_ 7 1 7 */
+/*:ref: filld_ 14 3 7 4 7 */
+/*:ref: vsclg_ 14 4 7 7 4 7 */
+
+extern int invort_(doublereal *m, doublereal *mit);
+/*:ref: dpmax_ 7 0 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: xpose_ 14 2 7 7 */
+
+extern int invstm_(doublereal *mat, doublereal *invmat);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: xposbl_ 14 5 7 4 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ioerr_(char *action, char *file, integer *iostat, ftnlen action_len, ftnlen file_len);
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+
+extern int irftrn_(char *refa, char *refb, doublereal *rotab, ftnlen refa_len, ftnlen refb_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int iso2utc_(char *tstrng, char *utcstr, char *error, ftnlen tstrng_len, ftnlen utcstr_len, ftnlen error_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical isopen_(char *file, ftnlen file_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern logical isordv_(integer *array, integer *n);
+
+extern integer isrchc_(char *value, integer *ndim, char *array, ftnlen value_len, ftnlen array_len);
+
+extern integer isrchd_(doublereal *value, integer *ndim, doublereal *array);
+
+extern integer isrchi_(integer *value, integer *ndim, integer *array);
+
+extern logical isrot_(doublereal *m, doublereal *ntol, doublereal *dtol);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: det_ 7 1 7 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+
+extern doublereal j1900_(void);
+
+extern doublereal j1950_(void);
+
+extern doublereal j2000_(void);
+
+extern doublereal j2100_(void);
+
+extern int jul2gr_(integer *year, integer *month, integer *day, integer *doy);
+extern int gr2jul_(integer *year, integer *month, integer *day, integer *doy);
+/*:ref: rmaini_ 14 4 4 4 4 4 */
+/*:ref: lstlti_ 4 3 4 4 4 */
+
+extern doublereal jyear_(void);
+
+extern int keeper_(integer *which, char *kind, char *file, integer *count, char *filtyp, integer *handle, char *source, logical *found, ftnlen kind_len, ftnlen file_len, ftnlen filtyp_len, ftnlen source_len);
+extern int furnsh_(char *file, ftnlen file_len);
+extern int ktotal_(char *kind, integer *count, ftnlen kind_len);
+extern int kdata_(integer *which, char *kind, char *file, char *filtyp, char *source, integer *handle, logical *found, ftnlen kind_len, ftnlen file_len, ftnlen filtyp_len, ftnlen source_len);
+extern int kinfo_(char *file, char *filtyp, char *source, integer *handle, logical *found, ftnlen file_len, ftnlen filtyp_len, ftnlen source_len);
+extern int kclear_(void);
+extern int unload_(char *file, ftnlen file_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzldker_ 14 7 13 13 13 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: stpool_ 14 9 13 4 13 13 4 12 124 124 124 */
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: samsub_ 12 8 13 4 4 13 4 4 124 124 */
+/*:ref: repsub_ 14 8 13 4 4 13 13 124 124 124 */
+/*:ref: repmot_ 14 9 13 13 4 13 13 124 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dvpool_ 14 2 13 124 */
+/*:ref: fndnwd_ 14 5 13 4 4 4 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: spkuef_ 14 1 4 */
+/*:ref: ckupf_ 14 1 4 */
+/*:ref: pckuof_ 14 1 4 */
+/*:ref: ekuef_ 14 1 4 */
+/*:ref: clpool_ 14 0 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: ldpool_ 14 2 13 124 */
+/*:ref: spklef_ 14 3 13 4 124 */
+/*:ref: cklpf_ 14 3 13 4 124 */
+/*:ref: pcklof_ 14 3 13 4 124 */
+/*:ref: eklef_ 14 3 13 4 124 */
+
+extern doublereal kepleq_(doublereal *ml, doublereal *h__, doublereal *k);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: kpsolv_ 7 1 7 */
+
+extern doublereal kpsolv_(doublereal *evec);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int kxtrct_(char *keywd, char *terms, integer *nterms, char *string, logical *found, char *substr, ftnlen keywd_len, ftnlen terms_len, ftnlen string_len, ftnlen substr_len);
+/*:ref: wdindx_ 4 4 13 13 124 124 */
+/*:ref: nblen_ 4 2 13 124 */
+/*:ref: fndnwd_ 14 5 13 4 4 4 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: shiftl_ 14 7 13 4 13 13 124 124 124 */
+
+extern integer lastnb_(char *string, ftnlen string_len);
+
+extern integer lastpc_(char *string, ftnlen string_len);
+
+extern int latcyl_(doublereal *radius, doublereal *long__, doublereal *lat, doublereal *r__, doublereal *longc, doublereal *z__);
+
+extern int latrec_(doublereal *radius, doublereal *long__, doublereal *lat, doublereal *rectan);
+
+extern int latsph_(doublereal *radius, doublereal *long__, doublereal *lat, doublereal *rho, doublereal *colat, doublereal *longs);
+/*:ref: halfpi_ 7 0 */
+
+extern int lbuild_(char *items, integer *n, char *delim, char *list, ftnlen items_len, ftnlen delim_len, ftnlen list_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int lcase_(char *in, char *out, ftnlen in_len, ftnlen out_len);
+
+extern doublereal lgresp_(integer *n, doublereal *first, doublereal *step, doublereal *yvals, doublereal *work, doublereal *x);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lgrind_(integer *n, doublereal *xvals, doublereal *yvals, doublereal *work, doublereal *x, doublereal *p, doublereal *dp);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+
+extern doublereal lgrint_(integer *n, doublereal *xvals, doublereal *yvals, doublereal *work, doublereal *x);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+
+extern int ljust_(char *input, char *output, ftnlen input_len, ftnlen output_len);
+
+extern int lnkan_(integer *pool, integer *new__);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lnkfsl_(integer *head, integer *tail, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer lnkhl_(integer *node, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lnkila_(integer *prev, integer *list, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lnkilb_(integer *list, integer *next, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lnkini_(integer *size, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer lnknfn_(integer *pool);
+
+extern integer lnknxt_(integer *node, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer lnkprv_(integer *node, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer lnksiz_(integer *pool);
+
+extern integer lnktl_(integer *node, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lnkxsl_(integer *head, integer *tail, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int locati_(integer *id, integer *idsz, integer *list, integer *pool, integer *at, logical *presnt);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnksiz_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: lnkxsl_ 14 3 4 4 4 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+
+extern int locln_(integer *unit, char *bmark, char *emark, char *line, integer *bline, integer *eline, logical *found, ftnlen bmark_len, ftnlen emark_len, ftnlen line_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ltrim_ 4 2 13 124 */
+
+extern int lparse_(char *list, char *delim, integer *nmax, integer *n, char *items, ftnlen list_len, ftnlen delim_len, ftnlen items_len);
+
+extern int lparsm_(char *list, char *delims, integer *nmax, integer *n, char *items, ftnlen list_len, ftnlen delims_len, ftnlen items_len);
+
+extern int lparss_(char *list, char *delims, char *set, ftnlen list_len, ftnlen delims_len, ftnlen set_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: insrtc_ 14 4 13 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: validc_ 14 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern doublereal lspcn_(char *body, doublereal *et, char *abcorr, ftnlen body_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: tipbod_ 14 5 13 4 7 7 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: twovec_ 14 5 7 4 7 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: spkezr_ 14 11 13 7 13 13 13 7 7 124 124 124 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: recrad_ 14 4 7 7 7 7 */
+
+extern integer lstcld_(doublereal *x, integer *n, doublereal *array);
+
+extern integer lstcli_(integer *x, integer *n, integer *array);
+
+extern integer lstlec_(char *string, integer *n, char *array, ftnlen string_len, ftnlen array_len);
+
+extern integer lstled_(doublereal *x, integer *n, doublereal *array);
+
+extern integer lstlei_(integer *x, integer *n, integer *array);
+
+extern integer lstltc_(char *string, integer *n, char *array, ftnlen string_len, ftnlen array_len);
+
+extern integer lstltd_(doublereal *x, integer *n, doublereal *array);
+
+extern integer lstlti_(integer *x, integer *n, integer *array);
+
+extern int ltime_(doublereal *etobs, integer *obs, char *dir, integer *targ, doublereal *ettarg, doublereal *elapsd, ftnlen dir_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: clight_ 7 0 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: failed_ 12 0 */
+
+extern integer ltrim_(char *string, ftnlen string_len);
+/*:ref: frstnb_ 4 2 13 124 */
+
+extern int lun2fn_(integer *lunit, char *filnam, ftnlen filnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lx4dec_(char *string, integer *first, integer *last, integer *nchar, ftnlen string_len);
+/*:ref: lx4uns_ 14 5 13 4 4 4 124 */
+/*:ref: lx4sgn_ 14 5 13 4 4 4 124 */
+
+extern int lx4num_(char *string, integer *first, integer *last, integer *nchar, ftnlen string_len);
+/*:ref: lx4dec_ 14 5 13 4 4 4 124 */
+/*:ref: lx4sgn_ 14 5 13 4 4 4 124 */
+
+extern int lx4sgn_(char *string, integer *first, integer *last, integer *nchar, ftnlen string_len);
+/*:ref: lx4uns_ 14 5 13 4 4 4 124 */
+
+extern int lx4uns_(char *string, integer *first, integer *last, integer *nchar, ftnlen string_len);
+
+extern int lxname_(char *hdchrs, char *tlchrs, char *string, integer *first, integer *last, integer *idspec, integer *nchar, ftnlen hdchrs_len, ftnlen tlchrs_len, ftnlen string_len);
+extern int lxidnt_(integer *idspec, char *string, integer *first, integer *last, integer *nchar, ftnlen string_len);
+extern int lxdfid_(integer *idspec);
+extern int lxcsid_(char *hdchrs, char *tlchrs, integer *idspec, ftnlen hdchrs_len, ftnlen tlchrs_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: bsrchi_ 4 3 4 4 4 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: validi_ 14 3 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: appndi_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: cardi_ 4 1 4 */
+
+extern int lxqstr_(char *string, char *qchar, integer *first, integer *last, integer *nchar, ftnlen string_len, ftnlen qchar_len);
+
+extern int m2eul_(doublereal *r__, integer *axis3, integer *axis2, integer *axis1, doublereal *angle3, doublereal *angle2, doublereal *angle1);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: isrot_ 12 3 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: mtxm_ 14 3 7 7 7 */
+
+extern int m2q_(doublereal *r__, doublereal *q);
+/*:ref: isrot_ 12 3 7 7 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical matchi_(char *string, char *templ, char *wstr, char *wchr, ftnlen string_len, ftnlen templ_len, ftnlen wstr_len, ftnlen wchr_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: samch_ 12 6 13 4 13 4 124 124 */
+/*:ref: nechr_ 12 4 13 13 124 124 */
+/*:ref: samchi_ 12 6 13 4 13 4 124 124 */
+
+extern logical matchw_(char *string, char *templ, char *wstr, char *wchr, ftnlen string_len, ftnlen templ_len, ftnlen wstr_len, ftnlen wchr_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: samch_ 12 6 13 4 13 4 124 124 */
+
+extern int maxac_(char *array, integer *ndim, char *maxval, integer *loc, ftnlen array_len, ftnlen maxval_len);
+
+extern int maxad_(doublereal *array, integer *ndim, doublereal *maxval, integer *loc);
+
+extern int maxai_(integer *array, integer *ndim, integer *maxval, integer *loc);
+
+extern int mequ_(doublereal *m1, doublereal *mout);
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int mequg_(doublereal *m1, integer *nr, integer *nc, doublereal *mout);
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int minac_(char *array, integer *ndim, char *minval, integer *loc, ftnlen array_len, ftnlen minval_len);
+
+extern int minad_(doublereal *array, integer *ndim, doublereal *minval, integer *loc);
+
+extern int minai_(integer *array, integer *ndim, integer *minval, integer *loc);
+
+extern int movec_(char *arrfrm, integer *ndim, char *arrto, ftnlen arrfrm_len, ftnlen arrto_len);
+
+extern int movei_(integer *arrfrm, integer *ndim, integer *arrto);
+
+extern int mtxm_(doublereal *m1, doublereal *m2, doublereal *mout);
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int mtxmg_(doublereal *m1, doublereal *m2, integer *nc1, integer *nr1r2, integer *nc2, doublereal *mout);
+
+extern int mtxv_(doublereal *matrix, doublereal *vin, doublereal *vout);
+
+extern int mtxvg_(doublereal *m1, doublereal *v2, integer *nc1, integer *nr1r2, doublereal *vout);
+
+extern int mxm_(doublereal *m1, doublereal *m2, doublereal *mout);
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int mxmg_(doublereal *m1, doublereal *m2, integer *row1, integer *col1, integer *col2, doublereal *mout);
+
+extern int mxmt_(doublereal *m1, doublereal *m2, doublereal *mout);
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int mxmtg_(doublereal *m1, doublereal *m2, integer *nr1, integer *nc1c2, integer *nr2, doublereal *mout);
+
+extern int mxv_(doublereal *matrix, doublereal *vin, doublereal *vout);
+
+extern int mxvg_(doublereal *m1, doublereal *v2, integer *nr1, integer *nc1r2, doublereal *vout);
+
+extern integer nblen_(char *string, ftnlen string_len);
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+
+extern integer nbwid_(char *array, integer *nelt, ftnlen array_len);
+
+extern integer ncpos_(char *str, char *chars, integer *start, ftnlen str_len, ftnlen chars_len);
+
+extern integer ncposr_(char *str, char *chars, integer *start, ftnlen str_len, ftnlen chars_len);
+
+extern int nearpt_(doublereal *positn, doublereal *a, doublereal *b, doublereal *c__, doublereal *npoint, doublereal *alt);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: orderd_ 14 3 7 4 4 */
+/*:ref: reordd_ 14 3 4 4 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: approx_ 12 3 7 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: surfnm_ 14 5 7 7 7 7 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+
+extern int nextwd_(char *string, char *next, char *rest, ftnlen string_len, ftnlen next_len, ftnlen rest_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+
+extern logical notru_(logical *logcls, integer *n);
+
+extern int nparsd_(char *string, doublereal *x, char *error, integer *ptr, ftnlen string_len, ftnlen error_len);
+/*:ref: dpmax_ 7 0 */
+/*:ref: zzinssub_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: pi_ 7 0 */
+
+extern int nparsi_(char *string, integer *n, char *error, integer *pnter, ftnlen string_len, ftnlen error_len);
+/*:ref: intmax_ 4 0 */
+/*:ref: intmin_ 4 0 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+
+extern int npedln_(doublereal *a, doublereal *b, doublereal *c__, doublereal *linept, doublereal *linedr, doublereal *pnear, doublereal *dist);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: nvc2pl_ 14 3 7 7 7 */
+/*:ref: inedpl_ 14 6 7 7 7 7 7 12 */
+/*:ref: pjelpl_ 14 3 7 7 7 */
+/*:ref: vprjp_ 14 3 7 7 7 */
+/*:ref: npelpt_ 14 4 7 7 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: vprjpi_ 14 5 7 7 7 7 12 */
+/*:ref: vsclip_ 14 2 7 7 */
+
+extern int npelpt_(doublereal *point, doublereal *ellips, doublereal *pnear, doublereal *dist);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: twovec_ 14 5 7 4 7 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+
+extern int nplnpt_(doublereal *linpt, doublereal *lindir, doublereal *point, doublereal *pnear, doublereal *dist);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vproj_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+
+extern int nthwd_(char *string, integer *nth, char *word, integer *loc, ftnlen string_len, ftnlen word_len);
+
+extern int nvc2pl_(doublereal *normal, doublereal *const__, doublereal *plane);
+/*:ref: return_ 12 0 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int nvp2pl_(doublereal *normal, doublereal *point, doublereal *plane);
+/*:ref: return_ 12 0 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern logical odd_(integer *i__);
+
+extern logical opsgnd_(doublereal *x, doublereal *y);
+
+extern logical opsgni_(integer *x, integer *y);
+
+extern integer ordc_(char *item, char *set, ftnlen item_len, ftnlen set_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer ordd_(doublereal *item, doublereal *set);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bsrchd_ 4 3 7 4 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int orderc_(char *array, integer *ndim, integer *iorder, ftnlen array_len);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int orderd_(doublereal *array, integer *ndim, integer *iorder);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int orderi_(integer *array, integer *ndim, integer *iorder);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern integer ordi_(integer *item, integer *set);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bsrchi_ 4 3 4 4 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int oscelt_(doublereal *state, doublereal *et, doublereal *mu, doublereal *elts);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: exact_ 7 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: pi_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: dacosh_ 7 1 7 */
+
+extern int outmsg_(char *list, ftnlen list_len);
+/*:ref: lparse_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: getdev_ 14 2 13 124 */
+/*:ref: wrline_ 14 4 13 13 124 124 */
+/*:ref: msgsel_ 12 2 13 124 */
+/*:ref: tkvrsn_ 14 4 13 13 124 124 */
+/*:ref: getsms_ 14 2 13 124 */
+/*:ref: expln_ 14 4 13 13 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: getlms_ 14 2 13 124 */
+/*:ref: wdcnt_ 4 2 13 124 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: trcdep_ 14 1 4 */
+/*:ref: trcnam_ 14 3 4 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int packac_(char *in, integer *pack, integer *npack, integer *maxout, integer *nout, char *out, ftnlen in_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int packad_(doublereal *in, integer *pack, integer *npack, integer *maxout, integer *nout, doublereal *out);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int packai_(integer *in, integer *pack, integer *npack, integer *maxout, integer *nout, integer *out);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int parsqs_(char *string, char *qchar, char *value, integer *length, logical *error, char *errmsg, integer *ptr, ftnlen string_len, ftnlen qchar_len, ftnlen value_len, ftnlen errmsg_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int partof_(doublereal *ma, doublereal *d__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dcbrt_ 7 1 7 */
+
+extern int pck03a_(integer *handle, integer *ncsets, doublereal *coeffs, doublereal *epochs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgwfpk_ 14 5 4 4 7 4 7 */
+
+extern int pck03b_(integer *handle, char *segid, integer *body, char *frame, doublereal *first, doublereal *last, integer *chbdeg, ftnlen segid_len, ftnlen frame_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pckpds_ 14 7 4 13 4 7 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: sgbwfs_ 14 8 4 7 13 4 7 4 4 124 */
+
+extern int pck03e_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgwes_ 14 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pckbsr_(char *fname, integer *handle, integer *body, doublereal *et, doublereal *descr, char *ident, logical *found, ftnlen fname_len, ftnlen ident_len);
+extern int pcklof_(char *fname, integer *handle, ftnlen fname_len);
+extern int pckuof_(integer *handle);
+extern int pcksfs_(integer *body, doublereal *et, integer *handle, doublereal *descr, char *ident, logical *found, ftnlen ident_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: lnkprv_ 4 2 4 4 */
+/*:ref: dpmin_ 7 0 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafbbs_ 14 1 4 */
+/*:ref: daffpa_ 14 1 12 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: dafgn_ 14 2 13 124 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: lnktl_ 4 2 4 4 */
+
+extern int pckcls_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int pckcov_(char *pck, integer *idcode, doublereal *cover, ftnlen pck_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int pcke02_(doublereal *et, doublereal *record, doublereal *eulang);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spke02_ 14 3 7 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pcke03_(doublereal *et, doublereal *record, doublereal *rotmat);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chbval_ 14 5 7 4 7 7 7 */
+/*:ref: rpd_ 7 0 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pckeul_(integer *body, doublereal *et, logical *found, char *ref, doublereal *eulang, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: pcksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: irfnam_ 14 3 4 13 124 */
+/*:ref: pckr02_ 14 4 4 7 7 7 */
+/*:ref: pcke02_ 14 3 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pckfrm_(char *pck, integer *ids, ftnlen pck_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int pckmat_(integer *body, doublereal *et, integer *ref, doublereal *tsipm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: pcksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: pckr02_ 14 4 4 7 7 7 */
+/*:ref: pcke02_ 14 3 7 7 7 */
+/*:ref: eul2xf_ 14 5 7 4 4 4 7 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: pckr03_ 14 4 4 7 7 7 */
+/*:ref: pcke03_ 14 3 7 7 7 */
+
+extern int pckopn_(char *name__, char *ifname, integer *ncomch, integer *handle, ftnlen name_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafonw_ 14 10 13 13 4 4 13 4 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pckpds_(integer *body, char *frame, integer *type__, doublereal *first, doublereal *last, doublereal *descr, ftnlen frame_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+
+extern int pckr02_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pckr03_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: sgfrvi_ 14 6 4 7 7 7 4 12 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+
+extern int pckuds_(doublereal *descr, integer *body, integer *frame, integer *type__, doublereal *first, doublereal *last, integer *begin, integer *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pckw02_(integer *handle, integer *body, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *intlen, integer *n, integer *polydg, doublereal *cdata, doublereal *btime, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: chckid_ 14 5 13 4 13 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern integer pcwid_(char *array, integer *nelt, ftnlen array_len);
+
+extern int pgrrec_(char *body, doublereal *lon, doublereal *lat, doublereal *alt, doublereal *re, doublereal *f, doublereal *rectan, ftnlen body_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: plnsns_ 4 1 4 */
+/*:ref: georec_ 14 6 7 7 7 7 7 7 */
+
+extern doublereal pi_(void);
+
+extern int pjelpl_(doublereal *elin, doublereal *plane, doublereal *elout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vprjp_ 14 3 7 7 7 */
+/*:ref: cgv2el_ 14 4 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pl2nvc_(doublereal *plane, doublereal *normal, doublereal *const__);
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int pl2nvp_(doublereal *plane, doublereal *normal, doublereal *point);
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+
+extern int pl2psv_(doublereal *plane, doublereal *point, doublereal *span1, doublereal *span2);
+/*:ref: pl2nvp_ 14 3 7 7 7 */
+/*:ref: frame_ 14 3 7 7 7 */
+
+extern integer plnsns_(integer *bodid);
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+
+extern int polyds_(doublereal *coeffs, integer *deg, integer *nderiv, doublereal *t, doublereal *p);
+
+extern int pool_(char *kernel, integer *unit, char *name__, char *names, integer *nnames, char *agent, integer *n, doublereal *values, logical *found, logical *update, integer *start, integer *room, char *cvals, integer *ivals, char *type__, char *uwvars, integer *uwptrs, integer *uwpool, char *uwagnt, ftnlen kernel_len, ftnlen name_len, ftnlen names_len, ftnlen agent_len, ftnlen cvals_len, ftnlen type_len, ftnlen uwvars_len, ftnlen uwagnt_len);
+extern int clpool_(void);
+extern int ldpool_(char *kernel, ftnlen kernel_len);
+extern int rtpool_(char *name__, integer *n, doublereal *values, logical *found, ftnlen name_len);
+extern int expool_(char *name__, logical *found, ftnlen name_len);
+extern int wrpool_(integer *unit);
+extern int swpool_(char *agent, integer *nnames, char *names, ftnlen agent_len, ftnlen names_len);
+extern int cvpool_(char *agent, logical *update, ftnlen agent_len);
+extern int gcpool_(char *name__, integer *start, integer *room, integer *n, char *cvals, logical *found, ftnlen name_len, ftnlen cvals_len);
+extern int gdpool_(char *name__, integer *start, integer *room, integer *n, doublereal *values, logical *found, ftnlen name_len);
+extern int gipool_(char *name__, integer *start, integer *room, integer *n, integer *ivals, logical *found, ftnlen name_len);
+extern int dtpool_(char *name__, logical *found, integer *n, char *type__, ftnlen name_len, ftnlen type_len);
+extern int pcpool_(char *name__, integer *n, char *cvals, ftnlen name_len, ftnlen cvals_len);
+extern int pdpool_(char *name__, integer *n, doublereal *values, ftnlen name_len);
+extern int pipool_(char *name__, integer *n, integer *ivals, ftnlen name_len);
+extern int lmpool_(char *cvals, integer *n, ftnlen cvals_len);
+extern int szpool_(char *name__, integer *n, logical *found, ftnlen name_len);
+extern int dvpool_(char *name__, ftnlen name_len);
+extern int gnpool_(char *name__, integer *start, integer *room, integer *n, char *cvals, logical *found, ftnlen name_len, ftnlen cvals_len);
+extern int dwpool_(char *agent, ftnlen agent_len);
+extern int zzvupool_(char *uwvars, integer *uwptrs, integer *uwpool, char *uwagnt, ftnlen uwvars_len, ftnlen uwagnt_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzpini_ 14 27 12 4 4 4 13 13 4 4 4 4 4 4 4 13 4 4 13 13 13 13 124 124 124 124 124 124 124 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: zznwpool_ 14 14 13 13 4 4 13 13 13 13 124 124 124 124 124 124 */
+/*:ref: rdknew_ 14 2 13 124 */
+/*:ref: zzrvar_ 14 13 4 4 13 4 4 7 4 13 13 12 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: elemc_ 12 4 13 13 124 124 */
+/*:ref: cltext_ 14 2 13 124 */
+/*:ref: zzhash_ 4 2 13 124 */
+/*:ref: ioerr_ 14 5 13 13 4 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzgapool_ 14 10 13 13 4 4 13 13 124 124 124 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnktl_ 4 2 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: lstltc_ 4 5 13 4 13 124 124 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: insrtc_ 14 4 13 13 124 124 */
+/*:ref: removc_ 14 4 13 13 124 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: intmin_ 4 0 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: zzgpnm_ 14 15 4 4 13 4 4 7 4 13 13 12 4 4 124 124 124 */
+/*:ref: zzcln_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: zzrvbf_ 14 17 13 4 4 4 4 13 4 4 7 4 13 13 12 124 124 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: matchi_ 12 8 13 13 13 13 124 124 124 124 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: copyc_ 14 4 13 13 124 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+
+extern integer pos_(char *str, char *substr, integer *start, ftnlen str_len, ftnlen substr_len);
+
+extern integer posr_(char *str, char *substr, integer *start, ftnlen str_len, ftnlen substr_len);
+
+extern int prefix_(char *pref, integer *spaces, char *string, ftnlen pref_len, ftnlen string_len);
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: shiftr_ 14 7 13 4 13 13 124 124 124 */
+
+extern doublereal prodad_(doublereal *array, integer *n);
+
+extern integer prodai_(integer *array, integer *n);
+
+extern int prompt_(char *prmpt, char *string, ftnlen prmpt_len, ftnlen string_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int prop2b_(doublereal *gm, doublereal *pvinit, doublereal *dt, doublereal *pvprop);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: brckti_ 4 3 4 4 4 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: stmp03_ 14 5 7 7 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vequg_ 14 3 7 4 7 */
+
+extern int prsdp_(char *string, doublereal *dpval, ftnlen string_len);
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int prsint_(char *string, integer *intval, ftnlen string_len);
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int prtenc_(integer *number, char *string, ftnlen string_len);
+extern int prtdec_(char *string, integer *number, ftnlen string_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical prtpkg_(logical *short__, logical *long__, logical *expl, logical *trace, logical *dfault, char *type__, ftnlen type_len);
+extern logical setprt_(logical *short__, logical *expl, logical *long__, logical *trace, logical *dfault);
+extern logical msgsel_(char *type__, ftnlen type_len);
+/*:ref: getdev_ 14 2 13 124 */
+/*:ref: wrline_ 14 4 13 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+
+extern int psv2pl_(doublereal *point, doublereal *span1, doublereal *span2, doublereal *plane);
+/*:ref: return_ 12 0 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int putact_(integer *action);
+extern int getact_(integer *action);
+
+extern int putdev_(char *device, ftnlen device_len);
+extern int getdev_(char *device, ftnlen device_len);
+
+extern int putlms_(char *msg, ftnlen msg_len);
+extern int getlms_(char *msg, ftnlen msg_len);
+
+extern int putsms_(char *msg, ftnlen msg_len);
+extern int getsms_(char *msg, ftnlen msg_len);
+
+extern int pxform_(char *from, char *to, doublereal *et, doublereal *rotate, ftnlen from_len, ftnlen to_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: refchg_ 14 4 4 4 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int q2m_(doublereal *q, doublereal *r__);
+
+extern int qderiv_(integer *n, doublereal *f0, doublereal *f2, doublereal *delta, doublereal *dfdt);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vlcomg_ 14 6 4 7 7 7 7 7 */
+
+extern int qdq2av_(doublereal *q, doublereal *dq, doublereal *av);
+/*:ref: vhatg_ 14 3 7 4 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: qxq_ 14 3 7 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+
+extern int quote_(char *in, char *left, char *right, char *out, ftnlen in_len, ftnlen left_len, ftnlen right_len, ftnlen out_len);
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+
+extern int qxq_(doublereal *q1, doublereal *q2, doublereal *qout);
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vlcom3_ 14 7 7 7 7 7 7 7 7 */
+
+extern int radrec_(doublereal *range, doublereal *ra, doublereal *dec, doublereal *rectan);
+/*:ref: latrec_ 14 4 7 7 7 7 */
+
+extern int rav2xf_(doublereal *rot, doublereal *av, doublereal *xform);
+/*:ref: mxm_ 14 3 7 7 7 */
+
+extern int raxisa_(doublereal *matrix, doublereal *axis, doublereal *angle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: m2q_ 14 2 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: pi_ 7 0 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+
+extern int rdencc_(integer *unit, integer *n, char *data, ftnlen data_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: hx2int_ 14 6 13 4 12 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int rdencd_(integer *unit, integer *n, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: hx2dp_ 14 6 13 7 12 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int rdenci_(integer *unit, integer *n, integer *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: hx2int_ 14 6 13 4 12 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int rdker_(char *kernel, char *line, integer *number, logical *eof, ftnlen kernel_len, ftnlen line_len);
+extern int rdknew_(char *kernel, ftnlen kernel_len);
+extern int rdkdat_(char *line, logical *eof, ftnlen line_len);
+extern int rdklin_(char *kernel, integer *number, ftnlen kernel_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cltext_ 14 2 13 124 */
+/*:ref: zzsetnnread_ 14 1 12 */
+/*:ref: rdtext_ 14 5 13 13 12 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: failed_ 12 0 */
+
+extern int rdkvar_(char *tabsym, integer *tabptr, doublereal *tabval, char *name__, logical *eof, ftnlen tabsym_len, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: rdkdat_ 14 3 13 12 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: replch_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+/*:ref: sydeld_ 14 6 13 13 4 7 124 124 */
+/*:ref: tparse_ 14 5 13 7 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: syenqd_ 14 7 13 7 13 4 7 124 124 */
+
+extern int rdnbl_(char *file, char *line, logical *eof, ftnlen file_len, ftnlen line_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: rdtext_ 14 5 13 13 12 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int rdtext_(char *file, char *line, logical *eof, ftnlen file_len, ftnlen line_len);
+extern int cltext_(char *file, ftnlen file_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: getlun_ 14 1 4 */
+
+extern int readla_(integer *unit, integer *maxlin, integer *numlin, char *array, logical *eof, ftnlen array_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: readln_ 14 4 4 13 12 124 */
+/*:ref: failed_ 12 0 */
+
+extern int readln_(integer *unit, char *line, logical *eof, ftnlen line_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int reccyl_(doublereal *rectan, doublereal *r__, doublereal *long__, doublereal *z__);
+/*:ref: twopi_ 7 0 */
+
+extern int recgeo_(doublereal *rectan, doublereal *re, doublereal *f, doublereal *long__, doublereal *lat, doublereal *alt);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: surfnm_ 14 5 7 7 7 7 7 */
+/*:ref: reclat_ 14 4 7 7 7 7 */
+
+extern int reclat_(doublereal *rectan, doublereal *radius, doublereal *long__, doublereal *lat);
+
+extern int recpgr_(char *body, doublereal *rectan, doublereal *re, doublereal *f, doublereal *lon, doublereal *lat, doublereal *alt, ftnlen body_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: plnsns_ 4 1 4 */
+/*:ref: recgeo_ 14 6 7 7 7 7 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+
+extern int recrad_(doublereal *rectan, doublereal *range, doublereal *ra, doublereal *dec);
+/*:ref: reclat_ 14 4 7 7 7 7 */
+/*:ref: twopi_ 7 0 */
+
+extern int recsph_(doublereal *rectan, doublereal *r__, doublereal *colat, doublereal *long__);
+
+extern int refchg_(integer *frame1, integer *frame2, doublereal *et, doublereal *rotate);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ident_ 14 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: rotget_ 14 5 4 7 7 4 12 */
+/*:ref: zzrxr_ 14 3 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zznofcon_ 14 7 7 4 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: xpose_ 14 2 7 7 */
+
+extern int remlac_(integer *ne, integer *loc, char *array, integer *na, ftnlen array_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int remlad_(integer *ne, integer *loc, doublereal *array, integer *na);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int remlai_(integer *ne, integer *loc, integer *array, integer *na);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int removc_(char *item, char *a, ftnlen item_len, ftnlen a_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int removd_(doublereal *item, doublereal *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: bsrchd_ 4 3 7 4 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int removi_(integer *item, integer *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: bsrchi_ 4 3 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int remsub_(char *in, integer *left, integer *right, char *out, ftnlen in_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int reordc_(integer *iorder, integer *ndim, char *array, ftnlen array_len);
+
+extern int reordd_(integer *iorder, integer *ndim, doublereal *array);
+
+extern int reordi_(integer *iorder, integer *ndim, integer *array);
+
+extern int reordl_(integer *iorder, integer *ndim, logical *array);
+
+extern int replch_(char *instr, char *old, char *new__, char *outstr, ftnlen instr_len, ftnlen old_len, ftnlen new_len, ftnlen outstr_len);
+
+extern int replwd_(char *instr, integer *nth, char *new__, char *outstr, ftnlen instr_len, ftnlen new_len, ftnlen outstr_len);
+/*:ref: nthwd_ 14 6 13 4 13 4 124 124 */
+/*:ref: fndnwd_ 14 5 13 4 4 4 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int repmc_(char *in, char *marker, char *value, char *out, ftnlen in_len, ftnlen marker_len, ftnlen value_len, ftnlen out_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: zzrepsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int repmct_(char *in, char *marker, integer *value, char *case__, char *out, ftnlen in_len, ftnlen marker_len, ftnlen case_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: inttxt_ 14 3 4 13 124 */
+/*:ref: lcase_ 14 4 13 13 124 124 */
+/*:ref: repsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int repmd_(char *in, char *marker, doublereal *value, integer *sigdig, char *out, ftnlen in_len, ftnlen marker_len, ftnlen out_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: dpstr_ 14 4 7 4 13 124 */
+/*:ref: zzrepsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int repmf_(char *in, char *marker, doublereal *value, integer *sigdig, char *format, char *out, ftnlen in_len, ftnlen marker_len, ftnlen format_len, ftnlen out_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: dpstrf_ 14 6 7 4 13 13 124 124 */
+/*:ref: zzrepsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int repmi_(char *in, char *marker, integer *value, char *out, ftnlen in_len, ftnlen marker_len, ftnlen out_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: zzrepsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int repmot_(char *in, char *marker, integer *value, char *case__, char *out, ftnlen in_len, ftnlen marker_len, ftnlen case_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: intord_ 14 3 4 13 124 */
+/*:ref: lcase_ 14 4 13 13 124 124 */
+/*:ref: repsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int repsub_(char *in, integer *left, integer *right, char *string, char *out, ftnlen in_len, ftnlen string_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+
+extern int reset_(void);
+/*:ref: seterr_ 12 1 12 */
+/*:ref: putsms_ 14 2 13 124 */
+/*:ref: putlms_ 14 2 13 124 */
+/*:ref: accept_ 12 1 12 */
+
+extern logical return_(void);
+/*:ref: getact_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+
+extern int rjust_(char *input, char *output, ftnlen input_len, ftnlen output_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int rmaind_(doublereal *num, doublereal *denom, doublereal *q, doublereal *rem);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int rmaini_(integer *num, integer *denom, integer *q, integer *rem);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int rmdupc_(integer *nelt, char *array, ftnlen array_len);
+/*:ref: shellc_ 14 3 4 13 124 */
+
+extern int rmdupd_(integer *nelt, doublereal *array);
+/*:ref: shelld_ 14 2 4 7 */
+
+extern int rmdupi_(integer *nelt, integer *array);
+/*:ref: shelli_ 14 2 4 4 */
+
+extern int rotate_(doublereal *angle, integer *iaxis, doublereal *mout);
+
+extern int rotget_(integer *infrm, doublereal *et, doublereal *rotate, integer *outfrm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: tipbod_ 14 5 13 4 7 7 124 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckfrot_ 14 5 4 7 7 4 12 */
+/*:ref: tkfram_ 14 4 4 7 4 12 */
+/*:ref: zzdynrot_ 14 5 4 4 7 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int rotmat_(doublereal *m1, doublereal *angle, integer *iaxis, doublereal *mout);
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int rotvec_(doublereal *v1, doublereal *angle, integer *iaxis, doublereal *vout);
+
+extern doublereal rpd_(void);
+
+extern int rquad_(doublereal *a, doublereal *b, doublereal *c__, doublereal *root1, doublereal *root2);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern integer rtrim_(char *string, ftnlen string_len);
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int saelgv_(doublereal *vec1, doublereal *vec2, doublereal *smajor, doublereal *sminor);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: diags2_ 14 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+
+extern logical samch_(char *str1, integer *l1, char *str2, integer *l2, ftnlen str1_len, ftnlen str2_len);
+
+extern logical samchi_(char *str1, integer *l1, char *str2, integer *l2, ftnlen str1_len, ftnlen str2_len);
+/*:ref: eqchr_ 12 4 13 13 124 124 */
+
+extern logical sameai_(integer *a1, integer *a2, integer *ndim);
+
+extern logical samsbi_(char *str1, integer *b1, integer *e1, char *str2, integer *b2, integer *e2, ftnlen str1_len, ftnlen str2_len);
+/*:ref: nechr_ 12 4 13 13 124 124 */
+
+extern logical samsub_(char *str1, integer *b1, integer *e1, char *str2, integer *b2, integer *e2, ftnlen str1_len, ftnlen str2_len);
+
+extern int sc01_(integer *sc, char *clkstr, doublereal *ticks, doublereal *sclkdp, doublereal *et, ftnlen clkstr_len);
+extern int sctk01_(integer *sc, char *clkstr, doublereal *ticks, ftnlen clkstr_len);
+extern int scfm01_(integer *sc, doublereal *ticks, char *clkstr, ftnlen clkstr_len);
+extern int scte01_(integer *sc, doublereal *sclkdp, doublereal *et);
+extern int scet01_(integer *sc, doublereal *et, doublereal *sclkdp);
+extern int scec01_(integer *sc, doublereal *et, doublereal *sclkdp);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: scli01_ 14 6 13 4 4 4 4 124 */
+/*:ref: scld01_ 14 6 13 4 4 4 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: lparsm_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dpstrf_ 14 6 7 4 13 13 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: unitim_ 7 5 7 13 13 124 124 */
+
+extern int scanit_(char *string, integer *start, integer *room, integer *nmarks, char *marks, integer *mrklen, integer *pnters, integer *ntokns, integer *ident, integer *beg, integer *end, ftnlen string_len, ftnlen marks_len);
+extern int scanpr_(integer *nmarks, char *marks, integer *mrklen, integer *pnters, ftnlen marks_len);
+extern int scan_(char *string, char *marks, integer *mrklen, integer *pnters, integer *room, integer *start, integer *ntokns, integer *ident, integer *beg, integer *end, ftnlen string_len, ftnlen marks_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: rmdupc_ 14 3 4 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: ncpos_ 4 5 13 13 4 124 124 */
+
+extern int scanrj_(integer *ids, integer *n, integer *ntokns, integer *ident, integer *beg, integer *end);
+/*:ref: isrchi_ 4 3 4 4 4 */
+
+extern int scardc_(integer *card, char *cell, ftnlen cell_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dechar_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: enchar_ 14 3 4 13 124 */
+
+extern int scardd_(integer *card, doublereal *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int scardi_(integer *card, integer *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int scdecd_(integer *sc, doublereal *sclkdp, char *sclkch, ftnlen sclkch_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: scpart_ 14 4 4 4 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: scfmt_ 14 4 4 7 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+
+extern int sce2c_(integer *sc, doublereal *et, doublereal *sclkdp);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sctype_ 4 1 4 */
+/*:ref: scec01_ 14 3 4 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sce2s_(integer *sc, doublereal *et, char *sclkch, ftnlen sclkch_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sce2t_ 14 3 4 7 7 */
+/*:ref: scdecd_ 14 4 4 7 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sce2t_(integer *sc, doublereal *et, doublereal *sclkdp);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sctype_ 4 1 4 */
+/*:ref: scet01_ 14 3 4 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int scencd_(integer *sc, char *sclkch, doublereal *sclkdp, ftnlen sclkch_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+/*:ref: sctiks_ 14 4 4 13 7 124 */
+/*:ref: scpart_ 14 4 4 4 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+
+extern int scfmt_(integer *sc, doublereal *ticks, char *clkstr, ftnlen clkstr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sctype_ 4 1 4 */
+/*:ref: scfm01_ 14 4 4 7 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sclu01_(char *name__, integer *sc, integer *maxnv, integer *n, integer *ival, doublereal *dval, ftnlen name_len);
+extern int scli01_(char *name__, integer *sc, integer *maxnv, integer *n, integer *ival, ftnlen name_len);
+extern int scld01_(char *name__, integer *sc, integer *maxnv, integer *n, doublereal *dval, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: repmd_ 14 8 13 13 7 4 13 124 124 124 */
+
+extern int scpars_(integer *sc, char *sclkch, logical *error, char *msg, doublereal *sclkdp, ftnlen sclkch_len, ftnlen msg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+/*:ref: sctype_ 4 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: scps01_ 14 7 4 13 12 13 7 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: scpart_ 14 4 4 4 7 7 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+
+extern int scpart_(integer *sc, integer *nparts, doublereal *pstart, doublereal *pstop);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: scld01_ 14 6 13 4 4 4 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int scps01_(integer *sc, char *clkstr, logical *error, char *msg, doublereal *ticks, ftnlen clkstr_len, ftnlen msg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: scli01_ 14 6 13 4 4 4 4 124 */
+/*:ref: scld01_ 14 6 13 4 4 4 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lparsm_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+
+extern int scs2e_(integer *sc, char *sclkch, doublereal *et, ftnlen sclkch_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: scencd_ 14 4 4 13 7 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sct2e_(integer *sc, doublereal *sclkdp, doublereal *et);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sctype_ 4 1 4 */
+/*:ref: scte01_ 14 3 4 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sctiks_(integer *sc, char *clkstr, doublereal *ticks, ftnlen clkstr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sctype_ 4 1 4 */
+/*:ref: sctk01_ 14 4 4 13 7 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sctran_(char *clknam, integer *clkid, logical *found, ftnlen clknam_len);
+extern int scn2id_(char *clknam, integer *clkid, logical *found, ftnlen clknam_len);
+extern int scid2n_(integer *clkid, char *clknam, logical *found, ftnlen clknam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: posr_ 4 5 13 13 4 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: bodn2c_ 14 4 13 4 12 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern integer sctype_(integer *sc);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: scli01_ 14 6 13 4 4 4 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sdiffc_(char *a, char *b, char *c__, ftnlen a_len, ftnlen b_len, ftnlen c_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: excess_ 14 3 4 13 124 */
+
+extern int sdiffd_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sdiffi_(integer *a, integer *b, integer *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical setc_(char *a, char *op, char *b, ftnlen a_len, ftnlen op_len, ftnlen b_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern logical setd_(doublereal *a, char *op, doublereal *b, ftnlen op_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern logical seterr_(logical *status);
+extern logical failed_(void);
+
+extern logical seti_(integer *a, char *op, integer *b, ftnlen op_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int setmsg_(char *msg, ftnlen msg_len);
+/*:ref: allowd_ 12 0 */
+/*:ref: putlms_ 14 2 13 124 */
+
+extern int sgfcon_(integer *handle, doublereal *descr, integer *first, integer *last, doublereal *values);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int sgfpkt_(integer *handle, doublereal *descr, integer *first, integer *last, doublereal *values, integer *ends);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int sgfref_(integer *handle, doublereal *descr, integer *first, integer *last, doublereal *values);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int sgfrvi_(integer *handle, doublereal *descr, doublereal *x, doublereal *value, integer *indx, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+
+extern int sgmeta_(integer *handle, doublereal *descr, integer *mnemon, integer *value);
+/*:ref: return_ 12 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafhsf_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int sgseqw_(integer *handle, doublereal *descr, char *segid, integer *nconst, doublereal *const__, integer *npkts, integer *pktsiz, doublereal *pktdat, integer *nrefs, doublereal *refdat, integer *idxtyp, ftnlen segid_len);
+extern int sgbwfs_(integer *handle, doublereal *descr, char *segid, integer *nconst, doublereal *const__, integer *pktsiz, integer *idxtyp, ftnlen segid_len);
+extern int sgbwvs_(integer *handle, doublereal *descr, char *segid, integer *nconst, doublereal *const__, integer *idxtyp, ftnlen segid_len);
+extern int sgwfpk_(integer *handle, integer *npkts, doublereal *pktdat, integer *nrefs, doublereal *refdat);
+extern int sgwvpk_(integer *handle, integer *npkts, integer *pktsiz, doublereal *pktdat, integer *nrefs, doublereal *refdat);
+extern int sgwes_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: dafhsf_ 14 3 4 4 4 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafcad_ 14 1 4 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafena_ 14 0 */
+
+extern int sharpr_(doublereal *rot);
+/*:ref: vhatip_ 14 1 7 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+
+extern int shellc_(integer *ndim, char *array, ftnlen array_len);
+/*:ref: swapc_ 14 4 13 13 124 124 */
+
+extern int shelld_(integer *ndim, doublereal *array);
+/*:ref: swapd_ 14 2 7 7 */
+
+extern int shelli_(integer *ndim, integer *array);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int shiftc_(char *in, char *dir, integer *nshift, char *fillc, char *out, ftnlen in_len, ftnlen dir_len, ftnlen fillc_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: shiftl_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: shiftr_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int shiftl_(char *in, integer *nshift, char *fillc, char *out, ftnlen in_len, ftnlen fillc_len, ftnlen out_len);
+
+extern int shiftr_(char *in, integer *nshift, char *fillc, char *out, ftnlen in_len, ftnlen fillc_len, ftnlen out_len);
+
+extern int sigdgt_(char *in, char *out, ftnlen in_len, ftnlen out_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+
+extern int sigerr_(char *msg, ftnlen msg_len);
+/*:ref: getact_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: seterr_ 12 1 12 */
+/*:ref: putsms_ 14 2 13 124 */
+/*:ref: freeze_ 14 0 */
+/*:ref: outmsg_ 14 2 13 124 */
+/*:ref: accept_ 12 1 12 */
+/*:ref: byebye_ 14 2 13 124 */
+
+extern int sincpt_(char *method, char *target, doublereal *et, char *fixref, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, doublereal *spoint, doublereal *trgepc, doublereal *srfvec, logical *found, ftnlen method_len, ftnlen target_len, ftnlen fixref_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: dasine_ 7 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: npedln_ 14 7 7 7 7 7 7 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: vhatip_ 14 1 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+
+extern integer sizec_(char *cell, ftnlen cell_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dechar_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer sized_(doublereal *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer sizei_(integer *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical smsgnd_(doublereal *x, doublereal *y);
+
+extern logical smsgni_(integer *x, integer *y);
+
+extern logical somfls_(logical *logcls, integer *n);
+
+extern logical somtru_(logical *logcls, integer *n);
+
+extern int spca2b_(char *text, char *binary, ftnlen text_len, ftnlen binary_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: txtopr_ 14 3 13 4 124 */
+/*:ref: spct2b_ 14 3 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spcac_(integer *handle, integer *unit, char *bmark, char *emark, ftnlen bmark_len, ftnlen emark_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: locln_ 14 10 4 13 13 13 4 4 12 124 124 124 */
+/*:ref: countc_ 4 5 4 4 4 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafarr_ 14 2 4 4 */
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int spcb2a_(char *binary, char *text, ftnlen binary_len, ftnlen text_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: txtopn_ 14 3 13 4 124 */
+/*:ref: spcb2t_ 14 3 13 4 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spcb2t_(char *binary, integer *unit, ftnlen binary_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafb2t_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: spcec_ 14 2 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int spcdc_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafrrr_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spcec_(integer *handle, integer *unit);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int spcopn_(char *spc, char *ifname, integer *handle, ftnlen spc_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafopn_ 14 8 13 4 4 13 4 4 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spcrfl_(integer *handle, char *line, logical *eoc, ftnlen line_len);
+extern int spcrnl_(char *line, logical *eoc, ftnlen line_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+
+extern int spct2b_(integer *unit, char *binary, ftnlen binary_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: daft2b_ 14 4 4 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: dafopw_ 14 3 13 4 124 */
+/*:ref: spcac_ 14 6 4 4 13 13 124 124 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern doublereal spd_(void);
+
+extern int sphcyl_(doublereal *radius, doublereal *colat, doublereal *slong, doublereal *r__, doublereal *long__, doublereal *z__);
+
+extern int sphlat_(doublereal *r__, doublereal *colat, doublereal *longs, doublereal *radius, doublereal *long__, doublereal *lat);
+/*:ref: halfpi_ 7 0 */
+
+extern int sphrec_(doublereal *r__, doublereal *colat, doublereal *long__, doublereal *rectan);
+
+extern doublereal sphsd_(doublereal *radius, doublereal *long1, doublereal *lat1, doublereal *long2, doublereal *lat2);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+
+extern int spk14a_(integer *handle, integer *ncsets, doublereal *coeffs, doublereal *epochs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgwfpk_ 14 5 4 4 7 4 7 */
+
+extern int spk14b_(integer *handle, char *segid, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, integer *chbdeg, ftnlen segid_len, ftnlen frame_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: sgbwfs_ 14 8 4 7 13 4 7 4 4 124 */
+
+extern int spk14e_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgwes_ 14 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkacs_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: spkaps_ 14 11 4 7 13 13 7 7 7 7 7 124 124 */
+
+extern int spkapo_(integer *targ, doublereal *et, char *ref, doublereal *sobs, char *abcorr, doublereal *ptarg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: spkgps_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+
+extern int spkapp_(integer *targ, doublereal *et, char *ref, doublereal *sobs, char *abcorr, doublereal *starg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+
+extern int spkaps_(integer *targ, doublereal *et, char *ref, char *abcorr, doublereal *stobs, doublereal *accobs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: spkltc_ 14 10 4 7 13 13 7 7 7 7 124 124 */
+/*:ref: zzstelab_ 14 6 12 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int spkbsr_(char *fname, integer *handle, integer *body, doublereal *et, doublereal *descr, char *ident, logical *found, ftnlen fname_len, ftnlen ident_len);
+extern int spklef_(char *fname, integer *handle, ftnlen fname_len);
+extern int spkuef_(integer *handle);
+extern int spksfs_(integer *body, doublereal *et, integer *handle, doublereal *descr, char *ident, logical *found, ftnlen ident_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: lnkprv_ 4 2 4 4 */
+/*:ref: dpmin_ 7 0 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafbbs_ 14 1 4 */
+/*:ref: daffpa_ 14 1 12 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: dafgn_ 14 2 13 124 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: lnktl_ 4 2 4 4 */
+
+extern int spkcls_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int spkcov_(char *spk, integer *idcode, doublereal *cover, ftnlen spk_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int spke01_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int spke02_(doublereal *et, doublereal *record, doublereal *xyzdot);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chbint_ 14 6 7 4 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke03_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chbval_ 14 5 7 4 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke05_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: prop2b_ 14 4 7 7 7 7 */
+/*:ref: pi_ 7 0 */
+/*:ref: vlcomg_ 14 6 4 7 7 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke08_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: xposeg_ 14 4 7 4 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: lgresp_ 7 6 4 7 7 7 7 7 */
+
+extern int spke09_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: xposeg_ 14 4 7 4 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: lgrint_ 7 5 4 7 7 7 7 */
+
+extern int spke10_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: pi_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: spd_ 7 0 */
+/*:ref: ev2lin_ 14 4 7 7 7 7 */
+/*:ref: dpspce_ 14 4 7 7 7 7 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: zzmobliq_ 14 3 7 7 7 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vlcomg_ 14 6 4 7 7 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: zzeprcss_ 14 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke12_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: hrmesp_ 14 8 4 7 7 7 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke13_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: hrmint_ 14 7 4 7 7 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke14_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chbval_ 14 5 7 4 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke15_(doublereal *et, doublereal *recin, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vhatip_ 14 1 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: dpr_ 7 0 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: prop2b_ 14 4 7 7 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: pi_ 7 0 */
+/*:ref: vrotv_ 14 4 7 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int spke17_(doublereal *et, doublereal *recin, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqncpv_ 14 6 7 7 7 7 7 7 */
+
+extern int spke18_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: xpsgip_ 14 3 4 4 7 */
+/*:ref: lgrint_ 7 5 4 7 7 7 7 */
+/*:ref: hrmint_ 14 7 4 7 7 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int spkez_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *starg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: spkacs_ 14 10 4 7 13 13 4 7 7 7 124 124 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: spkltc_ 14 10 4 7 13 13 7 7 7 7 124 124 */
+/*:ref: frmchg_ 14 4 4 4 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+
+extern int spkezp_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *ptarg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: eqchr_ 12 4 13 13 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: spkgps_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: spkapo_ 14 9 4 7 13 7 13 7 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: refchg_ 14 4 4 4 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+
+extern int spkezr_(char *targ, doublereal *et, char *ref, char *abcorr, char *obs, doublereal *starg, doublereal *lt, ftnlen targ_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen obs_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzbodn2c_ 14 4 13 4 12 124 */
+/*:ref: beint_ 12 2 13 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+
+extern int spkgeo_(integer *targ, doublereal *et, char *ref, integer *obs, doublereal *state, doublereal *lt, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: frmchg_ 14 4 4 4 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: vaddg_ 14 4 7 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+
+extern int spkgps_(integer *targ, doublereal *et, char *ref, integer *obs, doublereal *pos, doublereal *lt, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: refchg_ 14 4 4 4 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+
+extern int spkltc_(integer *targ, doublereal *et, char *ref, char *abcorr, doublereal *stobs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int spkobj_(char *spk, integer *ids, ftnlen spk_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int spkopa_(char *file, integer *handle, ftnlen file_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: exists_ 12 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafopw_ 14 3 13 4 124 */
+
+extern int spkopn_(char *name__, char *ifname, integer *ncomch, integer *handle, ftnlen name_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafonw_ 14 10 13 13 4 4 13 4 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkpds_(integer *body, integer *center, char *frame, integer *type__, doublereal *first, doublereal *last, doublereal *descr, ftnlen frame_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+
+extern int spkpos_(char *targ, doublereal *et, char *ref, char *abcorr, char *obs, doublereal *ptarg, doublereal *lt, ftnlen targ_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen obs_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzbodn2c_ 14 4 13 4 12 124 */
+/*:ref: beint_ 12 2 13 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+
+extern int spkpv_(integer *handle, doublereal *descr, doublereal *et, char *ref, doublereal *state, integer *center, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: frmchg_ 14 4 4 4 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkpvn_(integer *handle, doublereal *descr, doublereal *et, integer *ref, doublereal *state, integer *center);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: spkr01_ 14 4 4 7 7 7 */
+/*:ref: spke01_ 14 3 7 7 7 */
+/*:ref: spkr02_ 14 4 4 7 7 7 */
+/*:ref: spke02_ 14 3 7 7 7 */
+/*:ref: spkr03_ 14 4 4 7 7 7 */
+/*:ref: spke03_ 14 3 7 7 7 */
+/*:ref: spkr05_ 14 4 4 7 7 7 */
+/*:ref: spke05_ 14 3 7 7 7 */
+/*:ref: spkr08_ 14 4 4 7 7 7 */
+/*:ref: spke08_ 14 3 7 7 7 */
+/*:ref: spkr09_ 14 4 4 7 7 7 */
+/*:ref: spke09_ 14 3 7 7 7 */
+/*:ref: spkr10_ 14 4 4 7 7 7 */
+/*:ref: spke10_ 14 3 7 7 7 */
+/*:ref: spkr12_ 14 4 4 7 7 7 */
+/*:ref: spke12_ 14 3 7 7 7 */
+/*:ref: spkr13_ 14 4 4 7 7 7 */
+/*:ref: spke13_ 14 3 7 7 7 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: spkr14_ 14 4 4 7 7 7 */
+/*:ref: spke14_ 14 3 7 7 7 */
+/*:ref: spkr15_ 14 4 4 7 7 7 */
+/*:ref: spke15_ 14 3 7 7 7 */
+/*:ref: spkr17_ 14 4 4 7 7 7 */
+/*:ref: spke17_ 14 3 7 7 7 */
+/*:ref: spkr18_ 14 4 4 7 7 7 */
+/*:ref: spke18_ 14 3 7 7 7 */
+
+extern int spkr01_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkr02_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkr03_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkr05_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int spkr08_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: odd_ 12 1 4 */
+
+extern int spkr09_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+/*:ref: odd_ 12 1 4 */
+
+extern int spkr10_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: sgfrvi_ 14 6 4 7 7 7 4 12 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkr12_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkr08_ 14 4 4 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkr13_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkr09_ 14 4 4 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkr14_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: sgfrvi_ 14 6 4 7 7 7 4 12 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+
+extern int spkr15_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int spkr17_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int spkr18_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+
+extern int spks01_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spks02_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spks03_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spks05_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spks08_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+
+extern int spks09_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+
+extern int spks10_(integer *srchan, doublereal *srcdsc, integer *dsthan, doublereal *dstdsc, char *dstsid, ftnlen dstsid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: sgbwfs_ 14 8 4 7 13 4 7 4 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgfrvi_ 14 6 4 7 7 7 4 12 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+/*:ref: sgfref_ 14 5 4 7 4 4 7 */
+/*:ref: sgwfpk_ 14 5 4 4 7 4 7 */
+/*:ref: sgwes_ 14 1 4 */
+
+extern int spks12_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spks08_ 14 5 4 4 4 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spks13_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spks09_ 14 5 4 4 4 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spks14_(integer *srchan, doublereal *srcdsc, integer *dsthan, doublereal *dstdsc, char *dstsid, ftnlen dstsid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: irfnam_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sgfrvi_ 14 6 4 7 7 7 4 12 */
+/*:ref: spk14b_ 14 10 4 13 4 4 13 7 7 4 124 124 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+/*:ref: sgfref_ 14 5 4 7 4 4 7 */
+/*:ref: spk14a_ 14 4 4 4 7 7 */
+/*:ref: spk14e_ 14 1 4 */
+
+extern int spks15_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+
+extern int spks17_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+
+extern int spks18_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+
+extern int spkssb_(integer *targ, doublereal *et, char *ref, doublereal *starg, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spksub_(integer *handle, doublereal *descr, char *ident, doublereal *begin, doublereal *end, integer *newh, ftnlen ident_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: spks01_ 14 5 4 4 4 7 7 */
+/*:ref: dafena_ 14 0 */
+/*:ref: spks02_ 14 5 4 4 4 7 7 */
+/*:ref: spks03_ 14 5 4 4 4 7 7 */
+/*:ref: spks05_ 14 5 4 4 4 7 7 */
+/*:ref: spks08_ 14 5 4 4 4 7 7 */
+/*:ref: spks09_ 14 5 4 4 4 7 7 */
+/*:ref: spks10_ 14 6 4 7 4 7 13 124 */
+/*:ref: spks12_ 14 5 4 4 4 7 7 */
+/*:ref: spks13_ 14 5 4 4 4 7 7 */
+/*:ref: spks14_ 14 6 4 7 4 7 13 124 */
+/*:ref: spks15_ 14 5 4 4 4 7 7 */
+/*:ref: spks17_ 14 5 4 4 4 7 7 */
+/*:ref: spks18_ 14 5 4 4 4 7 7 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int spkuds_(doublereal *descr, integer *body, integer *center, integer *frame, integer *type__, doublereal *first, doublereal *last, integer *begin, integer *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkw01_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, integer *n, doublereal *dlines, doublereal *epochs, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw02_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *intlen, integer *n, integer *polydg, doublereal *cdata, doublereal *btime, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: chckid_ 14 5 13 4 13 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw03_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *intlen, integer *n, integer *polydg, doublereal *cdata, doublereal *btime, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: chckid_ 14 5 13 4 13 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw05_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *gm, integer *n, doublereal *states, doublereal *epochs, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw08_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, integer *degree, integer *n, doublereal *states, doublereal *epoch1, doublereal *step, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw09_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, integer *degree, integer *n, doublereal *states, doublereal *epochs, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw10_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *consts, integer *n, doublereal *elems, doublereal *epochs, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgbwfs_ 14 8 4 7 13 4 7 4 4 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: zzwahr_ 14 2 7 7 */
+/*:ref: sgwfpk_ 14 5 4 4 7 4 7 */
+/*:ref: sgwes_ 14 1 4 */
+
+extern int spkw12_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, integer *degree, integer *n, doublereal *states, doublereal *epoch1, doublereal *step, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw13_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, integer *degree, integer *n, doublereal *states, doublereal *epochs, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw15_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *epoch, doublereal *tp, doublereal *pa, doublereal *p, doublereal *ecc, doublereal *j2flg, doublereal *pv, doublereal *gm, doublereal *j2, doublereal *radius, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: dpr_ 7 0 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw17_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *epoch, doublereal *eqel, doublereal *rapol, doublereal *decpol, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw18_(integer *handle, integer *subtyp, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, integer *degree, integer *n, doublereal *packts, doublereal *epochs, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int srfrec_(integer *body, doublereal *long__, doublereal *lat, doublereal *rectan);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int srfxpt_(char *method, char *target, doublereal *et, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, doublereal *spoint, doublereal *dist, doublereal *trgepc, doublereal *obspos, logical *found, ftnlen method_len, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: eqchr_ 12 4 13 13 124 124 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: dasine_ 7 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: npedln_ 14 7 7 7 7 7 7 7 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: touchd_ 7 1 7 */
+
+extern int ssizec_(integer *size, char *cell, ftnlen cell_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: enchar_ 14 3 4 13 124 */
+
+extern int ssized_(integer *size, doublereal *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ssizei_(integer *size, integer *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int stcc01_(char *catfnm, char *tabnam, logical *istyp1, char *errmsg, ftnlen catfnm_len, ftnlen tabnam_len, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ekopr_ 14 3 13 4 124 */
+/*:ref: eknseg_ 4 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ekssum_ 14 14 4 4 13 4 4 13 13 4 4 12 12 124 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: nblen_ 4 2 13 124 */
+/*:ref: ekcls_ 14 1 4 */
+
+extern int stcf01_(char *catnam, doublereal *westra, doublereal *eastra, doublereal *sthdec, doublereal *nthdec, integer *nstars, ftnlen catnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dpr_ 7 0 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: repmd_ 14 8 13 13 7 4 13 124 124 124 */
+/*:ref: ekfind_ 14 6 13 4 12 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int stcg01_(integer *index, doublereal *ra, doublereal *dec, doublereal *rasig, doublereal *decsig, integer *catnum, char *sptype, doublereal *vmag, ftnlen sptype_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ekgd_ 14 6 4 4 4 7 12 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ekgi_ 14 6 4 4 4 4 12 12 */
+/*:ref: ekgc_ 14 7 4 4 4 13 12 12 124 */
+/*:ref: rpd_ 7 0 */
+
+extern int stcl01_(char *catfnm, char *tabnam, integer *handle, ftnlen catfnm_len, ftnlen tabnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: stcc01_ 14 7 13 13 12 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eklef_ 14 3 13 4 124 */
+
+extern int stdio_(char *name__, integer *unit, ftnlen name_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int stelab_(doublereal *pobj, doublereal *vobs, doublereal *appobj);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vrotv_ 14 4 7 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int stlabx_(doublereal *pobj, doublereal *vobs, doublereal *corpos);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int stmp03_(doublereal *x, doublereal *c0, doublereal *c1, doublereal *c2, doublereal *c3);
+/*:ref: dpmax_ 7 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int stpool_(char *item, integer *nth, char *contin, char *string, integer *size, logical *found, ftnlen item_len, ftnlen contin_len, ftnlen string_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int str2et_(char *string, doublereal *et, ftnlen string_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: timdef_ 14 6 13 13 13 124 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: zzutcpm_ 14 7 13 4 7 7 4 12 124 */
+/*:ref: tpartv_ 14 15 13 7 4 13 13 12 12 12 13 13 124 124 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: ttrans_ 14 5 13 13 7 124 124 */
+/*:ref: tchckd_ 14 2 13 124 */
+/*:ref: tparch_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: tcheck_ 14 9 7 13 12 13 12 13 124 124 124 */
+/*:ref: texpyr_ 14 1 4 */
+/*:ref: jul2gr_ 14 4 4 4 4 4 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: dpfmt_ 14 5 7 13 13 124 124 */
+/*:ref: gr2jul_ 14 4 4 4 4 4 */
+
+extern int subpnt_(char *method, char *target, doublereal *et, char *fixref, char *abcorr, char *obsrvr, doublereal *spoint, doublereal *trgepc, doublereal *srfvec, ftnlen method_len, ftnlen target_len, ftnlen fixref_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: lparse_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: touchd_ 7 1 7 */
+
+extern int subpt_(char *method, char *target, doublereal *et, char *abcorr, char *obsrvr, doublereal *spoint, doublereal *alt, ftnlen method_len, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vdist_ 7 2 7 7 */
+
+extern int subslr_(char *method, char *target, doublereal *et, char *fixref, char *abcorr, char *obsrvr, doublereal *spoint, doublereal *trgepc, doublereal *srfvec, ftnlen method_len, ftnlen target_len, ftnlen fixref_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: lparse_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: touchd_ 7 1 7 */
+
+extern int subsol_(char *method, char *target, doublereal *et, char *abcorr, char *obsrvr, doublereal *spoint, ftnlen method_len, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: ltime_ 14 7 7 4 13 4 7 7 124 */
+/*:ref: spkpos_ 14 11 13 7 13 13 13 7 7 124 124 124 124 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+
+extern int suffix_(char *suff, integer *spaces, char *string, ftnlen suff_len, ftnlen string_len);
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern doublereal sumad_(doublereal *array, integer *n);
+
+extern integer sumai_(integer *array, integer *n);
+
+extern int surfnm_(doublereal *a, doublereal *b, doublereal *c__, doublereal *point, doublereal *normal);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vhatip_ 14 1 7 */
+
+extern int surfpt_(doublereal *positn, doublereal *u, doublereal *a, doublereal *b, doublereal *c__, doublereal *point, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int surfpv_(doublereal *stvrtx, doublereal *stdir, doublereal *a, doublereal *b, doublereal *c__, doublereal *stx, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dvhat_ 14 2 7 7 */
+/*:ref: surfnm_ 14 5 7 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: vlcom3_ 14 7 7 7 7 7 7 7 7 */
+
+extern int swapac_(integer *n, integer *locn, integer *m, integer *locm, char *array, ftnlen array_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: swapc_ 14 4 13 13 124 124 */
+/*:ref: cyacip_ 14 6 4 13 4 13 124 124 */
+
+extern int swapad_(integer *n, integer *locn, integer *m, integer *locm, doublereal *array);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: swapd_ 14 2 7 7 */
+/*:ref: cyadip_ 14 5 4 13 4 7 124 */
+
+extern int swapai_(integer *n, integer *locn, integer *m, integer *locm, integer *array);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: swapi_ 14 2 4 4 */
+/*:ref: cyaiip_ 14 5 4 13 4 4 124 */
+
+extern int swapc_(char *a, char *b, ftnlen a_len, ftnlen b_len);
+
+extern int swapd_(doublereal *a, doublereal *b);
+
+extern int swapi_(integer *a, integer *b);
+
+extern int sxform_(char *from, char *to, doublereal *et, doublereal *xform, ftnlen from_len, ftnlen to_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frmchg_ 14 4 4 4 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sydelc_(char *name__, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sydeld_(char *name__, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: remlad_ 14 4 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sydeli_(char *name__, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer sydimc_(char *name__, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer sydimd_(char *name__, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer sydimi_(char *name__, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sydupc_(char *name__, char *copy, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen copy_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sydupd_(char *name__, char *copy, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen copy_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: remlad_ 14 4 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sydupi_(char *name__, char *copy, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen copy_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syenqc_(char *name__, char *value, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen value_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sysetc_ 14 9 13 13 13 4 13 124 124 124 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syenqd_(char *name__, doublereal *value, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sysetd_ 14 7 13 7 13 4 7 124 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: inslad_ 14 5 7 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syenqi_(char *name__, integer *value, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: syseti_ 14 7 13 4 13 4 4 124 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syfetc_(integer *nth, char *tabsym, integer *tabptr, char *tabval, char *name__, logical *found, ftnlen tabsym_len, ftnlen tabval_len, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syfetd_(integer *nth, char *tabsym, integer *tabptr, doublereal *tabval, char *name__, logical *found, ftnlen tabsym_len, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syfeti_(integer *nth, char *tabsym, integer *tabptr, integer *tabval, char *name__, logical *found, ftnlen tabsym_len, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sygetc_(char *name__, char *tabsym, integer *tabptr, char *tabval, integer *n, char *values, logical *found, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len, ftnlen values_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sygetd_(char *name__, char *tabsym, integer *tabptr, doublereal *tabval, integer *n, doublereal *values, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sygeti_(char *name__, char *tabsym, integer *tabptr, integer *tabval, integer *n, integer *values, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int synthc_(char *name__, integer *nth, char *tabsym, integer *tabptr, char *tabval, char *value, logical *found, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len, ftnlen value_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int synthd_(char *name__, integer *nth, char *tabsym, integer *tabptr, doublereal *tabval, doublereal *value, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int synthi_(char *name__, integer *nth, char *tabsym, integer *tabptr, integer *tabval, integer *value, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syordc_(char *name__, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: shellc_ 14 3 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syordd_(char *name__, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: shelld_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syordi_(char *name__, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: shelli_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sypopc_(char *name__, char *tabsym, integer *tabptr, char *tabval, char *value, logical *found, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len, ftnlen value_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sypopd_(char *name__, char *tabsym, integer *tabptr, doublereal *tabval, doublereal *value, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlad_ 14 4 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sypopi_(char *name__, char *tabsym, integer *tabptr, integer *tabval, integer *value, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sypshc_(char *name__, char *value, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen value_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sysetc_ 14 9 13 13 13 4 13 124 124 124 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sypshd_(char *name__, doublereal *value, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sysetd_ 14 7 13 7 13 4 7 124 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: inslad_ 14 5 7 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sypshi_(char *name__, integer *value, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: syseti_ 14 7 13 4 13 4 4 124 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syputc_(char *name__, char *values, integer *n, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen values_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+
+extern int syputd_(char *name__, doublereal *values, integer *n, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: remlad_ 14 4 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: inslad_ 14 5 7 4 4 7 4 */
+
+extern int syputi_(char *name__, integer *values, integer *n, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+
+extern int syrenc_(char *old, char *new__, char *tabsym, integer *tabptr, char *tabval, ftnlen old_len, ftnlen new_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sydelc_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: swapac_ 14 6 4 4 4 4 13 124 */
+/*:ref: swapai_ 14 5 4 4 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syrend_(char *old, char *new__, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen old_len, ftnlen new_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sydeld_ 14 6 13 13 4 7 124 124 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: swapad_ 14 5 4 4 4 4 7 */
+/*:ref: swapac_ 14 6 4 4 4 4 13 124 */
+/*:ref: swapai_ 14 5 4 4 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syreni_(char *old, char *new__, char *tabsym, integer *tabptr, integer *tabval, ftnlen old_len, ftnlen new_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sydeli_ 14 6 13 13 4 4 124 124 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: swapai_ 14 5 4 4 4 4 4 */
+/*:ref: swapac_ 14 6 4 4 4 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syselc_(char *name__, integer *begin, integer *end, char *tabsym, integer *tabptr, char *tabval, char *values, logical *found, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len, ftnlen values_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syseld_(char *name__, integer *begin, integer *end, char *tabsym, integer *tabptr, doublereal *tabval, doublereal *values, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syseli_(char *name__, integer *begin, integer *end, char *tabsym, integer *tabptr, integer *tabval, integer *values, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sysetc_(char *name__, char *value, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen value_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sysetd_(char *name__, doublereal *value, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlad_ 14 4 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: inslad_ 14 5 7 4 4 7 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syseti_(char *name__, integer *value, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sytrnc_(char *name__, integer *i__, integer *j, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: swapc_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sytrnd_(char *name__, integer *i__, integer *j, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: swapd_ 14 2 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sytrni_(char *name__, integer *i__, integer *j, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: swapi_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int tcheck_(doublereal *tvec, char *type__, logical *mods, char *modify, logical *ok, char *error, ftnlen type_len, ftnlen modify_len, ftnlen error_len);
+extern int tparch_(char *type__, ftnlen type_len);
+extern int tchckd_(char *type__, ftnlen type_len);
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: repmd_ 14 8 13 13 7 4 13 124 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+
+extern int texpyr_(integer *year);
+extern int tsetyr_(integer *year);
+
+extern int timdef_(char *action, char *item, char *value, ftnlen action_len, ftnlen item_len, ftnlen value_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: zzutcpm_ 14 7 13 4 7 7 4 12 124 */
+
+extern int timout_(doublereal *et, char *pictur, char *output, ftnlen pictur_len, ftnlen output_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: scanpr_ 14 5 4 13 4 4 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: scan_ 14 12 13 13 4 4 4 4 4 4 4 4 124 124 */
+/*:ref: timdef_ 14 6 13 13 13 124 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: zzutcpm_ 14 7 13 4 7 7 4 12 124 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: scanrj_ 14 6 4 4 4 4 4 4 */
+/*:ref: unitim_ 7 5 7 13 13 124 124 */
+/*:ref: spd_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: j1950_ 7 0 */
+/*:ref: brckti_ 4 3 4 4 4 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: dpfmt_ 14 5 7 13 13 124 124 */
+/*:ref: ttrans_ 14 5 13 13 7 124 124 */
+/*:ref: gr2jul_ 14 4 4 4 4 4 */
+/*:ref: jul2gr_ 14 4 4 4 4 4 */
+/*:ref: rmaind_ 14 4 7 7 7 7 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: lcase_ 14 4 13 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int tipbod_(char *ref, integer *body, doublereal *et, doublereal *tipm, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irftrn_ 14 5 13 13 7 124 124 */
+/*:ref: bodmat_ 14 3 4 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int tisbod_(char *ref, integer *body, doublereal *et, doublereal *tsipm, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: pckmat_ 14 5 4 7 4 7 12 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: ccifrm_ 14 7 4 4 4 13 4 12 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzbodbry_ 4 1 4 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: spd_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: bodfnd_ 12 3 4 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: rpd_ 7 0 */
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: twopi_ 7 0 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: failed_ 12 0 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: eul2xf_ 14 5 7 4 4 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+
+extern int tkfram_(integer *id, doublereal *rot, integer *frame, logical *found);
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnktl_ 4 2 4 4 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: locati_ 14 6 4 4 4 4 4 12 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: dwpool_ 14 2 13 124 */
+/*:ref: ident_ 14 1 7 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: frmnam_ 14 3 4 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: badkpv_ 12 10 13 13 13 4 4 13 124 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: sharpr_ 14 1 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: vhatg_ 14 3 7 4 7 */
+/*:ref: q2m_ 14 2 7 7 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+
+extern int tkvrsn_(char *item, char *verstr, ftnlen item_len, ftnlen verstr_len);
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+
+extern int tostdo_(char *line, ftnlen line_len);
+/*:ref: stdio_ 14 3 13 4 124 */
+/*:ref: writln_ 14 3 13 4 124 */
+
+extern H_f touchc_(char *ret_val, ftnlen ret_val_len, char *string, ftnlen string_len);
+
+extern doublereal touchd_(doublereal *dp);
+
+extern integer touchi_(integer *int__);
+
+extern logical touchl_(logical *log__);
+
+extern int tparse_(char *string, doublereal *sp2000, char *error, ftnlen string_len, ftnlen error_len);
+/*:ref: tpartv_ 14 15 13 7 4 13 13 12 12 12 13 13 124 124 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: j2000_ 7 0 */
+/*:ref: spd_ 7 0 */
+/*:ref: tcheck_ 14 9 7 13 12 13 12 13 124 124 124 */
+/*:ref: texpyr_ 14 1 4 */
+/*:ref: rmaini_ 14 4 4 4 4 4 */
+
+extern int tpartv_(char *string, doublereal *tvec, integer *ntvec, char *type__, char *modify, logical *mods, logical *yabbrv, logical *succes, char *pictur, char *error, ftnlen string_len, ftnlen type_len, ftnlen modify_len, ftnlen pictur_len, ftnlen error_len);
+/*:ref: zztpats_ 12 6 4 4 13 13 124 124 */
+/*:ref: zztokns_ 12 4 13 13 124 124 */
+/*:ref: zzcmbt_ 12 5 13 13 12 124 124 */
+/*:ref: zzsubt_ 12 5 13 13 12 124 124 */
+/*:ref: zzrept_ 12 5 13 13 12 124 124 */
+/*:ref: zzremt_ 12 2 13 124 */
+/*:ref: zzist_ 12 2 13 124 */
+/*:ref: zznote_ 12 4 13 4 4 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzunpck_ 12 11 13 12 7 4 13 13 13 124 124 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: zzvalt_ 12 6 13 4 4 13 124 124 */
+/*:ref: zzgrep_ 12 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: zzispt_ 12 4 13 4 4 124 */
+/*:ref: zzinssub_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+
+extern int tpictr_(char *sample, char *pictur, logical *ok, char *error, ftnlen sample_len, ftnlen pictur_len, ftnlen error_len);
+/*:ref: tpartv_ 14 15 13 7 4 13 13 12 12 12 13 13 124 124 124 124 124 */
+
+extern doublereal trace_(doublereal *matrix);
+
+extern doublereal traceg_(doublereal *matrix, integer *ndim);
+
+extern int trcpkg_(integer *depth, integer *index, char *module, char *trace, char *name__, ftnlen module_len, ftnlen trace_len, ftnlen name_len);
+extern int chkin_(char *module, ftnlen module_len);
+extern int chkout_(char *module, ftnlen module_len);
+extern int trcdep_(integer *depth);
+extern int trcmxd_(integer *depth);
+extern int trcnam_(integer *index, char *name__, ftnlen name_len);
+extern int qcktrc_(char *trace, ftnlen trace_len);
+extern int freeze_(void);
+extern int trcoff_(void);
+/*:ref: wrline_ 14 4 13 13 124 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: getdev_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: getact_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int ttrans_(char *from, char *to, doublereal *tvec, ftnlen from_len, ftnlen to_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spd_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: ssizec_ 14 3 4 13 124 */
+/*:ref: insrtc_ 14 4 13 13 124 124 */
+/*:ref: orderc_ 14 4 13 4 4 124 */
+/*:ref: reordc_ 14 4 4 4 13 124 */
+/*:ref: reordi_ 14 3 4 4 4 */
+/*:ref: reordl_ 14 3 4 4 12 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: rmaini_ 14 4 4 4 4 4 */
+/*:ref: lstlei_ 4 3 4 4 4 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: rmaind_ 14 4 7 7 7 7 */
+/*:ref: elemc_ 12 4 13 13 124 124 */
+/*:ref: unitim_ 7 5 7 13 13 124 124 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: lstlti_ 4 3 4 4 4 */
+
+extern doublereal twopi_(void);
+
+extern int twovec_(doublereal *axdef, integer *indexa, doublereal *plndef, integer *indexp, doublereal *mout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int twovxf_(doublereal *axdef, integer *indexa, doublereal *plndef, integer *indexp, doublereal *xform);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zztwovxf_ 14 5 7 4 7 4 7 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int txtopn_(char *fname, integer *unit, ftnlen fname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int txtopr_(char *fname, integer *unit, ftnlen fname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern doublereal tyear_(void);
+
+extern int ucase_(char *in, char *out, ftnlen in_len, ftnlen out_len);
+
+extern int ucrss_(doublereal *v1, doublereal *v2, doublereal *vout);
+/*:ref: vnorm_ 7 1 7 */
+
+extern int uddc_(U_fp udfunc, doublereal *x, doublereal *dx, logical *isdecr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: uddf_ 14 4 200 7 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int uddf_(S_fp udfunc, doublereal *x, doublereal *dx, doublereal *deriv);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+
+extern int unionc_(char *a, char *b, char *c__, ftnlen a_len, ftnlen b_len, ftnlen c_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: excess_ 14 3 4 13 124 */
+
+extern int uniond_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int unioni_(integer *a, integer *b, integer *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern doublereal unitim_(doublereal *epoch, char *insys, char *outsys, ftnlen insys_len, ftnlen outsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spd_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: validc_ 14 4 4 4 13 124 */
+/*:ref: ssizec_ 14 3 4 13 124 */
+/*:ref: unionc_ 14 6 13 13 13 124 124 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: somfls_ 12 2 12 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: insrtc_ 14 4 13 13 124 124 */
+/*:ref: setc_ 12 6 13 13 13 124 124 124 */
+/*:ref: elemc_ 12 4 13 13 124 124 */
+
+extern int unorm_(doublereal *v1, doublereal *vout, doublereal *vmag);
+/*:ref: vnorm_ 7 1 7 */
+
+extern int unormg_(doublereal *v1, integer *ndim, doublereal *vout, doublereal *vmag);
+/*:ref: vnormg_ 7 2 7 4 */
+
+extern int utc2et_(char *utcstr, doublereal *et, ftnlen utcstr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: tpartv_ 14 15 13 7 4 13 13 12 12 12 13 13 124 124 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: tcheck_ 14 9 7 13 12 13 12 13 124 124 124 */
+/*:ref: texpyr_ 14 1 4 */
+/*:ref: ttrans_ 14 5 13 13 7 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int vadd_(doublereal *v1, doublereal *v2, doublereal *vout);
+
+extern int vaddg_(doublereal *v1, doublereal *v2, integer *ndim, doublereal *vout);
+
+extern int validc_(integer *size, integer *n, char *a, ftnlen a_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rmdupc_ 14 3 4 13 124 */
+/*:ref: ssizec_ 14 3 4 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+
+extern int validd_(integer *size, integer *n, doublereal *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rmdupd_ 14 2 4 7 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: scardd_ 14 2 4 7 */
+
+extern int validi_(integer *size, integer *n, integer *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rmdupi_ 14 2 4 4 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+
+extern int vcrss_(doublereal *v1, doublereal *v2, doublereal *vout);
+
+extern doublereal vdist_(doublereal *v1, doublereal *v2);
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+
+extern doublereal vdistg_(doublereal *v1, doublereal *v2, integer *ndim);
+
+extern doublereal vdot_(doublereal *v1, doublereal *v2);
+
+extern doublereal vdotg_(doublereal *v1, doublereal *v2, integer *ndim);
+
+extern int vequ_(doublereal *vin, doublereal *vout);
+
+extern int vequg_(doublereal *vin, integer *ndim, doublereal *vout);
+
+extern int vhat_(doublereal *v1, doublereal *vout);
+/*:ref: vnorm_ 7 1 7 */
+
+extern int vhatg_(doublereal *v1, integer *ndim, doublereal *vout);
+/*:ref: vnormg_ 7 2 7 4 */
+
+extern int vhatip_(doublereal *v);
+/*:ref: vnorm_ 7 1 7 */
+
+extern int vlcom_(doublereal *a, doublereal *v1, doublereal *b, doublereal *v2, doublereal *sum);
+
+extern int vlcom3_(doublereal *a, doublereal *v1, doublereal *b, doublereal *v2, doublereal *c__, doublereal *v3, doublereal *sum);
+
+extern int vlcomg_(integer *n, doublereal *a, doublereal *v1, doublereal *b, doublereal *v2, doublereal *sum);
+
+extern int vminug_(doublereal *vin, integer *ndim, doublereal *vout);
+
+extern int vminus_(doublereal *v1, doublereal *vout);
+
+extern doublereal vnorm_(doublereal *v1);
+
+extern doublereal vnormg_(doublereal *v1, integer *ndim);
+
+extern int vpack_(doublereal *x, doublereal *y, doublereal *z__, doublereal *v);
+
+extern int vperp_(doublereal *a, doublereal *b, doublereal *p);
+/*:ref: vproj_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+
+extern int vprjp_(doublereal *vin, doublereal *plane, doublereal *vout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int vprjpi_(doublereal *vin, doublereal *projpl, doublereal *invpl, doublereal *vout, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int vproj_(doublereal *a, doublereal *b, doublereal *p);
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+
+extern int vprojg_(doublereal *a, doublereal *b, integer *ndim, doublereal *p);
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: vsclg_ 14 4 7 7 4 7 */
+
+extern doublereal vrel_(doublereal *v1, doublereal *v2);
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+
+extern doublereal vrelg_(doublereal *v1, doublereal *v2, integer *ndim);
+/*:ref: vdistg_ 7 3 7 7 4 */
+/*:ref: vnormg_ 7 2 7 4 */
+
+extern int vrotv_(doublereal *v, doublereal *axis, doublereal *theta, doublereal *r__);
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vproj_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+
+extern int vscl_(doublereal *s, doublereal *v1, doublereal *vout);
+
+extern int vsclg_(doublereal *s, doublereal *v1, integer *ndim, doublereal *vout);
+
+extern int vsclip_(doublereal *s, doublereal *v);
+
+extern doublereal vsep_(doublereal *v1, doublereal *v2);
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: pi_ 7 0 */
+
+extern doublereal vsepg_(doublereal *v1, doublereal *v2, integer *ndim);
+/*:ref: vnormg_ 7 2 7 4 */
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: pi_ 7 0 */
+
+extern int vsub_(doublereal *v1, doublereal *v2, doublereal *vout);
+
+extern int vsubg_(doublereal *v1, doublereal *v2, integer *ndim, doublereal *vout);
+
+extern doublereal vtmv_(doublereal *v1, doublereal *matrix, doublereal *v2);
+
+extern doublereal vtmvg_(doublereal *v1, doublereal *matrix, doublereal *v2, integer *nrow, integer *ncol);
+
+extern int vupack_(doublereal *v, doublereal *x, doublereal *y, doublereal *z__);
+
+extern logical vzero_(doublereal *v);
+
+extern logical vzerog_(doublereal *v, integer *ndim);
+
+extern integer wdcnt_(char *string, ftnlen string_len);
+
+extern integer wdindx_(char *string, char *word, ftnlen string_len, ftnlen word_len);
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+
+extern integer wncard_(doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: even_ 12 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wncomd_(doublereal *left, doublereal *right, doublereal *window, doublereal *result);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+/*:ref: failed_ 12 0 */
+
+extern int wncond_(doublereal *left, doublereal *right, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: wnexpd_ 14 3 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wndifd_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: copyd_ 14 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern logical wnelmd_(doublereal *point, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnexpd_(doublereal *left, doublereal *right, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnextd_(char *side, doublereal *window, ftnlen side_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnfetd_(doublereal *window, integer *n, doublereal *left, doublereal *right);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnfild_(doublereal *small, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnfltd_(doublereal *small, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical wnincd_(doublereal *left, doublereal *right, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wninsd_(doublereal *left, doublereal *right, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+
+extern int wnintd_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical wnreld_(doublereal *a, char *op, doublereal *b, ftnlen op_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: wnincd_ 12 3 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnsumd_(doublereal *window, doublereal *meas, doublereal *avg, doublereal *stddev, integer *short__, integer *long__);
+/*:ref: return_ 12 0 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: even_ 12 1 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnunid_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnvald_(integer *size, integer *n, doublereal *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+
+extern int wrencc_(integer *unit, integer *n, char *data, ftnlen data_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wrencd_(integer *unit, integer *n, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dp2hx_ 14 4 7 13 4 124 */
+
+extern int wrenci_(integer *unit, integer *n, integer *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: int2hx_ 14 4 4 13 4 124 */
+
+extern int writla_(integer *numlin, char *array, integer *unit, ftnlen array_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: writln_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+
+extern int writln_(char *line, integer *unit, ftnlen line_len);
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wrkvar_(integer *unit, char *name__, char *dirctv, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen dirctv_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sydimd_ 4 6 13 13 4 7 124 124 */
+/*:ref: synthd_ 14 9 13 4 13 4 7 7 12 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: rjust_ 14 4 13 13 124 124 */
+/*:ref: ioerr_ 14 5 13 13 4 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wrline_(char *device, char *line, ftnlen device_len, ftnlen line_len);
+extern int clline_(char *device, ftnlen device_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: fndlun_ 14 1 4 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+
+extern int xf2eul_(doublereal *xform, integer *axisa, integer *axisb, integer *axisc, doublereal *eulang, logical *unique);
+extern int eul2xf_(doublereal *eulang, integer *axisa, integer *axisb, integer *axisc, doublereal *xform);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: m2eul_ 14 7 7 4 4 4 7 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: mxmt_ 14 3 7 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+
+extern int xf2rav_(doublereal *xform, doublereal *rot, doublereal *av);
+/*:ref: mtxm_ 14 3 7 7 7 */
+
+extern int xposbl_(doublereal *bmat, integer *nrow, integer *ncol, integer *bsize, doublereal *btmat);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int xpose_(doublereal *m1, doublereal *mout);
+
+extern int xposeg_(doublereal *matrix, integer *nrow, integer *ncol, doublereal *xposem);
+
+extern int xpsgip_(integer *nrow, integer *ncol, doublereal *matrix);
+
+extern int zzascii_(char *file, char *line, logical *check, char *termin, ftnlen file_len, ftnlen line_len, ftnlen termin_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzasryel_(char *extrem, doublereal *ellips, doublereal *vertex, doublereal *dir, doublereal *angle, doublereal *extpt, ftnlen extrem_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: psv2pl_ 14 4 7 7 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: vprjp_ 14 3 7 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: inrypl_ 14 5 7 7 7 4 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vlcom3_ 14 7 7 7 7 7 7 7 7 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: swapd_ 14 2 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+
+extern int zzbodblt_(integer *room, char *names, char *nornam, integer *codes, integer *nvals, char *device, char *reqst, ftnlen names_len, ftnlen nornam_len, ftnlen device_len, ftnlen reqst_len);
+extern int zzbodget_(integer *room, char *names, char *nornam, integer *codes, integer *nvals, ftnlen names_len, ftnlen nornam_len);
+extern int zzbodlst_(char *device, char *reqst, ftnlen device_len, ftnlen reqst_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzidmap_ 14 3 4 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: wrline_ 14 4 13 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: orderi_ 14 3 4 4 4 */
+/*:ref: orderc_ 14 4 13 4 4 124 */
+
+extern integer zzbodbry_(integer *body);
+
+extern int zzbodini_(char *names, char *nornam, integer *codes, integer *nvals, integer *ordnom, integer *ordcod, integer *nocds, ftnlen names_len, ftnlen nornam_len);
+/*:ref: orderc_ 14 4 13 4 4 124 */
+/*:ref: orderi_ 14 3 4 4 4 */
+
+extern int zzbodker_(char *names, char *nornam, integer *codes, integer *nvals, integer *ordnom, integer *ordcod, integer *nocds, logical *extker, ftnlen names_len, ftnlen nornam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: orderc_ 14 4 13 4 4 124 */
+/*:ref: zzbodini_ 14 9 13 13 4 4 4 4 4 124 124 */
+
+extern int zzbodtrn_(char *name__, integer *code, logical *found, ftnlen name_len);
+extern int zzbodn2c_(char *name__, integer *code, logical *found, ftnlen name_len);
+extern int zzbodc2n_(integer *code, char *name__, logical *found, ftnlen name_len);
+extern int zzboddef_(char *name__, integer *code, ftnlen name_len);
+extern int zzbodkik_(void);
+extern int zzbodrst_(void);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzbodget_ 14 7 4 13 13 4 4 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzbodini_ 14 9 13 13 4 4 4 4 4 124 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: zzbodker_ 14 10 13 13 4 4 4 4 4 12 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: bschoc_ 4 6 13 4 13 4 124 124 */
+/*:ref: bschoi_ 4 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int zzbodvcd_(integer *bodyid, char *item, integer *maxn, integer *dim, doublereal *values, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+
+extern int zzck4d2i_(doublereal *dpcoef, integer *nsets, doublereal *parcod, integer *i__);
+
+extern int zzck4i2d_(integer *i__, integer *nsets, doublereal *parcod, doublereal *dpcoef);
+
+extern int zzckcv01_(integer *handle, integer *arrbeg, integer *arrend, integer *sclkid, doublereal *tol, char *timsys, doublereal *schedl, ftnlen timsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+
+extern int zzckcv02_(integer *handle, integer *arrbeg, integer *arrend, integer *sclkid, doublereal *tol, char *timsys, doublereal *schedl, ftnlen timsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+
+extern int zzckcv03_(integer *handle, integer *arrbeg, integer *arrend, integer *sclkid, doublereal *tol, char *timsys, doublereal *schedl, ftnlen timsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+
+extern int zzckcv04_(integer *handle, integer *arrbeg, integer *arrend, integer *sclkid, doublereal *tol, char *timsys, doublereal *schedl, ftnlen timsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: cknr04_ 14 3 4 7 4 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+
+extern int zzckcv05_(integer *handle, integer *arrbeg, integer *arrend, integer *sclkid, doublereal *dc, doublereal *tol, char *timsys, doublereal *schedl, ftnlen timsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: errint_ 14 3 13 7 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+
+extern int zzckspk_(integer *handle, char *ckspk, ftnlen ckspk_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafhsf_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: zzsizeok_ 14 6 4 4 4 4 12 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int zzcln_(integer *lookat, integer *nameat, integer *namlst, integer *datlst, integer *nmpool, integer *chpool, integer *dppool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzcorepc_(char *abcorr, doublereal *et, doublereal *lt, doublereal *etcorr, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzcorsxf_(logical *xmit, doublereal *dlt, doublereal *xform, doublereal *corxfm);
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+
+extern int zzcputim_(doublereal *tvec);
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzdafgdr_(integer *handle, integer *recno, doublereal *dprec, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhnfo_ 14 7 4 13 4 4 4 12 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzxlated_ 14 5 4 13 4 7 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int zzdafgfr_(integer *handle, char *idword, integer *nd, integer *ni, char *ifname, integer *fward, integer *bward, integer *free, logical *found, ftnlen idword_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhnfo_ 14 7 4 13 4 4 4 12 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzxlatei_ 14 5 4 13 4 4 124 */
+
+extern int zzdafgsr_(integer *handle, integer *recno, integer *nd, integer *ni, doublereal *dprec, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhnfo_ 14 7 4 13 4 4 4 12 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzxlated_ 14 5 4 13 4 7 124 */
+/*:ref: zzxlatei_ 14 5 4 13 4 4 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int zzdafnfr_(integer *lun, char *idword, integer *nd, integer *ni, char *ifname, integer *fward, integer *bward, integer *free, char *format, ftnlen idword_len, ftnlen ifname_len, ftnlen format_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzftpstr_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzdasnfr_(integer *lun, char *idword, char *ifname, integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc, char *format, ftnlen idword_len, ftnlen ifname_len, ftnlen format_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzftpstr_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer zzddhclu_(logical *utlck, integer *nut);
+
+extern int zzddhf2h_(char *fname, integer *ftabs, integer *ftamh, integer *ftarc, integer *ftbff, integer *fthan, char *ftnam, integer *ftrtm, integer *nft, integer *utcst, integer *uthan, logical *utlck, integer *utlun, integer *nut, logical *exists, logical *opened, integer *handle, logical *found, ftnlen fname_len, ftnlen ftnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zzddhgtu_ 14 6 4 4 12 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzddhrmu_ 14 7 4 4 4 4 12 4 4 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int zzddhgsd_(char *class__, integer *id, char *label, ftnlen class_len, ftnlen label_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+
+extern int zzddhgtu_(integer *utcst, integer *uthan, logical *utlck, integer *utlun, integer *nut, integer *uindex);
+/*:ref: return_ 12 0 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: orderi_ 14 3 4 4 4 */
+/*:ref: frelun_ 14 1 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzddhini_(integer *natbff, integer *supbff, integer *numsup, char *stramh, char *strarc, char *strbff, ftnlen stramh_len, ftnlen strarc_len, ftnlen strbff_len);
+/*:ref: return_ 12 0 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+
+extern int zzddhivf_(char *nsum, integer *bff, logical *found, ftnlen nsum_len);
+
+extern int zzddhman_(logical *lock, char *arch, char *fname, char *method, integer *handle, integer *unit, integer *intamh, integer *intarc, integer *intbff, logical *native, logical *found, logical *kill, ftnlen arch_len, ftnlen fname_len, ftnlen method_len);
+extern int zzddhopn_(char *fname, char *method, char *arch, integer *handle, ftnlen fname_len, ftnlen method_len, ftnlen arch_len);
+extern int zzddhcls_(integer *handle, char *arch, logical *kill, ftnlen arch_len);
+extern int zzddhhlu_(integer *handle, char *arch, logical *lock, integer *unit, ftnlen arch_len);
+extern int zzddhunl_(integer *handle, char *arch, ftnlen arch_len);
+extern int zzddhnfo_(integer *handle, char *fname, integer *intarc, integer *intbff, integer *intamh, logical *found, ftnlen fname_len);
+extern int zzddhisn_(integer *handle, logical *native, logical *found);
+extern int zzddhfnh_(char *fname, integer *handle, logical *found, ftnlen fname_len);
+extern int zzddhluh_(integer *unit, integer *handle, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhini_ 14 9 4 4 4 13 13 13 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzpltchk_ 14 1 12 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: zzddhclu_ 4 2 12 4 */
+/*:ref: zzddhf2h_ 14 20 13 4 4 4 4 4 13 4 4 4 4 12 4 4 12 12 4 12 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: bsrchi_ 4 3 4 4 4 */
+/*:ref: zzddhrcm_ 14 3 4 4 4 */
+/*:ref: zzddhgtu_ 14 6 4 4 12 4 4 4 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: zzddhppf_ 14 3 4 4 4 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zzddhrmu_ 14 7 4 4 4 4 12 4 4 */
+/*:ref: frelun_ 14 1 4 */
+
+extern int zzddhppf_(integer *unit, integer *arch, integer *bff);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzftpstr_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: idw2at_ 14 6 13 13 13 124 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: zzftpchk_ 14 3 13 12 124 */
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzddhivf_ 14 4 13 4 12 124 */
+
+extern int zzddhrcm_(integer *nut, integer *utcst, integer *reqcnt);
+/*:ref: intmax_ 4 0 */
+
+extern int zzddhrmu_(integer *uindex, integer *nft, integer *utcst, integer *uthan, logical *utlck, integer *utlun, integer *nut);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: reslun_ 14 1 4 */
+
+extern int zzdynbid_(char *frname, integer *frcode, char *item, integer *idcode, ftnlen frname_len, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+
+extern int zzdynfid_(char *frname, integer *frcode, char *item, integer *idcode, ftnlen frname_len, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: beint_ 12 2 13 124 */
+/*:ref: prsint_ 14 3 13 4 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+
+extern int zzdynfr0_(integer *infram, integer *center, doublereal *et, doublereal *xform, integer *basfrm);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: bodn2c_ 14 4 13 4 12 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: frmnam_ 14 3 4 13 124 */
+/*:ref: zzdynfid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzdynvac_ 14 9 13 4 13 4 4 13 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzdynoad_ 14 9 13 4 13 4 4 7 12 124 124 */
+/*:ref: zzdynoac_ 14 10 13 4 13 4 4 13 12 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: zzeprc76_ 14 2 7 7 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: zzenut80_ 14 2 7 7 */
+/*:ref: mxmg_ 14 6 7 7 4 4 4 7 */
+/*:ref: zzmobliq_ 14 3 7 7 7 */
+/*:ref: eul2xf_ 14 5 7 4 4 4 7 */
+/*:ref: zzfrmch1_ 14 4 4 4 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzdynbid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzspkez1_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzspkzp1_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vminug_ 14 3 7 4 7 */
+/*:ref: dnearp_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: zzspksb1_ 14 5 4 7 13 7 124 */
+/*:ref: zzdynvad_ 14 8 13 4 13 4 4 7 124 124 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: zztwovxf_ 14 5 7 4 7 4 7 */
+/*:ref: zzdynvai_ 14 8 13 4 13 4 4 4 124 124 */
+/*:ref: polyds_ 14 5 7 4 4 7 7 */
+
+extern int zzdynfrm_(integer *infram, integer *center, doublereal *et, doublereal *xform, integer *basfrm);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: bodn2c_ 14 4 13 4 12 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: frmnam_ 14 3 4 13 124 */
+/*:ref: zzdynfid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzdynvac_ 14 9 13 4 13 4 4 13 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzdynoad_ 14 9 13 4 13 4 4 7 12 124 124 */
+/*:ref: zzdynoac_ 14 10 13 4 13 4 4 13 12 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: zzeprc76_ 14 2 7 7 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: zzenut80_ 14 2 7 7 */
+/*:ref: mxmg_ 14 6 7 7 4 4 4 7 */
+/*:ref: zzmobliq_ 14 3 7 7 7 */
+/*:ref: eul2xf_ 14 5 7 4 4 4 7 */
+/*:ref: zzfrmch0_ 14 4 4 4 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzdynbid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzspkez0_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzspkzp0_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vminug_ 14 3 7 4 7 */
+/*:ref: dnearp_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: zzspksb0_ 14 5 4 7 13 7 124 */
+/*:ref: zzdynvad_ 14 8 13 4 13 4 4 7 124 124 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: zztwovxf_ 14 5 7 4 7 4 7 */
+/*:ref: zzdynvai_ 14 8 13 4 13 4 4 4 124 124 */
+/*:ref: polyds_ 14 5 7 4 4 7 7 */
+
+extern int zzdynoac_(char *frname, integer *frcode, char *item, integer *maxn, integer *n, char *values, logical *found, ftnlen frname_len, ftnlen item_len, ftnlen values_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+
+extern int zzdynoad_(char *frname, integer *frcode, char *item, integer *maxn, integer *n, doublereal *values, logical *found, ftnlen frname_len, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+
+extern int zzdynrot_(integer *infram, integer *center, doublereal *et, doublereal *rotate, integer *basfrm);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: bodn2c_ 14 4 13 4 12 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: frmnam_ 14 3 4 13 124 */
+/*:ref: zzdynfid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzdynvac_ 14 9 13 4 13 4 4 13 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzdynoad_ 14 9 13 4 13 4 4 7 12 124 124 */
+/*:ref: zzdynoac_ 14 10 13 4 13 4 4 13 12 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: zzeprc76_ 14 2 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: zzenut80_ 14 2 7 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: zzmobliq_ 14 3 7 7 7 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: zzrefch0_ 14 4 4 4 7 7 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzdynbid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzspkzp0_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzspkez0_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: zzspksb0_ 14 5 4 7 13 7 124 */
+/*:ref: zzdynvad_ 14 8 13 4 13 4 4 7 124 124 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: twovec_ 14 5 7 4 7 4 7 */
+/*:ref: zzdynvai_ 14 8 13 4 13 4 4 4 124 124 */
+/*:ref: polyds_ 14 5 7 4 4 7 7 */
+
+extern int zzdynrt0_(integer *infram, integer *center, doublereal *et, doublereal *rotate, integer *basfrm);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: bodn2c_ 14 4 13 4 12 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: frmnam_ 14 3 4 13 124 */
+/*:ref: zzdynfid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzdynvac_ 14 9 13 4 13 4 4 13 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzdynoad_ 14 9 13 4 13 4 4 7 12 124 124 */
+/*:ref: zzdynoac_ 14 10 13 4 13 4 4 13 12 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: zzeprc76_ 14 2 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: zzenut80_ 14 2 7 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: zzmobliq_ 14 3 7 7 7 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: zzrefch1_ 14 4 4 4 7 7 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzdynbid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzspkzp1_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzspkez1_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: zzspksb1_ 14 5 4 7 13 7 124 */
+/*:ref: zzdynvad_ 14 8 13 4 13 4 4 7 124 124 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: twovec_ 14 5 7 4 7 4 7 */
+/*:ref: zzdynvai_ 14 8 13 4 13 4 4 4 124 124 */
+/*:ref: polyds_ 14 5 7 4 4 7 7 */
+
+extern int zzdynvac_(char *frname, integer *frcode, char *item, integer *maxn, integer *n, char *values, ftnlen frname_len, ftnlen item_len, ftnlen values_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+
+extern int zzdynvad_(char *frname, integer *frcode, char *item, integer *maxn, integer *n, doublereal *values, ftnlen frname_len, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+
+extern int zzdynvai_(char *frname, integer *frcode, char *item, integer *maxn, integer *n, integer *values, ftnlen frname_len, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+
+extern int zzedterm_(char *type__, doublereal *a, doublereal *b, doublereal *c__, doublereal *srcrad, doublereal *srcpos, integer *npts, doublereal *trmpts, ftnlen type_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: frame_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: nvp2pl_ 14 3 7 7 7 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+
+extern int zzekac01_(integer *handle, integer *segdsc, integer *coldsc, integer *ivals, logical *nlflgs, integer *rcptrs, integer *wkindx);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzekordi_ 14 5 4 12 12 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: zzektr1s_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzekac02_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dvals, logical *nlflgs, integer *rcptrs, integer *wkindx);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: zzekpgwd_ 14 3 4 4 7 */
+/*:ref: zzekordd_ 14 5 7 12 12 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: zzektr1s_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzekac03_(integer *handle, integer *segdsc, integer *coldsc, char *cvals, logical *nlflgs, integer *rcptrs, integer *wkindx, ftnlen cvals_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: prtenc_ 14 3 4 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: prtdec_ 14 3 13 4 124 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: zzekordc_ 14 6 13 12 12 4 4 124 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: zzektr1s_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzekac04_(integer *handle, integer *segdsc, integer *coldsc, integer *ivals, integer *entszs, logical *nlflgs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+
+extern int zzekac05_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dvals, integer *entszs, logical *nlflgs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: zzekpgwd_ 14 3 4 4 7 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+
+extern int zzekac06_(integer *handle, integer *segdsc, integer *coldsc, char *cvals, integer *entszs, logical *nlflgs, ftnlen cvals_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: prtenc_ 14 3 4 13 124 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+
+extern int zzekac07_(integer *handle, integer *segdsc, integer *coldsc, integer *ivals, logical *nlflgs, integer *wkindx);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekacps_ 14 6 4 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekordi_ 14 5 4 12 12 4 4 */
+/*:ref: zzekwpai_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzekwpal_ 14 6 4 4 4 12 4 4 */
+
+extern int zzekac08_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dvals, logical *nlflgs, integer *wkindx);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekacps_ 14 6 4 4 4 4 4 4 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: zzekpgwd_ 14 3 4 4 7 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekordd_ 14 5 7 12 12 4 4 */
+/*:ref: zzekwpai_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzekwpal_ 14 6 4 4 4 12 4 4 */
+
+extern int zzekac09_(integer *handle, integer *segdsc, integer *coldsc, char *cvals, logical *nlflgs, integer *wkindx, ftnlen cvals_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekacps_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekordc_ 14 6 13 12 12 4 4 124 */
+/*:ref: zzekwpai_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzekwpal_ 14 6 4 4 4 12 4 4 */
+
+extern int zzekacps_(integer *handle, integer *segdsc, integer *type__, integer *n, integer *p, integer *base);
+/*:ref: zzekpgan_ 14 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+/*:ref: zzektrap_ 14 4 4 4 4 4 */
+
+extern int zzekad01_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *ival, logical *isnull);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzekiii1_ 14 6 4 4 4 4 4 12 */
+
+extern int zzekad02_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, doublereal *dval, logical *isnull);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: dasudd_ 14 4 4 4 4 7 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzekiid1_ 14 6 4 4 4 7 4 12 */
+
+extern int zzekad03_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, char *cval, logical *isnull, ftnlen cval_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: zzeksei_ 14 3 4 4 4 */
+/*:ref: dasudc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekiic1_ 14 7 4 4 4 13 4 12 124 */
+
+extern int zzekad04_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *nvals, integer *ivals, logical *isnull);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+
+extern int zzekad05_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *nvals, doublereal *dvals, logical *isnull);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: dasudd_ 14 4 4 4 4 7 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+
+extern int zzekad06_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *nvals, char *cvals, logical *isnull, ftnlen cvals_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzeksei_ 14 3 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: dasudc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+
+extern int zzekaps_(integer *handle, integer *segdsc, integer *type__, logical *new__, integer *p, integer *base);
+/*:ref: zzekpgan_ 14 4 4 4 4 4 */
+/*:ref: zzekpgal_ 14 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+/*:ref: zzektrap_ 14 4 4 4 4 4 */
+
+extern int zzekbs01_(integer *handle, char *tabnam, integer *ncols, char *cnames, integer *cdscrs, integer *segno, ftnlen tabnam_len, ftnlen cnames_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgan_ 14 4 4 4 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: eknseg_ 4 1 4 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: zzekcix1_ 14 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzektrap_ 14 4 4 4 4 4 */
+
+extern int zzekbs02_(integer *handle, char *tabnam, integer *ncols, char *cnames, integer *cdscrs, integer *segno, ftnlen tabnam_len, ftnlen cnames_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgan_ 14 4 4 4 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: eknseg_ 4 1 4 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzektrap_ 14 4 4 4 4 4 */
+
+extern int zzekcchk_(char *query, integer *eqryi, char *eqryc, integer *ntab, char *tablst, char *alslst, integer *base, logical *error, char *errmsg, integer *errptr, ftnlen query_len, ftnlen eqryc_len, ftnlen tablst_len, ftnlen alslst_len, ftnlen errmsg_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: ekccnt_ 14 3 13 4 124 */
+/*:ref: ekcii_ 14 6 13 4 13 4 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+
+extern int zzekcdsc_(integer *handle, integer *segdsc, char *column, integer *coldsc, ftnlen column_len);
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekcix1_(integer *handle, integer *coldsc);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrit_ 14 2 4 4 */
+
+extern int zzekcnam_(integer *handle, integer *coldsc, char *column, ftnlen column_len);
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+
+extern int zzekde01_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekixdl_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzekde02_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekixdl_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzekde03_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekixdl_ 14 4 4 4 4 4 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekgfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzekde04_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekgfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzekde05_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekgfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzekde06_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekgfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzekdps_(integer *handle, integer *segdsc, integer *type__, integer *p);
+/*:ref: zzekpgfr_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzektrls_ 4 3 4 4 4 */
+/*:ref: zzektrdl_ 14 3 4 4 4 */
+
+extern integer zzekecmp_(integer *hans, integer *sgdscs, integer *cldscs, integer *rows, integer *elts);
+/*:ref: zzekrsi_ 14 8 4 4 4 4 4 4 12 12 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrsd_ 14 8 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrsc_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+
+extern int zzekencd_(char *query, integer *eqryi, char *eqryc, doublereal *eqryd, logical *error, char *errmsg, integer *errptr, ftnlen query_len, ftnlen eqryc_len, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekqini_ 14 6 4 4 4 13 7 124 */
+/*:ref: zzekscan_ 14 17 13 4 4 4 4 4 4 4 7 13 4 4 12 13 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpars_ 14 19 13 4 4 4 4 4 7 13 4 4 4 13 7 12 13 124 124 124 124 */
+/*:ref: zzeknres_ 14 9 13 4 13 12 13 4 124 124 124 */
+/*:ref: zzektres_ 14 10 13 4 13 7 12 13 4 124 124 124 */
+/*:ref: zzeksemc_ 14 9 13 4 13 12 13 4 124 124 124 */
+
+extern int zzekerc1_(integer *handle, integer *segdsc, integer *coldsc, char *ckey, integer *recptr, logical *null, integer *prvidx, integer *prvptr, ftnlen ckey_len);
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrsz_ 4 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzekerd1_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dkey, integer *recptr, logical *null, integer *prvidx, integer *prvptr);
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrsz_ 4 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzekeri1_(integer *handle, integer *segdsc, integer *coldsc, integer *ikey, integer *recptr, logical *null, integer *prvidx, integer *prvptr);
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrsz_ 4 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern integer zzekesiz_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: zzeksz04_ 4 4 4 4 4 4 */
+/*:ref: zzeksz05_ 4 4 4 4 4 4 */
+/*:ref: zzeksz06_ 4 4 4 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekff01_(integer *handle, integer *segno, integer *rcptrs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: zzektr1s_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzekfrx_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *pos);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekrsc_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: zzekrsd_ 14 8 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrsi_ 14 8 4 4 4 4 4 4 12 12 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: zzeklerc_ 14 9 4 4 4 13 4 12 4 4 124 */
+/*:ref: zzeklerd_ 14 8 4 4 4 7 4 12 4 4 */
+/*:ref: zzekleri_ 14 8 4 4 4 4 4 12 4 4 */
+
+extern int zzekgcdp_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *datptr);
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzekgei_(integer *handle, integer *addrss, integer *ival);
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: prtdec_ 14 3 13 4 124 */
+
+extern int zzekgfwd_(integer *handle, integer *type__, integer *p, integer *fward);
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzekglnk_(integer *handle, integer *type__, integer *p, integer *nlinks);
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzekgrcp_(integer *handle, integer *recptr, integer *ptr);
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzekgrs_(integer *handle, integer *recptr, integer *status);
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzekif01_(integer *handle, integer *segno, integer *rcptrs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekstop_ 14 1 4 */
+/*:ref: zzeksdec_ 14 1 4 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekif02_(integer *handle, integer *segno);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekiic1_(integer *handle, integer *segdsc, integer *coldsc, char *ckey, integer *recptr, logical *null, ftnlen ckey_len);
+/*:ref: failed_ 12 0 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzeklerc_ 14 9 4 4 4 13 4 12 4 4 124 */
+/*:ref: zzektrin_ 14 4 4 4 4 4 */
+
+extern int zzekiid1_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dkey, integer *recptr, logical *null);
+/*:ref: failed_ 12 0 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzeklerd_ 14 8 4 4 4 7 4 12 4 4 */
+/*:ref: zzektrin_ 14 4 4 4 4 4 */
+
+extern int zzekiii1_(integer *handle, integer *segdsc, integer *coldsc, integer *ikey, integer *recptr, logical *null);
+/*:ref: failed_ 12 0 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekleri_ 14 8 4 4 4 4 4 12 4 4 */
+/*:ref: zzektrin_ 14 4 4 4 4 4 */
+
+extern integer zzekille_(integer *handle, integer *segdsc, integer *coldsc, integer *nrows, integer *dtype, char *cval, doublereal *dval, integer *ival, ftnlen cval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekllec_ 14 7 4 4 4 13 4 4 124 */
+/*:ref: zzeklled_ 14 6 4 4 4 7 4 4 */
+/*:ref: zzekllei_ 14 6 4 4 4 4 4 4 */
+
+extern integer zzekillt_(integer *handle, integer *segdsc, integer *coldsc, integer *nrows, integer *dtype, char *cval, doublereal *dval, integer *ival, ftnlen cval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzeklltc_ 14 7 4 4 4 13 4 4 124 */
+/*:ref: zzeklltd_ 14 6 4 4 4 7 4 4 */
+/*:ref: zzekllti_ 14 6 4 4 4 4 4 4 */
+
+extern int zzekinqc_(char *value, integer *length, integer *lexbeg, integer *lexend, integer *eqryi, char *eqryc, integer *descr, ftnlen value_len, ftnlen eqryc_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+
+extern int zzekinqn_(doublereal *value, integer *type__, integer *lexbeg, integer *lexend, integer *eqryi, doublereal *eqryd, integer *descr);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+
+extern int zzekixdl_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekfrx_ 14 5 4 4 4 4 4 */
+/*:ref: zzektrdl_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int zzekixlk_(integer *handle, integer *coldsc, integer *key, integer *recptr);
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekjoin_(integer *jbase1, integer *jbase2, integer *njcnst, logical *active, integer *cpidx1, integer *clidx1, integer *elts1, integer *ops, integer *cpidx2, integer *clidx2, integer *elts2, integer *sthan, integer *stsdsc, integer *stdtpt, integer *dtpool, integer *dtdscs, integer *jbase3, integer *nrows);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: zzekstop_ 14 1 4 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzeksupd_ 14 3 4 4 4 */
+/*:ref: zzekjprp_ 14 23 4 4 4 4 4 4 4 4 4 4 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzekjnxt_ 14 2 12 4 */
+
+extern int zzekjsqz_(integer *jrsbas);
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzeksupd_ 14 3 4 4 4 */
+
+extern int zzekjsrt_(integer *njrs, integer *ubases, integer *norder, integer *otabs, integer *ocols, integer *oelts, integer *senses, integer *sthan, integer *stsdsc, integer *stdtpt, integer *dtpool, integer *dtdscs, integer *ordbas);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: zzekvset_ 14 2 4 4 */
+/*:ref: zzekvcal_ 14 3 4 4 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: zzekrsc_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: zzekrsd_ 14 8 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrsi_ 14 8 4 4 4 4 4 4 12 12 */
+/*:ref: zzekvcmp_ 12 15 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: swapi_ 14 2 4 4 */
+/*:ref: zzekstop_ 14 1 4 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzeksupd_ 14 3 4 4 4 */
+
+extern int zzekjtst_(integer *segvec, integer *jbase1, integer *nt1, integer *rb1, integer *nr1, integer *jbase2, integer *nt2, integer *rb2, integer *nr2, integer *njcnst, logical *active, integer *cpidx1, integer *clidx1, integer *elts1, integer *ops, integer *cpidx2, integer *clidx2, integer *elts2, integer *sthan, integer *stsdsc, integer *stdtpt, integer *dtpool, integer *dtdscs, logical *found, integer *rowvec);
+extern int zzekjprp_(integer *segvec, integer *jbase1, integer *nt1, integer *rb1, integer *nr1, integer *jbase2, integer *nt2, integer *rb2, integer *nr2, integer *njcnst, logical *active, integer *cpidx1, integer *clidx1, integer *elts1, integer *ops, integer *cpidx2, integer *clidx2, integer *elts2, integer *sthan, integer *stsdsc, integer *stdtpt, integer *dtpool, integer *dtdscs);
+extern int zzekjnxt_(logical *found, integer *rowvec);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: zzekstop_ 14 1 4 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: zzeksupd_ 14 3 4 4 4 */
+/*:ref: zzekjsrt_ 14 13 4 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzekrcmp_ 12 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzekvmch_ 12 13 4 12 4 4 4 4 4 4 4 4 4 4 4 */
+
+extern int zzekkey_(integer *handle, integer *segdsc, integer *nrows, integer *ncnstr, integer *clidxs, integer *dsclst, integer *ops, integer *dtypes, char *chrbuf, integer *cbegs, integer *cends, doublereal *dvals, integer *ivals, logical *active, integer *key, integer *keydsc, integer *begidx, integer *endidx, logical *found, ftnlen chrbuf_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: zzekillt_ 4 9 4 4 4 4 4 13 7 4 124 */
+/*:ref: zzekille_ 4 9 4 4 4 4 4 13 7 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ordi_ 4 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+
+extern int zzeklerc_(integer *handle, integer *segdsc, integer *coldsc, char *ckey, integer *recptr, logical *null, integer *prvidx, integer *prvptr, ftnlen ckey_len);
+/*:ref: failed_ 12 0 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekerc1_ 14 9 4 4 4 13 4 12 4 4 124 */
+
+extern int zzeklerd_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dkey, integer *recptr, logical *null, integer *prvidx, integer *prvptr);
+/*:ref: failed_ 12 0 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekerd1_ 14 8 4 4 4 7 4 12 4 4 */
+
+extern int zzekleri_(integer *handle, integer *segdsc, integer *coldsc, integer *ikey, integer *recptr, logical *null, integer *prvidx, integer *prvptr);
+/*:ref: failed_ 12 0 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekeri1_ 14 8 4 4 4 4 4 12 4 4 */
+
+extern int zzekllec_(integer *handle, integer *segdsc, integer *coldsc, char *ckey, integer *prvloc, integer *prvptr, ftnlen ckey_len);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzeklled_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dkey, integer *prvloc, integer *prvptr);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzekllei_(integer *handle, integer *segdsc, integer *coldsc, integer *ikey, integer *prvloc, integer *prvptr);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzeklltc_(integer *handle, integer *segdsc, integer *coldsc, char *ckey, integer *prvloc, integer *prvptr, ftnlen ckey_len);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzeklltd_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dkey, integer *prvloc, integer *prvptr);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzekllti_(integer *handle, integer *segdsc, integer *coldsc, integer *ikey, integer *prvloc, integer *prvptr);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzekmloc_(integer *handle, integer *segno, integer *page, integer *base);
+/*:ref: eknseg_ 4 1 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+
+extern int zzeknres_(char *query, integer *eqryi, char *eqryc, logical *error, char *errmsg, integer *errptr, ftnlen query_len, ftnlen eqryc_len, ftnlen errmsg_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekqtab_ 14 8 4 13 4 13 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: ekntab_ 14 1 4 */
+/*:ref: ektnam_ 14 3 4 13 124 */
+/*:ref: ekccnt_ 14 3 13 4 124 */
+/*:ref: zzekcchk_ 14 15 13 4 13 4 13 13 4 12 13 4 124 124 124 124 124 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+
+extern int zzeknrml_(char *query, integer *ntoken, integer *lxbegs, integer *lxends, integer *tokens, integer *values, doublereal *numvls, char *chrbuf, integer *chbegs, integer *chends, integer *eqryi, char *eqryc, doublereal *eqryd, logical *error, char *prserr, ftnlen query_len, ftnlen chrbuf_len, ftnlen eqryc_len, ftnlen prserr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektloc_ 14 7 4 4 4 4 4 4 12 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: zzekinqn_ 14 7 7 4 4 4 4 7 4 */
+/*:ref: zzekinqc_ 14 9 13 4 4 4 4 13 4 124 124 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: lnkhl_ 4 2 4 4 */
+/*:ref: lnkprv_ 4 2 4 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnktl_ 4 2 4 4 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: appndi_ 14 2 4 4 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+
+extern int zzekordc_(char *cvals, logical *nullok, logical *nlflgs, integer *nvals, integer *iorder, ftnlen cvals_len);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int zzekordd_(doublereal *dvals, logical *nullok, logical *nlflgs, integer *nvals, integer *iorder);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int zzekordi_(integer *ivals, logical *nullok, logical *nlflgs, integer *nvals, integer *iorder);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int zzekpage_(integer *handle, integer *type__, integer *addrss, char *stat, integer *p, char *pagec, doublereal *paged, integer *pagei, integer *base, integer *value, ftnlen stat_len, ftnlen pagec_len);
+extern int zzekpgin_(integer *handle);
+extern int zzekpgan_(integer *handle, integer *type__, integer *p, integer *base);
+extern int zzekpgal_(integer *handle, integer *type__, integer *p, integer *base);
+extern int zzekpgfr_(integer *handle, integer *type__, integer *p);
+extern int zzekpgrc_(integer *handle, integer *p, char *pagec, ftnlen pagec_len);
+extern int zzekpgrd_(integer *handle, integer *p, doublereal *paged);
+extern int zzekpgri_(integer *handle, integer *p, integer *pagei);
+extern int zzekpgwc_(integer *handle, integer *p, char *pagec, ftnlen pagec_len);
+extern int zzekpgwd_(integer *handle, integer *p, doublereal *paged);
+extern int zzekpgwi_(integer *handle, integer *p, integer *pagei);
+extern int zzekpgbs_(integer *type__, integer *p, integer *base);
+extern int zzekpgpg_(integer *type__, integer *addrss, integer *p, integer *base);
+extern int zzekpgst_(integer *handle, char *stat, integer *value, ftnlen stat_len);
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: fillc_ 14 5 13 4 13 124 124 */
+/*:ref: filld_ 14 3 7 4 7 */
+/*:ref: filli_ 14 3 4 4 4 */
+/*:ref: dasadi_ 14 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: dasadc_ 14 6 4 4 4 4 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasadd_ 14 3 4 4 7 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: prtdec_ 14 3 13 4 124 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: prtenc_ 14 3 4 13 124 */
+/*:ref: dasudc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: dasudd_ 14 4 4 4 4 7 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int zzekpars_(char *query, integer *ntoken, integer *lxbegs, integer *lxends, integer *tokens, integer *values, doublereal *numvls, char *chrbuf, integer *chbegs, integer *chends, integer *eqryi, char *eqryc, doublereal *eqryd, logical *error, char *prserr, ftnlen query_len, ftnlen chrbuf_len, ftnlen eqryc_len, ftnlen prserr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekqini_ 14 6 4 4 4 13 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektloc_ 14 7 4 4 4 4 4 4 12 */
+/*:ref: zzekinqc_ 14 9 13 4 4 4 4 13 4 124 124 */
+/*:ref: appndi_ 14 2 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: zzeknrml_ 14 19 13 4 4 4 4 4 7 13 4 4 4 13 7 12 13 124 124 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+
+extern int zzekpcol_(char *qcol, integer *eqryi, char *eqryc, char *table, char *alias, integer *tabidx, char *column, integer *colidx, logical *error, char *errmsg, ftnlen qcol_len, ftnlen eqryc_len, ftnlen table_len, ftnlen alias_len, ftnlen column_len, ftnlen errmsg_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekscan_ 14 17 13 4 4 4 4 4 4 4 7 13 4 4 12 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzekqtab_ 14 8 4 13 4 13 13 124 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: ekccnt_ 14 3 13 4 124 */
+/*:ref: ekcii_ 14 6 13 4 13 4 124 124 */
+
+extern int zzekpdec_(char *decl, integer *pardsc, ftnlen decl_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: lparsm_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+
+extern int zzekpgch_(integer *handle, char *access, ftnlen access_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+
+extern int zzekqcnj_(integer *eqryi, integer *n, integer *size);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzekqcon_(integer *eqryi, char *eqryc, doublereal *eqryd, integer *n, integer *cnstyp, char *ltname, integer *ltidx, char *lcname, integer *lcidx, integer *opcode, char *rtname, integer *rtidx, char *rcname, integer *rcidx, integer *dtype, integer *cbeg, integer *cend, doublereal *dval, integer *ival, ftnlen eqryc_len, ftnlen ltname_len, ftnlen lcname_len, ftnlen rtname_len, ftnlen rcname_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzekqini_(integer *isize, integer *dsize, integer *eqryi, char *eqryc, doublereal *eqryd, ftnlen eqryc_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: appndi_ 14 2 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+
+extern int zzekqord_(integer *eqryi, char *eqryc, integer *n, char *table, integer *tabidx, char *column, integer *colidx, integer *sense, ftnlen eqryc_len, ftnlen table_len, ftnlen column_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzekqsel_(integer *eqryi, char *eqryc, integer *n, integer *lxbeg, integer *lxend, char *table, integer *tabidx, char *column, integer *colidx, ftnlen eqryc_len, ftnlen table_len, ftnlen column_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzekqtab_(integer *eqryi, char *eqryc, integer *n, char *table, char *alias, ftnlen eqryc_len, ftnlen table_len, ftnlen alias_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzekrbck_(char *action, integer *handle, integer *segdsc, integer *coldsc, integer *recno, ftnlen action_len);
+
+extern logical zzekrcmp_(integer *op, integer *ncols, integer *han1, integer *sgdsc1, integer *cdlst1, integer *row1, integer *elts1, integer *han2, integer *sgdsc2, integer *cdlst2, integer *row2, integer *elts2);
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekecmp_ 4 5 4 4 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekrd01_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *ival, logical *isnull);
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzekrd02_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, doublereal *dval, logical *isnull);
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int zzekrd03_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *cvlen, char *cval, logical *isnull, ftnlen cval_len);
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int zzekrd04_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *beg, integer *end, integer *ivals, logical *isnull, logical *found);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekgfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int zzekrd05_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *beg, integer *end, doublereal *dvals, logical *isnull, logical *found);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekgfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int zzekrd06_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *beg, integer *end, char *cvals, logical *isnull, logical *found, ftnlen cvals_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+
+extern int zzekrd07_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *ival, logical *isnull);
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+
+extern int zzekrd08_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, doublereal *dval, logical *isnull);
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+
+extern int zzekrd09_(integer *handle, integer *segdsc, integer *coldsc, integer *recno, integer *cvlen, char *cval, logical *isnull, ftnlen cval_len);
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+
+extern int zzekreqi_(integer *eqryi, char *name__, integer *value, ftnlen name_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical zzekrmch_(integer *ncnstr, logical *active, integer *handle, integer *segdsc, integer *cdscrs, integer *row, integer *elts, integer *ops, integer *vtypes, char *chrbuf, integer *cbegs, integer *cends, doublereal *dvals, integer *ivals, ftnlen chrbuf_len);
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern integer zzekrp2n_(integer *handle, integer *segno, integer *recptr);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrls_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekrplk_(integer *handle, integer *segdsc, integer *n, integer *recptr);
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekrsc_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *eltidx, integer *cvlen, char *cval, logical *isnull, logical *found, ftnlen cval_len);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrd03_ 14 8 4 4 4 4 4 13 12 124 */
+/*:ref: zzekrd06_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: zzekrd09_ 14 8 4 4 4 4 4 13 12 124 */
+
+extern int zzekrsd_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *eltidx, doublereal *dval, logical *isnull, logical *found);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrd02_ 14 6 4 4 4 4 7 12 */
+/*:ref: zzekrd05_ 14 9 4 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrd08_ 14 6 4 4 4 4 7 12 */
+
+extern int zzekrsi_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *eltidx, integer *ival, logical *isnull, logical *found);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrd01_ 14 6 4 4 4 4 4 12 */
+/*:ref: zzekrd04_ 14 9 4 4 4 4 4 4 4 12 12 */
+/*:ref: zzekrd07_ 14 6 4 4 4 4 4 12 */
+
+extern int zzeksca_(integer *n, integer *beg, integer *end, integer *idata, integer *top);
+extern int zzekstop_(integer *top);
+extern int zzekspsh_(integer *n, integer *idata);
+extern int zzekspop_(integer *n, integer *idata);
+extern int zzeksdec_(integer *n);
+extern int zzeksupd_(integer *beg, integer *end, integer *idata);
+extern int zzeksrd_(integer *beg, integer *end, integer *idata);
+extern int zzekscln_(void);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasops_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: dasadi_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: daswbr_ 14 1 4 */
+/*:ref: dasllc_ 14 1 4 */
+
+extern int zzekscan_(char *query, integer *maxntk, integer *maxnum, integer *ntoken, integer *tokens, integer *lxbegs, integer *lxends, integer *values, doublereal *numvls, char *chrbuf, integer *chbegs, integer *chends, logical *scnerr, char *errmsg, ftnlen query_len, ftnlen chrbuf_len, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: lxcsid_ 14 5 13 13 4 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lxqstr_ 14 7 13 13 4 4 4 124 124 */
+/*:ref: parsqs_ 14 11 13 13 13 4 12 13 4 124 124 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: lx4num_ 14 5 13 4 4 4 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: beint_ 12 2 13 124 */
+/*:ref: lxidnt_ 14 6 4 13 4 4 4 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: frstpc_ 4 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int zzekscdp_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *datptr);
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern logical zzekscmp_(integer *op, integer *handle, integer *segdsc, integer *coldsc, integer *row, integer *eltidx, integer *dtype, char *cval, doublereal *dval, integer *ival, logical *null, ftnlen cval_len);
+/*:ref: zzekrsc_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekrsd_ 14 8 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrsi_ 14 8 4 4 4 4 4 4 12 12 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: matchi_ 12 8 13 13 13 13 124 124 124 124 */
+
+extern int zzeksdsc_(integer *handle, integer *segno, integer *segdsc);
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzeksei_(integer *handle, integer *addrss, integer *ival);
+/*:ref: prtenc_ 14 3 4 13 124 */
+/*:ref: dasudc_ 14 7 4 4 4 4 4 13 124 */
+
+extern int zzeksemc_(char *query, integer *eqryi, char *eqryc, logical *error, char *errmsg, integer *errptr, ftnlen query_len, ftnlen eqryc_len, ftnlen errmsg_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekqtab_ 14 8 4 13 4 13 13 124 124 124 */
+/*:ref: ekcii_ 14 6 13 4 13 4 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+
+extern int zzeksfwd_(integer *handle, integer *type__, integer *p, integer *fward);
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzeksei_ 14 3 4 4 4 */
+/*:ref: dasudd_ 14 4 4 4 4 7 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzeksinf_(integer *handle, integer *segno, char *tabnam, integer *segdsc, char *cnames, integer *cdscrs, ftnlen tabnam_len, ftnlen cnames_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eknseg_ 4 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+
+extern int zzekslnk_(integer *handle, integer *type__, integer *p, integer *nlinks);
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzeksei_ 14 3 4 4 4 */
+/*:ref: dasudd_ 14 4 4 4 4 7 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzeksrcp_(integer *handle, integer *recptr, integer *recno);
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzeksrs_(integer *handle, integer *recptr, integer *status);
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern integer zzekstyp_(integer *ncols, integer *cdscrs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer zzeksz04_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern integer zzeksz05_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+
+extern integer zzeksz06_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+
+extern int zzektcnv_(char *timstr, doublereal *et, logical *error, char *errmsg, ftnlen timstr_len, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: posr_ 4 5 13 13 4 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: scn2id_ 14 4 13 4 12 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: scpars_ 14 7 4 13 12 13 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: tpartv_ 14 15 13 7 4 13 13 12 12 12 13 13 124 124 124 124 124 */
+/*:ref: str2et_ 14 3 13 7 124 */
+
+extern int zzektloc_(integer *tokid, integer *kwcode, integer *ntoken, integer *tokens, integer *values, integer *loc, logical *found);
+
+extern int zzektr13_(integer *handle, integer *tree);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgal_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+
+extern int zzektr1s_(integer *handle, integer *tree, integer *size, integer *values);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzektrsz_ 4 2 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: zzekpgal_ 14 4 4 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzektr23_(integer *handle, integer *tree, integer *left, integer *right, integer *parent, integer *pkidx, logical *overfl);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgal_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+
+extern int zzektr31_(integer *handle, integer *tree);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzekpgfr_ 14 3 4 4 4 */
+
+extern int zzektr32_(integer *handle, integer *tree, integer *left, integer *middle, integer *right, integer *parent, integer *lpkidx, logical *undrfl);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzekpgfr_ 14 3 4 4 4 */
+
+extern int zzektrap_(integer *handle, integer *tree, integer *value, integer *key);
+/*:ref: zzektrsz_ 4 2 4 4 */
+/*:ref: zzektrin_ 14 4 4 4 4 4 */
+
+extern int zzektrbn_(integer *handle, integer *tree, integer *left, integer *right, integer *parent, integer *pkidx);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrnk_ 4 3 4 4 4 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzektrrk_ 14 7 4 4 4 4 4 4 4 */
+
+extern integer zzektrbs_(integer *node);
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+
+extern int zzektrdl_(integer *handle, integer *tree, integer *key);
+/*:ref: zzektrud_ 14 5 4 4 4 4 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrlk_ 14 8 4 4 4 4 4 4 4 4 */
+/*:ref: zzektrsb_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: zzektrnk_ 4 3 4 4 4 */
+/*:ref: zzektrpi_ 14 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzektrrk_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: zzektrbn_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzektrki_ 14 5 4 4 4 4 4 */
+/*:ref: zzektr32_ 14 8 4 4 4 4 4 4 4 12 */
+/*:ref: zzektr31_ 14 2 4 4 */
+
+extern int zzektrdp_(integer *handle, integer *tree, integer *key, integer *ptr);
+/*:ref: zzektrlk_ 14 8 4 4 4 4 4 4 4 4 */
+
+extern int zzektres_(char *query, integer *eqryi, char *eqryc, doublereal *eqryd, logical *error, char *errmsg, integer *errptr, ftnlen query_len, ftnlen eqryc_len, ftnlen errmsg_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekqtab_ 14 8 4 13 4 13 13 124 124 124 */
+/*:ref: ekcii_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzektcnv_ 14 6 13 7 12 13 124 124 */
+/*:ref: zzekinqn_ 14 7 7 4 4 4 4 7 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+
+extern int zzektrfr_(integer *handle, integer *tree);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgfr_ 14 3 4 4 4 */
+
+extern int zzektrin_(integer *handle, integer *tree, integer *key, integer *value);
+/*:ref: zzektrui_ 14 5 4 4 4 4 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrlk_ 14 8 4 4 4 4 4 4 4 4 */
+/*:ref: zzektrpi_ 14 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzektrnk_ 4 3 4 4 4 */
+/*:ref: zzektrbn_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzektrki_ 14 5 4 4 4 4 4 */
+/*:ref: zzektr23_ 14 7 4 4 4 4 4 4 12 */
+/*:ref: zzektr13_ 14 2 4 4 */
+
+extern int zzektrit_(integer *handle, integer *tree);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgal_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzektrki_(integer *handle, integer *tree, integer *nodkey, integer *n, integer *key);
+/*:ref: zzektrlk_ 14 8 4 4 4 4 4 4 4 4 */
+/*:ref: zzektrnk_ 4 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzektrlk_(integer *handle, integer *tree, integer *key, integer *idx, integer *node, integer *noffst, integer *level, integer *value);
+/*:ref: dasham_ 14 3 4 13 124 */
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lstlei_ 4 3 4 4 4 */
+
+extern integer zzektrls_(integer *handle, integer *tree, integer *ival);
+/*:ref: zzektrsz_ 4 2 4 4 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+
+extern integer zzektrnk_(integer *handle, integer *tree, integer *node);
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzektrpi_(integer *handle, integer *tree, integer *key, integer *parent, integer *pkey, integer *poffst, integer *lpidx, integer *lpkey, integer *lsib, integer *rpidx, integer *rpkey, integer *rsib);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lstlei_ 4 3 4 4 4 */
+
+extern int zzektrrk_(integer *handle, integer *tree, integer *left, integer *right, integer *parent, integer *pkidx, integer *nrot);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+
+extern int zzektrsb_(integer *handle, integer *tree, integer *key, integer *lsib, integer *lkey, integer *rsib, integer *rkey);
+/*:ref: zzektrpi_ 14 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern integer zzektrsz_(integer *handle, integer *tree);
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzektrud_(integer *handle, integer *tree, integer *key, integer *trgkey, logical *undrfl);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzektrlk_ 14 8 4 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrpi_ 14 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzektrui_(integer *handle, integer *tree, integer *key, integer *value, logical *overfl);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzektrlk_ 14 8 4 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrpi_ 14 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+
+extern int zzekue01_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *ival, logical *isnull);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekixdl_ 14 4 4 4 4 4 */
+/*:ref: zzekiii1_ 14 6 4 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekad01_ 14 6 4 4 4 4 4 12 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int zzekue02_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, doublereal *dval, logical *isnull);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekixdl_ 14 4 4 4 4 4 */
+/*:ref: zzekiid1_ 14 6 4 4 4 7 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: dasudd_ 14 4 4 4 4 7 */
+/*:ref: zzekad02_ 14 6 4 4 4 4 7 12 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int zzekue03_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, char *cval, logical *isnull, ftnlen cval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekde03_ 14 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekad03_ 14 7 4 4 4 4 13 12 124 */
+
+extern int zzekue04_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *nvals, integer *ivals, logical *isnull);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekde04_ 14 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekad04_ 14 7 4 4 4 4 4 4 12 */
+
+extern int zzekue05_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *nvals, doublereal *dvals, logical *isnull);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekde05_ 14 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekad05_ 14 7 4 4 4 4 4 7 12 */
+
+extern int zzekue06_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *nvals, char *cvals, logical *isnull, ftnlen cvals_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekde06_ 14 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekad06_ 14 8 4 4 4 4 4 13 12 124 */
+
+extern int zzekvadr_(integer *njrs, integer *bases, integer *rwvidx, integer *rwvbas, integer *sgvbas);
+extern int zzekvset_(integer *njrs, integer *bases);
+extern int zzekvcal_(integer *rwvidx, integer *rwvbas, integer *sgvbas);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekstop_ 14 1 4 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: lstlei_ 4 3 4 4 4 */
+
+extern logical zzekvcmp_(integer *op, integer *ncols, integer *tabs, integer *cols, integer *elts, integer *senses, integer *sthan, integer *stsdsc, integer *stdtpt, integer *dtpool, integer *dtdscs, integer *sgvec1, integer *rwvec1, integer *sgvec2, integer *rwvec2);
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekecmp_ 4 5 4 4 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical zzekvmch_(integer *ncnstr, logical *active, integer *lhans, integer *lsdscs, integer *lcdscs, integer *lrows, integer *lelts, integer *ops, integer *rhans, integer *rsdscs, integer *rcdscs, integer *rrows, integer *relts);
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekecmp_ 4 5 4 4 4 4 4 */
+/*:ref: zzekrsc_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: matchi_ 12 8 13 13 13 13 124 124 124 124 */
+
+extern int zzekweed_(integer *njrs, integer *bases, integer *nrows);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekvset_ 14 2 4 4 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: sameai_ 12 3 4 4 4 */
+/*:ref: zzeksupd_ 14 3 4 4 4 */
+/*:ref: zzekjsqz_ 14 1 4 */
+
+extern int zzekweqi_(char *name__, integer *value, integer *eqryi, ftnlen name_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekwpac_(integer *handle, integer *segdsc, integer *nvals, integer *l, char *cvals, integer *p, integer *base, ftnlen cvals_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekacps_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+
+extern int zzekwpai_(integer *handle, integer *segdsc, integer *nvals, integer *ivals, integer *p, integer *base);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekacps_ 14 6 4 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekwpal_(integer *handle, integer *segdsc, integer *nvals, logical *lvals, integer *p, integer *base);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekacps_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzelvupy_(doublereal *ellips, doublereal *vertex, doublereal *axis, integer *n, doublereal *bounds, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: saelgv_ 14 4 7 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cgv2el_ 14 4 7 7 7 7 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: pi_ 7 0 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: repmot_ 14 9 13 13 4 13 13 124 124 124 124 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: nvp2pl_ 14 3 7 7 7 */
+/*:ref: inrypl_ 14 5 7 7 7 4 7 */
+/*:ref: zzwind_ 4 4 7 4 7 7 */
+/*:ref: psv2pl_ 14 4 7 7 7 7 */
+/*:ref: inelpl_ 14 5 7 7 4 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int zzenut80_(doublereal *et, doublereal *nutxf);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzwahr_ 14 2 7 7 */
+/*:ref: zzmobliq_ 14 3 7 7 7 */
+/*:ref: eul2xf_ 14 5 7 4 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzeprc76_(doublereal *et, doublereal *precxf);
+/*:ref: jyear_ 7 0 */
+/*:ref: rpd_ 7 0 */
+/*:ref: eul2xf_ 14 5 7 4 4 4 7 */
+
+extern int zzeprcss_(doublereal *et, doublereal *precm);
+/*:ref: jyear_ 7 0 */
+/*:ref: rpd_ 7 0 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+
+extern int zzfdat_(integer *ncount, char *name__, integer *idcode, integer *center, integer *type__, integer *typid, integer *norder, integer *corder, integer *centrd, ftnlen name_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnam_ 14 3 4 13 124 */
+/*:ref: orderc_ 14 4 13 4 4 124 */
+/*:ref: orderi_ 14 3 4 4 4 */
+
+extern int zzfovaxi_(char *inst, integer *n, doublereal *bounds, doublereal *axis, ftnlen inst_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: zzhullax_ 14 5 13 4 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: vhatip_ 14 1 7 */
+
+extern int zzfrmch0_(integer *frame1, integer *frame2, doublereal *et, doublereal *xform);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzfrmgt0_ 14 5 4 7 7 4 12 */
+/*:ref: zzmsxf_ 14 3 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zznofcon_ 14 7 7 4 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: invstm_ 14 2 7 7 */
+
+extern int zzfrmch1_(integer *frame1, integer *frame2, doublereal *et, doublereal *xform);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzfrmgt1_ 14 5 4 7 7 4 12 */
+/*:ref: zzmsxf_ 14 3 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zznofcon_ 14 7 7 4 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: invstm_ 14 2 7 7 */
+
+extern int zzfrmgt0_(integer *infrm, doublereal *et, doublereal *xform, integer *outfrm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: tisbod_ 14 5 13 4 7 7 124 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: ckfxfm_ 14 5 4 7 7 4 12 */
+/*:ref: tkfram_ 14 4 4 7 4 12 */
+/*:ref: zzdynfr0_ 14 5 4 4 7 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+
+extern int zzfrmgt1_(integer *infrm, doublereal *et, doublereal *xform, integer *outfrm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: tisbod_ 14 5 13 4 7 7 124 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: ckfxfm_ 14 5 4 7 7 4 12 */
+/*:ref: tkfram_ 14 4 4 7 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: failed_ 12 0 */
+
+extern int zzftpchk_(char *string, logical *ftperr, ftnlen string_len);
+/*:ref: zzftpstr_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: zzrbrkst_ 14 10 13 13 13 13 4 12 124 124 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+
+extern int zzftpstr_(char *tstcom, char *lend, char *rend, char *delim, ftnlen tstcom_len, ftnlen lend_len, ftnlen rend_len, ftnlen delim_len);
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int zzgapool_(char *varnam, char *wtvars, integer *wtptrs, integer *wtpool, char *wtagnt, char *agtset, ftnlen varnam_len, ftnlen wtvars_len, ftnlen wtagnt_len, ftnlen agtset_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: validc_ 14 4 4 4 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+
+extern int zzgetbff_(integer *bffid);
+
+extern int zzgetelm_(integer *frstyr, char *lines, doublereal *epoch, doublereal *elems, logical *ok, char *error, ftnlen lines_len, ftnlen error_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: rpd_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: repmd_ 14 8 13 13 7 4 13 124 124 124 */
+/*:ref: ttrans_ 14 5 13 13 7 124 124 */
+
+extern int zzgfcoq_(char *vecdef, char *method, integer *trgid, doublereal *et, char *ref, char *abcorr, integer *obsid, char *dref, doublereal *dvec, char *crdsys, integer *ctrid, doublereal *re, doublereal *f, char *crdnam, doublereal *value, logical *found, ftnlen vecdef_len, ftnlen method_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen dref_len, ftnlen crdsys_len, ftnlen crdnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: bodc2s_ 14 3 4 13 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: subpnt_ 14 14 13 13 7 13 13 13 7 7 7 124 124 124 124 124 */
+/*:ref: sincpt_ 14 18 13 13 7 13 13 13 13 7 7 7 7 12 124 124 124 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: reclat_ 14 4 7 7 7 7 */
+/*:ref: recrad_ 14 4 7 7 7 7 */
+/*:ref: recsph_ 14 4 7 7 7 7 */
+/*:ref: reccyl_ 14 4 7 7 7 7 */
+/*:ref: recgeo_ 14 6 7 7 7 7 7 7 */
+/*:ref: recpgr_ 14 8 13 7 7 7 7 7 7 124 */
+
+extern int zzgfcost_(char *vecdef, char *method, integer *trgid, doublereal *et, char *ref, char *abcorr, integer *obsid, char *dref, integer *dctr, doublereal *dvec, doublereal *radii, doublereal *state, logical *found, ftnlen vecdef_len, ftnlen method_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen dref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzgfssob_ 14 11 13 4 7 13 13 4 7 7 124 124 124 */
+/*:ref: zzgfssin_ 14 16 13 4 7 13 13 4 13 4 7 7 7 12 124 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzgfcou_(char *vecdef, char *method, char *target, doublereal *et, char *ref, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, char *crdsys, char *crdnam, doublereal *refval, logical *decres, logical *lssthn, doublereal *crdval, logical *crdfnd, ftnlen vecdef_len, ftnlen method_len, ftnlen target_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len, ftnlen crdsys_len, ftnlen crdnam_len);
+extern int zzgfcoin_(char *vecdef, char *method, char *target, char *ref, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, char *crdsys, char *crdnam, doublereal *refval, ftnlen vecdef_len, ftnlen method_len, ftnlen target_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len, ftnlen crdsys_len, ftnlen crdnam_len);
+extern int zzgfcour_(doublereal *refval);
+extern int zzgfcog_(doublereal *et, doublereal *crdval);
+extern int zzgfcolt_(doublereal *et, logical *lssthn);
+extern int zzgfcodc_(doublereal *et, logical *decres);
+extern int zzgfcoex_(doublereal *et, logical *crdfnd);
+extern int zzgfcocg_(doublereal *et, doublereal *crdval);
+extern int zzgfcosg_(doublereal *et, doublereal *crdval);
+extern int zzgfcocl_(doublereal *et, logical *lssthn);
+extern int zzgfcosl_(doublereal *et, logical *lssthn);
+extern int zzgfcocd_(doublereal *et, logical *decres);
+extern int zzgfcosd_(doublereal *et, logical *decres);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzvalcor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: bodc2s_ 14 3 4 13 124 */
+/*:ref: recpgr_ 14 8 13 7 7 7 7 7 7 124 */
+/*:ref: pi_ 7 0 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: zzgfcoq_ 14 23 13 13 4 7 13 13 4 13 7 13 4 7 7 13 7 12 124 124 124 124 124 124 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: zzgfcost_ 14 18 13 13 4 7 13 13 4 13 4 7 7 7 12 124 124 124 124 124 */
+/*:ref: zzgfcprx_ 14 7 7 13 7 7 4 4 124 */
+/*:ref: reclat_ 14 4 7 7 7 7 */
+/*:ref: recrad_ 14 4 7 7 7 7 */
+/*:ref: recsph_ 14 4 7 7 7 7 */
+/*:ref: reccyl_ 14 4 7 7 7 7 */
+/*:ref: recgeo_ 14 6 7 7 7 7 7 7 */
+
+extern int zzgfcprx_(doublereal *state, char *corsys, doublereal *re, doublereal *f, integer *sense, integer *cdsign, ftnlen corsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: recgeo_ 14 6 7 7 7 7 7 7 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: vhatip_ 14 1 7 */
+/*:ref: zzrtnmat_ 14 2 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+
+extern int zzgfcslv_(char *vecdef, char *method, char *target, char *ref, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, char *crdsys, char *crdnam, char *relate, doublereal *refval, doublereal *tol, doublereal *adjust, U_fp udstep, U_fp udrefn, logical *rpt, S_fp udrepi, U_fp udrepu, S_fp udrepf, logical *bail, L_fp udbail, integer *mw, integer *nw, doublereal *work, doublereal *cnfine, doublereal *result, ftnlen vecdef_len, ftnlen method_len, ftnlen target_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len, ftnlen crdsys_len, ftnlen crdnam_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: zzgfcoin_ 14 20 13 13 13 13 13 13 13 7 13 13 7 124 124 124 124 124 124 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: wncard_ 4 1 7 */
+/*:ref: wnfetd_ 14 4 7 4 7 7 */
+/*:ref: zzgfsolv_ 14 13 200 200 200 12 212 12 7 7 7 7 12 200 7 */
+/*:ref: wncond_ 14 3 7 7 7 */
+/*:ref: copyd_ 14 2 7 7 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: zzgflong_ 14 37 13 13 13 13 13 13 13 7 13 13 13 7 7 7 200 200 12 214 200 214 12 212 4 4 7 7 7 124 124 124 124 124 124 124 124 124 124 */
+/*:ref: zzgfrel_ 14 26 200 200 200 200 200 200 13 7 7 7 7 4 4 7 12 214 200 214 13 13 12 212 7 124 124 124 */
+
+extern int zzgfdiq_(integer *targid, doublereal *et, char *abcorr, integer *obsid, doublereal *dist, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vnorm_ 7 1 7 */
+
+extern int zzgfdiu_(char *target, char *abcorr, char *obsrvr, doublereal *refval, doublereal *et, logical *decres, logical *lssthn, doublereal *dist, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+extern int zzgfdiin_(char *target, char *abcorr, char *obsrvr, doublereal *refval, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+extern int zzgfdiur_(doublereal *refval);
+extern int zzgfdidc_(doublereal *et, logical *decres);
+extern int zzgfdigq_(doublereal *et, doublereal *dist);
+extern int zzgfdilt_(doublereal *et, logical *lssthn);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzvalcor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: zzgfdiq_ 14 6 4 7 13 4 7 124 */
+
+extern int zzgfdsps_(integer *nlead, char *string, char *fmt, integer *ntrail, ftnlen string_len, ftnlen fmt_len);
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzgffvu_(char *inst, char *tshape, doublereal *raydir, char *target, char *tframe, char *abcorr, char *obsrvr, doublereal *time, logical *vistat, ftnlen inst_len, ftnlen tshape_len, ftnlen target_len, ftnlen tframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+extern int zzgffvin_(char *inst, char *tshape, doublereal *raydir, char *target, char *tframe, char *abcorr, char *obsrvr, ftnlen inst_len, ftnlen tshape_len, ftnlen target_len, ftnlen tframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+extern int zzgffvst_(doublereal *time, logical *vistat);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzvalcor_ 14 3 13 12 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: getfov_ 14 9 4 4 13 13 7 4 7 124 124 */
+/*:ref: zzfovaxi_ 14 5 13 4 7 7 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: dpr_ 7 0 */
+/*:ref: nvc2pl_ 14 3 7 7 7 */
+/*:ref: vrotv_ 14 4 7 7 7 7 */
+/*:ref: inrypl_ 14 5 7 7 7 4 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: frame_ 14 3 7 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: edlimb_ 14 5 7 7 7 7 7 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: cgv2el_ 14 4 7 7 7 7 */
+/*:ref: zzelvupy_ 14 6 7 7 7 4 7 12 */
+/*:ref: zzocced_ 4 5 7 7 7 7 7 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: zzwind2d_ 4 3 4 7 7 */
+
+extern int zzgflong_(char *vecdef, char *method, char *target, char *ref, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, char *crdsys, char *crdnam, char *relate, doublereal *refval, doublereal *tol, doublereal *adjust, U_fp udstep, U_fp udrefn, logical *rpt, U_fp udrepi, U_fp udrepu, U_fp udrepf, logical *bail, L_fp udbail, integer *mw, integer *nw, doublereal *work, doublereal *cnfine, doublereal *result, ftnlen vecdef_len, ftnlen method_len, ftnlen target_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len, ftnlen crdsys_len, ftnlen crdnam_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: zzgfcoin_ 14 20 13 13 13 13 13 13 13 7 13 13 7 124 124 124 124 124 124 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: wncard_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: copyd_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: bodc2s_ 14 3 4 13 124 */
+/*:ref: recpgr_ 14 8 13 7 7 7 7 7 7 124 */
+/*:ref: pi_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: zzgfrel_ 14 26 200 200 200 200 214 200 13 7 7 7 7 4 4 7 12 200 200 200 13 13 12 212 7 124 124 124 */
+/*:ref: zzgfcosg_ 14 2 7 7 */
+/*:ref: zzgfcocg_ 14 2 7 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: smsgnd_ 12 2 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+/*:ref: wndifd_ 14 3 7 7 7 */
+/*:ref: zzgfcog_ 14 2 7 7 */
+/*:ref: wnunid_ 14 3 7 7 7 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: wnintd_ 14 3 7 7 7 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: elemi_ 12 2 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+
+extern int zzgfocu_(char *occtyp, char *front, char *fshape, char *fframe, char *back, char *bshape, char *bframe, char *obsrvr, char *abcorr, doublereal *time, logical *ocstat, ftnlen occtyp_len, ftnlen front_len, ftnlen fshape_len, ftnlen fframe_len, ftnlen back_len, ftnlen bshape_len, ftnlen bframe_len, ftnlen obsrvr_len, ftnlen abcorr_len);
+extern int zzgfocin_(char *occtyp, char *front, char *fshape, char *fframe, char *back, char *bshape, char *bframe, char *obsrvr, char *abcorr, ftnlen occtyp_len, ftnlen front_len, ftnlen fshape_len, ftnlen fframe_len, ftnlen back_len, ftnlen bshape_len, ftnlen bframe_len, ftnlen obsrvr_len, ftnlen abcorr_len);
+extern int zzgfocst_(doublereal *time, logical *ocstat);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: zzvalcor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: minad_ 14 4 7 4 7 4 */
+/*:ref: maxad_ 14 4 7 4 7 4 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: zzocced_ 4 5 7 7 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: dasine_ 7 2 7 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: sincpt_ 14 18 13 13 7 13 13 13 13 7 7 7 7 12 124 124 124 124 124 124 */
+
+extern int zzgfref_(doublereal *refval);
+/*:ref: zzholdd_ 14 3 13 7 124 */
+
+extern int zzgfrel_(U_fp udstep, U_fp udrefn, U_fp udqdec, U_fp udcond, S_fp udfunc, S_fp udqref, char *relate, doublereal *refval, doublereal *tol, doublereal *adjust, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, logical *rpt, S_fp udrepi, U_fp udrepu, S_fp udrepf, char *rptpre, char *rptsuf, logical *bail, L_fp udbail, doublereal *result, ftnlen relate_len, ftnlen rptpre_len, ftnlen rptsuf_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: copyd_ 14 2 7 7 */
+/*:ref: wnexpd_ 14 3 7 7 7 */
+/*:ref: wncard_ 4 1 7 */
+/*:ref: wnfetd_ 14 4 7 4 7 7 */
+/*:ref: zzgfsolv_ 14 13 200 200 200 12 212 12 7 7 7 7 12 200 7 */
+/*:ref: wnextd_ 14 3 13 7 124 */
+/*:ref: zzgfwsts_ 14 5 7 7 13 7 124 */
+/*:ref: wnintd_ 14 3 7 7 7 */
+/*:ref: wndifd_ 14 3 7 7 7 */
+/*:ref: zzwninsd_ 14 5 7 7 13 7 124 */
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int zzgfrelx_(U_fp udstep, U_fp udrefn, U_fp udqdec, U_fp udcond, S_fp udfunc, S_fp udqref, char *relate, doublereal *refval, doublereal *tol, doublereal *adjust, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, logical *rpt, S_fp udrepi, U_fp udrepu, S_fp udrepf, char *rptpre, char *rptsuf, logical *bail, L_fp udbail, doublereal *result, ftnlen relate_len, ftnlen rptpre_len, ftnlen rptsuf_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: copyd_ 14 2 7 7 */
+/*:ref: wnexpd_ 14 3 7 7 7 */
+/*:ref: wncard_ 4 1 7 */
+/*:ref: wnfetd_ 14 4 7 4 7 7 */
+/*:ref: zzgfsolvx_ 14 14 214 200 200 200 12 212 12 7 7 7 7 12 200 7 */
+/*:ref: wnextd_ 14 3 13 7 124 */
+/*:ref: zzgfwsts_ 14 5 7 7 13 7 124 */
+/*:ref: wnintd_ 14 3 7 7 7 */
+/*:ref: wndifd_ 14 3 7 7 7 */
+/*:ref: zzwninsd_ 14 5 7 7 13 7 124 */
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int zzgfrpwk_(integer *unit, doublereal *total, doublereal *freq, integer *tcheck, char *begin, char *end, doublereal *incr, ftnlen begin_len, ftnlen end_len);
+extern int zzgftswk_(doublereal *total, doublereal *freq, integer *tcheck, char *begin, char *end, ftnlen begin_len, ftnlen end_len);
+extern int zzgfwkin_(doublereal *incr);
+extern int zzgfwkad_(doublereal *freq, integer *tcheck, char *begin, char *end, ftnlen begin_len, ftnlen end_len);
+extern int zzgfwkun_(integer *unit);
+extern int zzgfwkmo_(integer *unit, doublereal *total, doublereal *freq, integer *tcheck, char *begin, char *end, doublereal *incr, ftnlen begin_len, ftnlen end_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: stdio_ 14 3 13 4 124 */
+/*:ref: zzcputim_ 14 1 7 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: zzgfdsps_ 14 6 4 13 13 4 124 124 */
+/*:ref: writln_ 14 3 13 4 124 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: dpfmt_ 14 5 7 13 13 124 124 */
+
+extern int zzgfrrq_(doublereal *et, integer *targ, integer *obs, char *abcorr, doublereal *value, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dvnorm_ 7 1 7 */
+
+extern int zzgfrru_(char *target, char *abcorr, char *obsrvr, doublereal *refval, doublereal *et, doublereal *dt, logical *decres, logical *lssthn, doublereal *rvl, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+extern int zzgfrrin_(char *target, char *abcorr, char *obsrvr, doublereal *refval, doublereal *dt, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+extern int zzgfrrur_(doublereal *refval);
+extern int zzgfrrdc_(doublereal *et, logical *decres);
+extern int zzgfrrgq_(doublereal *et, doublereal *rvl);
+extern int zzgfrrlt_(doublereal *et, logical *lssthn);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzvalcor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: dvhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: zzgfrrq_ 14 6 7 4 4 13 7 124 */
+
+extern int zzgfsolv_(S_fp udcond, S_fp udstep, S_fp udrefn, logical *bail, L_fp udbail, logical *cstep, doublereal *step, doublereal *start, doublereal *finish, doublereal *tol, logical *rpt, S_fp udrepu, doublereal *result);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: zzwninsd_ 14 5 7 7 13 7 124 */
+
+extern int zzgfsolvx_(U_fp udfunc, S_fp udcond, S_fp udstep, S_fp udrefn, logical *bail, L_fp udbail, logical *cstep, doublereal *step, doublereal *start, doublereal *finish, doublereal *tol, logical *rpt, S_fp udrepu, doublereal *result);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: zzwninsd_ 14 5 7 7 13 7 124 */
+
+extern int zzgfspq_(doublereal *et, integer *targ1, integer *targ2, doublereal *r1, doublereal *r2, integer *obs, char *abcorr, char *ref, doublereal *value, ftnlen abcorr_len, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: dasine_ 7 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: vsep_ 7 2 7 7 */
+
+extern int zzgfspu_(char *of, char *from, char *shape, char *frame, doublereal *refval, doublereal *et, char *abcorr, logical *decres, logical *lssthn, doublereal *sep, ftnlen of_len, ftnlen from_len, ftnlen shape_len, ftnlen frame_len, ftnlen abcorr_len);
+extern int zzgfspin_(char *of, char *from, char *shape, char *frame, doublereal *refval, char *abcorr, ftnlen of_len, ftnlen from_len, ftnlen shape_len, ftnlen frame_len, ftnlen abcorr_len);
+extern int zzgfspur_(doublereal *refval);
+extern int zzgfspdc_(doublereal *et, logical *decres);
+extern int zzgfgsep_(doublereal *et, doublereal *sep);
+extern int zzgfsplt_(doublereal *et, logical *lssthn);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzvalcor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: zzgftreb_ 14 2 4 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: dvsep_ 7 2 7 7 */
+/*:ref: dhfa_ 7 2 7 7 */
+/*:ref: zzgfspq_ 14 11 7 4 4 7 7 4 13 13 7 124 124 */
+
+extern int zzgfssin_(char *method, integer *trgid, doublereal *et, char *fixref, char *abcorr, integer *obsid, char *dref, integer *dctr, doublereal *dvec, doublereal *radii, doublereal *state, logical *found, ftnlen method_len, ftnlen fixref_len, ftnlen abcorr_len, ftnlen dref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bodc2s_ 14 3 4 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vminug_ 14 3 7 4 7 */
+/*:ref: surfpv_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: spkacs_ 14 10 4 7 13 13 4 7 7 7 124 124 */
+/*:ref: zzcorsxf_ 14 4 12 7 7 7 */
+/*:ref: sincpt_ 14 18 13 13 7 13 13 13 13 7 7 7 7 12 124 124 124 124 124 124 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: vaddg_ 14 4 7 7 4 7 */
+/*:ref: zzstelab_ 14 6 12 7 7 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: clight_ 7 0 */
+
+extern int zzgfssob_(char *method, integer *trgid, doublereal *et, char *fixref, char *abcorr, integer *obsid, doublereal *radii, doublereal *state, ftnlen method_len, ftnlen fixref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bodc2s_ 14 3 4 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vminug_ 14 3 7 4 7 */
+/*:ref: dnearp_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: surfpv_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: subpnt_ 14 14 13 13 7 13 13 13 7 7 7 124 124 124 124 124 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: sxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: zzcorsxf_ 14 4 12 7 7 7 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: vaddg_ 14 4 7 7 4 7 */
+/*:ref: zzstelab_ 14 6 12 7 7 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: clight_ 7 0 */
+
+extern int zzgftreb_(integer *body, doublereal *axes);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzgfudlt_(S_fp udfunc, doublereal *et, logical *isless);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzholdd_ 14 3 13 7 124 */
+
+extern int zzgfwsts_(doublereal *wndw1, doublereal *wndw2, char *inclsn, doublereal *wndw3, ftnlen inclsn_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: scardd_ 14 2 4 7 */
+
+extern int zzgpnm_(integer *namlst, integer *nmpool, char *names, integer *datlst, integer *dppool, doublereal *dpvals, integer *chpool, char *chvals, char *varnam, logical *found, integer *lookat, integer *nameat, ftnlen names_len, ftnlen chvals_len, ftnlen varnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzhash_ 4 2 13 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzholdd_(char *op, doublereal *value, ftnlen op_len);
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int zzhullax_(char *inst, integer *n, doublereal *bounds, doublereal *axis, ftnlen inst_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: pi_ 7 0 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vhatip_ 14 1 7 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: reclat_ 14 4 7 7 7 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vrotv_ 14 4 7 7 7 7 */
+
+extern int zzidmap_(integer *bltcod, char *bltnam, ftnlen bltnam_len);
+
+extern int zzinssub_(char *in, char *sub, integer *loc, char *out, ftnlen in_len, ftnlen sub_len, ftnlen out_len);
+
+extern int zzldker_(char *file, char *nofile, char *filtyp, integer *handle, ftnlen file_len, ftnlen nofile_len, ftnlen filtyp_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: exists_ 12 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: spklef_ 14 3 13 4 124 */
+/*:ref: cklpf_ 14 3 13 4 124 */
+/*:ref: pcklof_ 14 3 13 4 124 */
+/*:ref: tkvrsn_ 14 4 13 13 124 124 */
+/*:ref: eklef_ 14 3 13 4 124 */
+/*:ref: ldpool_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzbodkik_ 14 0 */
+
+extern int zzmkpc_(char *pictur, integer *b, integer *e, char *mark, char *pattrn, ftnlen pictur_len, ftnlen mark_len, ftnlen pattrn_len);
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: zzrepsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int zzmobliq_(doublereal *et, doublereal *mob, doublereal *dmob);
+/*:ref: jyear_ 7 0 */
+/*:ref: rpd_ 7 0 */
+
+extern int zzmsxf_(doublereal *matrix, integer *n, doublereal *output);
+
+extern int zznofcon_(doublereal *et, integer *frame1, integer *endp1, integer *frame2, integer *endp2, char *errmsg, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: frmnam_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: repmf_ 14 10 13 13 7 4 13 13 124 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: ckmeta_ 14 4 4 13 4 124 */
+/*:ref: zzsclk_ 12 2 4 4 */
+
+extern int zznrddp_(doublereal *ao, doublereal *elems, doublereal *em, doublereal *omgasm, doublereal *omgdot, doublereal *t, doublereal *xinc, doublereal *xll, doublereal *xlldot, doublereal *xn, doublereal *xnodes, doublereal *xnodot, doublereal *xnodp);
+extern int zzdpinit_(doublereal *ao, doublereal *xlldot, doublereal *omgdot, doublereal *xnodot, doublereal *xnodp, doublereal *elems);
+extern int zzdpsec_(doublereal *xll, doublereal *omgasm, doublereal *xnodes, doublereal *em, doublereal *xinc, doublereal *xn, doublereal *t, doublereal *elems, doublereal *omgdot);
+extern int zzdpper_(doublereal *t, doublereal *em, doublereal *xinc, doublereal *omgasm, doublereal *xnodes, doublereal *xll);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pi_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: spd_ 7 0 */
+/*:ref: j1950_ 7 0 */
+/*:ref: zzsecprt_ 14 12 4 7 7 7 7 7 7 7 7 7 7 7 */
+
+extern int zznwpool_(char *varnam, char *wtvars, integer *wtptrs, integer *wtpool, char *wtagnt, char *agtwrk, char *notify, char *agents, ftnlen varnam_len, ftnlen wtvars_len, ftnlen wtagnt_len, ftnlen agtwrk_len, ftnlen notify_len, ftnlen agents_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzgapool_ 14 10 13 13 4 4 13 13 124 124 124 124 */
+/*:ref: unionc_ 14 6 13 13 13 124 124 124 */
+/*:ref: copyc_ 14 4 13 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer zzocced_(doublereal *viewpt, doublereal *centr1, doublereal *semax1, doublereal *centr2, doublereal *semax2);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: isrot_ 12 3 7 7 7 */
+/*:ref: det_ 7 1 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: dasine_ 7 2 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: edlimb_ 14 5 7 7 7 7 7 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: psv2pl_ 14 4 7 7 7 7 */
+/*:ref: vprjp_ 14 3 7 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: saelgv_ 14 4 7 7 7 7 */
+/*:ref: cgv2el_ 14 4 7 7 7 7 */
+/*:ref: zzasryel_ 14 7 13 7 7 7 7 7 124 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: pi_ 7 0 */
+
+extern integer zzphsh_(char *word, integer *m, integer *m2, ftnlen word_len);
+extern integer zzshsh_(integer *m);
+extern integer zzhash_(char *word, ftnlen word_len);
+extern integer zzhash2_(char *word, integer *m2, ftnlen word_len);
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzpini_(logical *first, integer *maxvar, integer *maxval, integer *maxlin, char *begdat, char *begtxt, integer *nmpool, integer *dppool, integer *chpool, integer *namlst, integer *datlst, integer *maxagt, integer *mxnote, char *wtvars, integer *wtptrs, integer *wtpool, char *wtagnt, char *agents, char *active, char *notify, ftnlen begdat_len, ftnlen begtxt_len, ftnlen wtvars_len, ftnlen wtagnt_len, ftnlen agents_len, ftnlen active_len, ftnlen notify_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzshsh_ 4 1 4 */
+/*:ref: touchi_ 4 1 4 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: ssizec_ 14 3 4 13 124 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: clearc_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzplatfm_(char *key, char *value, ftnlen key_len, ftnlen value_len);
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+
+extern int zzpltchk_(logical *ok);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: zzgetbff_ 14 1 4 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzprscor_(char *abcorr, logical *attblk, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: orderc_ 14 4 13 4 4 124 */
+/*:ref: reordc_ 14 4 4 4 13 124 */
+/*:ref: reordl_ 14 3 4 4 12 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzrbrkst_(char *string, char *lftend, char *rgtend, char *substr, integer *length, logical *bkpres, ftnlen string_len, ftnlen lftend_len, ftnlen rgtend_len, ftnlen substr_len);
+/*:ref: posr_ 4 5 13 13 4 124 124 */
+
+extern int zzrefch0_(integer *frame1, integer *frame2, doublereal *et, doublereal *rotate);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ident_ 14 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzrotgt0_ 14 5 4 7 7 4 12 */
+/*:ref: zzrxr_ 14 3 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zznofcon_ 14 7 7 4 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: xpose_ 14 2 7 7 */
+
+extern int zzrefch1_(integer *frame1, integer *frame2, doublereal *et, doublereal *rotate);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ident_ 14 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzrotgt1_ 14 5 4 7 7 4 12 */
+/*:ref: zzrxr_ 14 3 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zznofcon_ 14 7 7 4 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: xpose_ 14 2 7 7 */
+
+extern int zzrepsub_(char *in, integer *left, integer *right, char *string, char *out, ftnlen in_len, ftnlen string_len, ftnlen out_len);
+/*:ref: sumai_ 4 2 4 4 */
+
+extern logical zzrept_(char *sub, char *replac, logical *l2r, ftnlen sub_len, ftnlen replac_len);
+/*:ref: zzsubt_ 12 5 13 13 12 124 124 */
+/*:ref: zzremt_ 12 2 13 124 */
+
+extern int zzrotgt0_(integer *infrm, doublereal *et, doublereal *rotate, integer *outfrm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: tipbod_ 14 5 13 4 7 7 124 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckfrot_ 14 5 4 7 7 4 12 */
+/*:ref: tkfram_ 14 4 4 7 4 12 */
+/*:ref: zzdynrt0_ 14 5 4 4 7 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzrotgt1_(integer *infrm, doublereal *et, doublereal *rotate, integer *outfrm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: tipbod_ 14 5 13 4 7 7 124 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckfrot_ 14 5 4 7 7 4 12 */
+/*:ref: tkfram_ 14 4 4 7 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int zzrtnmat_(doublereal *v, doublereal *m);
+/*:ref: return_ 12 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+
+extern int zzrvar_(integer *namlst, integer *nmpool, char *names, integer *datlst, integer *dppool, doublereal *dpvals, integer *chpool, char *chvals, char *varnam, logical *eof, ftnlen names_len, ftnlen chvals_len, ftnlen varnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: rdkdat_ 14 3 13 12 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rdklin_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: lastpc_ 4 2 13 124 */
+/*:ref: zzhash_ 4 2 13 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: zzcln_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: tparse_ 14 5 13 7 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+
+extern int zzrvbf_(char *buffer, integer *bsize, integer *linnum, integer *namlst, integer *nmpool, char *names, integer *datlst, integer *dppool, doublereal *dpvals, integer *chpool, char *chvals, char *varnam, logical *eof, ftnlen buffer_len, ftnlen names_len, ftnlen chvals_len, ftnlen varnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: lastpc_ 4 2 13 124 */
+/*:ref: zzhash_ 4 2 13 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: zzcln_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: tparse_ 14 5 13 7 13 124 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+
+extern int zzrxr_(doublereal *matrix, integer *n, doublereal *output);
+/*:ref: ident_ 14 1 7 */
+
+extern logical zzsclk_(integer *ckid, integer *sclkid);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: elemi_ 12 2 4 4 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: removi_ 14 2 4 4 */
+
+extern int zzsecprt_(integer *isynfl, doublereal *dg, doublereal *del, doublereal *xni, doublereal *omegao, doublereal *atime, doublereal *omgdot, doublereal *xli, doublereal *xfact, doublereal *xldot, doublereal *xndot, doublereal *xnddt);
+
+extern int zzsizeok_(integer *size, integer *psize, integer *dsize, integer *offset, logical *ok, integer *n);
+/*:ref: rmaini_ 14 4 4 4 4 4 */
+
+extern int zzspkac0_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzspkgo0_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: zzspkas0_ 14 11 4 7 13 13 7 7 7 7 7 124 124 */
+
+extern int zzspkac1_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzspkgo1_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: zzspkas1_ 14 11 4 7 13 13 7 7 7 7 7 124 124 */
+
+extern int zzspkap0_(integer *targ, doublereal *et, char *ref, doublereal *sobs, char *abcorr, doublereal *starg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspksb0_ 14 5 4 7 13 7 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+
+extern int zzspkap1_(integer *targ, doublereal *et, char *ref, doublereal *sobs, char *abcorr, doublereal *starg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspksb1_ 14 5 4 7 13 7 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+
+extern int zzspkas0_(integer *targ, doublereal *et, char *ref, char *abcorr, doublereal *stobs, doublereal *accobs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspklt0_ 14 10 4 7 13 13 7 7 7 7 124 124 */
+/*:ref: zzstelab_ 14 6 12 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int zzspkas1_(integer *targ, doublereal *et, char *ref, char *abcorr, doublereal *stobs, doublereal *accobs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspklt1_ 14 10 4 7 13 13 7 7 7 7 124 124 */
+/*:ref: zzstelab_ 14 6 12 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int zzspkez0_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *starg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: zzspkgo0_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzspkac0_ 14 10 4 7 13 13 4 7 7 7 124 124 */
+/*:ref: zzspksb0_ 14 5 4 7 13 7 124 */
+/*:ref: zzspklt0_ 14 10 4 7 13 13 7 7 7 7 124 124 */
+/*:ref: zzfrmch0_ 14 4 4 4 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+
+extern int zzspkez1_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *starg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzspkgo1_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: zzspkac1_ 14 10 4 7 13 13 4 7 7 7 124 124 */
+/*:ref: zzspksb1_ 14 5 4 7 13 7 124 */
+/*:ref: zzspklt1_ 14 10 4 7 13 13 7 7 7 7 124 124 */
+/*:ref: zzfrmch1_ 14 4 4 4 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+
+extern int zzspkgo0_(integer *targ, doublereal *et, char *ref, integer *obs, doublereal *state, doublereal *lt, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: zzfrmch0_ 14 4 4 4 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: vaddg_ 14 4 7 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+
+extern int zzspkgo1_(integer *targ, doublereal *et, char *ref, integer *obs, doublereal *state, doublereal *lt, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: zzfrmch1_ 14 4 4 4 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: vaddg_ 14 4 7 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+
+extern int zzspkgp0_(integer *targ, doublereal *et, char *ref, integer *obs, doublereal *pos, doublereal *lt, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: zzrefch0_ 14 4 4 4 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+
+extern int zzspkgp1_(integer *targ, doublereal *et, char *ref, integer *obs, doublereal *pos, doublereal *lt, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: zzrefch1_ 14 4 4 4 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+
+extern int zzspklt0_(integer *targ, doublereal *et, char *ref, char *abcorr, doublereal *stobs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspkgo0_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int zzspklt1_(integer *targ, doublereal *et, char *ref, char *abcorr, doublereal *stobs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspkgo1_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int zzspkpa0_(integer *targ, doublereal *et, char *ref, doublereal *sobs, char *abcorr, doublereal *ptarg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspkgp0_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+
+extern int zzspkpa1_(integer *targ, doublereal *et, char *ref, doublereal *sobs, char *abcorr, doublereal *ptarg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspkgp1_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+
+extern int zzspksb0_(integer *targ, doublereal *et, char *ref, doublereal *starg, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzspkgo0_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzspksb1_(integer *targ, doublereal *et, char *ref, doublereal *starg, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzspkgo1_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzspkzp0_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *ptarg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: eqchr_ 12 4 13 13 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: zzspkgp0_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzspksb0_ 14 5 4 7 13 7 124 */
+/*:ref: zzspkpa0_ 14 9 4 7 13 7 13 7 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzrefch0_ 14 4 4 4 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+
+extern int zzspkzp1_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *ptarg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: eqchr_ 12 4 13 13 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: zzspkgp1_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: zzspksb1_ 14 5 4 7 13 7 124 */
+/*:ref: zzspkpa1_ 14 9 4 7 13 7 13 7 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzrefch1_ 14 4 4 4 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+
+extern int zzstelab_(logical *xmit, doublereal *accobs, doublereal *vobs, doublereal *starg, doublereal *scorr, doublereal *dscorr);
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: dvhat_ 14 2 7 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vlcom3_ 14 7 7 7 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+
+extern logical zztime_(char *string, char *transl, char *letter, char *error, char *pic, doublereal *tvec, integer *b, integer *e, logical *l2r, logical *yabbrv, ftnlen string_len, ftnlen transl_len, ftnlen letter_len, ftnlen error_len, ftnlen pic_len);
+extern logical zzcmbt_(char *string, char *letter, logical *l2r, ftnlen string_len, ftnlen letter_len);
+extern logical zzgrep_(char *string, ftnlen string_len);
+extern logical zzispt_(char *string, integer *b, integer *e, ftnlen string_len);
+extern logical zzist_(char *letter, ftnlen letter_len);
+extern logical zznote_(char *letter, integer *b, integer *e, ftnlen letter_len);
+extern logical zzremt_(char *letter, ftnlen letter_len);
+extern logical zzsubt_(char *string, char *transl, logical *l2r, ftnlen string_len, ftnlen transl_len);
+extern logical zztokns_(char *string, char *error, ftnlen string_len, ftnlen error_len);
+extern logical zzunpck_(char *string, logical *yabbrv, doublereal *tvec, integer *e, char *transl, char *pic, char *error, ftnlen string_len, ftnlen transl_len, ftnlen pic_len, ftnlen error_len);
+extern logical zzvalt_(char *string, integer *b, integer *e, char *letter, ftnlen string_len, ftnlen letter_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+/*:ref: posr_ 4 5 13 13 4 124 124 */
+/*:ref: zzrepsub_ 14 8 13 4 4 13 13 124 124 124 */
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: lx4uns_ 14 5 13 4 4 4 124 */
+/*:ref: zzinssub_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: samsbi_ 12 8 13 4 4 13 4 4 124 124 */
+/*:ref: samchi_ 12 6 13 4 13 4 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: zzmkpc_ 14 8 13 4 4 13 13 124 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+
+extern logical zztpats_(integer *room, integer *nknown, char *known, char *meanng, ftnlen known_len, ftnlen meanng_len);
+/*:ref: orderc_ 14 4 13 4 4 124 */
+/*:ref: reordc_ 14 4 4 4 13 124 */
+
+extern int zztwovxf_(doublereal *axdef, integer *indexa, doublereal *plndef, integer *indexp, doublereal *xform);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dvhat_ 14 2 7 7 */
+/*:ref: ducrss_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: vzero_ 12 1 7 */
+
+extern int zzutcpm_(char *string, integer *start, doublereal *hoff, doublereal *moff, integer *last, logical *succes, ftnlen string_len);
+/*:ref: lx4uns_ 14 5 13 4 4 4 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: samch_ 12 6 13 4 13 4 124 124 */
+
+extern int zzvalcor_(char *abcorr, logical *attblk, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzvstrng_(doublereal *x, char *fill, integer *from, integer *to, logical *rnd, integer *expont, char *substr, logical *did, ftnlen fill_len, ftnlen substr_len);
+extern int zzvststr_(doublereal *x, char *fill, integer *expont, ftnlen fill_len);
+extern int zzvsbstr_(integer *from, integer *to, logical *rnd, char *substr, logical *did, ftnlen substr_len);
+/*:ref: dpstr_ 14 4 7 4 13 124 */
+
+extern int zzwahr_(doublereal *et, doublereal *dvnut);
+/*:ref: pi_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: spd_ 7 0 */
+
+extern integer zzwind_(doublereal *plane, integer *n, doublereal *vertcs, doublereal *point);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: twopi_ 7 0 */
+
+extern integer zzwind2d_(integer *n, doublereal *vertcs, doublereal *point);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vsepg_ 7 3 7 7 4 */
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: twopi_ 7 0 */
+
+extern int zzwninsd_(doublereal *left, doublereal *right, char *context, doublereal *window, ftnlen context_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzxlated_(integer *inbff, char *input, integer *space, doublereal *output, ftnlen input_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: intmin_ 4 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int zzxlatei_(integer *inbff, char *input, integer *space, integer *output, ftnlen input_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: intmin_ 4 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
+
diff --git a/ext/spice/include/SpiceZim.h b/ext/spice/include/SpiceZim.h
new file mode 100644
index 0000000000..ee8d96ebc6
--- /dev/null
+++ b/ext/spice/include/SpiceZim.h
@@ -0,0 +1,1358 @@
+/*
+
+-Header_File SpiceZim.h ( CSPICE interface macros )
+
+-Abstract
+
+ Define interface macros to be called in place of CSPICE
+ user-interface-level functions. These macros are generally used
+ to compensate for compiler deficiencies.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Particulars
+
+ This header file defines interface macros to be called in place of
+ CSPICE user-interface-level functions. Currently, the sole purpose
+ of these macros is to implement automatic type casting under some
+ environments that generate compile-time warnings without the casts.
+ The typical case that causes a problem is a function argument list
+ containing an input formal argument of type
+
+ const double [3][3]
+
+ Under some compilers, a non-const actual argument supplied in a call
+ to such a function will generate a spurious warning due to the
+ "mismatched" type. These macros generate type casts that will
+ make such compilers happy.
+
+ Examples of compilers that generate warnings of this type are
+
+ gcc version 2.2.2, hosted on NeXT workstations running
+ NeXTStep 3.3
+
+ Sun C compiler, version 4.2, running under Solaris.
+
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 11.0.0, 09-MAR-2009 (NJB) (EDW)
+
+ Added macros for
+
+ dvsep_c
+ gfevnt_c
+ gffove_c
+ gfrfov_c
+ gfsntc_c
+ surfpv_c
+
+
+ -CSPICE Version 10.0.0, 19-FEB-2008 (NJB) (EDW)
+
+ Added macros for
+
+ ilumin_c
+ spkaps_c
+ spkltc_c
+
+ -CSPICE Version 9.0.0, 31-OCT-2005 (NJB)
+
+ Added macros for
+
+ qdq2av_c
+ qxq_c
+
+ -CSPICE Version 8.0.0, 23-FEB-2004 (NJB)
+
+ Added macro for
+
+ dafrs_c
+
+
+ -CSPICE Version 7.0.0, 23-FEB-2004 (EDW)
+
+ Added macro for
+
+ srfxpt_c
+
+ -CSPICE Version 6.0.1, 25-FEB-2003 (EDW) (NJB)
+
+ Remove duplicate macro definitions for ekaced_c and
+ ekacei_c. Visual Studio errored out when compiling
+ code that included SpiceZim.h.
+
+ Added macro for
+
+ dasac_c
+
+ -CSPICE Version 6.0.0, 17-AUG-2002 (NJB)
+
+ Added macros for
+
+ bschoc_c
+ bschoi_c
+ bsrchc_c
+ bsrchd_c
+ bsrchi_c
+ esrchc_c
+ isordv_c
+ isrchc_c
+ isrchd_c
+ isrchi_c
+ lstltc_c
+ lstltd_c
+ lstlti_c
+ lstlec_c
+ lstled_c
+ lstlei_c
+ orderc_c
+ orderd_c
+ orderi_c
+ reordc_c
+ reordd_c
+ reordi_c
+ reordl_c
+ spkw18_c
+
+ -CSPICE Version 5.0.0, 28-AUG-2001 (NJB)
+
+ Added macros for
+
+ conics_c
+ illum_c
+ invort_c
+ pdpool_c
+ prop2b_c
+ q2m_c
+ spkuds_c
+ xposeg_c
+
+ -CSPICE Version 4.0.0, 22-MAR-2000 (NJB)
+
+ Added macros for
+
+ spkw12_c
+ spkw13_c
+
+ -CSPICE Version 3.0.0, 27-AUG-1999 (NJB) (EDW)
+
+ Fixed cut & paste error in macro nvp2pl_c.
+
+ Added macros for
+
+ axisar_c
+ cgv2el_c
+ dafps_c
+ dafus_c
+ diags2_c
+ dvdot_c
+ dvhat_c
+ edlimb_c
+ ekacli_c
+ ekacld_c
+ ekacli_c
+ eul2xf_c
+ el2cgv_c
+ getelm_c
+ inedpl_c
+ isrot_c
+ mequ_c
+ npedln_c
+ nplnpt_c
+ rav2xf_c
+ raxisa_c
+ saelgv_c
+ spk14a_c
+ spkapo_c
+ spkapp_c
+ spkw02_c
+ spkw03_c
+ spkw05_c
+ spkw08_c
+ spkw09_c
+ spkw10_c
+ spkw15_c
+ spkw17_c
+ sumai_c
+ trace_c
+ vadd_g
+ vhatg_c
+ vlcomg_c
+ vminug_c
+ vrel_c
+ vrelg_c
+ vsepg_c
+ vtmv_c
+ vtmvg_c
+ vupack_c
+ vzerog_c
+ xf2eul_c
+ xf2rav_c
+
+ -CSPICE Version 2.0.0, 07-MAR-1999 (NJB)
+
+ Added macros for
+
+ inrypl_c
+ nvc2pl_c
+ nvp2pl_c
+ pl2nvc_c
+ pl2nvp_c
+ pl2psv_c
+ psv2pl_c
+ vprjp_c
+ vprjpi_c
+
+ -CSPICE Version 1.0.0, 24-JAN-1999 (NJB) (EDW)
+
+
+-Index_Entries
+
+ interface macros for CSPICE functions
+
+*/
+
+
+/*
+Include Files:
+*/
+
+
+#ifndef HAVE_SPICEDEFS_H
+#include "SpiceZdf.h"
+#endif
+
+#ifndef HAVE_SPICEIFMACROS_H
+#define HAVE_SPICEIFMACROS_H
+
+
+/*
+Macros used to abbreviate type casts:
+*/
+
+ #define CONST_BOOL ( ConstSpiceBoolean * )
+ #define CONST_ELLIPSE ( ConstSpiceEllipse * )
+ #define CONST_IVEC ( ConstSpiceInt * )
+ #define CONST_MAT ( ConstSpiceDouble (*) [3] )
+ #define CONST_MAT2 ( ConstSpiceDouble (*) [2] )
+ #define CONST_MAT6 ( ConstSpiceDouble (*) [6] )
+ #define CONST_PLANE ( ConstSpicePlane * )
+ #define CONST_VEC3 ( ConstSpiceDouble (*) [3] )
+ #define CONST_VEC4 ( ConstSpiceDouble (*) [4] )
+ #define CONST_STR ( ConstSpiceChar * )
+ #define CONST_VEC ( ConstSpiceDouble * )
+ #define CONST_VOID ( const void * )
+
+/*
+Macros that substitute for function calls:
+*/
+
+ #define axisar_c( axis, angle, r ) \
+ \
+ ( axisar_c( CONST_VEC(axis), (angle), (r) ) )
+
+
+ #define bschoc_c( value, ndim, lenvals, array, order ) \
+ \
+ ( bschoc_c ( CONST_STR(value), (ndim), (lenvals), \
+ CONST_VOID(array), CONST_IVEC(order) ) )
+
+
+ #define bschoi_c( value, ndim, array, order ) \
+ \
+ ( bschoi_c ( (value) , (ndim), \
+ CONST_IVEC(array), CONST_IVEC(order) ) )
+
+
+ #define bsrchc_c( value, ndim, lenvals, array ) \
+ \
+ ( bsrchc_c ( CONST_STR(value), (ndim), (lenvals), \
+ CONST_VOID(array) ) )
+
+
+ #define bsrchd_c( value, ndim, array ) \
+ \
+ ( bsrchd_c( (value), (ndim), CONST_VEC(array) ) )
+
+
+ #define bsrchi_c( value, ndim, array ) \
+ \
+ ( bsrchi_c( (value), (ndim), CONST_IVEC(array) ) )
+
+
+ #define ckw01_c( handle, begtim, endtim, inst, ref, avflag, \
+ segid, nrec, sclkdp, quats, avvs ) \
+ \
+ ( ckw01_c ( (handle), (begtim), (endtim), \
+ (inst), CONST_STR(ref), (avflag), \
+ CONST_STR(segid), (nrec), \
+ CONST_VEC(sclkdp), CONST_VEC4(quats), \
+ CONST_VEC3(avvs) ) )
+
+
+ #define ckw02_c( handle, begtim, endtim, inst, ref, segid, \
+ nrec, start, stop, quats, avvs, rates ) \
+ \
+ ( ckw02_c ( (handle), (begtim), (endtim), \
+ (inst), CONST_STR(ref), \
+ CONST_STR(segid), (nrec), \
+ CONST_VEC(start), CONST_VEC(stop), \
+ CONST_VEC4(quats), CONST_VEC3(avvs), \
+ CONST_VEC(rates) ) )
+
+
+ #define ckw03_c( handle, begtim, endtim, inst, ref, avflag, \
+ segid, nrec, sclkdp, quats, avvs, nints, \
+ starts ) \
+ \
+ ( ckw03_c ( (handle), (begtim), (endtim), \
+ (inst), CONST_STR(ref), (avflag), \
+ CONST_STR(segid), (nrec), \
+ CONST_VEC(sclkdp), CONST_VEC4(quats), \
+ CONST_VEC3(avvs), (nints), \
+ CONST_VEC(starts) ) )
+
+
+ #define ckw05_c( handle, subtyp, degree, begtim, endtim, inst, \
+ ref, avflag, segid, n, sclkdp, packts, \
+ rate, nints, starts ) \
+ \
+ ( ckw05_c ( (handle), (subtyp), (degree), \
+ (begtim), (endtim), \
+ (inst), CONST_STR(ref), (avflag), \
+ CONST_STR(segid), (n), \
+ CONST_VEC(sclkdp), CONST_VOID(packts), \
+ (rate), (nints), \
+ CONST_VEC(starts) ) )
+
+
+ #define cgv2el_c( center, vec1, vec2, ellipse ) \
+ \
+ ( cgv2el_c( CONST_VEC(center), CONST_VEC(vec1), \
+ CONST_VEC(vec2), (ellipse) ) )
+
+
+ #define conics_c( elts, et, state ) \
+ \
+ ( conics_c( CONST_VEC(elts), (et), (state) ) )
+
+
+ #define dafps_c( nd, ni, dc, ic, sum ) \
+ \
+ ( dafps_c ( (nd), (ni), CONST_VEC(dc), CONST_IVEC(ic), \
+ (sum) ) )
+
+
+ #define dafrs_c( sum ) \
+ \
+ ( dafrs_c ( CONST_VEC( sum ) ) )
+
+
+ #define dafus_c( sum, nd, ni, dc, ic ) \
+ \
+ ( dafus_c ( CONST_VEC(sum), (nd), (ni), (dc), (ic) ) )
+
+
+ #define dasac_c( handle, n, buflen, buffer ) \
+ \
+ ( dasac_c ( (handle), (n), (buflen), CONST_VOID(buffer) ) )
+
+
+ #define det_c( m1 ) \
+ \
+ ( det_c ( CONST_MAT(m1) ) )
+
+
+ #define diags2_c( symmat, diag, rotate ) \
+ \
+ ( diags2_c ( CONST_MAT2(symmat), (diag), (rotate) ) )
+
+
+
+ #define dvdot_c( s1, s2 ) \
+ \
+ ( dvdot_c ( CONST_VEC(s1), CONST_VEC(s2) ) )
+
+
+ #define dvhat_c( v1, v2 ) \
+ \
+ ( dvhat_c ( CONST_VEC(v1), (v2) ) )
+
+
+ #define dvsep_c( s1, s2 ) \
+ \
+ ( dvsep_c ( CONST_VEC(s1), CONST_VEC(s2) ) )
+
+
+ #define edlimb_c( a, b, c, viewpt, limb ) \
+ \
+ ( edlimb_c( (a), (b), (c), CONST_VEC(viewpt), (limb) ) )
+
+
+ #define ekacec_c( handle, segno, recno, column, nvals, vallen, \
+ cvals, isnull ) \
+ \
+ ( ekacec_c( (handle), (segno), (recno), CONST_STR(column), \
+ (nvals), (vallen), CONST_VOID(cvals), \
+ (isnull) ) )
+
+
+ #define ekaced_c( handle, segno, recno, column, nvals, \
+ dvals, isnull ) \
+ \
+ ( ekaced_c( (handle), (segno), (recno), CONST_STR(column), \
+ (nvals), CONST_VEC(dvals), (isnull) ) )
+
+
+ #define ekacei_c( handle, segno, recno, column, nvals, \
+ ivals, isnull ) \
+ \
+ ( ekacei_c( (handle), (segno), (recno), CONST_STR(column), \
+ (nvals), CONST_IVEC(ivals), (isnull) ) )
+
+
+ #define ekaclc_c( handle, segno, column, vallen, cvals, entszs, \
+ nlflgs, rcptrs, wkindx ) \
+ \
+ ( ekaclc_c( (handle), (segno), (column), (vallen), \
+ CONST_VOID(cvals), CONST_IVEC(entszs), \
+ CONST_BOOL(nlflgs), CONST_IVEC(rcptrs), \
+ (wkindx) ) )
+
+
+ #define ekacld_c( handle, segno, column, dvals, entszs, nlflgs, \
+ rcptrs, wkindx ) \
+ \
+ ( ekacld_c( (handle), (segno), (column), \
+ CONST_VEC(dvals), CONST_IVEC(entszs), \
+ CONST_BOOL(nlflgs), CONST_IVEC(rcptrs), \
+ (wkindx) ) )
+
+
+ #define ekacli_c( handle, segno, column, ivals, entszs, nlflgs, \
+ rcptrs, wkindx ) \
+ \
+ ( ekacli_c( (handle), (segno), (column), \
+ CONST_IVEC(ivals), CONST_IVEC(entszs), \
+ CONST_BOOL(nlflgs), CONST_IVEC(rcptrs), \
+ (wkindx) ) )
+
+
+ #define ekbseg_c( handle, tabnam, ncols, cnmlen, cnames, declen, \
+ decls, segno ) \
+ \
+ ( ekbseg_c( (handle), (tabnam), (ncols), (cnmlen), \
+ CONST_VOID(cnames), (declen), \
+ CONST_VOID(decls), (segno) ) )
+
+
+ #define ekifld_c( handle, tabnam, ncols, nrows, cnmlen, cnames, \
+ declen, decls, segno, rcptrs ) \
+ \
+ ( ekifld_c( (handle), (tabnam), (ncols), (nrows), (cnmlen), \
+ CONST_VOID(cnames), (declen), \
+ CONST_VOID(decls), (segno), (rcptrs) ) )
+
+
+ #define ekucec_c( handle, segno, recno, column, nvals, vallen, \
+ cvals, isnull ) \
+ \
+ ( ekucec_c( (handle), (segno), (recno), CONST_STR(column), \
+ (nvals), (vallen), CONST_VOID(cvals), \
+ (isnull) ) )
+
+ #define ekuced_c( handle, segno, recno, column, nvals, \
+ dvals, isnull ) \
+ \
+ ( ekuced_c( (handle), (segno), (recno), CONST_STR(column), \
+ (nvals), CONST_VOID(dvals), (isnull) ) )
+
+
+ #define ekucei_c( handle, segno, recno, column, nvals, \
+ ivals, isnull ) \
+ \
+ ( ekucei_c( (handle), (segno), (recno), CONST_STR(column), \
+ (nvals), CONST_VOID(ivals), (isnull) ) )
+
+
+ #define el2cgv_c( ellipse, center, smajor, sminor ) \
+ \
+ ( el2cgv_c( CONST_ELLIPSE(ellipse), (center), \
+ (smajor), (sminor) ) )
+
+
+ #define esrchc_c( value, ndim, lenvals, array ) \
+ \
+ ( esrchc_c ( CONST_STR(value), (ndim), (lenvals), \
+ CONST_VOID(array) ) )
+
+
+ #define eul2xf_c( eulang, axisa, axisb, axisc, xform ) \
+ \
+ ( eul2xf_c ( CONST_VEC(eulang), (axisa), (axisb), (axisc), \
+ (xform) ) )
+
+
+ #define getelm_c( frstyr, lineln, lines, epoch, elems ) \
+ \
+ ( getelm_c ( (frstyr), (lineln), CONST_VOID(lines), \
+ (epoch), (elems) ) )
+
+
+ #define gfevnt_c( udstep, udrefn, gquant, qnpars, lenvals, \
+ qpnams, qcpars, qdpars, qipars, qlpars, \
+ op, refval, tol, adjust, rpt, \
+ udrepi, udrepu, udrepf, nintvls, \
+ bail, udbail, cnfine, result ) \
+ \
+ ( gfevnt_c( (udstep), (udrefn), (gquant), \
+ (qnpars), (lenvals), CONST_VOID(qpnams),\
+ CONST_VOID(qcpars), (qdpars), (qipars), \
+ (qlpars), (op), (refval), \
+ (tol), (adjust), (rpt), \
+ (udrepi), (udrepu), (udrepf), \
+ (nintvls), (bail), \
+ (udbail), (cnfine), (result) ) )
+
+
+ #define gffove_c( inst, tshape, raydir, target, tframe, \
+ abcorr, obsrvr, tol, udstep, udrefn, \
+ rpt, udrepi, udrepu, udrepf, bail, \
+ udbail, cnfine, result ) \
+ \
+ ( gffove_c( (inst), (tshape), CONST_VEC(raydir), \
+ (target), (tframe), (abcorr), \
+ (obsrvr), (tol), (udstep), \
+ (udrefn), (rpt), (udrepi), \
+ (udrepu), (udrepf), (bail), \
+ (udbail), (cnfine), (result) ) )
+
+
+ #define gfrfov_c( inst, raydir, rframe, abcorr, obsrvr, \
+ step, cnfine, result ) \
+ \
+ ( gfrfov_c( (inst), CONST_VEC(raydir), (rframe), \
+ (abcorr), (obsrvr), (step), \
+ (cnfine), (result) ) )
+
+
+ #define gfsntc_c( target, fixref, method, abcorr, obsrvr, \
+ dref, dvec, crdsys, coord, relate, \
+ refval, adjust, step, nintvls, cnfine, \
+ result ) \
+ \
+ ( gfsntc_c( (target), (fixref), (method), \
+ (abcorr), (obsrvr), (dref), \
+ CONST_VEC(dvec), (crdsys), (coord), \
+ (relate), (refval), (adjust), \
+ (step), (nintvls), (cnfine), (result) ) )
+
+
+ #define illum_c( target, et, abcorr, obsrvr, \
+ spoint, phase, solar, emissn ) \
+ \
+ ( illum_c ( (target), (et), (abcorr), (obsrvr), \
+ CONST_VEC(spoint), (phase), (solar), (emissn) ) )
+
+
+ #define ilumin_c( method, target, et, fixref, \
+ abcorr, obsrvr, spoint, trgepc, \
+ srfvec, phase, solar, emissn ) \
+ \
+ ( ilumin_c ( (method), (target), (et), (fixref), \
+ (abcorr), (obsrvr), CONST_VEC(spoint), (trgepc), \
+ (srfvec), (phase), (solar), (emissn) ) )
+
+
+ #define inedpl_c( a, b, c, plane, ellipse, found ) \
+ \
+ ( inedpl_c ( (a), (b), (c), \
+ CONST_PLANE(plane), (ellipse), (found) ) )
+
+
+ #define inrypl_c( vertex, dir, plane, nxpts, xpt ) \
+ \
+ ( inrypl_c ( CONST_VEC(vertex), CONST_VEC(dir), \
+ CONST_PLANE(plane), (nxpts), (xpt) ) )
+
+
+ #define invert_c( m1, m2 ) \
+ \
+ ( invert_c ( CONST_MAT(m1), (m2) ) )
+
+
+ #define invort_c( m, mit ) \
+ \
+ ( invort_c ( CONST_MAT(m), (mit) ) )
+
+
+ #define isordv_c( array, n ) \
+ \
+ ( isordv_c ( CONST_IVEC(array), (n) ) )
+
+
+ #define isrchc_c( value, ndim, lenvals, array ) \
+ \
+ ( isrchc_c ( CONST_STR(value), (ndim), (lenvals), \
+ CONST_VOID(array) ) )
+
+ #define isrchd_c( value, ndim, array ) \
+ \
+ ( isrchd_c( (value), (ndim), CONST_VEC(array) ) )
+
+
+ #define isrchi_c( value, ndim, array ) \
+ \
+ ( isrchi_c( (value), (ndim), CONST_IVEC(array) ) )
+
+
+ #define isrot_c( m, ntol, dtol ) \
+ \
+ ( isrot_c ( CONST_MAT(m), (ntol), (dtol) ) )
+
+
+ #define lmpool_c( cvals, lenvals, n ) \
+ \
+ ( lmpool_c( CONST_VOID(cvals), (lenvals), (n) ) )
+
+
+ #define lstltc_c( value, ndim, lenvals, array ) \
+ \
+ ( lstltc_c ( CONST_STR(value), (ndim), (lenvals), \
+ CONST_VOID(array) ) )
+
+
+ #define lstled_c( value, ndim, array ) \
+ \
+ ( lstled_c( (value), (ndim), CONST_VEC(array) ) )
+
+
+ #define lstlei_c( value, ndim, array ) \
+ \
+ ( lstlei_c( (value), (ndim), CONST_IVEC(array) ) )
+
+
+ #define lstlec_c( value, ndim, lenvals, array ) \
+ \
+ ( lstlec_c ( CONST_STR(value), (ndim), (lenvals), \
+ CONST_VOID(array) ) )
+
+
+ #define lstltd_c( value, ndim, array ) \
+ \
+ ( lstltd_c( (value), (ndim), CONST_VEC(array) ) )
+
+
+ #define lstlti_c( value, ndim, array ) \
+ \
+ ( lstlti_c( (value), (ndim), CONST_IVEC(array) ) )
+
+
+ #define m2eul_c( r, axis3, axis2, axis1, \
+ angle3, angle2, angle1 ) \
+ \
+ ( m2eul_c ( CONST_MAT(r), (axis3), (axis2), (axis1), \
+ (angle3), (angle2), (angle1) ) )
+
+ #define m2q_c( r, q ) \
+ \
+ ( m2q_c ( CONST_MAT(r), (q) ) )
+
+
+ #define mequ_c( m1, m2 ) \
+ \
+ ( mequ_c ( CONST_MAT(m1), m2 ) )
+
+
+ #define mequg_c( m1, nr, nc, mout ) \
+ \
+ ( mequg_c ( CONST_MAT(m1), (nr), (nc), mout ) )
+
+
+ #define mtxm_c( m1, m2, mout ) \
+ \
+ ( mtxm_c ( CONST_MAT(m1), CONST_MAT(m2), (mout) ) )
+
+
+ #define mtxmg_c( m1, m2, ncol1, nr1r2, ncol2, mout ) \
+ \
+ ( mtxmg_c ( CONST_MAT(m1), CONST_MAT(m2), \
+ (ncol1), (nr1r2), (ncol2), (mout) ) )
+
+
+ #define mtxv_c( m1, vin, vout ) \
+ \
+ ( mtxv_c ( CONST_MAT(m1), CONST_VEC(vin), (vout) ) )
+
+
+ #define mtxvg_c( m1, v2, nrow1, nc1r2, vout ) \
+ \
+ ( mtxvg_c( CONST_VOID(m1), CONST_VOID(v2), \
+ (nrow1), (nc1r2), (vout) ) )
+
+ #define mxm_c( m1, m2, mout ) \
+ \
+ ( mxm_c ( CONST_MAT(m1), CONST_MAT(m2), (mout) ) )
+
+
+ #define mxmg_c( m1, m2, row1, col1, col2, mout ) \
+ \
+ ( mxmg_c ( CONST_VOID(m1), CONST_VOID(m2), \
+ (row1), (col1), (col2), (mout) ) )
+
+
+ #define mxmt_c( m1, m2, mout ) \
+ \
+ ( mxmt_c ( CONST_MAT(m1), CONST_MAT(m2), (mout) ) )
+
+
+ #define mxmtg_c( m1, m2, nrow1, nc1c2, nrow2, mout ) \
+ \
+ ( mxmtg_c ( CONST_VOID(m1), CONST_VOID(m2), \
+ (nrow1), (nc1c2), \
+ (nrow2), (mout) ) )
+
+
+ #define mxv_c( m1, vin, vout ) \
+ \
+ ( mxv_c ( CONST_MAT(m1), CONST_VEC(vin), (vout) ) )
+
+
+ #define mxvg_c( m1, v2, nrow1, nc1r2, vout ) \
+ \
+ ( mxvg_c( CONST_VOID(m1), CONST_VOID(v2), \
+ (nrow1), (nc1r2), (vout) ) )
+
+ #define nearpt_c( positn, a, b, c, npoint, alt ) \
+ \
+ ( nearpt_c ( CONST_VEC(positn), (a), (b), (c), \
+ (npoint), (alt) ) )
+
+
+ #define npedln_c( a, b, c, linept, linedr, pnear, dist ) \
+ \
+ ( npedln_c ( (a), (b), (c), \
+ CONST_VEC(linept), CONST_VEC(linedr), \
+ (pnear), (dist) ) )
+
+
+ #define nplnpt_c( linpt, lindir, point, pnear, dist ) \
+ \
+ ( nplnpt_c ( CONST_VEC(linpt), CONST_VEC(lindir), \
+ CONST_VEC(point), (pnear), (dist ) ) )
+
+
+ #define nvc2pl_c( normal, constant, plane ) \
+ \
+ ( nvc2pl_c ( CONST_VEC(normal), (constant), (plane) ) )
+
+
+ #define nvp2pl_c( normal, point, plane ) \
+ \
+ ( nvp2pl_c( CONST_VEC(normal), CONST_VEC(point), (plane) ) )
+
+
+ #define orderc_c( lenvals, array, ndim, iorder ) \
+ \
+ ( orderc_c ( (lenvals), CONST_VOID(array), (ndim), (iorder)) )
+
+
+ #define orderd_c( array, ndim, iorder ) \
+ \
+ ( orderd_c ( CONST_VEC(array), (ndim), (iorder) ) )
+
+
+ #define orderi_c( array, ndim, iorder ) \
+ \
+ ( orderi_c ( CONST_IVEC(array), (ndim), (iorder) ) )
+
+
+ #define oscelt_c( state, et, mu, elts ) \
+ \
+ ( oscelt_c ( CONST_VEC(state), (et), (mu), (elts) ) )
+
+
+ #define pcpool_c( name, n, lenvals, cvals ) \
+ \
+ ( pcpool_c ( (name), (n), (lenvals), CONST_VOID(cvals) ) )
+
+
+ #define pdpool_c( name, n, dvals ) \
+ \
+ ( pdpool_c ( (name), (n), CONST_VEC(dvals) ) )
+
+
+ #define pipool_c( name, n, ivals ) \
+ \
+ ( pipool_c ( (name), (n), CONST_IVEC(ivals) ) )
+
+
+ #define pl2nvc_c( plane, normal, constant ) \
+ \
+ ( pl2nvc_c ( CONST_PLANE(plane), (normal), (constant) ) )
+
+
+ #define pl2nvp_c( plane, normal, point ) \
+ \
+ ( pl2nvp_c ( CONST_PLANE(plane), (normal), (point) ) )
+
+
+ #define pl2psv_c( plane, point, span1, span2 ) \
+ \
+ ( pl2psv_c( CONST_PLANE(plane), (point), (span1), (span2) ) )
+
+
+ #define prop2b_c( gm, pvinit, dt, pvprop ) \
+ \
+ ( prop2b_c ( (gm), CONST_VEC(pvinit), (dt), (pvprop) ) )
+
+
+ #define psv2pl_c( point, span1, span2, plane ) \
+ \
+ ( psv2pl_c ( CONST_VEC(point), CONST_VEC(span1), \
+ CONST_VEC(span2), (plane) ) )
+
+
+ #define qdq2av_c( q, dq, av ) \
+ \
+ ( qdq2av_c ( CONST_VEC(q), CONST_VEC(dq), (av) ) )
+
+
+ #define q2m_c( q, r ) \
+ \
+ ( q2m_c ( CONST_VEC(q), (r) ) )
+
+
+ #define qxq_c( q1, q2, qout ) \
+ \
+ ( qxq_c ( CONST_VEC(q1), CONST_VEC(q2), (qout) ) )
+
+
+ #define rav2xf_c( rot, av, xform ) \
+ \
+ ( rav2xf_c ( CONST_MAT(rot), CONST_VEC(av), (xform) ) )
+
+
+ #define raxisa_c( matrix, axis, angle ) \
+ \
+ ( raxisa_c ( CONST_MAT(matrix), (axis), (angle) ) );
+
+
+ #define reccyl_c( rectan, r, lon, z ) \
+ \
+ ( reccyl_c ( CONST_VEC(rectan), (r), (lon), (z) ) )
+
+
+ #define recgeo_c( rectan, re, f, lon, lat, alt ) \
+ \
+ ( recgeo_c ( CONST_VEC(rectan), (re), (f), \
+ (lon), (lat), (alt) ) )
+
+ #define reclat_c( rectan, r, lon, lat ) \
+ \
+ ( reclat_c ( CONST_VEC(rectan), (r), (lon), (lat) ) )
+
+
+ #define recrad_c( rectan, radius, ra, dec ) \
+ \
+ ( recrad_c ( CONST_VEC(rectan), (radius), (ra), (dec) ) )
+
+
+ #define recsph_c( rectan, r, colat, lon ) \
+ \
+ ( recsph_c ( CONST_VEC(rectan), (r), (colat), (lon) ) )
+
+
+ #define reordd_c( iorder, ndim, array ) \
+ \
+ ( reordd_c ( CONST_IVEC(iorder), (ndim), (array) ) )
+
+
+ #define reordi_c( iorder, ndim, array ) \
+ \
+ ( reordi_c ( CONST_IVEC(iorder), (ndim), (array) ) )
+
+
+ #define reordl_c( iorder, ndim, array ) \
+ \
+ ( reordl_c ( CONST_IVEC(iorder), (ndim), (array) ) )
+
+
+ #define rotmat_c( m1, angle, iaxis, mout ) \
+ \
+ ( rotmat_c ( CONST_MAT(m1), (angle), (iaxis), (mout) ) )
+
+
+ #define rotvec_c( v1, angle, iaxis, vout ) \
+ \
+ ( rotvec_c ( CONST_VEC(v1), (angle), (iaxis), (vout) ) )
+
+
+ #define saelgv_c( vec1, vec2, smajor, sminor ) \
+ \
+ ( saelgv_c ( CONST_VEC(vec1), CONST_VEC(vec2), \
+ (smajor), (sminor) ) )
+
+
+ #define spk14a_c( handle, ncsets, coeffs, epochs ) \
+ \
+ ( spk14a_c ( (handle), (ncsets), \
+ CONST_VEC(coeffs), CONST_VEC(epochs) ) )
+
+
+ #define spkapo_c( targ, et, ref, sobs, abcorr, ptarg, lt ) \
+ \
+ ( spkapo_c ( (targ), (et), (ref), CONST_VEC(sobs), \
+ (abcorr), (ptarg), (lt) ) )
+
+
+ #define spkapp_c( targ, et, ref, sobs, abcorr, starg, lt ) \
+ \
+ ( spkapp_c ( (targ), (et), (ref), CONST_VEC(sobs), \
+ (abcorr), (starg), (lt) ) )
+
+
+ #define spkaps_c( targ, et, ref, abcorr, sobs, \
+ accobs, starg, lt, dlt ) \
+ \
+ ( spkaps_c ( (targ), (et), (ref), (abcorr), \
+ CONST_VEC(sobs), CONST_VEC(accobs), \
+ (starg), (lt), (dlt) ) )
+
+
+ #define spkltc_c( targ, et, ref, abcorr, sobs, starg, lt, dlt ) \
+ \
+ ( spkltc_c ( (targ), (et), (ref), (abcorr), \
+ CONST_VEC(sobs), (starg), (lt), (dlt) ) )
+
+
+ #define spkuds_c( descr, body, center, frame, type, \
+ first, last, begin, end ) \
+ \
+ ( spkuds_c ( CONST_VEC(descr), (body), (center), (frame), \
+ (type), (first), (last), (begin), (end) ) )
+
+
+ #define spkw02_c( handle, body, center, frame, first, last, \
+ segid, intlen, n, polydg, cdata, btime ) \
+ \
+ ( spkw02_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (intlen), \
+ (n), (polydg), CONST_VEC(cdata), (btime) ) )
+
+
+ #define spkw03_c( handle, body, center, frame, first, last, \
+ segid, intlen, n, polydg, cdata, btime ) \
+ \
+ ( spkw03_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (intlen), \
+ (n), (polydg), CONST_VEC(cdata), (btime) ) )
+
+
+
+ #define spkw05_c( handle, body, center, frame, first, last, \
+ segid, gm, n, states, epochs ) \
+ \
+ ( spkw05_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (gm), \
+ (n), \
+ CONST_MAT6(states), CONST_VEC(epochs) ) )
+
+
+ #define spkw08_c( handle, body, center, frame, first, last, \
+ segid, degree, n, states, epoch1, step ) \
+ \
+ ( spkw08_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (degree), \
+ (n), CONST_MAT6(states), (epoch1), \
+ (step) ) )
+
+
+ #define spkw09_c( handle, body, center, frame, first, last, \
+ segid, degree, n, states, epochs ) \
+ \
+ ( spkw09_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (degree), (n), \
+ CONST_MAT6(states), CONST_VEC(epochs) ) )
+
+
+ #define spkw10_c( handle, body, center, frame, first, last, \
+ segid, consts, n, elems, epochs ) \
+ \
+ ( spkw10_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), CONST_VEC(consts), \
+ (n), CONST_VEC(elems), CONST_VEC(epochs)) )
+
+
+ #define spkw12_c( handle, body, center, frame, first, last, \
+ segid, degree, n, states, epoch0, step ) \
+ \
+ ( spkw12_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (degree), \
+ (n), CONST_MAT6(states), (epoch0), \
+ (step) ) )
+
+
+ #define spkw13_c( handle, body, center, frame, first, last, \
+ segid, degree, n, states, epochs ) \
+ \
+ ( spkw13_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (degree), (n), \
+ CONST_MAT6(states), CONST_VEC(epochs) ) )
+
+
+
+
+
+ #define spkw15_c( handle, body, center, frame, first, last, \
+ segid, epoch, tp, pa, p, ecc, \
+ j2flg, pv, gm, j2, radius ) \
+ \
+ ( spkw15_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (epoch), \
+ CONST_VEC(tp), CONST_VEC(pa), \
+ (p), (ecc), (j2flg), CONST_VEC(pv), \
+ (gm), (j2), (radius) ) )
+
+
+ #define spkw17_c( handle, body, center, frame, first, last, \
+ segid, epoch, eqel, rapol, decpol ) \
+ \
+ ( spkw17_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (epoch), \
+ CONST_VEC(eqel), (rapol), (decpol) ) )
+
+
+
+ #define spkw18_c( handle, subtyp, body, center, frame, first, \
+ last, segid, degree, n, packts, epochs ) \
+ \
+ ( spkw18_c ( (handle), (subtyp), (body), (center), (frame), \
+ (first), (last), (segid), (degree), (n), \
+ CONST_VOID(packts), CONST_VEC(epochs) ) )
+
+
+ #define srfxpt_c( method, target, et, abcorr, obsrvr, dref, \
+ dvec, spoint, dist, trgepc, obspos, found ) \
+ \
+ ( srfxpt_c ( (method), (target), (et), (abcorr), (obsrvr), \
+ (dref), CONST_VEC(dvec), (spoint), (dist), \
+ (trgepc), (obspos), (found) ) )
+
+
+ #define stelab_c( pobj, vobj, appobj ) \
+ \
+ ( stelab_c ( CONST_VEC(pobj), CONST_VEC(vobj), (appobj) ) )
+
+
+ #define sumad_c( array, n ) \
+ \
+ ( sumad_c ( CONST_VEC(array), (n) ) )
+
+
+ #define sumai_c( array, n ) \
+ \
+ ( sumai_c ( CONST_IVEC(array), (n) ) )
+
+
+ #define surfnm_c( a, b, c, point, normal ) \
+ \
+ ( surfnm_c ( (a), (b), (c), CONST_VEC(point), (normal) ) )
+
+
+ #define surfpt_c( positn, u, a, b, c, point, found ) \
+ \
+ ( surfpt_c ( CONST_VEC(positn), CONST_VEC(u), \
+ (a), (b), (c), \
+ (point), (found) ) )
+
+
+ #define surfpv_c( stvrtx, stdir, a, b, c, stx, found ) \
+ \
+ ( surfpv_c ( CONST_VEC(stvrtx), CONST_VEC(stdir), \
+ (a), (b), (c), \
+ (stx), (found) ) )
+
+
+ #define swpool_c( agent, nnames, lenvals, names ) \
+ \
+ ( swpool_c( CONST_STR(agent), (nnames), \
+ (lenvals), CONST_VOID(names) ) )
+
+
+ #define trace_c( m1 ) \
+ \
+ ( trace_c ( CONST_MAT(m1) ) )
+
+
+ #define twovec_c( axdef, indexa, plndef, indexp, mout ) \
+ \
+ ( twovec_c ( CONST_VEC(axdef), (indexa), \
+ CONST_VEC(plndef), (indexp), (mout) ) )
+
+
+ #define ucrss_c( v1, v2, vout ) \
+ \
+ ( ucrss_c ( CONST_VEC(v1), CONST_VEC(v2), (vout) ) )
+
+
+ #define unorm_c( v1, vout, vmag ) \
+ \
+ ( unorm_c ( CONST_VEC(v1), (vout), (vmag) ) )
+
+
+ #define unormg_c( v1, ndim, vout, vmag ) \
+ \
+ ( unormg_c ( CONST_VEC(v1), (ndim), (vout), (vmag) ) )
+
+
+ #define vadd_c( v1, v2, vout ) \
+ \
+ ( vadd_c ( CONST_VEC(v1), CONST_VEC(v2), (vout) ) )
+
+
+ #define vaddg_c( v1, v2, ndim,vout ) \
+ \
+ ( vaddg_c ( CONST_VEC(v1), CONST_VEC(v2), (ndim), (vout) ) )
+
+
+ #define vcrss_c( v1, v2, vout ) \
+ \
+ ( vcrss_c ( CONST_VEC(v1), CONST_VEC(v2), (vout) ) )
+
+
+ #define vdist_c( v1, v2 ) \
+ \
+ ( vdist_c ( CONST_VEC(v1), CONST_VEC(v2) ) )
+
+
+ #define vdistg_c( v1, v2, ndim ) \
+ \
+ ( vdistg_c ( CONST_VEC(v1), CONST_VEC(v2), (ndim) ) )
+
+
+ #define vdot_c( v1, v2 ) \
+ \
+ ( vdot_c ( CONST_VEC(v1), CONST_VEC(v2) ) )
+
+
+ #define vdotg_c( v1, v2, ndim ) \
+ \
+ ( vdotg_c ( CONST_VEC(v1), CONST_VEC(v2), (ndim) ) )
+
+
+ #define vequ_c( vin, vout ) \
+ \
+ ( vequ_c ( CONST_VEC(vin), (vout) ) )
+
+
+ #define vequg_c( vin, ndim, vout ) \
+ \
+ ( vequg_c ( CONST_VEC(vin), (ndim), (vout) ) )
+
+
+ #define vhat_c( v1, vout ) \
+ \
+ ( vhat_c ( CONST_VEC(v1), (vout) ) )
+
+
+ #define vhatg_c( v1, ndim, vout ) \
+ \
+ ( vhatg_c ( CONST_VEC(v1), (ndim), (vout) ) )
+
+
+ #define vlcom3_c( a, v1, b, v2, c, v3, sum ) \
+ \
+ ( vlcom3_c ( (a), CONST_VEC(v1), \
+ (b), CONST_VEC(v2), \
+ (c), CONST_VEC(v3), (sum) ) )
+
+
+ #define vlcom_c( a, v1, b, v2, sum ) \
+ \
+ ( vlcom_c ( (a), CONST_VEC(v1), \
+ (b), CONST_VEC(v2), (sum) ) )
+
+
+ #define vlcomg_c( n, a, v1, b, v2, sum ) \
+ \
+ ( vlcomg_c ( (n), (a), CONST_VEC(v1), \
+ (b), CONST_VEC(v2), (sum) ) )
+
+
+ #define vminug_c( v1, ndim, vout ) \
+ \
+ ( vminug_c ( CONST_VEC(v1), (ndim), (vout) ) )
+
+
+ #define vminus_c( v1, vout ) \
+ \
+ ( vminus_c ( CONST_VEC(v1), (vout) ) )
+
+
+ #define vnorm_c( v1 ) \
+ \
+ ( vnorm_c ( CONST_VEC(v1) ) )
+
+
+ #define vnormg_c( v1, ndim ) \
+ \
+ ( vnormg_c ( CONST_VEC(v1), (ndim) ) )
+
+
+ #define vperp_c( a, b, p ) \
+ \
+ ( vperp_c ( CONST_VEC(a), CONST_VEC(b), (p) ) )
+
+
+ #define vprjp_c( vin, plane, vout ) \
+ \
+ ( vprjp_c ( CONST_VEC(vin), CONST_PLANE(plane), (vout) ) )
+
+
+ #define vprjpi_c( vin, projpl, invpl, vout, found ) \
+ \
+ ( vprjpi_c( CONST_VEC(vin), CONST_PLANE(projpl), \
+ CONST_PLANE(invpl), (vout), (found) ) )
+
+
+ #define vproj_c( a, b, p ) \
+ \
+ ( vproj_c ( CONST_VEC(a), CONST_VEC(b), (p) ) )
+
+
+ #define vrel_c( v1, v2 ) \
+ \
+ ( vrel_c ( CONST_VEC(v1), CONST_VEC(v2) ) )
+
+
+ #define vrelg_c( v1, v2, ndim ) \
+ \
+ ( vrelg_c ( CONST_VEC(v1), CONST_VEC(v2), (ndim) ) )
+
+
+ #define vrotv_c( v, axis, theta, r ) \
+ \
+ ( vrotv_c ( CONST_VEC(v), CONST_VEC(axis), (theta), (r) ) )
+
+
+ #define vscl_c( s, v1, vout ) \
+ \
+ ( vscl_c ( (s), CONST_VEC(v1), (vout) ) )
+
+
+ #define vsclg_c( s, v1, ndim, vout ) \
+ \
+ ( vsclg_c ( (s), CONST_VEC(v1), (ndim), (vout) ) )
+
+
+ #define vsep_c( v1, v2 ) \
+ \
+ ( vsep_c ( CONST_VEC(v1), CONST_VEC(v2) ) )
+
+
+ #define vsepg_c( v1, v2, ndim) \
+ \
+ ( vsepg_c ( CONST_VEC(v1), CONST_VEC(v2), ndim ) )
+
+
+ #define vsub_c( v1, v2, vout ) \
+ \
+ ( vsub_c ( CONST_VEC(v1), CONST_VEC(v2), (vout) ) )
+
+
+ #define vsubg_c( v1, v2, ndim, vout ) \
+ \
+ ( vsubg_c ( CONST_VEC(v1), CONST_VEC(v2), \
+ (ndim), (vout) ) )
+
+ #define vtmv_c( v1, mat, v2 ) \
+ \
+ ( vtmv_c ( CONST_VEC(v1), CONST_MAT(mat), CONST_VEC(v2) ) )
+
+
+ #define vtmvg_c( v1, mat, v2, nrow, ncol ) \
+ \
+ ( vtmvg_c ( CONST_VOID(v1), CONST_VOID(mat), CONST_VOID(v2), \
+ (nrow), (ncol) ) )
+
+
+ #define vupack_c( v, x, y, z ) \
+ \
+ ( vupack_c ( CONST_VEC(v), (x), (y), (z) ) )
+
+
+ #define vzero_c( v1 ) \
+ \
+ ( vzero_c ( CONST_VEC(v1) ) )
+
+
+ #define vzerog_c( v1, ndim ) \
+ \
+ ( vzerog_c ( CONST_VEC(v1), (ndim) ) )
+
+
+ #define xf2eul_c( xform, axisa, axisb, axisc, eulang, unique ) \
+ \
+ ( xf2eul_c( CONST_MAT6(xform), (axisa), (axisb), (axisc), \
+ (eulang), (unique) ) )
+
+
+ #define xf2rav_c( xform, rot, av ) \
+ \
+ ( xf2rav_c( CONST_MAT6(xform), (rot), (av) ) )
+
+
+ #define xpose6_c( m1, mout ) \
+ \
+ ( xpose6_c ( CONST_MAT6(m1), (mout) ) )
+
+
+ #define xpose_c( m1, mout ) \
+ \
+ ( xpose_c ( CONST_MAT(m1), (mout) ) )
+
+
+ #define xposeg_c( matrix, nrow, ncol, mout ) \
+ \
+ ( xposeg_c ( CONST_VOID(matrix), (nrow), (ncol), (mout) ) )
+
+
+#endif
diff --git a/ext/spice/include/SpiceZmc.h b/ext/spice/include/SpiceZmc.h
new file mode 100644
index 0000000000..df694a602e
--- /dev/null
+++ b/ext/spice/include/SpiceZmc.h
@@ -0,0 +1,975 @@
+/*
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+*/
+
+/*
+ CSPICE private macro file.
+
+-Particulars
+
+ Current list of macros (spelling counts)
+
+ BLANK
+ C2F_MAP_CELL
+ C2F_MAP_CELL2
+ C2F_MAP_CELL3
+ CELLINIT
+ CELLINIT2
+ CELLINIT3
+ CELLISSETCHK
+ CELLISSETCHK2
+ CELLISSETCHK2_VAL
+ CELLISSETCHK3
+ CELLISSETCHK3_VAL
+ CELLISSETCHK_VAL
+ CELLMATCH2
+ CELLMATCH2_VAL
+ CELLMATCH3
+ CELLMATCH3_VAL
+ CELLTYPECHK
+ CELLTYPECHK2
+ CELLTYPECHK2_VAL
+ CELLTYPECHK3
+ CELLTYPECHK3_VAL
+ CELLTYPECHK_VAL
+ CHKFSTR
+ CHKFSTR_VAL
+ CHKOSTR
+ CHKOSTR_VAL
+ CHKPTR
+ Constants
+ Even
+ F2C_MAP_CELL
+ Index values
+ MOVED
+ MOVEI
+ MaxAbs
+ MaxVal
+ MinAbs
+ MinVal
+ Odd
+ SpiceError
+ TolOrFail
+
+-Restrictions
+
+ This is a private macro file for use within CSPICE.
+ Do not use or alter any entry. Or else!
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 4.2.0, 16-FEB-2005 (NJB)
+
+ Bug fix: in the macro C2F_MAP_CELL, error checking has been
+ added after the sequence of calls to ssizec_ and scardc_.
+ If either of these routines signals an error, the dynamically
+ allocated memory for the "Fortran cell" is freed.
+
+ -CSPICE Version 4.1.0, 06-DEC-2002 (NJB)
+
+ Bug fix: added previous missing, bracketing parentheses to
+ references to input cell pointer argument in macro
+ CELLINIT.
+
+ Changed CELLINIT macro so it no longer initializes to zero
+ length all strings in data array of a character cell. Instead,
+ strings are terminated with a null in their final element.
+
+ -CSPICE Version 4.0.0, 22-AUG-2002 (NJB)
+
+ Added macro definitions to support CSPICE cells and sets:
+
+ C2F_MAP_CELL
+ C2F_MAP_CELL2
+ C2F_MAP_CELL3
+ CELLINIT
+ CELLINIT2
+ CELLINIT3
+ CELLISSETCHK
+ CELLISSETCHK2
+ CELLISSETCHK2_VAL
+ CELLISSETCHK3
+ CELLISSETCHK3_VAL
+ CELLISSETCHK_VAL
+ CELLMATCH2
+ CELLMATCH2_VAL
+ CELLMATCH3
+ CELLMATCH3_VAL
+ CELLTYPECHK
+ CELLTYPECHK2
+ CELLTYPECHK2_VAL
+ CELLTYPECHK3
+ CELLTYPECHK3_VAL
+ CELLTYPECHK_VAL
+ F2C_MAP_CELL
+
+ -CSPICE Version 3.0.0, 09-JAN-1998 (NJB)
+
+ Added output string check macros CHKOSTR and CHKOSTR_VAL.
+ Removed variable name arguments from macros
+
+ CHKPTR
+ CHKPTR_VAL
+ CHKFSTR
+ CHKRSTR_VAL
+
+ The strings containing names of the checked variables are now
+ generated from the variables themselves via the # operator.
+
+ -CSPICE Version 2.0.0, 03-DEC-1997 (NJB)
+
+ Added pointer check macro CHKPTR and Fortran string check macro
+ CHKFSTR.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (EDW)
+*/
+
+
+
+#include
+#include
+#include "SpiceZdf.h"
+
+
+#define MOVED( arrfrm, ndim, arrto ) \
+ \
+ ( memmove ( (void*) (arrto) , \
+ (void*) (arrfrm), \
+ sizeof (SpiceDouble) * (ndim) ) )
+
+
+
+
+
+#define MOVEI( arrfrm, ndim, arrto ) \
+ \
+ ( memmove ( (void*) (arrto) , \
+ (void*) (arrfrm), \
+ sizeof (SpiceInt) * (ndim) ) )
+
+
+
+
+
+/*
+Define a tolerance test for those pesky double precision reals.
+True if the difference is less than the tolerance, false otherwise.
+The tolerance refers to a percentage. x, y and tol should be declared
+double. All values are assumed to be non-zero. Okay?
+*/
+
+#define TolOrFail( x, y, tol ) \
+ \
+ ( fabs( x-y ) < ( tol * fabs(x) ) )
+
+
+
+
+
+/*
+Simple error output through standard SPICE error system . Set the error
+message and the type
+*/
+
+#define SpiceError( errmsg, errtype ) \
+ \
+ { \
+ setmsg_c ( errmsg ); \
+ sigerr_c ( errtype ); \
+ }
+
+
+
+
+
+
+/*
+Return a value which is the maximum/minimum of the absolute values of
+two values.
+*/
+
+#define MaxAbs(a,b) ( fabs(a) >= fabs(b) ? fabs(a) : fabs(b) )
+#define MinAbs(a,b) ( fabs(a) < fabs(b) ? fabs(a) : fabs(b) )
+
+
+
+
+
+/*
+Return a value which is the maximum/minimum value of two values.
+*/
+
+#define MaxVal(A,B) ( (A) >= (B) ? (A) : (B) )
+#define MinVal(A,B) ( (A) < (B) ? (A) : (B) )
+
+
+
+
+
+/*
+Determine whether a value is even or odd
+*/
+#define Even( x ) ( ( (x) & 1 ) == 0 )
+#define Odd ( x ) ( ( (x) & 1 ) != 0 )
+
+
+
+
+
+/*
+Array indexes for vectors.
+*/
+
+#define SpiceX 0
+#define SpiceY 1
+#define SpiceZ 2
+#define SpiceVx 3
+#define SpiceVy 4
+#define SpiceVz 5
+
+
+
+
+/*
+Physical constants and dates.
+*/
+
+#define B1900 2415020.31352
+#define J1900 2415020.0
+#define JYEAR 31557600.0
+#define TYEAR 31556925.9747
+#define J1950 2433282.5
+#define SPD 86400.0
+#define B1950 2433282.42345905
+#define J2100 2488070.0
+#define CLIGHT 299792.458
+#define J2000 2451545.0
+
+
+
+
+
+/*
+Common literal values.
+*/
+
+#define NULLCHAR ( (SpiceChar ) 0 )
+#define NULLCPTR ( (SpiceChar * ) 0 )
+#define BLANK ( (SpiceChar ) ' ' )
+
+
+
+/*
+Macro CHKPTR is used for checking for a null pointer. CHKPTR uses
+the constants
+
+ CHK_STANDARD
+ CHK_DISCOVER
+ CHK_REMAIN
+
+to control tracing behavior. Values and meanings are:
+
+ CHK_STANDARD Standard tracing. If an error
+ is found, signal it, check out
+ and return.
+
+ CHK_DISCOVER Discovery check-in. If an
+ error is found, check in, signal
+ the error, check out, and return.
+
+ CHK_REMAIN If an error is found, signal it.
+ Do not check out or return. This
+ would allow the caller to clean up
+ before returning, if necessary.
+ In such cases the caller must test
+ failed_c() after the macro call.
+
+CHKPTR should be used in void functions. In non-void functions,
+use CHKPTR_VAL, which is defined below.
+
+*/
+
+#define CHK_STANDARD 1
+#define CHK_DISCOVER 2
+#define CHK_REMAIN 3
+
+#define CHKPTR( errHandling, modname, pointer ) \
+ \
+ if ( (void *)(pointer) == (void *)0 ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Pointer \"#\" is null; a non-null " \
+ "pointer is required." ); \
+ errch_c ( "#", (#pointer) ); \
+ sigerr_c ( "SPICE(NULLPOINTER)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return; \
+ } \
+ }
+
+
+#define CHKPTR_VAL( errHandling, modname, pointer, retval ) \
+ \
+ if ( (void *)(pointer) == (void *)0 ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Pointer \"#\" is null; a non-null " \
+ "pointer is required." ); \
+ errch_c ( "#", (#pointer) ); \
+ sigerr_c ( "SPICE(NULLPOINTER)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return ( retval ); \
+ } \
+ }
+
+
+/*
+Macro CHKFSTR checks strings that are to be passed to Fortran or
+f2c'd Fortran routines. Such strings must have non-zero length,
+and their pointers must be non-null.
+
+CHKFSTR should be used in void functions. In non-void functions,
+use CHKFSTR_VAL, which is defined below.
+*/
+
+#define CHKFSTR( errHandling, modname, string ) \
+ \
+ CHKPTR ( errHandling, modname, string ); \
+ \
+ if ( ( (void *)string != (void *)0 ) \
+ && ( strlen(string) == 0 ) ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "String \"#\" has length zero." ); \
+ errch_c ( "#", (#string) ); \
+ sigerr_c ( "SPICE(EMPTYSTRING)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return; \
+ } \
+ }
+
+#define CHKFSTR_VAL( errHandling, modname, string, retval ) \
+ \
+ CHKPTR_VAL( errHandling, modname, string, retval); \
+ \
+ if ( ( (void *)string != (void *)0 ) \
+ && ( strlen(string) == 0 ) ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "String \"#\" has length zero." ); \
+ errch_c ( "#", (#string) ); \
+ sigerr_c ( "SPICE(EMPTYSTRING)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return ( retval ); \
+ } \
+ }
+
+
+/*
+Macro CHKOSTR checks output string pointers and the associated
+string length values supplied as input arguments. Output string
+pointers must be non-null, and the string lengths must be at
+least 2, so Fortran routine can write at least one character to
+the output string, and so a null terminator can be appended.
+CHKOSTR should be used in void functions. In non-void functions,
+use CHKOSTR_VAL, which is defined below.
+*/
+
+#define CHKOSTR( errHandling, modname, string, length ) \
+ \
+ CHKPTR ( errHandling, modname, string ); \
+ \
+ if ( ( (void *)string != (void *)0 ) \
+ && ( length < 2 ) ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "String \"#\" has length #; must be >= 2." ); \
+ errch_c ( "#", (#string) ); \
+ errint_c ( "#", (length) ); \
+ sigerr_c ( "SPICE(STRINGTOOSHORT)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return; \
+ } \
+ }
+
+
+#define CHKOSTR_VAL( errHandling, modname, string, length, retval ) \
+ \
+ CHKPTR_VAL( errHandling, modname, string, retval ); \
+ \
+ if ( ( (void *)string != (void *)0 ) \
+ && ( length < 2 ) ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "String \"#\" has length #; must be >= 2." ); \
+ errch_c ( "#", (#string) ); \
+ errint_c ( "#", (length) ); \
+ sigerr_c ( "SPICE(STRINGTOOSHORT)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return ( retval ); \
+ } \
+ }
+
+
+ /*
+ Definitions for Cells and Sets
+ */
+
+
+ /*
+ Cell initialization macros
+ */
+ #define CELLINIT( cellPtr ) \
+ \
+ if ( !( (cellPtr)->init ) ) \
+ { \
+ if ( (cellPtr)->dtype == SPICE_CHR ) \
+ { \
+ /* \
+ Make sure all elements of the data array, including \
+ the control area, start off null-terminated. We place \
+ the null character in the final element of each string, \
+ so as to avoid wiping out data that may have been \
+ assigned to the data array prior to initialization. \
+ */ \
+ SpiceChar * sPtr; \
+ SpiceInt i; \
+ SpiceInt nmax; \
+ \
+ nmax = SPICE_CELL_CTRLSZ + (cellPtr)->size; \
+ \
+ for ( i = 1; i <= nmax; i++ ) \
+ { \
+ sPtr = (SpiceChar *)((cellPtr)->base) \
+ + i * (cellPtr)->length \
+ - 1; \
+ \
+ *sPtr = NULLCHAR; \
+ } \
+ } \
+ else \
+ { \
+ zzsynccl_c ( C2F, (cellPtr) ); \
+ } \
+ \
+ (cellPtr)->init = SPICETRUE; \
+ }
+
+
+ #define CELLINIT2( cellPtr1, cellPtr2 ) \
+ \
+ CELLINIT ( cellPtr1 ); \
+ CELLINIT ( cellPtr2 );
+
+
+ #define CELLINIT3( cellPtr1, cellPtr2, cellPtr3 ) \
+ \
+ CELLINIT ( cellPtr1 ); \
+ CELLINIT ( cellPtr2 ); \
+ CELLINIT ( cellPtr3 );
+
+
+ /*
+ Data type checking macros:
+ */
+ #define CELLTYPECHK( errHandling, modname, dType, cellPtr1 ) \
+ \
+ if ( (cellPtr1)->dtype != (dType) ) \
+ { \
+ SpiceChar * typstr[3] = \
+ { \
+ "character", "double precision", "integer" \
+ }; \
+ \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Data type of # is #; expected type " \
+ "is #." ); \
+ errch_c ( "#", (#cellPtr1) ); \
+ errch_c ( "#", typstr[ (cellPtr1)->dtype ] ); \
+ errch_c ( "#", typstr[ dType ] ); \
+ sigerr_c ( "SPICE(TYPEMISMATCH)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return; \
+ } \
+ }
+
+
+ #define CELLTYPECHK_VAL( errHandling, modname, \
+ dType, cellPtr1, retval ) \
+ \
+ if ( (cellPtr1)->dtype != (dType) ) \
+ { \
+ SpiceChar * typstr[3] = \
+ { \
+ "character", "double precision", "integer" \
+ }; \
+ \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Data type of # is #; expected type " \
+ "is #." ); \
+ errch_c ( "#", (#cellPtr1) ); \
+ errch_c ( "#", typstr[ (cellPtr1)->dtype ] ); \
+ errch_c ( "#", typstr[ dType ] ); \
+ sigerr_c ( "SPICE(TYPEMISMATCH)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return (retval); \
+ } \
+ }
+
+
+ #define CELLTYPECHK2( errHandling, modname, dtype, \
+ cellPtr1, cellPtr2 ) \
+ \
+ CELLTYPECHK( errHandling, modname, dtype, cellPtr1 ); \
+ CELLTYPECHK( errHandling, modname, dtype, cellPtr2 );
+
+
+
+ #define CELLTYPECHK2_VAL( errHandling, modname, dtype, \
+ cellPtr1, cellPtr2, retval ) \
+ \
+ CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr1, \
+ retval ); \
+ CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr2, \
+ retval );
+
+
+
+ #define CELLTYPECHK3( errHandling, modname, dtype, \
+ cellPtr1, cellPtr2, cellPtr3 ) \
+ \
+ CELLTYPECHK( errHandling, modname, dtype, cellPtr1 ); \
+ CELLTYPECHK( errHandling, modname, dtype, cellPtr2 ); \
+ CELLTYPECHK( errHandling, modname, dtype, cellPtr3 );
+
+
+ #define CELLTYPECHK3_VAL( errHandling, modname, dtype, \
+ cellPtr1, cellPtr2, cellPtr3, \
+ retval ) \
+ \
+ CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr1, \
+ retval ); \
+ CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr2, \
+ retval ); \
+ CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr3 \
+ retval );
+
+
+
+ #define CELLMATCH2( errHandling, modname, cellPtr1, cellPtr2 ) \
+ \
+ if ( (cellPtr1)->dtype != (cellPtr2)->dtype ) \
+ { \
+ SpiceChar * typstr[3] = \
+ { \
+ "character", "double precision", "integer" \
+ }; \
+ \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Data type of # is #; data type of # " \
+ "is #, but types must match." ); \
+ errch_c ( "#", (#cellPtr1) ); \
+ errch_c ( "#", typstr[ (cellPtr1)->dtype ] ); \
+ errch_c ( "#", (#cellPtr2) ); \
+ errch_c ( "#", typstr[ (cellPtr2)->dtype ] ); \
+ sigerr_c ( "SPICE(TYPEMISMATCH)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return; \
+ } \
+ }
+
+ #define CELLMATCH2_VAL( errHandling, modname, \
+ cellPtr1, cellPtr2, retval ) \
+ \
+ if ( (cellPtr1)->dtype != (cellPtr2)->dtype ) \
+ { \
+ SpiceChar * typstr[3] = \
+ { \
+ "character", "double precision", "integer" \
+ }; \
+ \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Data type of # is #; data type of # " \
+ "is #, but types must match." ); \
+ errch_c ( "#", (#cellPtr1) ); \
+ errch_c ( "#", typstr [ (cellPtr1)->dtype ] ); \
+ errch_c ( "#", (#cellPtr2) ); \
+ errch_c ( "#", typstr [ (cellPtr2)->dtype ] ); \
+ sigerr_c ( "SPICE(TYPEMISMATCH)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return ( retval ); \
+ } \
+ }
+
+
+ #define CELLMATCH3( errHandling, modname, \
+ cellPtr1, cellPtr2, cellPtr3 ) \
+ \
+ CELLMATCH2 ( errHandling, modname, cellPtr1, cellPtr2 ); \
+ CELLMATCH2 ( errHandling, modname, cellPtr2, cellPtr3 );
+
+
+
+
+ #define CELLMATCH3_VAL( errHandling, modname, cellPtr1, \
+ cellPtr2, cellPtr3, retval ) \
+ \
+ CELLMATCH2_VAL ( errHandling, modname, \
+ cellPtr1, cellPtr2, retval ); \
+ \
+ CELLMATCH2_VAL ( errHandling, modname, \
+ cellPtr2, cellPtr3, retval );
+
+ /*
+ Set checking macros:
+ */
+ #define CELLISSETCHK( errHandling, modname, cellPtr1 ) \
+ \
+ if ( !(cellPtr1)->isSet ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Cell # must be sorted and have unique " \
+ "values in order to be a CSPICE set. " \
+ "The isSet flag in this cell is SPICEFALSE, " \
+ "indicating the cell may have been modified " \
+ "by a routine that doesn't preserve these " \
+ "properties." ); \
+ errch_c ( "#", (#cellPtr1) ); \
+ sigerr_c ( "SPICE(NOTASET)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return; \
+ } \
+ }
+
+
+ #define CELLISSETCHK_VAL( errHandling, modname, \
+ cellPtr1, retval ) \
+ \
+ if ( !(cellPtr1)->isSet ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Cell # must be sorted and have unique " \
+ "values in order to be a CSPICE set. " \
+ "The isSet flag in this cell is SPICEFALSE, " \
+ "indicating the cell may have been modified " \
+ "by a routine that doesn't preserve these " \
+ "properties." ); \
+ errch_c ( "#", (#cellPtr1) ); \
+ sigerr_c ( "SPICE(NOTASET)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return (retval); \
+ } \
+ }
+
+
+ #define CELLISSETCHK2( errHandling, modname, \
+ cellPtr1, cellPtr2 ) \
+ \
+ CELLISSETCHK( errHandling, modname, cellPtr1 ); \
+ CELLISSETCHK( errHandling, modname, cellPtr2 );
+
+
+
+ #define CELLISSETCHK2_VAL( errHandling, modname, \
+ cellPtr1, cellPtr2, retval ) \
+ \
+ CELLISSETCHK_VAL( errHandling, modname, cellPtr1, retval ); \
+ CELLISSETCHK_VAL( errHandling, modname, cellPtr2, retval ); \
+
+
+
+ #define CELLISSETCHK3( errHandling, modname, \
+ cellPtr1, cellPtr2, cellPtr3 ) \
+ \
+ CELLISSETCHK ( errHandling, modname, cellPtr1 ); \
+ CELLISSETCHK ( errHandling, modname, cellPtr2 ); \
+ CELLISSETCHK ( errHandling, modname, cellPtr3 );
+
+
+ #define CELLISSETCHK3_VAL( errHandling, modname, cellPtr1, \
+ cellPtr2, cellPtr3, retval ) \
+ \
+ CELLISSETCHK_VAL ( errHandling, modname, cellPtr1, retval ); \
+ CELLISSETCHK_VAL ( errHandling, modname, cellPtr2, retval ); \
+ CELLISSETCHK_VAL ( errHandling, modname, cellPtr3, retval );
+
+
+ /*
+ C-to-Fortran and Fortran-to-C character cell translation macros:
+ */
+
+ /*
+ Macros that map one or more character C cells to dynamically
+ allocated Fortran-style character cells:
+ */
+ #define C2F_MAP_CELL( caller, CCell, fCell, fLen ) \
+ \
+ { \
+ /* \
+ fCell and fLen are to be passed by reference, as if this \
+ macro were a function. \
+ \
+ \
+ Caution: dynamically allocates array fCell, which is to be \
+ freed by caller! \
+ */ \
+ SpiceInt ndim; \
+ SpiceInt lenvals; \
+ \
+ \
+ ndim = (CCell)->size + SPICE_CELL_CTRLSZ; \
+ lenvals = (CCell)->length; \
+ \
+ C2F_MapFixStrArr ( (caller), ndim, lenvals, \
+ (CCell)->base, (fLen), (fCell) ); \
+ \
+ if ( !failed_c() ) \
+ { \
+ /* \
+ Explicitly set the control area info in the Fortran cell.\
+ */ \
+ ssizec_ ( ( integer * ) &((CCell)->size), \
+ ( char * ) *(fCell), \
+ ( ftnlen ) *(fLen) ); \
+ \
+ scardc_ ( ( integer * ) &((CCell)->card), \
+ ( char * ) *(fCell), \
+ ( ftnlen ) *(fLen) ); \
+ \
+ if ( failed_c() ) \
+ { \
+ /* \
+ Setting size or cardinality of the Fortran cell \
+ can fail, for example if the cell's string length \
+ is too short. \
+ */ \
+ free ( *(fCell) ); \
+ } \
+ } \
+ }
+
+
+ #define C2F_MAP_CELL2( caller, CCell1, fCell1, fLen1, \
+ CCell2, fCell2, fLen2 ) \
+ \
+ { \
+ C2F_MAP_CELL( caller, CCell1, fCell1, fLen1 ); \
+ \
+ if ( !failed_c() ) \
+ { \
+ C2F_MAP_CELL( caller, CCell2, fCell2, fLen2 ); \
+ \
+ if ( failed_c() ) \
+ { \
+ free ( *(fCell1) ); \
+ } \
+ } \
+ }
+
+
+ #define C2F_MAP_CELL3( caller, CCell1, fCell1, fLen1, \
+ CCell2, fCell2, fLen2, \
+ CCell3, fCell3, fLen3 ) \
+ \
+ { \
+ C2F_MAP_CELL2( caller, CCell1, fCell1, fLen1, \
+ CCell2, fCell2, fLen2 ); \
+ \
+ if ( !failed_c() ) \
+ { \
+ C2F_MAP_CELL( caller, CCell3, fCell3, fLen3 ); \
+ \
+ if ( failed_c() ) \
+ { \
+ free ( *(fCell1) ); \
+ free ( *(fCell2) ); \
+ } \
+ } \
+ }
+
+
+
+ /*
+ Macro that maps a Fortran-style character cell to a C cell
+ (Note: this macro frees the Fortran cell):
+ */
+
+ #define F2C_MAP_CELL( fCell, fLen, CCell ) \
+ \
+ { \
+ SpiceInt card; \
+ SpiceInt lenvals; \
+ SpiceInt ndim; \
+ SpiceInt nBytes; \
+ SpiceInt size; \
+ void * array; \
+ \
+ ndim = (CCell)->size + SPICE_CELL_CTRLSZ; \
+ lenvals = (CCell)->length; \
+ array = (CCell)->base; \
+ \
+ /* \
+ Capture the size and cardinality of the Fortran cell. \
+ */ \
+ if ( !failed_c() ) \
+ { \
+ size = sizec_ ( ( char * ) (fCell), \
+ ( ftnlen ) fLen ); \
+ \
+ card = cardc_ ( ( char * ) (fCell), \
+ ( ftnlen ) fLen ); \
+ } \
+ \
+ \
+ /* \
+ Copy the Fortran array into the output array. \
+ */ \
+ \
+ nBytes = ndim * fLen * sizeof(SpiceChar); \
+ memmove ( array, fCell, nBytes ); \
+ /* \
+ Convert the output array from Fortran to C style. \
+ */ \
+ F2C_ConvertTrStrArr ( ndim, lenvals, (SpiceChar *)array ); \
+ \
+ /* \
+ Sync the size and cardinality of the C cell. \
+ */ \
+ if ( !failed_c() ) \
+ { \
+ (CCell)->size = size; \
+ (CCell)->card = card; \
+ } \
+ }
+
+
+
+/*
+ End of header SpiceZmc.h
+*/
diff --git a/ext/spice/include/SpiceZpl.h b/ext/spice/include/SpiceZpl.h
new file mode 100644
index 0000000000..1413202b69
--- /dev/null
+++ b/ext/spice/include/SpiceZpl.h
@@ -0,0 +1,109 @@
+/*
+
+-Header_File SpiceZpl.h ( CSPICE platform macros )
+
+-Abstract
+
+ Define macros identifying the host platform for which this
+ version of CSPICE is targeted.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Particulars
+
+ This header file defines macros that enable CSPICE code to be
+ compiled conditionally based on the identity of the host platform.
+
+ The macros defined here ARE visible in the macro name space of
+ any file that includes SpiceUsr.h. The names are prefixed with
+ the string CSPICE_ to help prevent conflicts with macros defined
+ by users' applications.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ B.V. Semenov (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 2.2.0, 14-MAY-2010 (EDW)(BVS)
+
+ Updated for the:
+
+ MAC-OSX-64BIT-INTEL_C
+ PC-64BIT-MS_C
+ SUN-SOLARIS-64BIT-NATIVE_C
+ SUN-SOLARIS-INTEL-64BIT-CC_C
+ SUN-SOLARIS-INTEL-CC_C
+
+ environments.
+
+ -CSPICE Version 2.1.0, 15-NOV-2006 (BVS)
+
+ Updated for MAC-OSX-INTEL_C environment.
+
+ -CSPICE Version 2.0.0, 21-FEB-2006 (NJB)
+
+ Updated for PC-LINUX-64BIT-GCC_C environment.
+
+ -CSPICE Version 1.3.0, 06-MAR-2005 (NJB)
+
+ Updated for SUN-SOLARIS-64BIT-GCC_C environment.
+
+ -CSPICE Version 1.2.0, 03-JAN-2005 (BVS)
+
+ Updated for PC-CYGWIN_C environment.
+
+ -CSPICE Version 1.1.0, 27-JUL-2002 (BVS)
+
+ Updated for MAC-OSX-NATIVE_C environment.
+
+ -CSPICE Version 1.0.0, 26-FEB-1999 (NJB) (EDW)
+
+-Index_Entries
+
+ platform ID defines for CSPICE
+
+*/
+
+
+#ifndef HAVE_PLATFORM_MACROS_H
+#define HAVE_PLATFORM_MACROS_H
+
+
+ #define CSPICE_PC_LINUX_64BIT_GCC
+
+#endif
+
diff --git a/ext/spice/include/SpiceZpr.h b/ext/spice/include/SpiceZpr.h
new file mode 100644
index 0000000000..b4d672e98c
--- /dev/null
+++ b/ext/spice/include/SpiceZpr.h
@@ -0,0 +1,3853 @@
+/*
+
+-Header_File SpiceZpr.h ( CSPICE prototypes )
+
+-Abstract
+
+ Define prototypes for CSPICE user-interface-level functions.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Particulars
+
+ This is the header file containing prototypes for CSPICE user-level
+ C routines. Prototypes for the underlying f2c'd SPICELIB routines
+ are contained in the separate header file SpiceZfc. However, those
+ routines are not part of the official CSPICE API.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ W.L. Taber (JPL)
+ F.S. Turner (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 12.12.0, 19-FEB-2010 (EDW) (NJB)
+
+ Added prototypes for
+
+ bodc2s_c
+ dafgsr_c
+ dafrfr_c
+ dp2hx_c
+ ducrss_c
+ dvcrss_c
+ dvnorm_c
+ gfrr_c
+ gfuds_c
+ hx2dp_c
+ uddc_c
+ uddf_c
+
+ -CSPICE Version 12.11.0, 29-MAR-2009 (EDW) (NJB)
+
+ Added prototypes for
+
+ dvsep_c
+ gfbail_c
+ gfclrh_c
+ gfdist_c
+ gfevnt_c
+ gffove_c
+ gfinth_c
+ gfocce_c
+ gfoclt_c
+ gfposc_c
+ gfrefn_c
+ gfrepf_c
+ gfrepi_c
+ gfrepu_c
+ gfrfov_c
+ gfsep_c
+ gfseth_c
+ gfsntc_c
+ gfsstp_c
+ gfstep_c
+ gfsubc_c
+ gftfov_c
+ surfpv_c
+ zzgfgeth_c
+ zzgfsavh_c
+
+ -CSPICE Version 12.10.0, 30-JAN-2008 (EDW) (NJB)
+
+ Added prototypes for:
+
+ ilumin_c
+ pckcov_c
+ pckfrm_c
+ sincpt_c
+ spkacs_c
+ spkaps_c
+ spkltc_c
+ subpnt_c
+ subslr_c
+ wncard_c
+
+ -CSPICE Version 12.9.0, 16-NOV-2006 (NJB)
+
+ Bug fix: corrected prototype for vhatg_c.
+
+ Renamed wnfild_c and wnfltd_c arguments `small' to 'smal' for
+ compatibility with MS Visual C++.
+
+ Added prototypes for
+
+ dafac_c
+ dafdc_c
+ dafec_c
+ dafgda_c
+ dascls_c
+ dasopr_c
+ kclear_c
+
+ -CSPICE Version 12.8.0, 07-NOV-2005 (NJB)
+
+ Added prototypes for
+
+ bodvcd_c
+ qdq2av_c
+ qxq_c
+ srfrec_c
+
+ -CSPICE Version 12.7.0, 06-JAN-2004 (NJB)
+
+ Added prototypes for
+
+ bods2c_c
+ ckcov_c
+ ckobj_c
+ dafopw_c
+ dafrs_c
+ dpgrdr_c
+ drdpgr_c
+ lspcn_c
+ pgrrec_c
+ recpgr_c
+ spkcov_c
+ spkobj_c
+
+ -CSPICE Version 12.6.0, 24-FEB-2003 (NJB)
+
+ Added prototype for
+
+ bodvrd_c
+ deltet_c
+ srfxpt_c
+
+ -CSPICE Version 12.5.0, 14-MAY-2003 (NJB)
+
+ Removed prototype for getcml_.
+
+
+ -CSPICE Version 12.4.0, 25-FEB-2003 (NJB)
+
+ Added prototypes for
+
+ dasac_c
+ dasec_c
+ et2lst_c
+
+ -CSPICE Version 12.3.0, 03-SEP-2002 (NJB)
+
+ Added prototypes for
+
+ appndc_c
+ appndd_c
+ appndi_c
+ bschoc_c
+ bschoi_c
+ bsrchc_c
+ bsrchd_c
+ bsrchi_c
+ card_c
+ ckw05_c
+ copy_c
+ cpos_c
+ cposr_c
+ diff_c
+ elemc_c
+ elemd_c
+ elemi_c
+ esrchc_c
+ insrtc_c
+ insrtd_c
+ insrti_c
+ inter_c
+ isordv_c
+ isrchc_c
+ isrchd_c
+ isrchi_c
+ lparss_c
+ lstlec_c
+ lstled_c
+ lstlei_c
+ lstltc_c
+ lstltd_c
+ lstlti_c
+ lx4dec_c
+ lx4num_c
+ lx4sgn_c
+ lx4uns_c
+ lxqstr_c
+ ncpos_c
+ ncposr_c
+ ordc_c
+ ordd_c
+ ordi_c
+ orderc_c
+ orderd_c
+ orderi_c
+ pos_c
+ posr_c
+ prefix_c
+ remove_c
+ reordc_c
+ reordd_c
+ reordi_c
+ reordl_c
+ removc_c
+ removd_c
+ removi_c
+ repmc_c
+ repmct_c
+ repmd_c
+ repmf_c
+ repmi_c
+ repmot_c
+ scard_c
+ sdiff_c
+ set_c
+ shellc_c
+ shelld_c
+ shelli_c
+ size_c
+ scard_c
+ spkw18_c
+ ssize_c
+ union_c
+ valid_c
+ wncomd_c
+ wncond_c
+ wndifd_c
+ wnelmd_c
+ wnexpd_c
+ wnextd_c
+ wnfetd_c
+ wnfild_c
+ wnfltd_c
+ wnincd_c
+ wninsd_c
+ wnintd_c
+ wnreld_c
+ wnsumd_c
+ wnunid_c
+ wnvald_c
+ zzsynccl_c
+
+
+ -CSPICE Version 12.2.0, 23-OCT-2001 (NJB)
+
+ Added prototypes for
+
+ badkpv_c
+ dcyldr_c
+ dgeodr_c
+ dlatdr_c
+ drdcyl_c
+ drdgeo_c
+ drdlat_c
+ drdsph_c
+ dsphdr_c
+ ekacec_c
+ ekaced_c
+ ekacei_c
+ ekappr_c
+ ekbseg_c
+ ekccnt_c
+ ekcii_c
+ ekdelr_c
+ ekinsr_c
+ ekntab_c
+ ekrcec_c
+ ekrced_c
+ ekrcei_c
+ ektnam_c
+ ekucec_c
+ ekuced_c
+ ekucei_c
+ inelpl_c
+ invort_c
+ kxtrct_c
+
+ Added const qualifier to input array arguments of
+
+ conics_c
+ illum_c
+ pdpool_c
+ prop2b_c
+ q2m_c
+ spkuds_c
+ xposeg_c
+
+ Added const qualifier to the return value of
+
+ tkvrsn_c
+
+ -CSPICE Version 12.1.0, 12-APR-2000 (FST)
+
+ Added prototype for
+
+ getfov_c
+
+ -CSPICE Version 12.0.0, 22-MAR-2000 (NJB)
+
+ Added prototypes for
+
+ lparse_c
+ lparsm_c
+ spkw12_c
+ spkw13_c
+
+
+ -CSPICE Version 11.1.0, 17-DEC-1999 (WLT)
+
+ Added prototype for
+
+ dafrda_c
+
+ -CSPICE Version 11.0.0, 07-OCT-1999 (NJB) (EDW)
+
+ Changed ekaclc_c, ekacld_c, ekacli_c prototypes to make input
+ pointers const-qualified where appropriate.
+
+ Changed prompt_c prototype to accommodate memory leak bug fix.
+
+ Changed ekpsel_c prototype to be consistent with other interfaces
+ having string array outputs.
+
+ Added prototypes for
+
+ axisar_c
+ brcktd_c
+ brckti_c
+ cidfrm_c
+ cgv2el_c
+ clpool_c
+ cmprss_c
+ cnmfrm_c
+ convrt_c
+ cvpool_c
+ dafbbs_c
+ dafbfs_c
+ dafcls_c
+ dafcs_c
+ daffna_c
+ daffpa_c
+ dafgh_c
+ dafgn_c
+ dafgs_c
+ dafopr_c
+ dafps_c
+ dafus_c
+ diags2_c
+ dtpool_c
+ dvdot_c
+ dvhat_c
+ dvpool_c
+ edlimb_c
+ ekops_c
+ ekopw_c
+ eul2xf_c
+ ftncls_c
+ furnsh_c
+ getmsg_c
+ getelm_c
+ gnpool_c
+ ident_c
+ illum_c
+ inedpl_c
+ kdata_c
+ kinfo_c
+ ktotal_c
+ lmpool_c
+ matchi_c
+ matchw_c
+ maxd_c
+ maxi_c
+ mequ_c
+ mind_c
+ mini_c
+ moved_
+ npedln_c
+ npelpt_c
+ nplnpt_c
+ pcpool_c
+ pdpool_c
+ pipool_c
+ pjelpl_c
+ pxform_c
+ rav2xf_c
+ raxisa_c
+ rquad_c
+ saelgv_c
+ spk14a_c
+ spk14b_c
+ spk14e_c
+ spkapp_c
+ spkapo_c
+ spkcls_c
+ spkezp_c
+ spkgps_c
+ spkopn_c
+ spkpds_c
+ spkpos_c
+ spkssb_c
+ spksub_c
+ spkuds_c
+ spkw02_c
+ spkw03_c
+ spkw05_c
+ spkw08_c
+ spkw09_c
+ spkw10_c
+ spkw15_c
+ spkw17_c
+ stpool_c
+ subpt_c
+ subsol_c
+ swpool_c
+ szpool_c
+ tparse_c
+ trace_c
+ unload_c
+ vaddg_c
+ vhatg_c
+ vlcomg_c
+ vminug_c
+ vrel_c
+ vrelg_c
+ vsepg_c
+ vtmv_c
+ vtmvg_c
+ vzerog_c
+ xf2eul_c
+ xf2rav_c
+ xposeg_c
+
+
+ -CSPICE Version 10.0.0, 09-MAR-1999 (NJB)
+
+ Added prototypes for
+
+ frame_c
+ inrypl_c
+ nvc2pl_c
+ nvp2pl_c
+ pl2nvc_c
+ pl2nvp_c
+ pl2psv_c
+ psv2pl_c
+ sce2c_c
+ vprjp_c
+ vprjpi_c
+
+ Now conditionally includes SpiceEll.h and SpicePln.h.
+
+
+ -CSPICE Version 9.0.0, 25-FEB-1999 (NJB)
+
+ Added prototypes for
+
+ eknseg_c
+ eknelt_c
+ ekpsel_c
+ ekssum_c
+
+ Now conditionally includes SpiceEK.h.
+
+
+ -CSPICE Version 8.0.0, 20-OCT-1998 (NJB)
+
+ Added const qualifier to all input matrix and vector arguments.
+
+ Added prototypes for
+
+ det_c
+ dpmax_c
+ dpmax_
+ dpmin_c
+ dpmin_
+ frinfo_c
+ frmnam_c
+ getfat_c
+ intmax_c
+ intmax_
+ intmin_c
+ intmin_
+ invert_c
+ namfrm_c
+ vrotv_c
+ vsclg_c
+
+
+ -CSPICE Version 7.0.0, 02-APR-1998 (EDW)
+
+ Added prototypes for
+
+ mequg_c
+ unormg_g
+ vdistg_c
+ vdotg_c
+ vequg_c
+ vnormg_c
+
+ -CSPICE Version 6.0.0, 31-MAR-1998 (NJB)
+
+ Added prototypes for
+
+ ekaclc_c
+ ekacld_c
+ ekacli_c
+ ekcls_c
+ ekffld_c
+ ekfind_c
+ ekgc_c
+ ekgd_c
+ ekgi_c
+ ekifld_c
+ eklef_c
+ ekopr_c
+ ekopn_c
+ ekuef_c
+
+ -CSPICE Version 5.0.1, 05-MAR-1998 (EDW)
+
+ Remove some non printing characters.
+
+ -CSPICE Version 5.0.0, 03-MAR-1998 (NJB)
+
+ Added prototypes for
+
+ etcal_c
+ ltime_c
+ stelab_c
+ tpictr_c
+ twovec_c
+ vsubg_c
+
+ -CSPICE Version 4.0.0, 11-FEB-1998 (EDW)
+
+ Added prototypes for
+
+ timdef_c
+ tsetyr_c
+
+
+ -CSPICE Version 3.0.0, 02-FEB-1998 (NJB)
+
+ Added prototypes for
+
+ pckuof_c
+ tipbod_c
+
+ Type SpiceVoid was replaced with void.
+
+ -CSPICE Version 2.0.0, 06-JAN-1998 (NJB)
+
+ Changed all input-only character pointers to type ConstSpiceChar.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB) (KRG) (EDW)
+
+-Index_Entries
+
+ prototypes of CSPICE functions
+
+*/
+
+
+/*
+Include Files:
+*/
+
+
+#ifndef HAVE_SPICEDEFS_H
+#include "SpiceZdf.h"
+#endif
+
+#ifndef HAVE_SPICE_EK_H
+#include "SpiceEK.h"
+#endif
+
+#ifndef HAVE_SPICE_PLANES_H
+#include "SpicePln.h"
+#endif
+
+#ifndef HAVE_SPICE_ELLIPSES_H
+#include "SpiceEll.h"
+#endif
+
+#ifndef HAVE_SPICE_CELLS_H
+#include "SpiceCel.h"
+#endif
+
+#ifndef HAVE_SPICE_SPK_H
+#include "SpiceSPK.h"
+#endif
+
+#ifndef HAVE_SPICEWRAPPERS_H
+#define HAVE_SPICEWRAPPERS_H
+
+
+
+
+/*
+ Function prototypes for CSPICE functions are listed below.
+ Each prototype is accompanied by a function abstract and brief I/O
+ description.
+
+ See the headers of the C wrappers for detailed descriptions of the
+ routines' interfaces.
+
+ The list below should be maintained in alphabetical order.
+*/
+
+ void appndc_c ( ConstSpiceChar * item,
+ SpiceCell * cell );
+
+
+ void appndd_c ( SpiceDouble item,
+ SpiceCell * cell );
+
+
+ void appndi_c ( SpiceInt item,
+ SpiceCell * cell );
+
+
+ void axisar_c ( ConstSpiceDouble axis [3],
+ SpiceDouble angle,
+ SpiceDouble r [3][3] );
+
+
+ SpiceBoolean badkpv_c ( ConstSpiceChar *caller,
+ ConstSpiceChar *name,
+ ConstSpiceChar *comp,
+ SpiceInt size,
+ SpiceInt divby,
+ SpiceChar type );
+
+
+ void bodc2n_c ( SpiceInt code,
+ SpiceInt namelen,
+ SpiceChar * name,
+ SpiceBoolean * found );
+
+
+ void bodc2s_c ( SpiceInt code,
+ SpiceInt lenout,
+ SpiceChar * name );
+
+ void boddef_c ( ConstSpiceChar * name,
+ SpiceInt code );
+
+
+ SpiceBoolean bodfnd_c ( SpiceInt body,
+ ConstSpiceChar * item );
+
+
+ void bodn2c_c ( ConstSpiceChar * name,
+ SpiceInt * code,
+ SpiceBoolean * found );
+
+
+ void bods2c_c ( ConstSpiceChar * name,
+ SpiceInt * code,
+ SpiceBoolean * found );
+
+
+ void bodvar_c ( SpiceInt body,
+ ConstSpiceChar * item,
+ SpiceInt * dim ,
+ SpiceDouble * values );
+
+
+ void bodvcd_c ( SpiceInt body,
+ ConstSpiceChar * item,
+ SpiceInt maxn,
+ SpiceInt * dim ,
+ SpiceDouble * values );
+
+
+ void bodvrd_c ( ConstSpiceChar * body,
+ ConstSpiceChar * item,
+ SpiceInt maxn,
+ SpiceInt * dim ,
+ SpiceDouble * values );
+
+
+ SpiceDouble brcktd_c ( SpiceDouble number,
+ SpiceDouble end1,
+ SpiceDouble end2 );
+
+
+ SpiceInt brckti_c ( SpiceInt number,
+ SpiceInt end1,
+ SpiceInt end2 );
+
+
+ SpiceInt bschoc_c ( ConstSpiceChar * value,
+ SpiceInt ndim,
+ SpiceInt lenvals,
+ const void * array,
+ ConstSpiceInt * order );
+
+
+ SpiceInt bschoi_c ( SpiceInt value,
+ SpiceInt ndim,
+ ConstSpiceInt * array,
+ ConstSpiceInt * order );
+
+
+ SpiceInt bsrchc_c ( ConstSpiceChar * value,
+ SpiceInt ndim,
+ SpiceInt lenvals,
+ const void * array );
+
+
+ SpiceInt bsrchd_c ( SpiceDouble value,
+ SpiceInt ndim,
+ ConstSpiceDouble * array );
+
+
+ SpiceInt bsrchi_c ( SpiceInt value,
+ SpiceInt ndim,
+ ConstSpiceInt * array );
+
+
+ SpiceDouble b1900_c ( void );
+
+
+ SpiceDouble b1950_c ( void );
+
+
+ SpiceInt card_c ( SpiceCell * cell );
+
+
+ void cgv2el_c ( ConstSpiceDouble center[3],
+ ConstSpiceDouble vec1 [3],
+ ConstSpiceDouble vec2 [3],
+ SpiceEllipse * ellipse );
+
+
+ void chkin_c ( ConstSpiceChar * module );
+
+
+ void chkout_c ( ConstSpiceChar * module );
+
+
+ void cidfrm_c ( SpiceInt cent,
+ SpiceInt lenout,
+ SpiceInt * frcode,
+ SpiceChar * frname,
+ SpiceBoolean * found );
+
+
+ void ckcls_c ( SpiceInt handle );
+
+
+ void ckcov_c ( ConstSpiceChar * ck,
+ SpiceInt idcode,
+ SpiceBoolean needav,
+ ConstSpiceChar * level,
+ SpiceDouble tol,
+ ConstSpiceChar * timsys,
+ SpiceCell * cover );
+
+
+ void ckobj_c ( ConstSpiceChar * ck,
+ SpiceCell * ids );
+
+
+ void ckgp_c ( SpiceInt inst,
+ SpiceDouble sclkdp,
+ SpiceDouble tol,
+ ConstSpiceChar * ref,
+ SpiceDouble cmat[3][3],
+ SpiceDouble * clkout,
+ SpiceBoolean * found );
+
+
+ void ckgpav_c ( SpiceInt inst,
+ SpiceDouble sclkdp,
+ SpiceDouble tol,
+ ConstSpiceChar * ref,
+ SpiceDouble cmat[3][3],
+ SpiceDouble av[3],
+ SpiceDouble * clkout,
+ SpiceBoolean * found );
+
+
+ void cklpf_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void ckopn_c ( ConstSpiceChar * name,
+ ConstSpiceChar * ifname,
+ SpiceInt ncomch,
+ SpiceInt * handle );
+
+
+ void ckupf_c ( SpiceInt handle );
+
+
+ void ckw01_c ( SpiceInt handle,
+ SpiceDouble begtime,
+ SpiceDouble endtime,
+ SpiceInt inst,
+ ConstSpiceChar * ref,
+ SpiceBoolean avflag,
+ ConstSpiceChar * segid,
+ SpiceInt nrec,
+ ConstSpiceDouble sclkdp [],
+ ConstSpiceDouble quats [][4],
+ ConstSpiceDouble avvs [][3] );
+
+
+ void ckw02_c ( SpiceInt handle,
+ SpiceDouble begtim,
+ SpiceDouble endtim,
+ SpiceInt inst,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * segid,
+ SpiceInt nrec,
+ ConstSpiceDouble start [],
+ ConstSpiceDouble stop [],
+ ConstSpiceDouble quats [][4],
+ ConstSpiceDouble avvs [][3],
+ ConstSpiceDouble rates [] );
+
+
+ void ckw03_c ( SpiceInt handle,
+ SpiceDouble begtim,
+ SpiceDouble endtim,
+ SpiceInt inst,
+ ConstSpiceChar * ref,
+ SpiceBoolean avflag,
+ ConstSpiceChar * segid,
+ SpiceInt nrec,
+ ConstSpiceDouble sclkdp [],
+ ConstSpiceDouble quats [][4],
+ ConstSpiceDouble avvs [][3],
+ SpiceInt nints,
+ ConstSpiceDouble starts [] );
+
+
+ void ckw05_c ( SpiceInt handle,
+ SpiceCK05Subtype subtyp,
+ SpiceInt degree,
+ SpiceDouble begtim,
+ SpiceDouble endtim,
+ SpiceInt inst,
+ ConstSpiceChar * ref,
+ SpiceBoolean avflag,
+ ConstSpiceChar * segid,
+ SpiceInt n,
+ ConstSpiceDouble sclkdp[],
+ const void * packets,
+ SpiceDouble rate,
+ SpiceInt nints,
+ ConstSpiceDouble starts[] );
+
+
+ SpiceDouble clight_c ( void );
+
+
+ void clpool_c ( void );
+
+
+ void cmprss_c ( SpiceChar delim,
+ SpiceInt n,
+ ConstSpiceChar * input,
+ SpiceInt lenout,
+ SpiceChar * output );
+
+
+ void cnmfrm_c ( ConstSpiceChar * cname,
+ SpiceInt lenout,
+ SpiceInt * frcode,
+ SpiceChar * frname,
+ SpiceBoolean * found );
+
+
+ void conics_c ( ConstSpiceDouble elts[8],
+ SpiceDouble et,
+ SpiceDouble state[6] );
+
+
+ void convrt_c ( SpiceDouble x,
+ ConstSpiceChar * in,
+ ConstSpiceChar * out,
+ SpiceDouble * y );
+
+
+ void copy_c ( SpiceCell * a,
+ SpiceCell * b );
+
+
+
+ SpiceInt cpos_c ( ConstSpiceChar * str,
+ ConstSpiceChar * chars,
+ SpiceInt start );
+
+
+ SpiceInt cposr_c ( ConstSpiceChar * str,
+ ConstSpiceChar * chars,
+ SpiceInt start );
+
+
+ void cvpool_c ( ConstSpiceChar * agent,
+ SpiceBoolean * update );
+
+
+ void cyllat_c ( SpiceDouble r,
+ SpiceDouble lonc,
+ SpiceDouble z,
+ SpiceDouble * radius,
+ SpiceDouble * lon,
+ SpiceDouble * lat );
+
+
+ void cylrec_c ( SpiceDouble r,
+ SpiceDouble lon,
+ SpiceDouble z,
+ SpiceDouble rectan[3] );
+
+
+ void cylsph_c ( SpiceDouble r,
+ SpiceDouble lonc,
+ SpiceDouble z,
+ SpiceDouble * radius,
+ SpiceDouble * colat,
+ SpiceDouble * lon );
+
+
+ void dafac_c ( SpiceInt handle,
+ SpiceInt n,
+ SpiceInt lenvals,
+ const void * buffer );
+
+
+ void dafbbs_c ( SpiceInt handle );
+
+
+ void dafbfs_c ( SpiceInt handle );
+
+
+ void dafcls_c ( SpiceInt handle );
+
+
+ void dafcs_c ( SpiceInt handle );
+
+
+ void dafdc_c ( SpiceInt handle );
+
+
+ void dafec_c ( SpiceInt handle,
+ SpiceInt bufsiz,
+ SpiceInt lenout,
+ SpiceInt * n,
+ void * buffer,
+ SpiceBoolean * done );
+
+
+ void daffna_c ( SpiceBoolean * found );
+
+
+ void daffpa_c ( SpiceBoolean * found );
+
+
+ void dafgda_c ( SpiceInt handle,
+ SpiceInt begin,
+ SpiceInt end,
+ SpiceDouble * data );
+
+
+ void dafgh_c ( SpiceInt * handle );
+
+
+ void dafgn_c ( SpiceInt lenout,
+ SpiceChar * name );
+
+
+ void dafgs_c ( SpiceDouble sum[] );
+
+
+ void dafgsr_c ( SpiceInt handle,
+ SpiceInt recno,
+ SpiceInt begin,
+ SpiceInt end,
+ SpiceDouble * data,
+ SpiceBoolean * found );
+
+
+ void dafopr_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void dafopw_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void dafps_c ( SpiceInt nd,
+ SpiceInt ni,
+ ConstSpiceDouble dc [],
+ ConstSpiceInt ic [],
+ SpiceDouble sum [] );
+
+
+ void dafrda_c ( SpiceInt handle,
+ SpiceInt begin,
+ SpiceInt end,
+ SpiceDouble * data );
+
+
+
+ void dafrfr_c ( SpiceInt handle,
+ SpiceInt lenout,
+ SpiceInt * nd,
+ SpiceInt * ni,
+ SpiceChar * ifname,
+ SpiceInt * fward,
+ SpiceInt * bward,
+ SpiceInt * free );
+
+
+
+ void dafrs_c ( ConstSpiceDouble * sum );
+
+
+ void dafus_c ( ConstSpiceDouble sum [],
+ SpiceInt nd,
+ SpiceInt ni,
+ SpiceDouble dc [],
+ SpiceInt ic [] );
+
+
+ void dasac_c ( SpiceInt handle,
+ SpiceInt n,
+ SpiceInt buflen,
+ const void * buffer );
+
+
+ void dascls_c ( SpiceInt handle );
+
+
+ void dasec_c ( SpiceInt handle,
+ SpiceInt bufsiz,
+ SpiceInt buflen,
+ SpiceInt * n,
+ void * buffer,
+ SpiceBoolean * done );
+
+
+ void dasopr_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void dcyldr_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble jacobi[3][3] );
+
+
+ void deltet_c ( SpiceDouble epoch,
+ ConstSpiceChar * eptype,
+ SpiceDouble * delta );
+
+
+ SpiceDouble det_c ( ConstSpiceDouble m1[3][3] );
+
+
+ void diags2_c ( ConstSpiceDouble symmat [2][2],
+ SpiceDouble diag [2][2],
+ SpiceDouble rotate [2][2] );
+
+
+ void diff_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ void dgeodr_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble jacobi[3][3] );
+
+
+ void dlatdr_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble jacobi[3][3] );
+
+ void dp2hx_c ( SpiceDouble number,
+ SpiceInt lenout,
+ SpiceChar * string,
+ SpiceInt * length
+ );
+
+ void dpgrdr_c ( ConstSpiceChar * body,
+ SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble jacobi[3][3] );
+
+
+ SpiceDouble dpmax_c ( void );
+
+
+ SpiceDouble dpmax_ ( void );
+
+
+ SpiceDouble dpmin_c ( void );
+
+
+ SpiceDouble dpmin_ ( void );
+
+
+ SpiceDouble dpr_c ( void );
+
+
+ void drdcyl_c ( SpiceDouble r,
+ SpiceDouble lon,
+ SpiceDouble z,
+ SpiceDouble jacobi[3][3] );
+
+
+ void drdgeo_c ( SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble alt,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble jacobi[3][3] );
+
+
+ void drdlat_c ( SpiceDouble r,
+ SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble jacobi[3][3] );
+
+
+ void drdpgr_c ( ConstSpiceChar * body,
+ SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble alt,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble jacobi[3][3] );
+
+
+ void drdsph_c ( SpiceDouble r,
+ SpiceDouble colat,
+ SpiceDouble lon,
+ SpiceDouble jacobi[3][3] );
+
+
+ void dsphdr_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble jacobi[3][3] );
+
+
+ void dtpool_c ( ConstSpiceChar * name,
+ SpiceBoolean * found,
+ SpiceInt * n,
+ SpiceChar type [1] );
+
+
+ void ducrss_c ( ConstSpiceDouble s1 [6],
+ ConstSpiceDouble s2 [6],
+ SpiceDouble sout[6] );
+
+
+ void dvcrss_c ( ConstSpiceDouble s1 [6],
+ ConstSpiceDouble s2 [6],
+ SpiceDouble sout[6] );
+
+
+ SpiceDouble dvdot_c ( ConstSpiceDouble s1 [6],
+ ConstSpiceDouble s2 [6] );
+
+
+ void dvhat_c ( ConstSpiceDouble s1 [6],
+ SpiceDouble sout[6] );
+
+ SpiceDouble dvnorm_c ( ConstSpiceDouble state[6] );
+
+ void dvpool_c ( ConstSpiceChar * name );
+
+
+ SpiceDouble dvsep_c ( ConstSpiceDouble * s1,
+ ConstSpiceDouble * s2 );
+
+
+ void edlimb_c ( SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ ConstSpiceDouble viewpt[3],
+ SpiceEllipse * limb );
+
+
+ void ekacec_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt nvals,
+ SpiceInt vallen,
+ const void * cvals,
+ SpiceBoolean isnull );
+
+
+ void ekaced_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt nvals,
+ ConstSpiceDouble * dvals,
+ SpiceBoolean isnull );
+
+
+ void ekacei_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt nvals,
+ ConstSpiceInt * ivals,
+ SpiceBoolean isnull );
+
+
+ void ekaclc_c ( SpiceInt handle,
+ SpiceInt segno,
+ ConstSpiceChar * column,
+ SpiceInt vallen,
+ const void * cvals,
+ ConstSpiceInt * entszs,
+ ConstSpiceBoolean * nlflgs,
+ ConstSpiceInt * rcptrs,
+ SpiceInt * wkindx );
+
+
+ void ekacld_c ( SpiceInt handle,
+ SpiceInt segno,
+ ConstSpiceChar * column,
+ ConstSpiceDouble * dvals,
+ ConstSpiceInt * entszs,
+ ConstSpiceBoolean * nlflgs,
+ ConstSpiceInt * rcptrs,
+ SpiceInt * wkindx );
+
+
+ void ekacli_c ( SpiceInt handle,
+ SpiceInt segno,
+ ConstSpiceChar * column,
+ ConstSpiceInt * ivals,
+ ConstSpiceInt * entszs,
+ ConstSpiceBoolean * nlflgs,
+ ConstSpiceInt * rcptrs,
+ SpiceInt * wkindx );
+
+
+ void ekappr_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt * recno );
+
+
+ void ekbseg_c ( SpiceInt handle,
+ ConstSpiceChar * tabnam,
+ SpiceInt ncols,
+ SpiceInt cnmlen,
+ const void * cnames,
+ SpiceInt declen,
+ const void * decls,
+ SpiceInt * segno );
+
+
+ void ekccnt_c ( ConstSpiceChar * table,
+ SpiceInt * ccount );
+
+
+ void ekcii_c ( ConstSpiceChar * table,
+ SpiceInt cindex,
+ SpiceInt lenout,
+ SpiceChar * column,
+ SpiceEKAttDsc * attdsc );
+
+
+ void ekcls_c ( SpiceInt handle );
+
+
+ void ekdelr_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno );
+
+
+ void ekffld_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt * rcptrs );
+
+
+ void ekfind_c ( ConstSpiceChar * query,
+ SpiceInt lenout,
+ SpiceInt * nmrows,
+ SpiceBoolean * error,
+ SpiceChar * errmsg );
+
+
+ void ekgc_c ( SpiceInt selidx,
+ SpiceInt row,
+ SpiceInt elment,
+ SpiceInt lenout,
+ SpiceChar * cdata,
+ SpiceBoolean * null,
+ SpiceBoolean * found );
+
+
+ void ekgd_c ( SpiceInt selidx,
+ SpiceInt row,
+ SpiceInt elment,
+ SpiceDouble * ddata,
+ SpiceBoolean * null,
+ SpiceBoolean * found );
+
+
+ void ekgi_c ( SpiceInt selidx,
+ SpiceInt row,
+ SpiceInt elment,
+ SpiceInt * idata,
+ SpiceBoolean * null,
+ SpiceBoolean * found );
+
+
+ void ekifld_c ( SpiceInt handle,
+ ConstSpiceChar * tabnam,
+ SpiceInt ncols,
+ SpiceInt nrows,
+ SpiceInt cnmlen,
+ const void * cnames,
+ SpiceInt declen,
+ const void * decls,
+ SpiceInt * segno,
+ SpiceInt * rcptrs );
+
+
+ void ekinsr_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno );
+
+
+ void eklef_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ SpiceInt eknelt_c ( SpiceInt selidx,
+ SpiceInt row );
+
+
+ SpiceInt eknseg_c ( SpiceInt handle );
+
+
+ void ekntab_c ( SpiceInt * n );
+
+
+ void ekopn_c ( ConstSpiceChar * fname,
+ ConstSpiceChar * ifname,
+ SpiceInt ncomch,
+ SpiceInt * handle );
+
+
+ void ekopr_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void ekops_c ( SpiceInt * handle );
+
+
+ void ekopw_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void ekpsel_c ( ConstSpiceChar * query,
+ SpiceInt msglen,
+ SpiceInt tablen,
+ SpiceInt collen,
+ SpiceInt * n,
+ SpiceInt * xbegs,
+ SpiceInt * xends,
+ SpiceEKDataType * xtypes,
+ SpiceEKExprClass * xclass,
+ void * tabs,
+ void * cols,
+ SpiceBoolean * error,
+ SpiceChar * errmsg );
+
+
+ void ekrcec_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt lenout,
+ SpiceInt * nvals,
+ void * cvals,
+ SpiceBoolean * isnull );
+
+
+ void ekrced_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt * nvals,
+ SpiceDouble * dvals,
+ SpiceBoolean * isnull );
+
+
+ void ekrcei_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt * nvals,
+ SpiceInt * ivals,
+ SpiceBoolean * isnull );
+
+
+ void ekssum_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceEKSegSum * segsum );
+
+
+ void ektnam_c ( SpiceInt n,
+ SpiceInt lenout,
+ SpiceChar * table );
+
+
+ void ekucec_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt nvals,
+ SpiceInt vallen,
+ const void * cvals,
+ SpiceBoolean isnull );
+
+
+ void ekuced_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt nvals,
+ ConstSpiceDouble * dvals,
+ SpiceBoolean isnull );
+
+
+ void ekucei_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt nvals,
+ ConstSpiceInt * ivals,
+ SpiceBoolean isnull );
+
+
+ void ekuef_c ( SpiceInt handle );
+
+
+ SpiceBoolean elemc_c ( ConstSpiceChar * item,
+ SpiceCell * set );
+
+
+ SpiceBoolean elemd_c ( SpiceDouble item,
+ SpiceCell * set );
+
+
+ SpiceBoolean elemi_c ( SpiceInt item,
+ SpiceCell * set );
+
+
+ SpiceBoolean eqstr_c ( ConstSpiceChar * a,
+ ConstSpiceChar * b );
+
+
+ void el2cgv_c ( ConstSpiceEllipse * ellipse,
+ SpiceDouble center[3],
+ SpiceDouble smajor[3],
+ SpiceDouble sminor[3] );
+
+
+ void erract_c ( ConstSpiceChar * operation,
+ SpiceInt lenout,
+ SpiceChar * action );
+
+
+ void errch_c ( ConstSpiceChar * marker,
+ ConstSpiceChar * string );
+
+
+ void errdev_c ( ConstSpiceChar * operation,
+ SpiceInt lenout,
+ SpiceChar * device );
+
+
+ void errdp_c ( ConstSpiceChar * marker,
+ SpiceDouble number );
+
+
+ void errint_c ( ConstSpiceChar * marker,
+ SpiceInt number );
+
+
+ void errprt_c ( ConstSpiceChar * operation,
+ SpiceInt lenout,
+ SpiceChar * list );
+
+
+ SpiceInt esrchc_c ( ConstSpiceChar * value,
+ SpiceInt ndim,
+ SpiceInt lenvals,
+ const void * array );
+
+
+ void etcal_c ( SpiceDouble et,
+ SpiceInt lenout,
+ SpiceChar * string );
+
+
+ void et2lst_c ( SpiceDouble et,
+ SpiceInt body,
+ SpiceDouble lon,
+ ConstSpiceChar * type,
+ SpiceInt timlen,
+ SpiceInt ampmlen,
+ SpiceInt * hr,
+ SpiceInt * mn,
+ SpiceInt * sc,
+ SpiceChar * time,
+ SpiceChar * ampm );
+
+
+ void et2utc_c ( SpiceDouble et ,
+ ConstSpiceChar * format,
+ SpiceInt prec,
+ SpiceInt lenout,
+ SpiceChar * utcstr );
+
+
+ void eul2m_c ( SpiceDouble angle3,
+ SpiceDouble angle2,
+ SpiceDouble angle1,
+ SpiceInt axis3,
+ SpiceInt axis2,
+ SpiceInt axis1,
+ SpiceDouble r [3][3] );
+
+
+ void eul2xf_c ( ConstSpiceDouble eulang[6],
+ SpiceInt axisa,
+ SpiceInt axisb,
+ SpiceInt axisc,
+ SpiceDouble xform [6][6] );
+
+
+ SpiceBoolean exists_c ( ConstSpiceChar * name );
+
+
+ void expool_c ( ConstSpiceChar * name,
+ SpiceBoolean * found );
+
+
+ SpiceBoolean failed_c ( void );
+
+
+ void frame_c ( SpiceDouble x[3],
+ SpiceDouble y[3],
+ SpiceDouble z[3] );
+
+
+ void frinfo_c ( SpiceInt frcode,
+ SpiceInt * cent,
+ SpiceInt * clss,
+ SpiceInt * clssid,
+ SpiceBoolean * found );
+
+
+ void frmnam_c ( SpiceInt frcode,
+ SpiceInt lenout,
+ SpiceChar * frname );
+
+
+ void ftncls_c ( SpiceInt unit );
+
+
+ void furnsh_c ( ConstSpiceChar * file );
+
+
+ void gcpool_c ( ConstSpiceChar * name,
+ SpiceInt start,
+ SpiceInt room,
+ SpiceInt lenout,
+ SpiceInt * n,
+ void * cvals,
+ SpiceBoolean * found );
+
+
+ void gdpool_c ( ConstSpiceChar * name,
+ SpiceInt start,
+ SpiceInt room,
+ SpiceInt * n,
+ SpiceDouble * values,
+ SpiceBoolean * found );
+
+
+ void georec_c ( SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble alt,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble rectan[3] );
+
+
+ void getcml_c ( SpiceInt * argc,
+ SpiceChar *** argv );
+
+
+ void getelm_c ( SpiceInt frstyr,
+ SpiceInt lineln,
+ const void * lines,
+ SpiceDouble * epoch,
+ SpiceDouble * elems );
+
+
+ void getfat_c ( ConstSpiceChar * file,
+ SpiceInt arclen,
+ SpiceInt typlen,
+ SpiceChar * arch,
+ SpiceChar * type );
+
+
+ void getfov_c ( SpiceInt instid,
+ SpiceInt room,
+ SpiceInt shapelen,
+ SpiceInt framelen,
+ SpiceChar * shape,
+ SpiceChar * frame,
+ SpiceDouble bsight [3],
+ SpiceInt * n,
+ SpiceDouble bounds [][3] );
+
+
+ void getmsg_c ( ConstSpiceChar * option,
+ SpiceInt lenout,
+ SpiceChar * msg );
+
+
+ SpiceBoolean gfbail_c ( void );
+
+
+ void gfclrh_c ( void );
+
+
+ void gfdist_c ( ConstSpiceChar * target,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+
+ void gfevnt_c ( void ( * udstep ) ( SpiceDouble et,
+ SpiceDouble * step ),
+
+ void ( * udrefn ) ( SpiceDouble t1,
+ SpiceDouble t2,
+ SpiceBoolean s1,
+ SpiceBoolean s2,
+ SpiceDouble * t ),
+ ConstSpiceChar * gquant,
+ SpiceInt qnpars,
+ SpiceInt lenvals,
+ const void * qpnams,
+ const void * qcpars,
+ ConstSpiceDouble * qdpars,
+ ConstSpiceInt * qipars,
+ ConstSpiceBoolean * qlpars,
+ ConstSpiceChar * op,
+ SpiceDouble refval,
+ SpiceDouble tol,
+ SpiceDouble adjust,
+ SpiceBoolean rpt,
+
+ void ( * udrepi ) ( SpiceCell * cnfine,
+ ConstSpiceChar * srcpre,
+ ConstSpiceChar * srcsuf ),
+
+ void ( * udrepu ) ( SpiceDouble ivbeg,
+ SpiceDouble ivend,
+ SpiceDouble et ),
+
+ void ( * udrepf ) ( void ),
+ SpiceInt nintvls,
+ SpiceBoolean bail,
+ SpiceBoolean ( * udbail ) ( void ),
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+
+ void gffove_c ( ConstSpiceChar * inst,
+ ConstSpiceChar * tshape,
+ ConstSpiceDouble raydir [3],
+ ConstSpiceChar * target,
+ ConstSpiceChar * tframe,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble tol,
+ void ( * udstep ) ( SpiceDouble et,
+ SpiceDouble * step ),
+ void ( * udrefn ) ( SpiceDouble t1,
+ SpiceDouble t2,
+ SpiceBoolean s1,
+ SpiceBoolean s2,
+ SpiceDouble * t ),
+ SpiceBoolean rpt,
+ void ( * udrepi ) ( SpiceCell * cnfine,
+ ConstSpiceChar * srcpre,
+ ConstSpiceChar * srcsuf ),
+ void ( * udrepu ) ( SpiceDouble ivbeg,
+ SpiceDouble ivend,
+ SpiceDouble et ),
+ void ( * udrepf ) ( void ),
+ SpiceBoolean bail,
+ SpiceBoolean ( * udbail ) ( void ),
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfinth_c ( int sigcode );
+
+
+ void gfocce_c ( ConstSpiceChar * occtyp,
+ ConstSpiceChar * front,
+ ConstSpiceChar * fshape,
+ ConstSpiceChar * fframe,
+ ConstSpiceChar * back,
+ ConstSpiceChar * bshape,
+ ConstSpiceChar * bframe,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * abcorr,
+ SpiceDouble tol,
+ void ( * udstep ) ( SpiceDouble et,
+ SpiceDouble * step ),
+ void ( * udrefn ) ( SpiceDouble t1,
+ SpiceDouble t2,
+ SpiceBoolean s1,
+ SpiceBoolean s2,
+ SpiceDouble * t ),
+ SpiceBoolean rpt,
+ void ( * udrepi ) ( SpiceCell * cnfine,
+ ConstSpiceChar * srcpre,
+ ConstSpiceChar * srcsuf ),
+ void ( * udrepu ) ( SpiceDouble ivbeg,
+ SpiceDouble ivend,
+ SpiceDouble et ),
+ void ( * udrepf ) ( void ),
+ SpiceBoolean bail,
+ SpiceBoolean ( * udbail ) ( void ),
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+
+ void gfoclt_c ( ConstSpiceChar * occtyp,
+ ConstSpiceChar * front,
+ ConstSpiceChar * fshape,
+ ConstSpiceChar * fframe,
+ ConstSpiceChar * back,
+ ConstSpiceChar * bshape,
+ ConstSpiceChar * bframe,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * abcorr,
+ SpiceDouble step,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfposc_c ( ConstSpiceChar * target,
+ ConstSpiceChar * frame,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * crdsys,
+ ConstSpiceChar * coord,
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfrefn_c ( SpiceDouble t1,
+ SpiceDouble t2,
+ SpiceBoolean s1,
+ SpiceBoolean s2,
+ SpiceDouble * t );
+
+
+ void gfrepf_c ( void );
+
+
+ void gfrepi_c ( SpiceCell * window,
+ ConstSpiceChar * begmss,
+ ConstSpiceChar * endmss );
+
+
+ void gfrepu_c ( SpiceDouble ivbeg,
+ SpiceDouble ivend,
+ SpiceDouble time );
+
+
+ void gfrfov_c ( ConstSpiceChar * inst,
+ ConstSpiceDouble raydir [3],
+ ConstSpiceChar * rframe,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble step,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfrr_c ( ConstSpiceChar * target,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfsep_c ( ConstSpiceChar * targ1,
+ ConstSpiceChar * frame1,
+ ConstSpiceChar * shape1,
+ ConstSpiceChar * targ2,
+ ConstSpiceChar * frame2,
+ ConstSpiceChar * shape2,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfsntc_c ( ConstSpiceChar * target,
+ ConstSpiceChar * fixref,
+ ConstSpiceChar * method,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * dref,
+ ConstSpiceDouble dvec [3],
+ ConstSpiceChar * crdsys,
+ ConstSpiceChar * coord,
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfsstp_c ( SpiceDouble step );
+
+
+ void gfstep_c ( SpiceDouble time,
+ SpiceDouble * step );
+
+
+ void gfsubc_c ( ConstSpiceChar * target,
+ ConstSpiceChar * fixref,
+ ConstSpiceChar * method,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * crdsys,
+ ConstSpiceChar * coord,
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gftfov_c ( ConstSpiceChar * inst,
+ ConstSpiceChar * target,
+ ConstSpiceChar * tshape,
+ ConstSpiceChar * tframe,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble step,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfuds_c ( void ( * udfunc ) ( SpiceDouble x,
+ SpiceDouble * value ),
+
+ void ( * udqdec ) ( void ( * udfunc )
+ ( SpiceDouble x,
+ SpiceDouble * value ),
+
+ SpiceDouble x,
+ SpiceBoolean * isdecr ),
+
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gipool_c ( ConstSpiceChar * name,
+ SpiceInt start,
+ SpiceInt room,
+ SpiceInt * n,
+ SpiceInt * ivals,
+ SpiceBoolean * found );
+
+
+ void gnpool_c ( ConstSpiceChar * name,
+ SpiceInt start,
+ SpiceInt room,
+ SpiceInt lenout,
+ SpiceInt * n,
+ void * kvars,
+ SpiceBoolean * found );
+
+
+ SpiceDouble halfpi_c ( void );
+
+ void hx2dp_c ( ConstSpiceChar * string,
+ SpiceInt lenout,
+ SpiceDouble * number,
+ SpiceBoolean * error,
+ SpiceChar * errmsg
+ );
+
+
+ void ident_c ( SpiceDouble matrix[3][3] );
+
+
+ void ilumin_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * fixref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceDouble spoint [3],
+ SpiceDouble * trgepc,
+ SpiceDouble srfvec [3],
+ SpiceDouble * phase,
+ SpiceDouble * solar,
+ SpiceDouble * emissn );
+
+
+ void illum_c ( ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceDouble spoint [3],
+ SpiceDouble * phase,
+ SpiceDouble * solar,
+ SpiceDouble * emissn );
+
+
+ void inedpl_c ( SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ ConstSpicePlane * plane,
+ SpiceEllipse * ellipse,
+ SpiceBoolean * found );
+
+
+ void inelpl_c ( ConstSpiceEllipse * ellips,
+ ConstSpicePlane * plane,
+ SpiceInt * nxpts,
+ SpiceDouble xpt1[3],
+ SpiceDouble xpt2[3] );
+
+
+ void insrtc_c ( ConstSpiceChar * item,
+ SpiceCell * set );
+
+
+ void insrtd_c ( SpiceDouble item,
+ SpiceCell * set );
+
+
+ void insrti_c ( SpiceInt item,
+ SpiceCell * set );
+
+
+ void inter_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ void inrypl_c ( ConstSpiceDouble vertex [3],
+ ConstSpiceDouble dir [3],
+ ConstSpicePlane * plane,
+ SpiceInt * nxpts,
+ SpiceDouble xpt [3] );
+
+
+ SpiceInt intmax_c ( void );
+
+
+ SpiceInt intmax_ ( void );
+
+
+ SpiceInt intmin_c ( void );
+
+
+ SpiceInt intmin_ ( void );
+
+
+ void invert_c ( ConstSpiceDouble m1[3][3],
+ SpiceDouble m2[3][3] );
+
+
+ void invort_c ( ConstSpiceDouble m [3][3],
+ SpiceDouble mit[3][3] );
+
+
+ SpiceBoolean isordv_c ( ConstSpiceInt * array,
+ SpiceInt n );
+
+
+ SpiceBoolean isrot_c ( ConstSpiceDouble m [3][3],
+ SpiceDouble ntol,
+ SpiceDouble dtol );
+
+
+
+ SpiceInt isrchc_c ( ConstSpiceChar * value,
+ SpiceInt ndim,
+ SpiceInt lenvals,
+ const void * array );
+
+
+ SpiceInt isrchd_c ( SpiceDouble value,
+ SpiceInt ndim,
+ ConstSpiceDouble * array );
+
+
+ SpiceInt isrchi_c ( SpiceInt value,
+ SpiceInt ndim,
+ ConstSpiceInt * array );
+
+
+ SpiceBoolean iswhsp_c ( ConstSpiceChar * string );
+
+
+ SpiceDouble j1900_c ( void );
+
+
+ SpiceDouble j1950_c ( void );
+
+
+ SpiceDouble j2000_c ( void );
+
+
+ SpiceDouble j2100_c ( void );
+
+
+ SpiceDouble jyear_c ( void );
+
+
+ void kclear_c ( void );
+
+
+ void kdata_c ( SpiceInt which,
+ ConstSpiceChar * kind,
+ SpiceInt fillen,
+ SpiceInt typlen,
+ SpiceInt srclen,
+ SpiceChar * file,
+ SpiceChar * filtyp,
+ SpiceChar * source,
+ SpiceInt * handle,
+ SpiceBoolean * found );
+
+
+ void kinfo_c ( ConstSpiceChar * file,
+ SpiceInt typlen,
+ SpiceInt srclen,
+ SpiceChar * filtyp,
+ SpiceChar * source,
+ SpiceInt * handle,
+ SpiceBoolean * found );
+
+
+ void ktotal_c ( ConstSpiceChar * kind,
+ SpiceInt * count );
+
+
+ void kxtrct_c ( ConstSpiceChar * keywd,
+ SpiceInt termlen,
+ const void * terms,
+ SpiceInt nterms,
+ SpiceInt stringlen,
+ SpiceInt substrlen,
+ SpiceChar * string,
+ SpiceBoolean * found,
+ SpiceChar * substr );
+
+
+ SpiceInt lastnb_c ( ConstSpiceChar * string );
+
+
+ void latcyl_c ( SpiceDouble radius,
+ SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble * r,
+ SpiceDouble * lonc,
+ SpiceDouble * z );
+
+
+ void latrec_c ( SpiceDouble radius,
+ SpiceDouble longitude,
+ SpiceDouble latitude,
+ SpiceDouble rectan [3] );
+
+
+ void latsph_c ( SpiceDouble radius,
+ SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble * rho,
+ SpiceDouble * colat,
+ SpiceDouble * lons );
+
+
+ void lcase_c ( SpiceChar * in,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void ldpool_c ( ConstSpiceChar * filename );
+
+
+ void lmpool_c ( const void * cvals,
+ SpiceInt lenvals,
+ SpiceInt n );
+
+
+ void lparse_c ( ConstSpiceChar * list,
+ ConstSpiceChar * delim,
+ SpiceInt nmax,
+ SpiceInt lenout,
+ SpiceInt * n,
+ void * items );
+
+
+ void lparsm_c ( ConstSpiceChar * list,
+ ConstSpiceChar * delims,
+ SpiceInt nmax,
+ SpiceInt lenout,
+ SpiceInt * n,
+ void * items );
+
+
+ void lparss_c ( ConstSpiceChar * list,
+ ConstSpiceChar * delims,
+ SpiceCell * set );
+
+
+ SpiceDouble lspcn_c ( ConstSpiceChar * body,
+ SpiceDouble et,
+ ConstSpiceChar * abcorr );
+
+
+ SpiceInt lstlec_c ( ConstSpiceChar * string,
+ SpiceInt n,
+ SpiceInt lenvals,
+ const void * array );
+
+
+ SpiceInt lstled_c ( SpiceDouble x,
+ SpiceInt n,
+ ConstSpiceDouble * array );
+
+
+ SpiceInt lstlei_c ( SpiceInt x,
+ SpiceInt n,
+ ConstSpiceInt * array );
+
+
+ SpiceInt lstltc_c ( ConstSpiceChar * string,
+ SpiceInt n,
+ SpiceInt lenvals,
+ const void * array );
+
+
+ SpiceInt lstltd_c ( SpiceDouble x,
+ SpiceInt n,
+ ConstSpiceDouble * array );
+
+
+ SpiceInt lstlti_c ( SpiceInt x,
+ SpiceInt n,
+ ConstSpiceInt * array );
+
+
+ void ltime_c ( SpiceDouble etobs,
+ SpiceInt obs,
+ ConstSpiceChar * dir,
+ SpiceInt targ,
+ SpiceDouble * ettarg,
+ SpiceDouble * elapsd );
+
+
+ void lx4dec_c ( ConstSpiceChar * string,
+ SpiceInt first,
+ SpiceInt * last,
+ SpiceInt * nchar );
+
+
+ void lx4num_c ( ConstSpiceChar * string,
+ SpiceInt first,
+ SpiceInt * last,
+ SpiceInt * nchar );
+
+
+ void lx4sgn_c ( ConstSpiceChar * string,
+ SpiceInt first,
+ SpiceInt * last,
+ SpiceInt * nchar );
+
+
+ void lx4uns_c ( ConstSpiceChar * string,
+ SpiceInt first,
+ SpiceInt * last,
+ SpiceInt * nchar );
+
+
+ void lxqstr_c ( ConstSpiceChar * string,
+ SpiceChar qchar,
+ SpiceInt first,
+ SpiceInt * last,
+ SpiceInt * nchar );
+
+
+ void m2eul_c ( ConstSpiceDouble r[3][3],
+ SpiceInt axis3,
+ SpiceInt axis2,
+ SpiceInt axis1,
+ SpiceDouble * angle3,
+ SpiceDouble * angle2,
+ SpiceDouble * angle1 );
+
+
+ void m2q_c ( ConstSpiceDouble r[3][3],
+ SpiceDouble q[4] );
+
+
+
+ SpiceBoolean matchi_c ( ConstSpiceChar * string,
+ ConstSpiceChar * templ,
+ SpiceChar wstr,
+ SpiceChar wchr );
+
+
+ SpiceBoolean matchw_c ( ConstSpiceChar * string,
+ ConstSpiceChar * templ,
+ SpiceChar wstr,
+ SpiceChar wchr );
+
+
+ SpiceDouble maxd_c ( SpiceInt n,
+ ... );
+
+
+ SpiceInt maxi_c ( SpiceInt n,
+ ... );
+
+
+ void mequ_c ( ConstSpiceDouble m1 [3][3],
+ SpiceDouble mout[3][3] );
+
+
+ void mequg_c ( const void * m1,
+ SpiceInt nr,
+ SpiceInt nc,
+ void * mout );
+
+
+ SpiceDouble mind_c ( SpiceInt n,
+ ... );
+
+
+ SpiceInt mini_c ( SpiceInt n,
+ ... );
+
+
+ int moved_ ( SpiceDouble * arrfrm,
+ SpiceInt * ndim,
+ SpiceDouble * arrto );
+
+
+ void mtxm_c ( ConstSpiceDouble m1 [3][3],
+ ConstSpiceDouble m2 [3][3],
+ SpiceDouble mout[3][3] );
+
+
+ void mtxmg_c ( const void * m1,
+ const void * m2,
+ SpiceInt row1,
+ SpiceInt col1,
+ SpiceInt col2,
+ void * mout );
+
+
+ void mtxv_c ( ConstSpiceDouble m1 [3][3],
+ ConstSpiceDouble vin [3],
+ SpiceDouble vout[3] );
+
+
+ void mtxvg_c ( const void * m1,
+ const void * v2,
+ SpiceInt ncol1,
+ SpiceInt nr1r2,
+ void * vout );
+
+
+ void mxm_c ( ConstSpiceDouble m1 [3][3],
+ ConstSpiceDouble m2 [3][3],
+ SpiceDouble mout[3][3] );
+
+
+ void mxmg_c ( const void * m1,
+ const void * m2,
+ SpiceInt row1,
+ SpiceInt col1,
+ SpiceInt col2,
+ void * mout );
+
+
+ void mxmt_c ( ConstSpiceDouble m1 [3][3],
+ ConstSpiceDouble m2 [3][3],
+ SpiceDouble mout[3][3] );
+
+
+ void mxmtg_c ( const void * m1,
+ const void * m2,
+ SpiceInt nrow1,
+ SpiceInt nc1c2,
+ SpiceInt nrow2,
+ void * mout );
+
+
+ void mxv_c ( ConstSpiceDouble m1[3][3],
+ ConstSpiceDouble vin[3],
+ SpiceDouble vout[3] );
+
+
+ void mxvg_c ( const void * m1,
+ const void * v2,
+ SpiceInt nrow1,
+ SpiceInt nc1r2,
+ void * vout );
+
+
+ void namfrm_c ( ConstSpiceChar * frname,
+ SpiceInt * frcode );
+
+
+ SpiceInt ncpos_c ( ConstSpiceChar * str,
+ ConstSpiceChar * chars,
+ SpiceInt start );
+
+
+ SpiceInt ncposr_c ( ConstSpiceChar * str,
+ ConstSpiceChar * chars,
+ SpiceInt start );
+
+
+ void nearpt_c ( ConstSpiceDouble positn[3],
+ SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ SpiceDouble npoint[3],
+ SpiceDouble * alt );
+
+
+ void npedln_c ( SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ ConstSpiceDouble linept[3],
+ ConstSpiceDouble linedr[3],
+ SpiceDouble pnear[3],
+ SpiceDouble * dist );
+
+
+ void npelpt_c ( ConstSpiceDouble point[3],
+ ConstSpiceEllipse * ellips,
+ SpiceDouble pnear[3],
+ SpiceDouble * dist );
+
+
+ void nplnpt_c ( ConstSpiceDouble linpt [3],
+ ConstSpiceDouble lindir [3],
+ ConstSpiceDouble point [3],
+ SpiceDouble pnear [3],
+ SpiceDouble * dist );
+
+
+ void nvc2pl_c ( ConstSpiceDouble normal[3],
+ SpiceDouble constant,
+ SpicePlane * plane );
+
+
+ void nvp2pl_c ( ConstSpiceDouble normal[3],
+ ConstSpiceDouble point[3],
+ SpicePlane * plane );
+
+
+ SpiceInt ordc_c ( ConstSpiceChar * item,
+ SpiceCell * set );
+
+
+ SpiceInt ordd_c ( SpiceDouble item,
+ SpiceCell * set );
+
+
+ SpiceInt ordi_c ( SpiceInt item,
+ SpiceCell * set );
+
+
+ void orderc_c ( SpiceInt lenvals,
+ const void * array,
+ SpiceInt ndim,
+ SpiceInt * iorder );
+
+
+ void orderd_c ( ConstSpiceDouble * array,
+ SpiceInt ndim,
+ SpiceInt * iorder );
+
+
+ void orderi_c ( ConstSpiceInt * array,
+ SpiceInt ndim,
+ SpiceInt * iorder );
+
+
+ void oscelt_c ( ConstSpiceDouble state[6],
+ SpiceDouble et ,
+ SpiceDouble mu ,
+ SpiceDouble elts[8] );
+
+
+ void pckcov_c ( ConstSpiceChar * pck,
+ SpiceInt idcode,
+ SpiceCell * cover );
+
+
+ void pckfrm_c ( ConstSpiceChar * pck,
+ SpiceCell * ids );
+
+
+ void pcklof_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void pckuof_c ( SpiceInt handle );
+
+
+ void pcpool_c ( ConstSpiceChar * name,
+ SpiceInt n,
+ SpiceInt lenvals,
+ const void * cvals );
+
+
+ void pdpool_c ( ConstSpiceChar * name,
+ SpiceInt n,
+ ConstSpiceDouble * dvals );
+
+
+ void pgrrec_c ( ConstSpiceChar * body,
+ SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble alt,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble rectan[3] );
+
+
+ SpiceDouble pi_c ( void );
+
+
+ void pipool_c ( ConstSpiceChar * name,
+ SpiceInt n,
+ ConstSpiceInt * ivals );
+
+
+ void pjelpl_c ( ConstSpiceEllipse * elin,
+ ConstSpicePlane * plane,
+ SpiceEllipse * elout );
+
+
+ void pl2nvc_c ( ConstSpicePlane * plane,
+ SpiceDouble normal[3],
+ SpiceDouble * constant );
+
+
+ void pl2nvp_c ( ConstSpicePlane * plane,
+ SpiceDouble normal[3],
+ SpiceDouble point[3] );
+
+
+ void pl2psv_c ( ConstSpicePlane * plane,
+ SpiceDouble point[3],
+ SpiceDouble span1[3],
+ SpiceDouble span2[3] );
+
+
+ SpiceInt pos_c ( ConstSpiceChar * str,
+ ConstSpiceChar * substr,
+ SpiceInt start );
+
+
+ SpiceInt posr_c ( ConstSpiceChar * str,
+ ConstSpiceChar * substr,
+ SpiceInt start );
+
+
+ void prefix_c ( ConstSpiceChar * pref,
+ SpiceInt spaces,
+ SpiceInt lenout,
+ SpiceChar * string );
+
+
+ SpiceChar * prompt_c ( ConstSpiceChar * prmptStr,
+ SpiceInt lenout,
+ SpiceChar * buffer );
+
+
+ void prop2b_c ( SpiceDouble gm,
+ ConstSpiceDouble pvinit[6],
+ SpiceDouble dt,
+ SpiceDouble pvprop[6] );
+
+
+ void prsdp_c ( ConstSpiceChar * string,
+ SpiceDouble * dpval );
+
+
+ void prsint_c ( ConstSpiceChar * string,
+ SpiceInt * intval );
+
+
+ void psv2pl_c ( ConstSpiceDouble point[3],
+ ConstSpiceDouble span1[3],
+ ConstSpiceDouble span2[3],
+ SpicePlane * plane );
+
+
+ void putcml_c ( SpiceInt argc ,
+ SpiceChar ** argv );
+
+
+ void pxform_c ( ConstSpiceChar * from,
+ ConstSpiceChar * to,
+ SpiceDouble et,
+ SpiceDouble rotate[3][3] );
+
+
+ void q2m_c ( ConstSpiceDouble q[4],
+ SpiceDouble r[3][3] );
+
+
+ void qdq2av_c ( ConstSpiceDouble q[4],
+ ConstSpiceDouble dq[4],
+ SpiceDouble av[3] );
+
+
+ void qxq_c ( ConstSpiceDouble q1[4],
+ ConstSpiceDouble q2[4],
+ SpiceDouble qout[4] );
+
+
+
+ void radrec_c ( SpiceDouble range,
+ SpiceDouble ra,
+ SpiceDouble dec,
+ SpiceDouble rectan[3] );
+
+
+ void rav2xf_c ( ConstSpiceDouble rot [3][3],
+ ConstSpiceDouble av [3],
+ SpiceDouble xform [6][6] );
+
+
+ void raxisa_c ( ConstSpiceDouble matrix[3][3],
+ SpiceDouble axis [3],
+ SpiceDouble * angle );
+
+
+ void rdtext_c ( ConstSpiceChar * file,
+ SpiceInt lenout,
+ SpiceChar * line,
+ SpiceBoolean * eof );
+
+
+ void reccyl_c ( ConstSpiceDouble rectan[3],
+ SpiceDouble * r,
+ SpiceDouble * lon,
+ SpiceDouble * z );
+
+
+ void recgeo_c ( ConstSpiceDouble rectan[3],
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble * lon,
+ SpiceDouble * lat,
+ SpiceDouble * alt );
+
+
+ void reclat_c ( ConstSpiceDouble rectan[3],
+ SpiceDouble * radius,
+ SpiceDouble * longitude,
+ SpiceDouble * latitude );
+
+
+ void recpgr_c ( ConstSpiceChar * body,
+ SpiceDouble rectan[3],
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble * lon,
+ SpiceDouble * lat,
+ SpiceDouble * alt );
+
+
+ void recrad_c ( ConstSpiceDouble rectan[3],
+ SpiceDouble * radius,
+ SpiceDouble * ra,
+ SpiceDouble * dec );
+
+
+
+ void reordc_c ( ConstSpiceInt * iorder,
+ SpiceInt ndim,
+ SpiceInt lenvals,
+ void * array );
+
+
+ void reordd_c ( ConstSpiceInt * iorder,
+ SpiceInt ndim,
+ SpiceDouble * array );
+
+
+ void reordi_c ( ConstSpiceInt * iorder,
+ SpiceInt ndim,
+ SpiceInt * array );
+
+
+ void reordl_c ( ConstSpiceInt * iorder,
+ SpiceInt ndim,
+ SpiceBoolean * array );
+
+
+ void removc_c ( ConstSpiceChar * item,
+ SpiceCell * set );
+
+
+ void removd_c ( SpiceDouble item,
+ SpiceCell * set );
+
+
+ void removi_c ( SpiceInt item,
+ SpiceCell * set );
+
+
+ void repmc_c ( ConstSpiceChar * in,
+ ConstSpiceChar * marker,
+ ConstSpiceChar * value,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void repmct_c ( ConstSpiceChar * in,
+ ConstSpiceChar * marker,
+ SpiceInt value,
+ SpiceChar strCase,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void repmd_c ( ConstSpiceChar * in,
+ ConstSpiceChar * marker,
+ SpiceDouble value,
+ SpiceInt sigdig,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void repmf_c ( ConstSpiceChar * in,
+ ConstSpiceChar * marker,
+ SpiceDouble value,
+ SpiceInt sigdig,
+ SpiceChar format,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void repmi_c ( ConstSpiceChar * in,
+ ConstSpiceChar * marker,
+ SpiceInt value,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void repmot_c ( ConstSpiceChar * in,
+ ConstSpiceChar * marker,
+ SpiceInt value,
+ SpiceChar strCase,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void reset_c ( void );
+
+
+ SpiceBoolean return_c ( void );
+
+
+ void recsph_c ( ConstSpiceDouble rectan[3],
+ SpiceDouble * r,
+ SpiceDouble * colat,
+ SpiceDouble * lon );
+
+
+ void rotate_c ( SpiceDouble angle,
+ SpiceInt iaxis,
+ SpiceDouble mout[3][3] );
+
+
+ void rotmat_c ( ConstSpiceDouble m1[3][3],
+ SpiceDouble angle,
+ SpiceInt iaxis,
+ SpiceDouble mout[3][3] );
+
+
+ void rotvec_c ( ConstSpiceDouble v1[3],
+ SpiceDouble angle,
+ SpiceInt iaxis,
+ SpiceDouble vout[3] );
+
+
+ SpiceDouble rpd_c ( void );
+
+
+ void rquad_c ( SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ SpiceDouble root1[2],
+ SpiceDouble root2[2] );
+
+
+ void saelgv_c ( ConstSpiceDouble vec1 [3],
+ ConstSpiceDouble vec2 [3],
+ SpiceDouble smajor[3],
+ SpiceDouble sminor[3] );
+
+
+ void scard_c ( SpiceInt card,
+ SpiceCell * cell );
+
+
+ void scdecd_c ( SpiceInt sc,
+ SpiceDouble sclkdp,
+ SpiceInt sclklen,
+ SpiceChar * sclkch );
+
+
+ void sce2s_c ( SpiceInt sc,
+ SpiceDouble et,
+ SpiceInt sclklen,
+ SpiceChar * sclkch );
+
+
+ void sce2c_c ( SpiceInt sc,
+ SpiceDouble et,
+ SpiceDouble * sclkdp );
+
+
+ void sce2t_c ( SpiceInt sc,
+ SpiceDouble et,
+ SpiceDouble * sclkdp );
+
+
+ void scencd_c ( SpiceInt sc,
+ ConstSpiceChar * sclkch,
+ SpiceDouble * sclkdp );
+
+
+ void scfmt_c ( SpiceInt sc,
+ SpiceDouble ticks,
+ SpiceInt clkstrlen,
+ SpiceChar * clkstr );
+
+
+ void scpart_c ( SpiceInt sc,
+ SpiceInt * nparts,
+ SpiceDouble * pstart,
+ SpiceDouble * pstop );
+
+
+ void scs2e_c ( SpiceInt sc,
+ ConstSpiceChar * sclkch,
+ SpiceDouble * et );
+
+
+ void sct2e_c ( SpiceInt sc,
+ SpiceDouble sclkdp,
+ SpiceDouble * et );
+
+
+ void sctiks_c ( SpiceInt sc,
+ ConstSpiceChar * clkstr,
+ SpiceDouble * ticks );
+
+
+ void sdiff_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ SpiceBoolean set_c ( SpiceCell * a,
+ ConstSpiceChar * op,
+ SpiceCell * b );
+
+
+ void setmsg_c ( ConstSpiceChar * msg );
+
+
+ void shellc_c ( SpiceInt ndim,
+ SpiceInt lenvals,
+ void * array );
+
+
+ void shelld_c ( SpiceInt ndim,
+ SpiceDouble * array );
+
+
+ void shelli_c ( SpiceInt ndim,
+ SpiceInt * array );
+
+
+ void sigerr_c ( ConstSpiceChar * message );
+
+
+ void sincpt_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * fixref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * dref,
+ ConstSpiceDouble dvec [3],
+ SpiceDouble spoint [3],
+ SpiceDouble * trgepc,
+ SpiceDouble srfvec [3],
+ SpiceBoolean * found );
+
+
+ SpiceInt size_c ( SpiceCell * size );
+
+
+ SpiceDouble spd_c ( void );
+
+
+ void sphcyl_c ( SpiceDouble radius,
+ SpiceDouble colat,
+ SpiceDouble slon,
+ SpiceDouble * r,
+ SpiceDouble * lon,
+ SpiceDouble * z );
+
+
+ void sphlat_c ( SpiceDouble r,
+ SpiceDouble colat,
+ SpiceDouble lons,
+ SpiceDouble * radius,
+ SpiceDouble * lon,
+ SpiceDouble * lat );
+
+
+ void sphrec_c ( SpiceDouble r,
+ SpiceDouble colat,
+ SpiceDouble lon,
+ SpiceDouble rectan[3] );
+
+
+ void spk14a_c ( SpiceInt handle,
+ SpiceInt ncsets,
+ ConstSpiceDouble coeffs [],
+ ConstSpiceDouble epochs [] );
+
+
+ void spk14b_c ( SpiceInt handle,
+ ConstSpiceChar * segid,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ SpiceInt chbdeg );
+
+
+ void spk14e_c ( SpiceInt handle );
+
+
+ void spkapo_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceDouble sobs[6],
+ ConstSpiceChar * abcorr,
+ SpiceDouble ptarg[3],
+ SpiceDouble * lt );
+
+
+ void spkapp_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceDouble sobs [6],
+ ConstSpiceChar * abcorr,
+ SpiceDouble starg [6],
+ SpiceDouble * lt );
+
+
+ void spkcls_c ( SpiceInt handle );
+
+
+ void spkcov_c ( ConstSpiceChar * spk,
+ SpiceInt idcode,
+ SpiceCell * cover );
+
+
+ void spkacs_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * abcorr,
+ SpiceInt obs,
+ SpiceDouble starg[6],
+ SpiceDouble * lt,
+ SpiceDouble * dlt );
+
+
+ void spkaps_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceDouble stobs[6],
+ ConstSpiceDouble accobs[6],
+ SpiceDouble starg[6],
+ SpiceDouble * lt,
+ SpiceDouble * dlt );
+
+
+ void spkez_c ( SpiceInt target,
+ SpiceDouble epoch,
+ ConstSpiceChar * frame,
+ ConstSpiceChar * abcorr,
+ SpiceInt observer,
+ SpiceDouble state[6],
+ SpiceDouble * lt );
+
+
+ void spkezp_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * abcorr,
+ SpiceInt obs,
+ SpiceDouble ptarg[3],
+ SpiceDouble * lt );
+
+
+ void spkezr_c ( ConstSpiceChar * target,
+ SpiceDouble epoch,
+ ConstSpiceChar * frame,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * observer,
+ SpiceDouble state[6],
+ SpiceDouble * lt );
+
+
+ void spkgeo_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ SpiceInt obs,
+ SpiceDouble state[6],
+ SpiceDouble * lt );
+
+
+ void spkgps_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ SpiceInt obs,
+ SpiceDouble pos[3],
+ SpiceDouble * lt );
+
+
+ void spklef_c ( ConstSpiceChar * filename,
+ SpiceInt * handle );
+
+
+ void spkltc_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceDouble stobs[6],
+ SpiceDouble starg[6],
+ SpiceDouble * lt,
+ SpiceDouble * dlt );
+
+
+ void spkobj_c ( ConstSpiceChar * spk,
+ SpiceCell * ids );
+
+
+ void spkopa_c ( ConstSpiceChar * file,
+ SpiceInt * handle );
+
+
+ void spkopn_c ( ConstSpiceChar * name,
+ ConstSpiceChar * ifname,
+ SpiceInt ncomch,
+ SpiceInt * handle );
+
+
+ void spkpds_c ( SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceInt type,
+ SpiceDouble first,
+ SpiceDouble last,
+ SpiceDouble descr[5] );
+
+
+ void spkpos_c ( ConstSpiceChar * targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obs,
+ SpiceDouble ptarg[3],
+ SpiceDouble * lt );
+
+
+ void spkssb_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ SpiceDouble starg[6] );
+
+
+ void spksub_c ( SpiceInt handle,
+ SpiceDouble descr[5],
+ ConstSpiceChar * ident,
+ SpiceDouble begin,
+ SpiceDouble end,
+ SpiceInt newh );
+
+
+ void spkuds_c ( ConstSpiceDouble descr [5],
+ SpiceInt * body,
+ SpiceInt * center,
+ SpiceInt * frame,
+ SpiceInt * type,
+ SpiceDouble * first,
+ SpiceDouble * last,
+ SpiceInt * begin,
+ SpiceInt * end );
+
+
+ void spkuef_c ( SpiceInt handle );
+
+
+ void spkw02_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceDouble intlen,
+ SpiceInt n,
+ SpiceInt polydg,
+ ConstSpiceDouble cdata [],
+ SpiceDouble btime );
+
+
+ void spkw03_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceDouble intlen,
+ SpiceInt n,
+ SpiceInt polydg,
+ ConstSpiceDouble cdata [],
+ SpiceDouble btime );
+
+
+ void spkw05_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceDouble gm,
+ SpiceInt n,
+ ConstSpiceDouble states [][6],
+ ConstSpiceDouble epochs [] );
+
+
+ void spkw08_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceInt degree,
+ SpiceInt n,
+ ConstSpiceDouble states[][6],
+ SpiceDouble epoch1,
+ SpiceDouble step );
+
+
+ void spkw09_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceInt degree,
+ SpiceInt n,
+ ConstSpiceDouble states[][6],
+ ConstSpiceDouble epochs[] );
+
+
+ void spkw10_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ ConstSpiceDouble consts [8],
+ SpiceInt n,
+ ConstSpiceDouble elems [],
+ ConstSpiceDouble epochs [] );
+
+
+ void spkw12_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceInt degree,
+ SpiceInt n,
+ ConstSpiceDouble states[][6],
+ SpiceDouble epoch0,
+ SpiceDouble step );
+
+
+ void spkw13_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceInt degree,
+ SpiceInt n,
+ ConstSpiceDouble states[][6],
+ ConstSpiceDouble epochs[] );
+
+
+ void spkw15_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceDouble epoch,
+ ConstSpiceDouble tp [3],
+ ConstSpiceDouble pa [3],
+ SpiceDouble p,
+ SpiceDouble ecc,
+ SpiceDouble j2flg,
+ ConstSpiceDouble pv [3],
+ SpiceDouble gm,
+ SpiceDouble j2,
+ SpiceDouble radius );
+
+
+ void spkw17_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceDouble epoch,
+ ConstSpiceDouble eqel [9],
+ SpiceDouble rapol,
+ SpiceDouble decpol );
+
+
+ void spkw18_c ( SpiceInt handle,
+ SpiceSPK18Subtype subtyp,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceInt degree,
+ SpiceInt n,
+ const void * packts,
+ ConstSpiceDouble epochs[] );
+
+
+ void srfrec_c ( SpiceInt body,
+ SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble rectan[3] );
+
+
+ void srfxpt_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * dref,
+ ConstSpiceDouble dvec [3],
+ SpiceDouble spoint [3],
+ SpiceDouble * dist,
+ SpiceDouble * trgepc,
+ SpiceDouble obspos [3],
+ SpiceBoolean * found );
+
+
+ void ssize_c ( SpiceInt size,
+ SpiceCell * cell );
+
+
+ void stelab_c ( ConstSpiceDouble pobj[3],
+ ConstSpiceDouble vobs[3],
+ SpiceDouble appobj[3] );
+
+
+ void stpool_c ( ConstSpiceChar * item,
+ SpiceInt nth,
+ ConstSpiceChar * contin,
+ SpiceInt lenout,
+ SpiceChar * string,
+ SpiceInt * size,
+ SpiceBoolean * found );
+
+
+ void str2et_c ( ConstSpiceChar * date,
+ SpiceDouble * et );
+
+
+ void subpnt_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * fixref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble spoint [3],
+ SpiceDouble * trgepc,
+ SpiceDouble srfvec [3] );
+
+
+ void subpt_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble spoint [3],
+ SpiceDouble * alt );
+
+
+ void subslr_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * fixref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble spoint [3],
+ SpiceDouble * trgepc,
+ SpiceDouble srfvec [3] );
+
+
+ void subsol_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble spoint[3] );
+
+
+ SpiceDouble sumad_c ( ConstSpiceDouble array[],
+ SpiceInt n );
+
+
+ SpiceInt sumai_c ( ConstSpiceInt array[],
+ SpiceInt n );
+
+
+ void surfnm_c ( SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ ConstSpiceDouble point[3],
+ SpiceDouble normal[3] );
+
+
+ void surfpt_c ( ConstSpiceDouble positn[3],
+ ConstSpiceDouble u[3],
+ SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ SpiceDouble point[3],
+ SpiceBoolean * found );
+
+
+ void surfpv_c ( ConstSpiceDouble stvrtx[6],
+ ConstSpiceDouble stdir [6],
+ SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ SpiceDouble stx [6],
+ SpiceBoolean * found );
+
+
+ void swpool_c ( ConstSpiceChar * agent,
+ SpiceInt nnames,
+ SpiceInt lenvals,
+ const void * names );
+
+
+ void sxform_c ( ConstSpiceChar * from,
+ ConstSpiceChar * to,
+ SpiceDouble et,
+ SpiceDouble xform[6][6] );
+
+
+ void szpool_c ( ConstSpiceChar * name,
+ SpiceInt * n,
+ SpiceBoolean * found );
+
+
+ void timdef_c ( ConstSpiceChar * action,
+ ConstSpiceChar * item,
+ SpiceInt lenout,
+ SpiceChar * value );
+
+
+ void timout_c ( SpiceDouble et,
+ ConstSpiceChar * pictur,
+ SpiceInt lenout,
+ SpiceChar * output );
+
+
+ void tipbod_c ( ConstSpiceChar * ref,
+ SpiceInt body,
+ SpiceDouble et,
+ SpiceDouble tipm[3][3] );
+
+
+ void tisbod_c ( ConstSpiceChar * ref,
+ SpiceInt body,
+ SpiceDouble et,
+ SpiceDouble tsipm[6][6] );
+
+
+ ConstSpiceChar * tkvrsn_c ( ConstSpiceChar * item );
+
+
+ void tparse_c ( ConstSpiceChar * string,
+ SpiceInt lenout,
+ SpiceDouble * sp2000,
+ SpiceChar * errmsg );
+
+
+ void tpictr_c ( ConstSpiceChar * sample,
+ SpiceInt lenpictur,
+ SpiceInt lenerror,
+ SpiceChar * pictur,
+ SpiceBoolean * ok,
+ SpiceChar * error );
+
+
+ SpiceDouble trace_c ( ConstSpiceDouble matrix[3][3] );
+
+
+ void trcoff_c ( void );
+
+
+ void tsetyr_c ( SpiceInt year );
+
+
+ SpiceDouble twopi_c ( void );
+
+
+ void twovec_c ( ConstSpiceDouble axdef [3],
+ SpiceInt indexa,
+ ConstSpiceDouble plndef [3],
+ SpiceInt indexp,
+ SpiceDouble mout [3][3] );
+
+
+ SpiceDouble tyear_c ( void );
+
+
+ void ucase_c ( SpiceChar * in,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void ucrss_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3],
+ SpiceDouble vout[3] );
+
+
+ void uddc_c ( void ( * udfunc ) ( SpiceDouble x,
+ SpiceDouble * value ),
+
+ SpiceDouble x,
+ SpiceDouble dx,
+ SpiceBoolean * isdecr );
+
+
+ void uddf_c ( void ( * udfunc ) ( SpiceDouble x,
+ SpiceDouble * value ),
+ SpiceDouble x,
+ SpiceDouble dx,
+ SpiceDouble * deriv );
+
+
+ void union_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ SpiceDouble unitim_c ( SpiceDouble epoch,
+ ConstSpiceChar * insys,
+ ConstSpiceChar * outsys );
+
+
+ void unload_c ( ConstSpiceChar * file );
+
+
+ void unorm_c ( ConstSpiceDouble v1[3],
+ SpiceDouble vout[3],
+ SpiceDouble * vmag );
+
+
+ void unormg_c ( ConstSpiceDouble * v1,
+ SpiceInt ndim,
+ SpiceDouble * vout,
+ SpiceDouble * vmag );
+
+
+ void utc2et_c ( ConstSpiceChar * utcstr,
+ SpiceDouble * et );
+
+
+ void vadd_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3],
+ SpiceDouble vout[3] ) ;
+
+
+ void vaddg_c ( ConstSpiceDouble * v1,
+ ConstSpiceDouble * v2,
+ SpiceInt ndim,
+ SpiceDouble * vout );
+
+
+ void valid_c ( SpiceInt size,
+ SpiceInt n,
+ SpiceCell * a );
+
+
+ void vcrss_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3],
+ SpiceDouble vout[3] );
+
+
+ SpiceDouble vdist_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3] );
+
+
+ SpiceDouble vdistg_c ( ConstSpiceDouble * v1,
+ ConstSpiceDouble * v2,
+ SpiceInt ndim );
+
+
+ SpiceDouble vdot_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3] );
+
+ SpiceDouble vdotg_c ( ConstSpiceDouble * v1,
+ ConstSpiceDouble * v2,
+ SpiceInt ndim );
+
+ void vequ_c ( ConstSpiceDouble vin[3],
+ SpiceDouble vout[3] );
+
+
+ void vequg_c ( ConstSpiceDouble * vin,
+ SpiceInt ndim,
+ SpiceDouble * vout );
+
+
+ void vhat_c ( ConstSpiceDouble v1 [3],
+ SpiceDouble vout[3] );
+
+
+ void vhatg_c ( ConstSpiceDouble * v1,
+ SpiceInt ndim,
+ SpiceDouble * vout );
+
+
+ void vlcom_c ( SpiceDouble a,
+ ConstSpiceDouble v1[3],
+ SpiceDouble b,
+ ConstSpiceDouble v2[3],
+ SpiceDouble sum[3] );
+
+
+ void vlcom3_c ( SpiceDouble a,
+ ConstSpiceDouble v1[3],
+ SpiceDouble b,
+ ConstSpiceDouble v2[3],
+ SpiceDouble c,
+ ConstSpiceDouble v3[3],
+ SpiceDouble sum[3] );
+
+
+ void vlcomg_c ( SpiceInt n,
+ SpiceDouble a,
+ ConstSpiceDouble * v1,
+ SpiceDouble b,
+ ConstSpiceDouble * v2,
+ SpiceDouble * sum );
+
+
+ void vminug_c ( ConstSpiceDouble * vin,
+ SpiceInt ndim,
+ SpiceDouble * vout );
+
+
+ void vminus_c ( ConstSpiceDouble v1[3],
+ SpiceDouble vout[3] );
+
+
+ SpiceDouble vnorm_c ( ConstSpiceDouble v1[3] );
+
+
+ SpiceDouble vnormg_c ( ConstSpiceDouble * v1,
+ SpiceInt ndim );
+
+
+ void vpack_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble v[3] );
+
+
+ void vperp_c ( ConstSpiceDouble a[3],
+ ConstSpiceDouble b[3],
+ SpiceDouble p[3] );
+
+
+ void vprjp_c ( ConstSpiceDouble vin [3],
+ ConstSpicePlane * plane,
+ SpiceDouble vout [3] );
+
+
+ void vprjpi_c ( ConstSpiceDouble vin [3],
+ ConstSpicePlane * projpl,
+ ConstSpicePlane * invpl,
+ SpiceDouble vout [3],
+ SpiceBoolean * found );
+
+
+ void vproj_c ( ConstSpiceDouble a[3],
+ ConstSpiceDouble b[3],
+ SpiceDouble p[3] );
+
+
+ SpiceDouble vrel_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3] );
+
+
+ SpiceDouble vrelg_c ( ConstSpiceDouble * v1,
+ ConstSpiceDouble * v2,
+ SpiceInt ndim );
+
+
+ void vrotv_c ( ConstSpiceDouble v[3],
+ ConstSpiceDouble axis[3],
+ SpiceDouble theta,
+ SpiceDouble r[3] );
+
+
+ void vscl_c ( SpiceDouble s,
+ ConstSpiceDouble v1[3],
+ SpiceDouble vout[3] );
+
+
+ void vsclg_c ( SpiceDouble s,
+ ConstSpiceDouble * v1,
+ SpiceInt ndim,
+ SpiceDouble * vout );
+
+
+ SpiceDouble vsep_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3] );
+
+
+ void vsub_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3],
+ SpiceDouble vout[3] );
+
+
+ void vsubg_c ( ConstSpiceDouble * v1,
+ ConstSpiceDouble * v2,
+ SpiceInt ndim,
+ SpiceDouble * vout );
+
+
+ SpiceDouble vsepg_c ( ConstSpiceDouble * v1,
+ ConstSpiceDouble * v2,
+ SpiceInt ndim );
+
+
+ SpiceDouble vtmv_c ( ConstSpiceDouble v1 [3],
+ ConstSpiceDouble matrix [3][3],
+ ConstSpiceDouble v2 [3] );
+
+
+ SpiceDouble vtmvg_c ( const void * v1,
+ const void * matrix,
+ const void * v2,
+ SpiceInt nrow,
+ SpiceInt ncol );
+
+
+ void vupack_c ( ConstSpiceDouble v[3],
+ SpiceDouble * x,
+ SpiceDouble * y,
+ SpiceDouble * z );
+
+ SpiceBoolean vzero_c ( ConstSpiceDouble v[3] );
+
+
+ SpiceBoolean vzerog_c ( ConstSpiceDouble * v,
+ SpiceInt ndim );
+
+ SpiceInt wncard_c ( SpiceCell * window );
+
+ void wncomd_c ( SpiceDouble left,
+ SpiceDouble right,
+ SpiceCell * window,
+ SpiceCell * result );
+
+
+ void wncond_c ( SpiceDouble left,
+ SpiceDouble right,
+ SpiceCell * window );
+
+
+ void wndifd_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ SpiceBoolean wnelmd_c ( SpiceDouble point,
+ SpiceCell * window );
+
+
+ void wnexpd_c ( SpiceDouble left,
+ SpiceDouble right,
+ SpiceCell * window );
+
+
+ void wnextd_c ( SpiceChar side,
+ SpiceCell * window );
+
+
+ void wnfetd_c ( SpiceCell * window,
+ SpiceInt n,
+ SpiceDouble * left,
+ SpiceDouble * right );
+
+
+ void wnfild_c ( SpiceDouble sml,
+ SpiceCell * window );
+
+
+ void wnfltd_c ( SpiceDouble sml,
+ SpiceCell * window );
+
+
+ SpiceBoolean wnincd_c ( SpiceDouble left,
+ SpiceDouble right,
+ SpiceCell * window );
+
+
+ void wninsd_c ( SpiceDouble left,
+ SpiceDouble right,
+ SpiceCell * window );
+
+
+ void wnintd_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ SpiceBoolean wnreld_c ( SpiceCell * a,
+ ConstSpiceChar * op,
+ SpiceCell * b );
+
+
+ void wnsumd_c ( SpiceCell * window,
+ SpiceDouble * meas,
+ SpiceDouble * avg,
+ SpiceDouble * stddev,
+ SpiceInt * shortest,
+ SpiceInt * longest );
+
+
+ void wnunid_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ void wnvald_c ( SpiceInt size,
+ SpiceInt n,
+ SpiceCell * window );
+
+
+
+ void xf2eul_c ( ConstSpiceDouble xform [6][6],
+ SpiceInt axisa,
+ SpiceInt axisb,
+ SpiceInt axisc,
+ SpiceDouble eulang [6],
+ SpiceBoolean * unique );
+
+
+ void xf2rav_c ( ConstSpiceDouble xform [6][6],
+ SpiceDouble rot [3][3],
+ SpiceDouble av [3] );
+
+
+ void xpose_c ( ConstSpiceDouble m1 [3][3],
+ SpiceDouble mout[3][3] );
+
+
+ void xpose6_c ( ConstSpiceDouble m1 [6][6],
+ SpiceDouble mout[6][6] );
+
+
+ void xposeg_c ( const void * matrix,
+ SpiceInt nrow,
+ SpiceInt ncol,
+ void * xposem );
+
+
+ void zzgetcml_c( SpiceInt * argc,
+ SpiceChar *** argv,
+ SpiceBoolean init );
+
+
+ SpiceBoolean zzgfgeth_c ( void );
+
+
+ void zzgfsavh_c( SpiceBoolean status );
+
+
+ void zzsynccl_c( SpiceTransDir xdir,
+ SpiceCell * cell );
+
+
+#endif
diff --git a/ext/spice/include/SpiceZst.h b/ext/spice/include/SpiceZst.h
new file mode 100644
index 0000000000..ba48b16c1c
--- /dev/null
+++ b/ext/spice/include/SpiceZst.h
@@ -0,0 +1,199 @@
+/*
+
+-Header_File SpiceZst.h ( Fortran/C string conversion utilities )
+
+-Abstract
+
+ Define prototypes for CSPICE Fortran/C string conversion utilities.
+
+ Caution: these prototypes are subject to revision without notice.
+
+ These are private routines and are not part of the official CSPICE
+ user interface.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 6.0.0, 10-JUL-2002 (NJB)
+
+ Added prototype for new functions C2F_MapStrArr and
+ C2F_MapFixStrArr.
+
+ -CSPICE Version 5.0.0, 18-MAY-2001 (WLT)
+
+ Added #ifdef's to add namespace specification for C++ compilation.
+
+ -CSPICE Version 4.0.0, 14-FEB-2000 (NJB)
+
+ Added prototype for new function C2F_CreateStrArr_Sig.
+
+ -CSPICE Version 3.0.0, 12-JUL-1999 (NJB)
+
+ Added prototype for function C2F_CreateFixStrArr.
+ Added prototype for function F2C_ConvertTrStrArr.
+ Removed reference in comments to C2F_CreateStrArr_Sig, which
+ does not exist.
+
+ -CSPICE Version 2.0.1, 06-MAR-1998 (NJB)
+
+ Type SpiceVoid was changed to void.
+
+ -CSPICE Version 2.0.1, 09-FEB-1998 (EDW)
+
+ Added prototype for F2C_ConvertStrArr.
+
+ -CSPICE Version 2.0.0, 04-JAN-1998 (NJB)
+
+ Added prototype for F2C_ConvertStr.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB) (KRG) (EDW)
+
+-Index_Entries
+
+ protoypes of CSPICE Fortran/C string conversion utilities
+
+*/
+
+#include
+#include
+#include "SpiceZdf.h"
+
+#ifndef HAVE_FCSTRINGS_H
+#define HAVE_FCSTRINGS_H
+
+#ifdef __cplusplus
+namespace Jpl_NAIF_CSpice {
+#endif
+
+ SpiceStatus C2F_CreateStr ( ConstSpiceChar *,
+ SpiceInt *,
+ SpiceChar ** );
+
+ void C2F_CreateStr_Sig ( ConstSpiceChar *,
+ SpiceInt *,
+ SpiceChar ** );
+
+ void C2F_CreateFixStrArr ( SpiceInt nStr,
+ SpiceInt cStrDim,
+ ConstSpiceChar ** cStrArr,
+ SpiceInt * fStrLen,
+ SpiceChar ** fStrArr );
+
+ SpiceStatus C2F_CreateStrArr ( SpiceInt,
+ ConstSpiceChar **,
+ SpiceInt *,
+ SpiceChar ** );
+
+ void C2F_CreateStrArr_Sig ( SpiceInt nStr,
+ ConstSpiceChar ** cStrArr,
+ SpiceInt * fStrLen,
+ SpiceChar ** fStrArr );
+
+ void C2F_MapFixStrArr ( ConstSpiceChar * caller,
+ SpiceInt nStr,
+ SpiceInt cStrLen,
+ const void * cStrArr,
+ SpiceInt * fStrLen,
+ SpiceChar ** fStrArr );
+
+ void C2F_MapStrArr ( ConstSpiceChar * caller,
+ SpiceInt nStr,
+ SpiceInt cStrLen,
+ const void * cStrArr,
+ SpiceInt * fStrLen,
+ SpiceChar ** fStrArr );
+
+ SpiceStatus C2F_StrCpy ( ConstSpiceChar *,
+ SpiceInt,
+ SpiceChar * );
+
+ void F_Alloc ( SpiceInt,
+ SpiceChar** );
+
+ void F2C_ConvertStr ( SpiceInt,
+ SpiceChar * );
+
+ void F2C_ConvertStrArr ( SpiceInt n,
+ SpiceInt lenout,
+ SpiceChar * cvals );
+
+ void F2C_ConvertTrStrArr ( SpiceInt n,
+ SpiceInt lenout,
+ SpiceChar * cvals );
+
+ SpiceStatus F2C_CreateStr ( SpiceInt,
+ ConstSpiceChar *,
+ SpiceChar ** );
+
+ void F2C_CreateStr_Sig ( SpiceInt,
+ ConstSpiceChar *,
+ SpiceChar ** );
+
+ SpiceStatus F2C_CreateStrArr ( SpiceInt,
+ SpiceInt,
+ ConstSpiceChar *,
+ SpiceChar *** );
+
+ void F2C_CreateStrArr_Sig ( SpiceInt,
+ SpiceInt,
+ ConstSpiceChar *,
+ SpiceChar *** );
+
+ void F2C_FreeStrArr ( SpiceChar **cStrArr );
+
+
+ SpiceStatus F2C_StrCpy ( SpiceInt,
+ ConstSpiceChar *,
+ SpiceInt,
+ SpiceChar * );
+
+ SpiceInt F_StrLen ( SpiceInt,
+ ConstSpiceChar * );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/ext/spice/include/f2c.h b/ext/spice/include/f2c.h
new file mode 100644
index 0000000000..079fdaf490
--- /dev/null
+++ b/ext/spice/include/f2c.h
@@ -0,0 +1,654 @@
+/*
+
+-Header_File f2c.h ( CSPICE version of the f2c standard header file )
+
+-Abstract
+
+ Perform standard f2c declarations, customized for the host
+ environment.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ The standard f2c header file f2c.h must be included by every function
+ generated by running f2c on Fortran source code. The header f2c.h
+ includes typedefs used to provide a level of indirection in mapping
+ Fortran data types to native C data types. For example, Fortran
+ INTEGER variables are mapped to variables of type integer, where
+ integer is a C typedef. In the standard f2c.h header, the typedef
+ integer translates to the C type long.
+
+ Because the standard version of f2c.h does not work on all platforms,
+ this header file contains two platform-dependent versions of it,
+ meant to be selected at build time via precompiler switches. The
+ precompiler switches reference macros defined in SpiceZpl.h to
+ determine for which host platform the code is targeted. The first
+ version of f2c.h, which works on most platforms, is copied directly
+ from the standard version of f2c.h. The second version is intended
+ for use on the DEC Alpha running Digital Unix and the Sun/Solaris
+ platform using 64 bit mode and running gcc. On those systems, longs
+ occupy 8 bytes, as do doubles. Because the Fortran standard requires
+ that INTEGERS occupy half the storage of DOUBLE PRECISION numbers,
+ INTEGERS should be mapped to 4-byte ints rather than 8-byte longs
+ on the platforms having 8-byte longs. In order to achieve this, the
+ header f2c.h was transformed using the sed command
+
+ sed 's/long //' f2c.h
+
+ The high-level structure of this file is then:
+
+ # if ( defined(CSPICE_ALPHA_DIGITAL_UNIX ) \
+ || defined(CSPICE_SUN_SOLARIS_64BIT_GCC ) )
+
+
+ [ Alpha/Digital Unix and Sun Solaris 64 bit mode/gcc
+ version of f2c.h source code ]
+
+ # else
+
+ [ Standard version of f2c.h source code ]
+
+ # endif
+
+
+-Restrictions
+
+ 1) This header file must be updated whenever the f2c processor
+ or the f2c libraries libI77 and libF77 are updated.
+
+ 2) This header may need to be updated to support new platforms.
+ The supported platforms at the time of the 31-JAN-1999 release
+ are:
+
+ ALPHA-DIGITAL-UNIX
+ HP
+ NEXT
+ PC-LINUX
+ PC-MS
+ SGI-IRIX-N32
+ SGI-IRIX-NO2
+ SUN-SOLARIS
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ B.V. Semenov (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 4.1.0, 14-MAY-2010 (EDW)(BVS)
+
+ Updated for:
+
+ MAC-OSX-64BIT-INTEL_C
+ SUN-SOLARIS-64BIT-NATIVE_C
+ SUN-SOLARIS-INTEL-64BIT-CC_C
+
+ environments. Added the corresponding tags:
+
+ CSPICE_MAC_OSX_INTEL_64BIT_GCC
+ CSPICE_SUN_SOLARIS_64BIT_NATIVE
+ CSPICE_SUN_SOLARIS_INTEL_64BIT_CC
+
+ tag to the #ifdefs set.
+
+ -CSPICE Version 4.0.0, 21-FEB-2006 (NJB)
+
+ Updated to support the PC Linux 64 bit mode/gcc platform.
+
+ -CSPICE Version 3.0.0, 27-JAN-2003 (NJB)
+
+ Updated to support the Sun Solaris 64 bit mode/gcc platform.
+
+ -CSPICE Version 2.0.0, 19-DEC-2001 (NJB)
+
+ Updated to support linking CSPICE into executables that
+ also link in objects compiled from Fortran, in particular
+ ones that perform Fortran I/O. To enable this odd mix,
+ one defines the preprocessor flag
+
+ MIX_C_AND_FORTRAN
+
+ This macro is undefined by default, since the action it invokes
+ is usually not desirable. See the header
+
+ f2cMang.h
+
+ for further information.
+
+ -CSPICE Version 1.0.0, 07-FEB-1999 (NJB)
+
+*/
+
+
+ /*
+ Optionally include name-mangling macros for f2c external symbols.
+ */
+ #ifdef MIX_C_AND_FORTRAN
+ #include "f2cMang.h"
+ #endif
+
+
+ /*
+ Include CSPICE platform macro definitions.
+ */
+ #include "SpiceZpl.h"
+
+
+#if ( defined(CSPICE_ALPHA_DIGITAL_UNIX ) \
+ || defined(CSPICE_SUN_SOLARIS_64BIT_GCC ) \
+ || defined(CSPICE_SUN_SOLARIS_64BIT_NATIVE ) \
+ || defined(CSPICE_MAC_OSX_INTEL_64BIT_GCC ) \
+ || defined(CSPICE_SUN_SOLARIS_INTEL_64BIT_CC ) \
+ || defined(CSPICE_PC_LINUX_64BIT_GCC ) )
+
+
+ /*
+ MODIFICATION
+
+ The following code is intended to be used on the platforms where
+ a long is the size of a double and an int is half the
+ size of a double.
+
+ Note that the comment line below indicating that the header is
+ "Standard" has been retained from the original, but is no longer
+ true.
+ */
+
+
+
+
+
+/* f2c.h -- Standard Fortran to C header file */
+
+#ifndef F2C_INCLUDE
+#define F2C_INCLUDE
+
+typedef int integer;
+typedef unsigned uinteger;
+typedef char *address;
+typedef short int shortint;
+typedef float real;
+typedef double doublereal;
+typedef struct { real r, i; } complex;
+typedef struct { doublereal r, i; } doublecomplex;
+typedef int logical;
+typedef short int shortlogical;
+typedef char logical1;
+typedef char integer1;
+#if 0 /* Adjust for integer*8. */
+typedef long longint; /* system-dependent */
+typedef unsigned long ulongint; /* system-dependent */
+#define qbit_clear(a,b) ((a) & ~((ulongint)1 << (b)))
+#define qbit_set(a,b) ((a) | ((ulongint)1 << (b)))
+#endif
+
+#define TRUE_ (1)
+#define FALSE_ (0)
+
+/* Extern is for use with -E */
+#ifndef Extern
+#define Extern extern
+#endif
+
+/* I/O stuff */
+
+#ifdef f2c_i2
+/* for -i2 */
+typedef short flag;
+typedef short ftnlen;
+typedef short ftnint;
+#else
+typedef int flag;
+typedef int ftnlen;
+typedef int ftnint;
+#endif
+
+/*external read, write*/
+typedef struct
+{ flag cierr;
+ ftnint ciunit;
+ flag ciend;
+ char *cifmt;
+ ftnint cirec;
+} cilist;
+
+/*internal read, write*/
+typedef struct
+{ flag icierr;
+ char *iciunit;
+ flag iciend;
+ char *icifmt;
+ ftnint icirlen;
+ ftnint icirnum;
+} icilist;
+
+/*open*/
+typedef struct
+{ flag oerr;
+ ftnint ounit;
+ char *ofnm;
+ ftnlen ofnmlen;
+ char *osta;
+ char *oacc;
+ char *ofm;
+ ftnint orl;
+ char *oblnk;
+} olist;
+
+/*close*/
+typedef struct
+{ flag cerr;
+ ftnint cunit;
+ char *csta;
+} cllist;
+
+/*rewind, backspace, endfile*/
+typedef struct
+{ flag aerr;
+ ftnint aunit;
+} alist;
+
+/* inquire */
+typedef struct
+{ flag inerr;
+ ftnint inunit;
+ char *infile;
+ ftnlen infilen;
+ ftnint *inex; /*parameters in standard's order*/
+ ftnint *inopen;
+ ftnint *innum;
+ ftnint *innamed;
+ char *inname;
+ ftnlen innamlen;
+ char *inacc;
+ ftnlen inacclen;
+ char *inseq;
+ ftnlen inseqlen;
+ char *indir;
+ ftnlen indirlen;
+ char *infmt;
+ ftnlen infmtlen;
+ char *inform;
+ ftnint informlen;
+ char *inunf;
+ ftnlen inunflen;
+ ftnint *inrecl;
+ ftnint *innrec;
+ char *inblank;
+ ftnlen inblanklen;
+} inlist;
+
+#define VOID void
+
+union Multitype { /* for multiple entry points */
+ integer1 g;
+ shortint h;
+ integer i;
+ /* longint j; */
+ real r;
+ doublereal d;
+ complex c;
+ doublecomplex z;
+ };
+
+typedef union Multitype Multitype;
+
+/*typedef int Long;*/ /* No longer used; formerly in Namelist */
+
+struct Vardesc { /* for Namelist */
+ char *name;
+ char *addr;
+ ftnlen *dims;
+ int type;
+ };
+typedef struct Vardesc Vardesc;
+
+struct Namelist {
+ char *name;
+ Vardesc **vars;
+ int nvars;
+ };
+typedef struct Namelist Namelist;
+
+#define abs(x) ((x) >= 0 ? (x) : -(x))
+#define dabs(x) (doublereal)abs(x)
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+#define dmin(a,b) (doublereal)min(a,b)
+#define dmax(a,b) (doublereal)max(a,b)
+#define bit_test(a,b) ((a) >> (b) & 1)
+#define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
+#define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
+
+/* procedure parameter types for -A and -C++ */
+
+#define F2C_proc_par_types 1
+#ifdef __cplusplus
+typedef int /* Unknown procedure type */ (*U_fp)(...);
+typedef shortint (*J_fp)(...);
+typedef integer (*I_fp)(...);
+typedef real (*R_fp)(...);
+typedef doublereal (*D_fp)(...), (*E_fp)(...);
+typedef /* Complex */ VOID (*C_fp)(...);
+typedef /* Double Complex */ VOID (*Z_fp)(...);
+typedef logical (*L_fp)(...);
+typedef shortlogical (*K_fp)(...);
+typedef /* Character */ VOID (*H_fp)(...);
+typedef /* Subroutine */ int (*S_fp)(...);
+#else
+typedef int /* Unknown procedure type */ (*U_fp)();
+typedef shortint (*J_fp)();
+typedef integer (*I_fp)();
+typedef real (*R_fp)();
+typedef doublereal (*D_fp)(), (*E_fp)();
+typedef /* Complex */ VOID (*C_fp)();
+typedef /* Double Complex */ VOID (*Z_fp)();
+typedef logical (*L_fp)();
+typedef shortlogical (*K_fp)();
+typedef /* Character */ VOID (*H_fp)();
+typedef /* Subroutine */ int (*S_fp)();
+#endif
+/* E_fp is for real functions when -R is not specified */
+typedef VOID C_f; /* complex function */
+typedef VOID H_f; /* character function */
+typedef VOID Z_f; /* double complex function */
+typedef doublereal E_f; /* real function with -R not specified */
+
+/* undef any lower-case symbols that your C compiler predefines, e.g.: */
+
+#ifndef Skip_f2c_Undefs
+#undef cray
+#undef gcos
+#undef mc68010
+#undef mc68020
+#undef mips
+#undef pdp11
+#undef sgi
+#undef sparc
+#undef sun
+#undef sun2
+#undef sun3
+#undef sun4
+#undef u370
+#undef u3b
+#undef u3b2
+#undef u3b5
+#undef unix
+#undef vax
+#endif
+#endif
+
+
+ /*
+ This marks the end of the MODIFICATION section version of f2c.h.
+ */
+
+#else
+
+ /*
+ The following code is the standard f2c.h header. In this
+ header, an "integer" is defined to be of type long.
+
+ Because the code is copied verbatim, it does not follow the usual
+ CSPICE indentation pattern.
+ */
+
+
+/* f2c.h -- Standard Fortran to C header file */
+
+
+#ifndef F2C_INCLUDE
+#define F2C_INCLUDE
+
+typedef long int integer;
+typedef unsigned long uinteger;
+typedef char *address;
+typedef short int shortint;
+typedef float real;
+typedef double doublereal;
+typedef struct { real r, i; } complex;
+typedef struct { doublereal r, i; } doublecomplex;
+typedef long int logical;
+typedef short int shortlogical;
+typedef char logical1;
+typedef char integer1;
+#if 0 /* Adjust for integer*8. */
+typedef long long longint; /* system-dependent */
+typedef unsigned long long ulongint; /* system-dependent */
+#define qbit_clear(a,b) ((a) & ~((ulongint)1 << (b)))
+#define qbit_set(a,b) ((a) | ((ulongint)1 << (b)))
+#endif
+
+#define TRUE_ (1)
+#define FALSE_ (0)
+
+/* Extern is for use with -E */
+#ifndef Extern
+#define Extern extern
+#endif
+
+/* I/O stuff */
+
+#ifdef f2c_i2
+/* for -i2 */
+typedef short flag;
+typedef short ftnlen;
+typedef short ftnint;
+#else
+typedef long int flag;
+typedef long int ftnlen;
+typedef long int ftnint;
+#endif
+
+/*external read, write*/
+typedef struct
+{ flag cierr;
+ ftnint ciunit;
+ flag ciend;
+ char *cifmt;
+ ftnint cirec;
+} cilist;
+
+/*internal read, write*/
+typedef struct
+{ flag icierr;
+ char *iciunit;
+ flag iciend;
+ char *icifmt;
+ ftnint icirlen;
+ ftnint icirnum;
+} icilist;
+
+/*open*/
+typedef struct
+{ flag oerr;
+ ftnint ounit;
+ char *ofnm;
+ ftnlen ofnmlen;
+ char *osta;
+ char *oacc;
+ char *ofm;
+ ftnint orl;
+ char *oblnk;
+} olist;
+
+/*close*/
+typedef struct
+{ flag cerr;
+ ftnint cunit;
+ char *csta;
+} cllist;
+
+/*rewind, backspace, endfile*/
+typedef struct
+{ flag aerr;
+ ftnint aunit;
+} alist;
+
+/* inquire */
+typedef struct
+{ flag inerr;
+ ftnint inunit;
+ char *infile;
+ ftnlen infilen;
+ ftnint *inex; /*parameters in standard's order*/
+ ftnint *inopen;
+ ftnint *innum;
+ ftnint *innamed;
+ char *inname;
+ ftnlen innamlen;
+ char *inacc;
+ ftnlen inacclen;
+ char *inseq;
+ ftnlen inseqlen;
+ char *indir;
+ ftnlen indirlen;
+ char *infmt;
+ ftnlen infmtlen;
+ char *inform;
+ ftnint informlen;
+ char *inunf;
+ ftnlen inunflen;
+ ftnint *inrecl;
+ ftnint *innrec;
+ char *inblank;
+ ftnlen inblanklen;
+} inlist;
+
+#define VOID void
+
+union Multitype { /* for multiple entry points */
+ integer1 g;
+ shortint h;
+ integer i;
+ /* longint j; */
+ real r;
+ doublereal d;
+ complex c;
+ doublecomplex z;
+ };
+
+typedef union Multitype Multitype;
+
+/*typedef long int Long;*/ /* No longer used; formerly in Namelist */
+
+struct Vardesc { /* for Namelist */
+ char *name;
+ char *addr;
+ ftnlen *dims;
+ int type;
+ };
+typedef struct Vardesc Vardesc;
+
+struct Namelist {
+ char *name;
+ Vardesc **vars;
+ int nvars;
+ };
+typedef struct Namelist Namelist;
+
+#define abs(x) ((x) >= 0 ? (x) : -(x))
+#define dabs(x) (doublereal)abs(x)
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+#define dmin(a,b) (doublereal)min(a,b)
+#define dmax(a,b) (doublereal)max(a,b)
+#define bit_test(a,b) ((a) >> (b) & 1)
+#define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
+#define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
+
+/* procedure parameter types for -A and -C++ */
+
+#define F2C_proc_par_types 1
+#ifdef __cplusplus
+typedef int /* Unknown procedure type */ (*U_fp)(...);
+typedef shortint (*J_fp)(...);
+typedef integer (*I_fp)(...);
+typedef real (*R_fp)(...);
+typedef doublereal (*D_fp)(...), (*E_fp)(...);
+typedef /* Complex */ VOID (*C_fp)(...);
+typedef /* Double Complex */ VOID (*Z_fp)(...);
+typedef logical (*L_fp)(...);
+typedef shortlogical (*K_fp)(...);
+typedef /* Character */ VOID (*H_fp)(...);
+typedef /* Subroutine */ int (*S_fp)(...);
+#else
+typedef int /* Unknown procedure type */ (*U_fp)();
+typedef shortint (*J_fp)();
+typedef integer (*I_fp)();
+typedef real (*R_fp)();
+typedef doublereal (*D_fp)(), (*E_fp)();
+typedef /* Complex */ VOID (*C_fp)();
+typedef /* Double Complex */ VOID (*Z_fp)();
+typedef logical (*L_fp)();
+typedef shortlogical (*K_fp)();
+typedef /* Character */ VOID (*H_fp)();
+typedef /* Subroutine */ int (*S_fp)();
+#endif
+/* E_fp is for real functions when -R is not specified */
+typedef VOID C_f; /* complex function */
+typedef VOID H_f; /* character function */
+typedef VOID Z_f; /* double complex function */
+typedef doublereal E_f; /* real function with -R not specified */
+
+/* undef any lower-case symbols that your C compiler predefines, e.g.: */
+
+#ifndef Skip_f2c_Undefs
+#undef cray
+#undef gcos
+#undef mc68010
+#undef mc68020
+#undef mips
+#undef pdp11
+#undef sgi
+#undef sparc
+#undef sun
+#undef sun2
+#undef sun3
+#undef sun4
+#undef u370
+#undef u3b
+#undef u3b2
+#undef u3b5
+#undef unix
+#undef vax
+#endif
+#endif
+
+
+ #endif
+
diff --git a/ext/spice/include/f2cMang.h b/ext/spice/include/f2cMang.h
new file mode 100644
index 0000000000..f18fded688
--- /dev/null
+++ b/ext/spice/include/f2cMang.h
@@ -0,0 +1,390 @@
+/*
+
+-Header_File f2cMang.h ( f2c external symbol mangling )
+
+-Abstract
+
+ Define macros that mangle the external symbols in the f2c F77 and I77
+ libraries.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header supports linking CSPICE into executables that
+ also link in objects compiled from Fortran, in particular
+ ones that perform Fortran I/O. To enable this odd mix,
+ one defines the preprocessor flag
+
+ MIX_C_AND_FORTRAN
+
+ This macro is undefined by default, since the action it invokes
+ is usually not desirable. When the flag is defined, this header
+ defines macros that mangle the f2c library external symbols:
+ the symbol
+
+ xxx
+
+ gets mapped to
+
+ xxx_f2c
+
+ This mangling prevents name collisions between the f2c
+ implementations of the F77 and I77 library routines and those
+ in the corresponding Fortran libraries on a host system.
+
+ The set of external symbols defined in the f2c libraries can
+ be determined by combining objects from both F77 and I77 into
+ a single Unix archive libarary, then running the Unix utility
+ nm on the that archive. If available, an nm option that selects
+ only external symbols should be invoked.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ 1) It is recommended that use of the features implemented by this
+ header be avoided if at all possible. There are robustness and
+ portability problems associated with linking Fortran and C objects
+ together in one executable.
+
+ 2) When f2c external symbol name mangling is invoked, objects
+ derived from C code translated from Fortran by f2c won't
+ link against CSPICE any longer, if these objects reference
+ the standard f2c external symbols.
+
+ 3) The features implemented by this header have been tested only
+ under the Sun Solaris GCC, Sun Solaris native ANSI C, and
+ PC/Linux/gcc environments.
+
+-Version
+
+ -CSPICE Version 2.0.1, 07-MAR-2009 (NJB)
+
+ Restrictions header section was updated to note successful
+ testing on the PC/Linux/gcc platform.
+
+ -CSPICE Version 2.0.0, 19-DEC-2001 (NJB)
+
+*/
+
+
+ /*
+ Define masking macros for f2c external symbols.
+ */
+ #ifdef MIX_C_AND_FORTRAN
+
+ /*
+ Define the macros only once, if they need to be defined.
+ */
+ #ifndef F2C_MANGLING_DONE
+
+ #define F77_aloc F77_aloc_f2c
+ #define F_err F_err_f2c
+ #define L_len L_len_f2c
+ #define abort_ abort__f2c
+ #define b_char b_char_f2c
+ #define c_abs c_abs_f2c
+ #define c_cos c_cos_f2c
+ #define c_dfe c_dfe_f2c
+ #define c_div c_div_f2c
+ #define c_due c_due_f2c
+ #define c_exp c_exp_f2c
+ #define c_le c_le_f2c
+ #define c_log c_log_f2c
+ #define c_sfe c_sfe_f2c
+ #define c_si c_si_f2c
+ #define c_sin c_sin_f2c
+ #define c_sqrt c_sqrt_f2c
+ #define c_sue c_sue_f2c
+ #define d_abs d_abs_f2c
+ #define d_acos d_acos_f2c
+ #define d_asin d_asin_f2c
+ #define d_atan d_atan_f2c
+ #define d_atn2 d_atn2_f2c
+ #define d_cnjg d_cnjg_f2c
+ #define d_cos d_cos_f2c
+ #define d_cosh d_cosh_f2c
+ #define d_dim d_dim_f2c
+ #define d_exp d_exp_f2c
+ #define d_imag d_imag_f2c
+ #define d_int d_int_f2c
+ #define d_lg10 d_lg10_f2c
+ #define d_log d_log_f2c
+ #define d_mod d_mod_f2c
+ #define d_nint d_nint_f2c
+ #define d_prod d_prod_f2c
+ #define d_sign d_sign_f2c
+ #define d_sin d_sin_f2c
+ #define d_sinh d_sinh_f2c
+ #define d_sqrt d_sqrt_f2c
+ #define d_tan d_tan_f2c
+ #define d_tanh d_tanh_f2c
+ #define derf_ derf__f2c
+ #define derfc_ derfc__f2c
+ #define do_fio do_fio_f2c
+ #define do_lio do_lio_f2c
+ #define do_ud do_ud_f2c
+ #define do_uio do_uio_f2c
+ #define do_us do_us_f2c
+ #define dtime_ dtime__f2c
+ #define e_rdfe e_rdfe_f2c
+ #define e_rdue e_rdue_f2c
+ #define e_rsfe e_rsfe_f2c
+ #define e_rsfi e_rsfi_f2c
+ #define e_rsle e_rsle_f2c
+ #define e_rsli e_rsli_f2c
+ #define e_rsue e_rsue_f2c
+ #define e_wdfe e_wdfe_f2c
+ #define e_wdue e_wdue_f2c
+ #define e_wsfe e_wsfe_f2c
+ #define e_wsfi e_wsfi_f2c
+ #define e_wsle e_wsle_f2c
+ #define e_wsli e_wsli_f2c
+ #define e_wsue e_wsue_f2c
+ #define ef1asc_ ef1asc__f2c
+ #define ef1cmc_ ef1cmc__f2c
+ #define en_fio en_fio_f2c
+ #define erf_ erf__f2c
+ #define erfc_ erfc__f2c
+ #define err__fl err__fl_f2c
+ #define etime_ etime__f2c
+ #define exit_ exit__f2c
+ #define f__Aquote f__Aquote_f2c
+ #define f__buflen f__buflen_f2c
+ #define f__cabs f__cabs_f2c
+ #define f__canseek f__canseek_f2c
+ #define f__cblank f__cblank_f2c
+ #define f__cf f__cf_f2c
+ #define f__cnt f__cnt_f2c
+ #define f__cp f__cp_f2c
+ #define f__cplus f__cplus_f2c
+ #define f__cursor f__cursor_f2c
+ #define f__curunit f__curunit_f2c
+ #define f__doed f__doed_f2c
+ #define f__doend f__doend_f2c
+ #define f__doned f__doned_f2c
+ #define f__donewrec f__donewrec_f2c
+ #define f__dorevert f__dorevert_f2c
+ #define f__elist f__elist_f2c
+ #define f__external f__external_f2c
+ #define f__fatal f__fatal_f2c
+ #define f__fmtbuf f__fmtbuf_f2c
+ #define f__formatted f__formatted_f2c
+ #define f__getn f__getn_f2c
+ #define f__hiwater f__hiwater_f2c
+ #define f__icend f__icend_f2c
+ #define f__icnum f__icnum_f2c
+ #define f__icptr f__icptr_f2c
+ #define f__icvt f__icvt_f2c
+ #define f__init f__init_f2c
+ #define f__inode f__inode_f2c
+ #define f__lchar f__lchar_f2c
+ #define f__lcount f__lcount_f2c
+ #define f__lioproc f__lioproc_f2c
+ #define f__lquit f__lquit_f2c
+ #define f__ltab f__ltab_f2c
+ #define f__ltype f__ltype_f2c
+ #define f__lx f__lx_f2c
+ #define f__ly f__ly_f2c
+ #define f__nonl f__nonl_f2c
+ #define f__nowreading f__nowreading_f2c
+ #define f__nowwriting f__nowwriting_f2c
+ #define f__parenlvl f__parenlvl_f2c
+ #define f__pc f__pc_f2c
+ #define f__putbuf f__putbuf_f2c
+ #define f__putn f__putn_f2c
+ #define f__r_mode f__r_mode_f2c
+ #define f__reading f__reading_f2c
+ #define f__reclen f__reclen_f2c
+ #define f__recloc f__recloc_f2c
+ #define f__recpos f__recpos_f2c
+ #define f__ret f__ret_f2c
+ #define f__revloc f__revloc_f2c
+ #define f__rp f__rp_f2c
+ #define f__scale f__scale_f2c
+ #define f__sequential f__sequential_f2c
+ #define f__svic f__svic_f2c
+ #define f__typesize f__typesize_f2c
+ #define f__units f__units_f2c
+ #define f__w_mode f__w_mode_f2c
+ #define f__workdone f__workdone_f2c
+ #define f_back f_back_f2c
+ #define f_clos f_clos_f2c
+ #define f_end f_end_f2c
+ #define f_exit f_exit_f2c
+ #define f_init f_init_f2c
+ #define f_inqu f_inqu_f2c
+ #define f_open f_open_f2c
+ #define f_rew f_rew_f2c
+ #define fk_open fk_open_f2c
+ #define flush_ flush__f2c
+ #define fmt_bg fmt_bg_f2c
+ #define fseek_ fseek__f2c
+ #define ftell_ ftell__f2c
+ #define g_char g_char_f2c
+ #define getenv_ getenv__f2c
+ #define h_abs h_abs_f2c
+ #define h_dim h_dim_f2c
+ #define h_dnnt h_dnnt_f2c
+ #define h_indx h_indx_f2c
+ #define h_len h_len_f2c
+ #define h_mod h_mod_f2c
+ #define h_nint h_nint_f2c
+ #define h_sign h_sign_f2c
+ #define hl_ge hl_ge_f2c
+ #define hl_gt hl_gt_f2c
+ #define hl_le hl_le_f2c
+ #define hl_lt hl_lt_f2c
+ #define i_abs i_abs_f2c
+ #define i_dim i_dim_f2c
+ #define i_dnnt i_dnnt_f2c
+ #define i_indx i_indx_f2c
+ #define i_len i_len_f2c
+ #define i_mod i_mod_f2c
+ #define i_nint i_nint_f2c
+ #define i_sign i_sign_f2c
+ #define iw_rev iw_rev_f2c
+ #define l_eof l_eof_f2c
+ #define l_ge l_ge_f2c
+ #define l_getc l_getc_f2c
+ #define l_gt l_gt_f2c
+ #define l_le l_le_f2c
+ #define l_lt l_lt_f2c
+ #define l_read l_read_f2c
+ #define l_ungetc l_ungetc_f2c
+ #define l_write l_write_f2c
+ #define lbit_bits lbit_bits_f2c
+ #define lbit_cshift lbit_cshift_f2c
+ #define lbit_shift lbit_shift_f2c
+ #define mk_hashtab mk_hashtab_f2c
+ #define nml_read nml_read_f2c
+ #define pars_f pars_f_f2c
+ #define pow_ci pow_ci_f2c
+ #define pow_dd pow_dd_f2c
+ #define pow_di pow_di_f2c
+ #define pow_hh pow_hh_f2c
+ #define pow_ii pow_ii_f2c
+ #define pow_ri pow_ri_f2c
+ #define pow_zi pow_zi_f2c
+ #define pow_zz pow_zz_f2c
+ #define r_abs r_abs_f2c
+ #define r_acos r_acos_f2c
+ #define r_asin r_asin_f2c
+ #define r_atan r_atan_f2c
+ #define r_atn2 r_atn2_f2c
+ #define r_cnjg r_cnjg_f2c
+ #define r_cos r_cos_f2c
+ #define r_cosh r_cosh_f2c
+ #define r_dim r_dim_f2c
+ #define r_exp r_exp_f2c
+ #define r_imag r_imag_f2c
+ #define r_int r_int_f2c
+ #define r_lg10 r_lg10_f2c
+ #define r_log r_log_f2c
+ #define r_mod r_mod_f2c
+ #define r_nint r_nint_f2c
+ #define r_sign r_sign_f2c
+ #define r_sin r_sin_f2c
+ #define r_sinh r_sinh_f2c
+ #define r_sqrt r_sqrt_f2c
+ #define r_tan r_tan_f2c
+ #define r_tanh r_tanh_f2c
+ #define rd_ed rd_ed_f2c
+ #define rd_ned rd_ned_f2c
+ #define s_cat s_cat_f2c
+ #define s_cmp s_cmp_f2c
+ #define s_copy s_copy_f2c
+ #define s_paus s_paus_f2c
+ #define s_rdfe s_rdfe_f2c
+ #define s_rdue s_rdue_f2c
+ #define s_rnge s_rnge_f2c
+ #define s_rsfe s_rsfe_f2c
+ #define s_rsfi s_rsfi_f2c
+ #define s_rsle s_rsle_f2c
+ #define s_rsli s_rsli_f2c
+ #define s_rsne s_rsne_f2c
+ #define s_rsni s_rsni_f2c
+ #define s_rsue s_rsue_f2c
+ #define s_stop s_stop_f2c
+ #define s_wdfe s_wdfe_f2c
+ #define s_wdue s_wdue_f2c
+ #define s_wsfe s_wsfe_f2c
+ #define s_wsfi s_wsfi_f2c
+ #define s_wsle s_wsle_f2c
+ #define s_wsli s_wsli_f2c
+ #define s_wsne s_wsne_f2c
+ #define s_wsni s_wsni_f2c
+ #define s_wsue s_wsue_f2c
+ #define sig_die sig_die_f2c
+ #define signal_ signal__f2c
+ #define system_ system__f2c
+ #define t_getc t_getc_f2c
+ #define t_runc t_runc_f2c
+ #define w_ed w_ed_f2c
+ #define w_ned w_ned_f2c
+ #define wrt_E wrt_E_f2c
+ #define wrt_F wrt_F_f2c
+ #define wrt_L wrt_L_f2c
+ #define x_endp x_endp_f2c
+ #define x_getc x_getc_f2c
+ #define x_putc x_putc_f2c
+ #define x_rev x_rev_f2c
+ #define x_rsne x_rsne_f2c
+ #define x_wSL x_wSL_f2c
+ #define x_wsne x_wsne_f2c
+ #define xrd_SL xrd_SL_f2c
+ #define y_getc y_getc_f2c
+ #define y_rsk y_rsk_f2c
+ #define z_abs z_abs_f2c
+ #define z_cos z_cos_f2c
+ #define z_div z_div_f2c
+ #define z_exp z_exp_f2c
+ #define z_getc z_getc_f2c
+ #define z_log z_log_f2c
+ #define z_putc z_putc_f2c
+ #define z_rnew z_rnew_f2c
+ #define z_sin z_sin_f2c
+ #define z_sqrt z_sqrt_f2c
+ #define z_wnew z_wnew_f2c
+
+ #define F2C_MANGLING_DONE
+
+ #endif
+
+
+ #endif
+
diff --git a/ext/spice/include/fio.h b/ext/spice/include/fio.h
new file mode 100644
index 0000000000..bb20dd2ca0
--- /dev/null
+++ b/ext/spice/include/fio.h
@@ -0,0 +1,107 @@
+#include "stdio.h"
+#include "errno.h"
+#ifndef NULL
+/* ANSI C */
+#include "stddef.h"
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#ifdef MSDOS
+#ifndef NON_UNIX_STDIO
+#define NON_UNIX_STDIO
+#endif
+#endif
+
+#ifdef UIOLEN_int
+typedef int uiolen;
+#else
+typedef long uiolen;
+#endif
+
+/*units*/
+typedef struct
+{ FILE *ufd; /*0=unconnected*/
+ char *ufnm;
+#ifndef MSDOS
+ long uinode;
+ int udev;
+#endif
+ int url; /*0=sequential*/
+ flag useek; /*true=can backspace, use dir, ...*/
+ flag ufmt;
+ flag urw; /* (1 for can read) | (2 for can write) */
+ flag ublnk;
+ flag uend;
+ flag uwrt; /*last io was write*/
+ flag uscrtch;
+} unit;
+
+extern flag f__init;
+extern cilist *f__elist; /*active external io list*/
+extern flag f__reading,f__external,f__sequential,f__formatted;
+#undef Void
+#ifdef KR_headers
+#define Void /*void*/
+extern int (*f__getn)(); /* for formatted input */
+extern void (*f__putn)(); /* for formatted output */
+extern void x_putc();
+extern long f__inode();
+extern VOID sig_die();
+extern int (*f__donewrec)(), t_putc(), x_wSL();
+extern int c_sfe(), err__fl(), xrd_SL(), f__putbuf();
+#else
+#define Void void
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int (*f__getn)(void); /* for formatted input */
+extern void (*f__putn)(int); /* for formatted output */
+extern void x_putc(int);
+extern long f__inode(char*,int*);
+extern void sig_die(char*,int);
+extern void f__fatal(int,char*);
+extern int t_runc(alist*);
+extern int f__nowreading(unit*), f__nowwriting(unit*);
+extern int fk_open(int,int,ftnint);
+extern int en_fio(void);
+extern void f_init(void);
+extern int (*f__donewrec)(void), t_putc(int), x_wSL(void);
+extern void b_char(char*,char*,ftnlen), g_char(char*,ftnlen,char*);
+extern int c_sfe(cilist*), z_rnew(void);
+extern int isatty(int);
+extern int err__fl(int,int,char*);
+extern int xrd_SL(void);
+extern int f__putbuf(int);
+#ifdef __cplusplus
+ }
+#endif
+#endif
+extern int (*f__doend)(Void);
+extern FILE *f__cf; /*current file*/
+extern unit *f__curunit; /*current unit*/
+extern unit f__units[];
+#define err(f,m,s) {if(f) errno= m; else f__fatal(m,s); return(m);}
+#define errfl(f,m,s) return err__fl((int)f,m,s)
+
+/*Table sizes*/
+#define MXUNIT 100
+
+extern int f__recpos; /*position in current record*/
+extern int f__cursor; /* offset to move to */
+extern int f__hiwater; /* so TL doesn't confuse us */
+
+#define WRITE 1
+#define READ 2
+#define SEQ 3
+#define DIR 4
+#define FMT 5
+#define UNF 6
+#define EXT 7
+#define INT 8
+
+#define buf_end(x) (x->_flag & _IONBF ? x->_ptr : x->_base + BUFSIZ)
diff --git a/ext/spice/include/fmt.h b/ext/spice/include/fmt.h
new file mode 100644
index 0000000000..19065a2f04
--- /dev/null
+++ b/ext/spice/include/fmt.h
@@ -0,0 +1,100 @@
+struct syl
+{ int op;
+ int p1;
+ union { int i[2]; char *s;} p2;
+ };
+#define RET1 1
+#define REVERT 2
+#define GOTO 3
+#define X 4
+#define SLASH 5
+#define STACK 6
+#define I 7
+#define ED 8
+#define NED 9
+#define IM 10
+#define APOS 11
+#define H 12
+#define TL 13
+#define TR 14
+#define T 15
+#define COLON 16
+#define S 17
+#define SP 18
+#define SS 19
+#define P 20
+#define BN 21
+#define BZ 22
+#define F 23
+#define E 24
+#define EE 25
+#define D 26
+#define G 27
+#define GE 28
+#define L 29
+#define A 30
+#define AW 31
+#define O 32
+#define NONL 33
+#define OM 34
+#define Z 35
+#define ZM 36
+extern int f__pc,f__parenlvl,f__revloc;
+typedef union
+{ real pf;
+ doublereal pd;
+} ufloat;
+typedef union
+{ short is;
+#ifndef KR_headers
+ signed
+#endif
+ char ic;
+ integer il;
+#ifdef Allow_TYQUAD
+ longint ili;
+#endif
+} Uint;
+#ifdef KR_headers
+extern int (*f__doed)(),(*f__doned)();
+extern int (*f__dorevert)();
+extern int rd_ed(),rd_ned();
+extern int w_ed(),w_ned();
+#else
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int (*f__doed)(struct syl*, char*, ftnlen),(*f__doned)(struct syl*);
+extern int (*f__dorevert)(void);
+extern void fmt_bg(void);
+extern int pars_f(char*);
+extern int rd_ed(struct syl*, char*, ftnlen),rd_ned(struct syl*);
+extern int w_ed(struct syl*, char*, ftnlen),w_ned(struct syl*);
+extern int wrt_E(ufloat*, int, int, int, ftnlen);
+extern int wrt_F(ufloat*, int, int, ftnlen);
+extern int wrt_L(Uint*, int, ftnlen);
+#ifdef __cplusplus
+ }
+#endif
+#endif
+extern flag f__cblank,f__cplus,f__workdone, f__nonl;
+extern char *f__fmtbuf;
+extern int f__scale;
+#define GET(x) if((x=(*f__getn)())<0) return(x)
+#define VAL(x) (x!='\n'?x:' ')
+#define PUT(x) (*f__putn)(x)
+extern int f__cursor;
+
+#undef TYQUAD
+#ifndef Allow_TYQUAD
+#undef longint
+#define longint long
+#else
+#define TYQUAD 14
+#endif
+
+#ifdef KR_headers
+extern char *f__icvt();
+#else
+extern char *f__icvt(longint, int*, int*, int);
+#endif
diff --git a/ext/spice/include/fp.h b/ext/spice/include/fp.h
new file mode 100644
index 0000000000..40743d79f7
--- /dev/null
+++ b/ext/spice/include/fp.h
@@ -0,0 +1,28 @@
+#define FMAX 40
+#define EXPMAXDIGS 8
+#define EXPMAX 99999999
+/* FMAX = max number of nonzero digits passed to atof() */
+/* EXPMAX = 10^EXPMAXDIGS - 1 = largest allowed exponent absolute value */
+
+#ifdef V10 /* Research Tenth-Edition Unix */
+#include "local.h"
+#endif
+
+/* MAXFRACDIGS and MAXINTDIGS are for wrt_F -- bounds (not necessarily
+ tight) on the maximum number of digits to the right and left of
+ * the decimal point.
+ */
+
+#ifdef VAX
+#define MAXFRACDIGS 56
+#define MAXINTDIGS 38
+#else
+#ifdef CRAY
+#define MAXFRACDIGS 9880
+#define MAXINTDIGS 9864
+#else
+/* values that suffice for IEEE double */
+#define MAXFRACDIGS 344
+#define MAXINTDIGS 308
+#endif
+#endif
diff --git a/ext/spice/include/lio.h b/ext/spice/include/lio.h
new file mode 100644
index 0000000000..012317206a
--- /dev/null
+++ b/ext/spice/include/lio.h
@@ -0,0 +1,74 @@
+/* copy of ftypes from the compiler */
+/* variable types
+ * numeric assumptions:
+ * int < reals < complexes
+ * TYDREAL-TYREAL = TYDCOMPLEX-TYCOMPLEX
+ */
+
+/* 0-10 retain their old (pre LOGICAL*1, etc.) */
+/* values to allow mixing old and new objects. */
+
+#define TYUNKNOWN 0
+#define TYADDR 1
+#define TYSHORT 2
+#define TYLONG 3
+#define TYREAL 4
+#define TYDREAL 5
+#define TYCOMPLEX 6
+#define TYDCOMPLEX 7
+#define TYLOGICAL 8
+#define TYCHAR 9
+#define TYSUBR 10
+#define TYINT1 11
+#define TYLOGICAL1 12
+#define TYLOGICAL2 13
+#ifdef Allow_TYQUAD
+#undef TYQUAD
+#define TYQUAD 14
+#endif
+
+#define LINTW 24
+#define LINE 80
+#define LLOGW 2
+#ifdef Old_list_output
+#define LLOW 1.0
+#define LHIGH 1.e9
+#define LEFMT " %# .8E"
+#define LFFMT " %# .9g"
+#else
+#define LGFMT "%.9G"
+#endif
+/* LEFBL 20 should suffice; 24 overcomes a NeXT bug. */
+#define LEFBL 24
+
+typedef union
+{
+ char flchar;
+ short flshort;
+ ftnint flint;
+#ifdef Allow_TYQUAD
+ longint fllongint;
+#endif
+ real flreal;
+ doublereal fldouble;
+} flex;
+extern int f__scale;
+#ifdef KR_headers
+extern int (*f__lioproc)(), (*l_getc)(), (*l_ungetc)();
+extern int l_read(), l_write();
+#else
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int (*f__lioproc)(ftnint*, char*, ftnlen, ftnint);
+extern int l_write(ftnint*, char*, ftnlen, ftnint);
+extern void x_wsne(cilist*);
+extern int c_le(cilist*), (*l_getc)(void), (*l_ungetc)(int,FILE*);
+extern int l_read(ftnint*,char*,ftnlen,ftnint);
+extern integer e_rsle(void), e_wsle(void), s_wsne(cilist*);
+extern int z_rnew(void);
+#ifdef __cplusplus
+ }
+#endif
+#endif
+extern ftnint L_len;
diff --git a/ext/spice/include/rawio.h b/ext/spice/include/rawio.h
new file mode 100644
index 0000000000..fd36a48260
--- /dev/null
+++ b/ext/spice/include/rawio.h
@@ -0,0 +1,41 @@
+#ifndef KR_headers
+#ifdef MSDOS
+#include "io.h"
+#ifndef WATCOM
+#define close _close
+#define creat _creat
+#define open _open
+#define read _read
+#define write _write
+#endif /*WATCOM*/
+#endif /*MSDOS*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifndef MSDOS
+#ifdef OPEN_DECL
+extern int creat(const char*,int), open(const char*,int);
+#endif
+extern int close(int);
+extern int read(int,void*,size_t), write(int,void*,size_t);
+extern int unlink(const char*);
+#ifndef _POSIX_SOURCE
+#ifndef NON_UNIX_STDIO
+extern FILE *fdopen(int, const char*);
+#endif
+#endif
+#endif /*KR_HEADERS*/
+
+extern char *mktemp(char*);
+
+#ifdef __cplusplus
+ }
+#endif
+#endif
+
+#include "fcntl.h"
+
+#ifndef O_WRONLY
+#define O_RDONLY 0
+#define O_WRONLY 1
+#endif
diff --git a/ext/spice/include/signal1.h b/ext/spice/include/signal1.h
new file mode 100644
index 0000000000..360d8d0118
--- /dev/null
+++ b/ext/spice/include/signal1.h
@@ -0,0 +1,118 @@
+/*
+
+-Header_File signal1.h (CSPICE version of the f2c signal1.h header file)
+
+-Abstract
+
+ Define macros associated with signal handling, customized for the
+ host environment.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header defines the macro signal1 referenced in main.c,
+ which is a generic main routine used in CSPICE executables that
+ link to code generated by f2c.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ 1) This header file must be updated whenever the f2c processor
+ or the f2c libraries libI77 and libF77 are updated.
+
+ 2) This header may need to be updated to support new platforms.
+ The supported platforms at the time of the 03-FEB-2000 release
+ are:
+
+ ALPHA-DIGITAL-UNIX_C
+ HP_C
+ NEXT_C
+ PC-LINUX_C
+ PC-MS_C
+ SGI-IRIX-N32_C
+ SGI-IRIX-NO2_C
+ SUN-SOLARIS-GCC_C
+ SUN-SOLARIS-NATIVE_C
+
+-Version
+
+ -CSPICE Version 1.0.0, 03-FEB-2000 (NJB)
+
+*/
+
+
+
+
+/* You may need to adjust the definition of signal1 to supply a */
+/* cast to the correct argument type. This detail is system- and */
+/* compiler-dependent. The #define below assumes signal.h declares */
+/* type SIG_PF for the signal function's second argument. */
+
+#include
+
+#ifndef Sigret_t
+#define Sigret_t void
+#endif
+#ifndef Sigarg_t
+#ifdef KR_headers
+#define Sigarg_t
+#else
+#ifdef __cplusplus
+#define Sigarg_t ...
+#else
+#define Sigarg_t int
+#endif
+#endif
+#endif /*Sigarg_t*/
+
+#ifdef USE_SIG_PF /* compile with -DUSE_SIG_PF under IRIX */
+#define sig_pf SIG_PF
+#else
+typedef Sigret_t (*sig_pf)(Sigarg_t);
+#endif
+
+#define signal1(a,b) signal(a,(sig_pf)b)
+
+#ifdef __cplusplus
+#define Sigarg ...
+#define Use_Sigarg
+#else
+#define Sigarg Int n
+#define Use_Sigarg n = n /* shut up compiler warning */
+#endif
+
diff --git a/ext/spice/include/zzalloc.h b/ext/spice/include/zzalloc.h
new file mode 100644
index 0000000000..572268c8eb
--- /dev/null
+++ b/ext/spice/include/zzalloc.h
@@ -0,0 +1,125 @@
+/*
+
+-Abstract
+
+ The memory allocation prototypes and macros for use in CSPICE.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Particulars
+
+ The routines maintain a count of the number of mallocs vs. free,
+ signalling an error if any unreleased memory exists at the end
+ of an Icy interface call.
+
+ The macro ALLOC_CHECK performs malloc/free test. If used, the macro
+ should exists at the end of any routine using these memory management
+ routines.
+
+ Prototypes in this file:
+
+ alloc_count
+ zzalloc_count
+ alloc_SpiceMemory
+ alloc_SpiceString_C_array
+ alloc_SpiceString_C_Copy_array
+ alloc_SpiceDouble_C_array
+ alloc_SpiceInt_C_array
+ alloc_SpiceString
+ alloc_SpiceString_Pointer_array
+ free_SpiceString_C_array
+ free_SpiceMemory
+
+-Version
+
+ CSPICE 1.0.3 02-MAY-2008 (EDW)
+
+ Added alloc_count prototype.
+
+ CSPICE 1.0.2 10-MAY-2007 (EDW)
+
+ Minor edits to clarify 'size' in alloc_SpiceMemory as
+ size_t.
+
+ CSPICE 1.0.1 23-JUN-2005 (EDW)
+
+ Add prototype for alloc_SpiceString_Pointer_array, allocate
+ an array of pointers to SpiceChar.
+
+ Icy 1.0.0 December 19, 2003 (EDW)
+
+ Initial release.
+
+*/
+
+#ifndef ZZALLOC_H
+#define ZZALLOC_H
+
+ /*
+ Allocation call prototypes:
+ */
+ int alloc_count ();
+
+ SpiceChar ** alloc_SpiceString_C_array ( int string_length,
+ int string_count );
+
+ SpiceChar ** alloc_SpiceString_C_Copy_array ( int array_len ,
+ int string_len,
+ SpiceChar ** array );
+
+ SpiceDouble * alloc_SpiceDouble_C_array ( int rows,
+ int cols );
+
+ SpiceInt * alloc_SpiceInt_C_array ( int rows,
+ int cols );
+
+ SpiceChar * alloc_SpiceString ( int length );
+
+ SpiceChar ** alloc_SpiceString_Pointer_array( int array_len );
+
+ void free_SpiceString_C_array ( int dim,
+ SpiceChar ** array );
+
+ void * alloc_SpiceMemory ( size_t size );
+
+ void free_SpiceMemory ( void * ptr );
+
+
+ /*
+ Simple macro to ensure a zero value alloc count at end of routine.
+ Note, the need to use this macro exists only in those routines
+ allocating/deallocating memory.
+ */
+#define ALLOC_CHECK if ( alloc_count() != 0 ) \
+ { \
+ setmsg_c ( "Malloc/Free count not zero at end of routine." \
+ " Malloc count = #."); \
+ errint_c ( "#", alloc_count() ); \
+ sigerr_c ( "SPICE(MALLOCCOUNT)" ); \
+ }
+
+#endif
+
diff --git a/ext/spice/include/zzerror.h b/ext/spice/include/zzerror.h
new file mode 100644
index 0000000000..5709c667d5
--- /dev/null
+++ b/ext/spice/include/zzerror.h
@@ -0,0 +1,80 @@
+/*
+
+-Abstract
+
+ The error control routine prototypes for use in CSPICE.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Particulars
+
+ Routines prototyped in this file:
+
+ zzerrorinit
+ zzerror
+
+-Examples
+
+ See the examples section in zzerror() and zzerrorinit().
+
+-Restrictions
+
+ None.
+
+-Exceptions
+
+ None.
+
+-Files
+
+ None.
+
+-Author_and_Institution
+
+ E. D. Wright (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ CSPICE 1.0.0 17-OCT-2005 (EDW)
+
+ Initial release.
+
+*/
+
+#ifndef ZZERROR_H
+#define ZZERROR_H
+
+ const char * zzerror( long cnt );
+ void zzerrorinit();
+
+#endif
+
+
+
diff --git a/ext/spice/src/cspice/F77_aloc.c b/ext/spice/src/cspice/F77_aloc.c
new file mode 100644
index 0000000000..e8ba7442f6
--- /dev/null
+++ b/ext/spice/src/cspice/F77_aloc.c
@@ -0,0 +1,32 @@
+#include "f2c.h"
+#undef abs
+#undef min
+#undef max
+#include "stdio.h"
+
+static integer memfailure = 3;
+
+#ifdef KR_headers
+extern char *malloc();
+extern void exit_();
+
+ char *
+F77_aloc(Len, whence) integer Len; char *whence;
+#else
+#include "stdlib.h"
+extern void exit_(integer*);
+
+ char *
+F77_aloc(integer Len, char *whence)
+#endif
+{
+ char *rv;
+ unsigned int uLen = (unsigned int) Len; /* for K&R C */
+
+ if (!(rv = (char*)malloc(uLen))) {
+ fprintf(stderr, "malloc(%u) failure in %s\n",
+ uLen, whence);
+ exit_(&memfailure);
+ }
+ return rv;
+ }
diff --git a/ext/spice/src/cspice/SpiceCK.h b/ext/spice/src/cspice/SpiceCK.h
new file mode 100644
index 0000000000..894d4e9a6c
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceCK.h
@@ -0,0 +1,155 @@
+/*
+
+-Header_File SpiceCK.h ( CSPICE CK definitions )
+
+-Abstract
+
+ Perform CSPICE definitions to support CK wrapper interfaces.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header defines types that may be referenced in
+ application code that calls CSPICE CK functions.
+
+ Typedef
+ =======
+
+ Name Description
+ ---- ----------
+
+ SpiceCK05Subtype Typedef for enum indicating the
+ mathematical representation used
+ in an CK type 05 segment. Possible
+ values and meanings are:
+
+ C05TP0:
+
+ Hermite interpolation, 8-
+ element packets containing
+
+ q0, q1, q2, q3,
+ dq0/dt, dq1/dt, dq2/dt dq3/dt
+
+ where q0, q1, q2, q3 represent
+ quaternion components and dq0/dt,
+ dq1/dt, dq2/dt, dq3/dt represent
+ quaternion time derivative components.
+
+ Quaternions are unitless. Quaternion
+ time derivatives have units of
+ 1/second.
+
+
+ C05TP1:
+
+ Lagrange interpolation, 4-
+ element packets containing
+
+ q0, q1, q2, q3,
+
+ where q0, q1, q2, q3 represent
+ quaternion components. Quaternion
+ derivatives are obtained by
+ differentiating interpolating
+ polynomials.
+
+
+ C05TP2:
+
+ Hermite interpolation, 14-
+ element packets containing
+
+ q0, q1, q2, q3,
+ dq0/dt, dq1/dt, dq2/dt dq3/dt,
+ av0, av1, av2,
+ dav0/dt, dav1/dt, dav2/dt
+
+ where q0, q1, q2, q3 represent
+ quaternion components and dq0/dt,
+ dq1/dt, dq2/dt, dq3/dt represent
+ quaternion time derivative components,
+ av0, av1, av2 represent angular
+ velocity components, and
+ dav0/dt, dav1/dt, dav2/dt represent
+ angular acceleration components.
+
+
+ C05TP3:
+
+ Lagrange interpolation, 7-
+ element packets containing
+
+ q0, q1, q2, q3,
+ av0, av1, av2
+
+ where q0, q1, q2, q3 represent
+ quaternion components and
+ av0, av1, av2 represent angular
+ velocity components.
+
+
+
+Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 20-AUG-2002 (NJB)
+
+*/
+
+#ifndef HAVE_SPICE_CK_H
+
+ #define HAVE_SPICE_CK_H
+
+
+
+ /*
+ CK type 05 subtype codes:
+ */
+
+ enum _SpiceCK05Subtype { C05TP0, C05TP1, C05TP2, C05TP3 };
+
+
+ typedef enum _SpiceCK05Subtype SpiceCK05Subtype;
+
+#endif
+
diff --git a/ext/spice/src/cspice/SpiceCel.h b/ext/spice/src/cspice/SpiceCel.h
new file mode 100644
index 0000000000..7b0537e9ee
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceCel.h
@@ -0,0 +1,441 @@
+/*
+
+-Header_File SpiceCel.h ( CSPICE Cell definitions )
+
+-Abstract
+
+ Perform CSPICE definitions for the SpiceCell data type.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CELLS
+
+-Particulars
+
+ This header defines structures, macros, and enumerated types that
+ may be referenced in application code that calls CSPICE cell
+ functions.
+
+ CSPICE cells are data structures that implement functionality
+ parallel to that of the cell abstract data type in SPICELIB. In
+ CSPICE, a cell is a C structure containing bookkeeping information,
+ including a pointer to an associated data array.
+
+ For numeric data types, the data array is simply a SPICELIB-style
+ cell, including a valid control area. For character cells, the data
+ array has the same number of elements as the corresponding
+ SPICELIB-style cell, but the contents of the control area are not
+ maintained, and the data elements are null-terminated C-style
+ strings.
+
+ CSPICE cells should be declared using the declaration macros
+ provided in this header file. See the table of macros below.
+
+
+ Structures
+ ==========
+
+ Name Description
+ ---- ----------
+
+ SpiceCell Structure containing CSPICE cell metadata.
+
+ The members are:
+
+ dtype: Data type of cell: character,
+ integer, or double precision.
+
+ dtype has type
+ SpiceCellDataType.
+
+ length: For character cells, the
+ declared length of the
+ cell's string array.
+
+ size: The maximum number of data
+ items that can be stored in
+ the cell's data array.
+
+ card: The cell's "cardinality": the
+ number of data items currently
+ present in the cell.
+
+ isSet: Boolean flag indicating whether
+ the cell is a CSPICE set.
+ Sets have no duplicate data
+ items, and their data items are
+ stored in increasing order.
+
+ adjust: Boolean flag indicating whether
+ the cell's data area has
+ adjustable size. Adjustable
+ size cell data areas are not
+ currently implemented.
+
+ init: Boolean flag indicating whether
+ the cell has been initialized.
+
+ base: is a void pointer to the
+ associated data array. base
+ points to the start of the
+ control area of this array.
+
+ data: is a void pointer to the
+ first data slot in the
+ associated data array. This
+ slot is the element following
+ the control area.
+
+
+ ConstSpiceCell A const SpiceCell.
+
+
+
+
+ Declaration Macros
+ ==================
+
+ Name Description
+ ---- ----------
+
+ SPICECHAR_CELL ( name, size, length ) Declare a
+ character CSPICE
+ cell having cell
+ name name,
+ maximum cell
+ cardinality size,
+ and string length
+ length. The
+ macro declares
+ both the cell and
+ the associated
+ data array. The
+ name of the data
+ array begins with
+ "SPICE_".
+
+
+ SPICEDOUBLE_CELL ( name, size ) Like SPICECHAR_CELL,
+ but declares a
+ double precision
+ cell.
+
+
+ SPICEINT_CELL ( name, size ) Like
+ SPICECHAR_CELL,
+ but declares an
+ integer cell.
+
+ Assignment Macros
+ =================
+
+ Name Description
+ ---- ----------
+ SPICE_CELL_SET_C( item, i, cell ) Assign the ith
+ element of a
+ character cell.
+ Arguments cell
+ and item are
+ pointers.
+
+ SPICE_CELL_SET_D( item, i, cell ) Assign the ith
+ element of a
+ double precision
+ cell. Argument
+ cell is a
+ pointer.
+
+ SPICE_CELL_SET_I( item, i, cell ) Assign the ith
+ element of an
+ integer cell.
+ Argument cell is
+ a pointer.
+
+
+ Fetch Macros
+ ==============
+
+ Name Description
+ ---- ----------
+ SPICE_CELL_GET_C( cell, i, lenout, item ) Fetch the ith
+ element from a
+ character cell.
+ Arguments cell
+ and item are
+ pointers.
+ Argument lenout
+ is the available
+ space in item.
+
+ SPICE_CELL_GET_D( cell, i, item ) Fetch the ith
+ element from a
+ double precision
+ cell. Arguments
+ cell and item are
+ pointers.
+
+ SPICE_CELL_GET_I( cell, i, item ) Fetch the ith
+ element from an
+ integer cell.
+ Arguments cell
+ and item are
+ pointers.
+ Element Pointer Macros
+ ======================
+
+ Name Description
+ ---- ----------
+ SPICE_CELL_ELEM_C( cell, i ) Macro evaluates
+ to a SpiceChar
+ pointer to the
+ ith data element
+ of a character
+ cell. Argument
+ cell is a
+ pointer.
+
+ SPICE_CELL_ELEM_D( cell, i ) Macro evaluates
+ to a SpiceDouble
+ pointer to the
+ ith data element
+ of a double
+ precision cell.
+ Argument cell is
+ a pointer.
+
+ SPICE_CELL_ELEM_I( cell, i ) Macro evaluates
+ to a SpiceInt
+ pointer to the
+ ith data element
+ of an integer
+ cell. Argument
+ cell is a
+ pointer.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 22-AUG-2002 (NJB)
+
+*/
+#ifndef HAVE_SPICE_CELLS_H
+
+ #define HAVE_SPICE_CELLS_H
+
+
+ /*
+ Data type codes:
+ */
+ typedef enum _SpiceDataType SpiceCellDataType;
+
+
+ /*
+ Cell structure:
+ */
+ struct _SpiceCell
+
+ { SpiceCellDataType dtype;
+ SpiceInt length;
+ SpiceInt size;
+ SpiceInt card;
+ SpiceBoolean isSet;
+ SpiceBoolean adjust;
+ SpiceBoolean init;
+ void * base;
+ void * data; };
+
+ typedef struct _SpiceCell SpiceCell;
+
+ typedef const SpiceCell ConstSpiceCell;
+
+
+ /*
+ SpiceCell control area size:
+ */
+ #define SPICE_CELL_CTRLSZ 6
+
+
+ /*
+ Declaration macros:
+ */
+
+ #define SPICECHAR_CELL( name, size, length ) \
+ \
+ static SpiceChar SPICE_CELL_##name[SPICE_CELL_CTRLSZ + size][length]; \
+ \
+ static SpiceCell name = \
+ \
+ { SPICE_CHR, \
+ length, \
+ size, \
+ 0, \
+ SPICETRUE, \
+ SPICEFALSE, \
+ SPICEFALSE, \
+ (void *) &(SPICE_CELL_##name), \
+ (void *) &(SPICE_CELL_##name[SPICE_CELL_CTRLSZ]) }
+
+
+ #define SPICEDOUBLE_CELL( name, size ) \
+ \
+ static SpiceDouble SPICE_CELL_##name [SPICE_CELL_CTRLSZ + size]; \
+ \
+ static SpiceCell name = \
+ \
+ { SPICE_DP, \
+ 0, \
+ size, \
+ 0, \
+ SPICETRUE, \
+ SPICEFALSE, \
+ SPICEFALSE, \
+ (void *) &(SPICE_CELL_##name), \
+ (void *) &(SPICE_CELL_##name[SPICE_CELL_CTRLSZ]) }
+
+
+ #define SPICEINT_CELL( name, size ) \
+ \
+ static SpiceInt SPICE_CELL_##name [SPICE_CELL_CTRLSZ + size]; \
+ \
+ static SpiceCell name = \
+ \
+ { SPICE_INT, \
+ 0, \
+ size, \
+ 0, \
+ SPICETRUE, \
+ SPICEFALSE, \
+ SPICEFALSE, \
+ (void *) &(SPICE_CELL_##name), \
+ (void *) &(SPICE_CELL_##name[SPICE_CELL_CTRLSZ]) }
+
+
+ /*
+ Access macros for individual elements:
+ */
+
+ /*
+ Data element pointer macros:
+ */
+
+ #define SPICE_CELL_ELEM_C( cell, i ) \
+ \
+ ( ( (SpiceChar *) (cell)->data ) + (i)*( (cell)->length ) )
+
+
+ #define SPICE_CELL_ELEM_D( cell, i ) \
+ \
+ ( ( (SpiceDouble *) (cell)->data )[(i)] )
+
+
+ #define SPICE_CELL_ELEM_I( cell, i ) \
+ \
+ ( ( (SpiceInt *) (cell)->data )[(i)] )
+
+
+ /*
+ "Fetch" macros:
+ */
+
+ #define SPICE_CELL_GET_C( cell, i, lenout, item ) \
+ \
+ { \
+ SpiceInt nBytes; \
+ \
+ nBytes = brckti_c ( (cell)->length, 0, (lenout-1) ) \
+ * sizeof ( SpiceChar ); \
+ \
+ memmove ( (item), SPICE_CELL_ELEM_C((cell), (i)), nBytes ); \
+ \
+ item[nBytes] = NULLCHAR; \
+ }
+
+
+ #define SPICE_CELL_GET_D( cell, i, item ) \
+ \
+ ( (*item) = ( (SpiceDouble *) (cell)->data)[i] )
+
+
+ #define SPICE_CELL_GET_I( cell, i, item ) \
+ \
+ ( (*item) = ( (SpiceInt *) (cell)->data)[i] )
+
+
+ /*
+ Assignment macros:
+ */
+
+ #define SPICE_CELL_SET_C( item, i, cell ) \
+ \
+ { \
+ SpiceChar * sPtr; \
+ SpiceInt nBytes; \
+ \
+ nBytes = brckti_c ( strlen(item), 0, (cell)->length - 1 ) \
+ * sizeof ( SpiceChar ); \
+ \
+ sPtr = SPICE_CELL_ELEM_C((cell), (i)); \
+ \
+ memmove ( sPtr, (item), nBytes ); \
+ \
+ sPtr[nBytes] = NULLCHAR; \
+ }
+
+
+ #define SPICE_CELL_SET_D( item, i, cell ) \
+ \
+ ( ( (SpiceDouble *) (cell)->data)[i] = (item) )
+
+
+ #define SPICE_CELL_SET_I( item, i, cell ) \
+ \
+ ( ( (SpiceInt *) (cell)->data)[i] = (item) )
+
+
+ /*
+ The enum SpiceTransDir is used to indicate language translation
+ direction: C to Fortran or vice versa.
+ */
+ enum _SpiceTransDir { C2F = 0, F2C = 1 };
+
+ typedef enum _SpiceTransDir SpiceTransDir;
+
+
+#endif
+
diff --git a/ext/spice/src/cspice/SpiceEK.h b/ext/spice/src/cspice/SpiceEK.h
new file mode 100644
index 0000000000..cbe213fb01
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceEK.h
@@ -0,0 +1,448 @@
+/*
+
+-Header_File SpiceEK.h ( CSPICE EK-specific definitions )
+
+-Abstract
+
+ Perform CSPICE EK-specific definitions, including macros and user-
+ defined types.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header defines macros, enumerated types, structures, and
+ typedefs that may be referenced in application code that calls CSPICE
+ EK functions.
+
+
+ Macros
+ ======
+
+ General limits
+ --------------
+
+ Name Description
+ ---- ----------
+ SPICE_EK_MXCLSG Maximum number of columns per segment.
+
+ SPICE_EK_TYPLEN Maximum length of a short string
+ indicating a data type (one of
+ {"CHR", "DP", "INT", "TIME"}). Such
+ strings are returned by some of the
+ Fortran SPICELIB EK routines, hence also
+ by their f2c'd counterparts.
+
+ Sizes of EK objects
+ -------------------
+
+ Name Description
+ ---- ----------
+
+ SPICE_EK_CNAMSZ Maximum length of column name.
+ SPICE_EK_CSTRLN Length of string required to hold column
+ name.
+ SPICE_EK_TNAMSZ Maximum length of table name.
+ SPICE_EK_TSTRLN Length of string required to hold table
+ name.
+
+
+ Query-related limits
+ --------------------
+
+ Name Description
+ ---- ----------
+
+ SPICE_EK_MAXQRY Maximum length of an input query. This
+ value is currently equivalent to
+ twenty-five 80-character lines.
+
+ SPICE_EK_MAXQSEL Maximum number of columns that may be
+ listed in the `SELECT clause' of a query.
+
+ SPICE_EK_MAXQTAB Maximum number of tables that may be
+ listed in the `FROM clause' of a query.
+
+ SPICE_EK_MAXQCON Maximum number of relational expressions
+ that may be listed in the `constraint
+ clause' of a query.
+
+ This limit applies to a query when it is
+ represented in `normalized form': that
+ is, the constraints have been expressed
+ as a disjunction of conjunctions of
+ relational expressions. The number of
+ relational expressions in a query that
+ has been expanded in this fashion may be
+ greater than the number of relations in
+ the query as orginally written. For
+ example, the expression
+
+ ( ( A LT 1 ) OR ( B GT 2 ) )
+ AND
+ ( ( C NE 3 ) OR ( D EQ 4 ) )
+
+ which contains 4 relational expressions,
+ expands to the equivalent normalized
+ constraint
+
+ ( ( A LT 1 ) AND ( C NE 3 ) )
+ OR
+ ( ( A LT 1 ) AND ( D EQ 4 ) )
+ OR
+ ( ( B GT 2 ) AND ( C NE 3 ) )
+ OR
+ ( ( B GT 2 ) AND ( D EQ 4 ) )
+
+ which contains eight relational
+ expressions.
+
+
+
+ SPICE_EK_MAXQJOIN Maximum number of tables that can be
+ joined.
+
+ SPICE_EK_MAXQJCON Maximum number of join constraints
+ allowed.
+
+ SPICE_EK_MAXQORD Maximum number of columns that may be
+ used in the `order-by clause' of a query.
+
+ SPICE_EK_MAXQTOK Maximum number of tokens in a query.
+ Tokens
+ are reserved words, column names,
+ parentheses, and values. Literal strings
+ and time values count as single tokens.
+
+ SPICE_EK_MAXQNUM Maximum number of numeric tokens in a
+ query.
+
+ SPICE_EK_MAXQCLN Maximum total length of character tokens
+ in a query.
+
+ SPICE_EK_MAXQSTR Maximum length of literal string values
+ allowed in queries.
+
+
+ Codes
+ -----
+
+ Name Description
+ ---- ----------
+
+ SPICE_EK_VARSIZ Code used to indicate variable-size
+ objects. Usually this is used in a
+ context where a non-negative integer
+ indicates the size of a fixed-size object
+ and the presence of this code indicates a
+ variable-size object.
+
+ The value of this constant must match the
+ parameter IFALSE used in the Fortran
+ library SPICELIB.
+
+
+ Enumerated Types
+ ================
+
+ Enumerated code values
+ ----------------------
+
+ Name Description
+ ---- ----------
+ SpiceEKDataType Codes for data types used in the EK
+ interface: character, double precision,
+ integer, and "time."
+
+ The values are:
+
+ { SPICE_CHR = 0,
+ SPICE_DP = 1,
+ SPICE_INT = 2,
+ SPICE_TIME = 3 }
+
+
+
+ SpiceEKExprClass Codes for types of expressions that may
+ appear in the SELECT clause of EK
+ queries. Values and meanings are:
+
+
+ SPICE_EK_EXP_COL Selected item was a
+ column. The column
+ may qualified by a
+ table name.
+
+ SPICE_EK_EXP_FUNC Selected item was
+ a simple function
+ invocation of the
+ form
+
+ F ( )
+
+ or else was
+
+ COUNT(*)
+
+ SPICE_EK_EXP_EXPR Selected item was a
+ more general
+ expression than
+ those shown above.
+
+
+ Numeric values are:
+
+ { SPICE_EK_EXP_COL = 0,
+ SPICE_EK_EXP_FUNC = 1,
+ SPICE_EK_EXP_EXPR = 2 }
+
+
+ Structures
+ ==========
+
+ EK API structures
+ -----------------
+
+ Name Description
+ ---- ----------
+
+ SpiceEKAttDsc EK column attribute descriptor. Note
+ that this object is distinct from the EK
+ column descriptors used internally in
+ the EK routines; those descriptors
+ contain pointers as well as attribute
+ information.
+
+ The members are:
+
+ cclass: Column class code.
+
+ dtype: Data type code: has type
+ SpiceEKDataType.
+
+ strlen: String length. Applies to
+ SPICE_CHR type. Value is
+ SPICE_EK_VARSIZ for
+ variable-length strings.
+
+ size: Column entry size; this is
+ the number of array
+ elements in a column
+ entry. The value is
+ SPICE_EK_VARSIZ for
+ variable-size columns.
+
+ indexd: Index flag; value is
+ SPICETRUE if the column is
+ indexed, SPICEFALSE
+ otherwise.
+
+ nullok: Null flag; value is
+ SPICETRUE if the column
+ may contain null values,
+ SPICEFALSE otherwise.
+
+
+
+ SpiceEKSegSum EK segment summary. This structure
+ contains user interface level descriptive
+ information. The structure contains the
+ following members:
+
+ tabnam The name of the table to
+ which the segment belongs.
+
+ nrows The number of rows in the
+ segment.
+
+ ncols The number of columns in
+ the segment.
+
+ cnames An array of names of
+ columns in the segment.
+ Column names may contain
+ as many as SPICE_EK_CNAMSZ
+ characters. The array
+ contains room for
+ SPICE_EK_MXCLSG column
+ names.
+
+ cdescrs An array of column
+ attribute descriptors of
+ type SpiceEKAttDsc.
+ The array contains room
+ for SPICE_EK_MXCLSG
+ descriptors. The Ith
+ descriptor corresponds to
+ the column whose name is
+ the Ith element of the
+ array cnames.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 2.0.0 27-JUL-2002 (NJB)
+
+ Defined SpiceEKDataType using SpiceDataType. Removed declaration
+ of enum _SpiceEKDataType.
+
+ -CSPICE Version 1.0.0, 05-JUL-1999 (NJB)
+
+ Renamed _SpiceEKAttDsc member "class" to "cclass." The
+ former name is a reserved word in C++.
+
+
+ -CSPICE Version 1.0.0, 24-FEB-1999 (NJB)
+
+*/
+
+#ifndef HAVE_SPICE_EK_H
+
+ #define HAVE_SPICE_EK_H
+
+
+
+ /*
+ Constants
+ */
+
+ /*
+ Sizes of EK objects:
+ */
+
+ #define SPICE_EK_CNAMSZ 32
+ #define SPICE_EK_CSTRLN ( SPICE_EK_CNAMSZ + 1 )
+ #define SPICE_EK_TNAMSZ 64
+ #define SPICE_EK_TSTRLN ( SPICE_EK_TNAMSZ + 1 )
+
+
+
+ /*
+ Maximum number of columns per segment:
+ */
+
+ #define SPICE_EK_MXCLSG 100
+
+
+ /*
+ Maximum length of string indicating data type:
+ */
+
+ #define SPICE_EK_TYPLEN 4
+
+
+ /*
+ Query-related limits (see header for details):
+ */
+
+ #define SPICE_EK_MAXQRY 2000
+ #define SPICE_EK_MAXQSEL 50
+ #define SPICE_EK_MAXQTAB 10
+ #define SPICE_EK_MAXQCON 1000
+ #define SPICE_EK_MAXQJOIN 10
+ #define SPICE_EK_MAXQJCON 100
+ #define SPICE_EK_MAXQORD 10
+ #define SPICE_EK_MAXQTOK 500
+ #define SPICE_EK_MAXQNUM 100
+ #define SPICE_EK_MAXQCLN SPICE_EK_MAXQRY
+ #define SPICE_EK_MAXQSTR 1024
+
+
+
+ /*
+ Code indicating "variable size":
+ */
+ #define SPICE_EK_VARSIZ (-1)
+
+
+
+ /*
+ Data type codes:
+ */
+ typedef SpiceDataType SpiceEKDataType;
+
+
+
+ /*
+ SELECT clause expression type codes:
+ */
+ enum _SpiceEKExprClass{ SPICE_EK_EXP_COL = 0,
+ SPICE_EK_EXP_FUNC = 1,
+ SPICE_EK_EXP_EXPR = 2 };
+
+ typedef enum _SpiceEKExprClass SpiceEKExprClass;
+
+
+
+ /*
+ EK column attribute descriptor:
+ */
+
+ struct _SpiceEKAttDsc
+
+ { SpiceInt cclass;
+ SpiceEKDataType dtype;
+ SpiceInt strlen;
+ SpiceInt size;
+ SpiceBoolean indexd;
+ SpiceBoolean nullok; };
+
+ typedef struct _SpiceEKAttDsc SpiceEKAttDsc;
+
+
+
+ /*
+ EK segment summary:
+ */
+
+ struct _SpiceEKSegSum
+
+ { SpiceChar tabnam [SPICE_EK_TSTRLN];
+ SpiceInt nrows;
+ SpiceInt ncols;
+ SpiceChar cnames [SPICE_EK_MXCLSG][SPICE_EK_CSTRLN];
+ SpiceEKAttDsc cdescrs[SPICE_EK_MXCLSG]; };
+
+ typedef struct _SpiceEKSegSum SpiceEKSegSum;
+
+
+#endif
+
diff --git a/ext/spice/src/cspice/SpiceEll.h b/ext/spice/src/cspice/SpiceEll.h
new file mode 100644
index 0000000000..d0c123ab06
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceEll.h
@@ -0,0 +1,115 @@
+/*
+
+-Header_File SpiceEll.h ( CSPICE Ellipse definitions )
+
+-Abstract
+
+ Perform CSPICE definitions for the SpiceEllipse data type.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header defines structures and typedefs that may be referenced in
+ application code that calls CSPICE Ellipse functions.
+
+
+ Structures
+ ==========
+
+ Name Description
+ ---- ----------
+
+ SpiceEllipse Structure representing an ellipse in 3-
+ dimensional space.
+
+ The members are:
+
+ center: Vector defining ellipse's
+ center.
+
+ semiMajor: Vector defining ellipse's
+ semi-major axis.
+
+ semiMinor: Vector defining ellipse's
+ semi-minor axis.
+
+ The ellipse is the set of points
+
+ {X: X = center
+ + cos(theta) * semiMajor
+ + sin(theta) * semiMinor,
+
+ theta in [0, 2*Pi) }
+
+
+ ConstSpiceEllipse A const SpiceEllipse.
+
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 04-MAR-1999 (NJB)
+
+*/
+
+#ifndef HAVE_SPICE_ELLIPSES
+
+ #define HAVE_SPICE_ELLIPSES
+
+
+
+ /*
+ Ellipse structure:
+ */
+
+ struct _SpiceEllipse
+
+ { SpiceDouble center [3];
+ SpiceDouble semiMajor [3];
+ SpiceDouble semiMinor [3]; };
+
+ typedef struct _SpiceEllipse SpiceEllipse;
+
+ typedef const SpiceEllipse ConstSpiceEllipse;
+
+#endif
+
diff --git a/ext/spice/src/cspice/SpiceGF.h b/ext/spice/src/cspice/SpiceGF.h
new file mode 100644
index 0000000000..14d10de2fd
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceGF.h
@@ -0,0 +1,319 @@
+/*
+
+-Header_File SpiceGF.h ( CSPICE GF-specific definitions )
+
+-Abstract
+
+ Perform CSPICE GF-specific definitions.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ GF
+
+-Keywords
+
+ GEOMETRY
+ SEARCH
+
+-Exceptions
+
+ None
+
+-Files
+
+ None
+
+-Particulars
+
+ This header defines macros that may be referenced in application
+ code that calls CSPICE GF functions.
+
+
+ Macros
+ ======
+
+ Workspace parameters
+ --------------------
+
+ CSPICE applications normally don't declare workspace arguments
+ and therefore don't directly reference workspace size parameters.
+ However, CSPICE GF APIs dealing with numeric constraints
+ dynamically allocate workspace memory; the amount allocated
+ depends on the number of intervals the workspace windows can
+ hold. This amount is an input argument to the GF numeric quantity
+ APIs.
+
+ The parameters below are used to calculate the amount of memory
+ required. Each workspace window contains 6 double precision
+ numbers in its control area and 2 double precision numbers for
+ each interval it can hold.
+
+
+ Name Description
+ ---- ----------
+ SPICE_GF_NWMAX Maximum number of windows required for
+ a user-defined workspace array.
+
+ SPICE_GF_NWDIST Number of workspace windows used by
+ gfdist_c and the underlying SPICELIB
+ routine GFDIST.
+
+ SPICE_GF_NWSEP Number of workspace windows used by
+ gfsep_c and the underlying SPICELIB
+ routine GFSEP.
+
+
+
+ Field of view (FOV) parameters
+ ------------------------------
+
+ Name Description
+ ---- ----------
+ SPICE_GF_MAXVRT Maximum allowed number of boundary
+ vectors for a polygonal FOV.
+
+ SPICE_GF_CIRFOV Parameter identifying a circular FOV.
+
+ SPICE_GF_ELLFOV Parameter identifying a elliptical FOV.
+
+ SPICE_GF_POLFOV Parameter identifying a polygonal FOV.
+
+ SPICE_GF_RECFOV Parameter identifying a rectangular FOV.
+
+ SPICE_GF_SHPLEN Parameter specifying maximum length of
+ a FOV shape name.
+
+ SPICE_GF_MARGIN is a small positive number used to
+ constrain the orientation of the
+ boundary vectors of polygonal FOVs. Such
+ FOVs must satisfy the following
+ constraints:
+
+ 1) The boundary vectors must be
+ contained within a right circular
+ cone of angular radius less than
+ than (pi/2) - MARGIN radians; in
+ other words, there must be a vector
+ A such that all boundary vectors
+ have angular separation from A of
+ less than (pi/2)-MARGIN radians.
+
+ 2) There must be a pair of boundary
+ vectors U, V such that all other
+ boundary vectors lie in the same
+ half space bounded by the plane
+ containing U and V. Furthermore, all
+ other boundary vectors must have
+ orthogonal projections onto a plane
+ normal to this plane such that the
+ projections have angular separation
+ of at least 2*MARGIN radians from
+ the plane spanned by U and V.
+
+ MARGIN is currently set to 1.D-12.
+
+
+ Occultation parameters
+ ----------------------
+
+ SPICE_GF_ANNULR Parameter identifying an "annular
+ occultation." This geometric condition
+ is more commonly known as a "transit."
+ The limb of the background object must
+ not be blocked by the foreground object
+ in order for an occultation to be
+ "annular."
+
+ SPICE_GF_ANY Parameter identifying any type of
+ occultation or transit.
+
+ SPICE_GF_FULL Parameter identifying a full
+ occultation: the foreground body
+ entirely blocks the background body.
+
+ SPICE_GF_PARTL Parameter identifying an "partial
+ occultation." This is an occultation in
+ which the foreground body blocks part,
+ but not all, of the limb of the
+ background body.
+
+
+
+ Target shape parameters
+ -----------------------
+
+ SPICE_GF_EDSHAP Parameter indicating a target object's
+ shape is modeled as an ellipsoid.
+
+ SPICE_GF_PTSHAP Parameter indicating a target object's
+ shape is modeled as a point.
+
+ SPICE_GF_RYSHAP Parameter indicating a target object's
+ "shape" is modeled as a ray emanating
+ from an observer's location. This model
+ may be used in visibility computations
+ for targets whose direction, but not
+ position, relative to an observer is
+ known.
+
+ SPICE_GF_SPSHAP Parameter indicating a target object's
+ shape is modeled as a point.
+
+
+
+ Search parameters
+ -----------------
+
+ These parameters affect the manner in which GF searches are
+ performed.
+
+ SPICE_GF_ADDWIN is a parameter used in numeric quantity
+ searches that use an equality
+ constraint. This parameter is used to
+ expand the confinement window (the
+ window over which the search is
+ performed) by a small amount at both
+ ends. This expansion accommodates the
+ case where a geometric quantity is equal
+ to a reference value at a boundary point
+ of the original confinement window.
+
+ SPICE_GF_CNVTOL is the default convergence tolerance
+ used by GF routines that don't support a
+ user-supplied tolerance value. GF
+ searches for roots will terminate when a
+ root is bracketed by times separated by
+ no more than this tolerance. Units are
+ seconds.
+
+ Configuration parameter
+ -----------------------
+
+ SPICE_GFEVNT_MAXPAR Parameter indicating the maximum number of
+ elements needed for the 'qnames' and 'q*pars'
+ arrays used in gfevnt_c.
+
+ SpiceChar qcpars[SPICE_GFEVNT_MAXPAR][LNSIZE];
+ SpiceDouble qdpars[SPICE_GFEVNT_MAXPAR];
+ SpiceInt qipars[SPICE_GFEVNT_MAXPAR];
+ SpiceBoolean qlpars[SPICE_GFEVNT_MAXPAR];
+
+-Examples
+
+ None
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ L.S. Elson (JPL)
+
+-Version
+
+ -CSPICE Version 2.0.0, 23-JUN-2009 (NJB)
+
+ Added parameter for maximum length of FOV shape string.
+
+ -CSPICE Version 1.0.0, 11-MAR-2009 (NJB)
+
+*/
+
+
+#ifndef HAVE_SPICE_GF_H
+
+ #define HAVE_SPICE_GF_H
+
+
+ /*
+ See the Particulars section above for parameter descriptions.
+ */
+
+ /*
+ Workspace parameters
+ */
+ #define SPICE_GF_NWMAX 15
+ #define SPICE_GF_NWDIST 5
+ #define SPICE_GF_NWSEP 5
+
+
+ /*
+ Field of view (FOV) parameters
+ */
+ #define SPICE_GF_MAXVRT 10000
+ #define SPICE_GF_CIRFOV "CIRCLE"
+ #define SPICE_GF_ELLFOV "ELLIPSE"
+ #define SPICE_GF_POLFOV "POLYGON"
+ #define SPICE_GF_RECFOV "RECTANGLE"
+ #define SPICE_GF_SHPLEN 10
+ #define SPICE_GF_MARGIN ( 1.e-12 )
+
+
+ /*
+ Occultation parameters
+ */
+ #define SPICE_GF_ANNULR "ANNULAR"
+ #define SPICE_GF_ANY "ANY"
+ #define SPICE_GF_FULL "FULL"
+ #define SPICE_GF_PARTL "PARTIAL"
+
+
+ /*
+ Target shape parameters
+ */
+ #define SPICE_GF_EDSHAP "ELLIPSOID"
+ #define SPICE_GF_PTSHAP "POINT"
+ #define SPICE_GF_RYSHAP "RAY"
+ #define SPICE_GF_SPSHAP "SPHERE"
+
+
+ /*
+ Search parameters
+ */
+ #define SPICE_GF_ADDWIN 1.0
+ #define SPICE_GF_CNVTOL 1.e-6
+
+
+ /*
+ Configuration parameters.
+ */
+ #define SPICE_GFEVNT_MAXPAR 10
+
+
+#endif
+
+
+/*
+ End of header file SpiceGF.h
+*/
diff --git a/ext/spice/src/cspice/SpicePln.h b/ext/spice/src/cspice/SpicePln.h
new file mode 100644
index 0000000000..839fb15606
--- /dev/null
+++ b/ext/spice/src/cspice/SpicePln.h
@@ -0,0 +1,106 @@
+/*
+
+-Header_File SpicePln.h ( CSPICE Plane definitions )
+
+-Abstract
+
+ Perform CSPICE definitions for the SpicePlane data type.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header defines structures and typedefs that may be referenced in
+ application code that calls CSPICE Plane functions.
+
+
+ Structures
+ ==========
+
+ Name Description
+ ---- ----------
+
+ SpicePlane Structure representing a plane in 3-
+ dimensional space.
+
+ The members are:
+
+ normal: Vector normal to plane.
+
+ constant: Constant of plane equation
+
+ Plane =
+
+ {X: = constant}
+
+
+
+ ConstSpicePlane A const SpicePlane.
+
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 04-MAR-1999 (NJB)
+
+*/
+
+#ifndef HAVE_SPICE_PLANES
+
+ #define HAVE_SPICE_PLANES
+
+
+
+ /*
+ Plane structure:
+ */
+
+ struct _SpicePlane
+
+ { SpiceDouble normal [3];
+ SpiceDouble constant; };
+
+ typedef struct _SpicePlane SpicePlane;
+
+ typedef const SpicePlane ConstSpicePlane;
+
+#endif
+
diff --git a/ext/spice/src/cspice/SpiceSPK.h b/ext/spice/src/cspice/SpiceSPK.h
new file mode 100644
index 0000000000..a4c8eac5f7
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceSPK.h
@@ -0,0 +1,128 @@
+/*
+
+-Header_File SpiceSPK.h ( CSPICE SPK definitions )
+
+-Abstract
+
+ Perform CSPICE definitions to support SPK wrapper interfaces.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header defines types that may be referenced in
+ application code that calls CSPICE SPK functions.
+
+ Typedef
+ =======
+
+ Name Description
+ ---- ----------
+
+ SpiceSPK18Subtype Typedef for enum indicating the
+ mathematical representation used
+ in an SPK type 18 segment. Possible
+ values and meanings are:
+
+ S18TP0:
+
+ Hermite interpolation, 12-
+ element packets containing
+
+ x, y, z, dx/dt, dy/dt, dz/dt,
+ vx, vy, vz, dvx/dt, dvy/dt, dvz/dt
+
+ where x, y, z represent Cartesian
+ position components and vx, vy, vz
+ represent Cartesian velocity
+ components. Note well: vx, vy, and
+ vz *are not necessarily equal* to the
+ time derivatives of x, y, and z.
+ This packet structure mimics that of
+ the Rosetta/MEX orbit file from which
+ the data are taken.
+
+ Position units are kilometers,
+ velocity units are kilometers per
+ second, and acceleration units are
+ kilometers per second per second.
+
+
+ S18TP1:
+
+ Lagrange interpolation, 6-
+ element packets containing
+
+ x, y, z, dx/dt, dy/dt, dz/dt
+
+ where x, y, z represent Cartesian
+ position components and vx, vy, vz
+ represent Cartesian velocity
+ components.
+
+ Position units are kilometers;
+ velocity units are kilometers per
+ second.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 16-AUG-2002 (NJB)
+
+*/
+
+#ifndef HAVE_SPICE_SPK_H
+
+ #define HAVE_SPICE_SPK_H
+
+
+
+ /*
+ SPK type 18 subtype codes:
+ */
+
+ enum _SpiceSPK18Subtype { S18TP0, S18TP1 };
+
+
+ typedef enum _SpiceSPK18Subtype SpiceSPK18Subtype;
+
+#endif
+
diff --git a/ext/spice/src/cspice/SpiceUsr.h b/ext/spice/src/cspice/SpiceUsr.h
new file mode 100644
index 0000000000..83038e32a3
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceUsr.h
@@ -0,0 +1,217 @@
+/*
+
+-Header_File SpiceUsr.h ( CSPICE user interface definitions )
+
+-Abstract
+
+ Perform CSPICE user interface declarations, including type
+ definitions and function prototype declarations.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This file is an umbrella header that includes all header files
+ required to support the CSPICE application programming interface
+ (API). Users' application code that calls CSPICE need include only
+ this single header file. This file includes function prototypes for
+ the entire set of CSPICE routines. Typedef statements used to create
+ SPICE data types are also included.
+
+
+ About SPICE data types
+ ======================
+
+ To assist with long-term maintainability of CSPICE, NAIF has elected
+ to use typedefs to represent data types occurring in argument lists
+ and as return values of CSPICE functions. These are:
+
+ SpiceBoolean
+ SpiceChar
+ SpiceDouble
+ SpiceInt
+ ConstSpiceBoolean
+ ConstSpiceChar
+ ConstSpiceDouble
+ ConstSpiceInt
+
+ The SPICE typedefs map in an arguably natural way to ANSI C types:
+
+ SpiceBoolean -> enum { SPICEFALSE = 0, SPICETRUE = 1 }
+ SpiceChar -> char
+ SpiceDouble -> double
+ SpiceInt -> int or long
+ ConstX -> const X (X = any of the above types)
+
+ The type SpiceInt is a special case: the corresponding type is picked
+ so as to be half the size of a double. On all currently supported
+ platforms, type double occupies 8 bytes and type int occupies 4
+ bytes. Other platforms may require a SpiceInt to map to type long.
+
+ While other data types may be used internally in CSPICE, no other
+ types appear in the API.
+
+
+ About CSPICE function prototypes
+ ================================
+
+ Because CSPICE function prototypes enable substantial
+ compile-time error checking, we recommend that user
+ applications always reference them. Including the header
+ file SpiceUsr.h in any module that calls CSPICE will
+ automatically make the prototypes available.
+
+
+ About CSPICE C style
+ ====================
+
+ CSPICE is written in ANSI C. No attempt has been made to support K&R
+ conventions or restrictions.
+
+
+ About C++ compatibility
+ =======================
+
+ The preprocessor directive -D__cplusplus should be used when
+ compiling C++ source code that includes this header file. This
+ directive will suppress mangling of CSPICE names, permitting linkage
+ to a CSPICE object library built from object modules produced by
+ an ANSI C compiler.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ E.D. Wright (JPL)
+
+-Restrictions
+
+ The #include statements contained in this file are not part of
+ the CSPICE API. The set of files included may change without notice.
+ Users should not include these files directly in their own
+ application code.
+
+-Version
+
+ -CSPICE Version 4.0.0, 30-SEP-2008 (NJB)
+
+ Updated to include header file
+
+ SpiceGF.h
+
+ -CSPICE Version 3.0.0, 19-AUG-2002 (NJB)
+
+ Updated to include header files
+
+ SpiceCel.h
+ SpiceCK.h
+ SpiceSPK.h
+
+ -CSPICE Version 3.0.0, 17-FEB-1999 (NJB)
+
+ Updated to support suppression of name mangling when included in
+ C++ source code. Also now interface macros to intercept function
+ calls and perform automatic type casting.
+
+ Now includes platform macro definition header file.
+
+ References to types SpiceVoid and ConstSpiceVoid were removed.
+
+ -CSPICE Version 2.0.0, 06-MAY-1998 (NJB) (EDW)
+
+*/
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+#ifndef HAVE_SPICE_USER
+
+ #define HAVE_SPICE_USER
+
+
+ /*
+ Include CSPICE platform macro definitions.
+ */
+ #include "SpiceZpl.h"
+
+ /*
+ Include CSPICE data type definitions.
+ */
+ #include "SpiceZdf.h"
+
+ /*
+ Include the CSPICE EK interface definitions.
+ */
+ #include "SpiceEK.h"
+
+ /*
+ Include the CSPICE Cell interface definitions.
+ */
+ #include "SpiceCel.h"
+
+ /*
+ Include the CSPICE CK interface definitions.
+ */
+ #include "SpiceCK.h"
+
+ /*
+ Include the CSPICE SPK interface definitions.
+ */
+ #include "SpiceSPK.h"
+
+ /*
+ Include the CSPICE GF interface definitions.
+ */
+ #include "SpiceGF.h"
+
+ /*
+ Include CSPICE prototypes.
+ */
+ #include "SpiceZpr.h"
+
+ /*
+ Define the CSPICE function interface macros.
+ */
+ #include "SpiceZim.h"
+
+
+
+#endif
+
+
+#ifdef __cplusplus
+ }
+#endif
+
diff --git a/ext/spice/src/cspice/SpiceZad.h b/ext/spice/src/cspice/SpiceZad.h
new file mode 100644
index 0000000000..f838e7f31c
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceZad.h
@@ -0,0 +1,205 @@
+/*
+
+-Header_File SpiceZad.h ( CSPICE adapter definitions )
+
+-Abstract
+
+ Perform CSPICE declarations to support passed-in function
+ adapters used in wrapper interfaces.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ This header file contains declarations used by the CSPICE
+ passed-in function adapter ("PFA") system. This system enables
+ CSPICE wrapper functions to support passed-in function
+ arguments whose prototypes are C-style, even when these
+ functions are to be called from f2c'd Fortran routines
+ expecting f2c-style interfaces.
+
+ This header declares:
+
+ - The prototype for the passed-in function argument
+ pointer storage and fetch routines
+
+ zzadsave_c
+ zzadget_c
+
+ - Prototypes for CSPICE adapter functions. Each passed-in
+ function argument in a CSPICE wrapper has a corresponding
+ adapter function. The adapter functions have interfaces
+ that match those of their f2c'd counterparts; this allows
+ the adapters to be called by f2c'd SPICELIB code. The
+ adapters look up saved function pointers for routines
+ passed in by the wrapper's caller and call these functions.
+
+ - Values for the enumerated type SpicePassedInFunc. These
+ values are used to map function pointers to the
+ functions they represent, enabling adapters to call
+ the correct passed-in functions.
+
+Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 2.1.0, 21-DEC-2009 (EDW)
+
+ Updated to support the user defined scalar function capability.
+
+ -CSPICE Version 2.0.0, 29-JAN-2009 (NJB)
+
+ Now conditionally includes SpiceZfc.h.
+
+ Updated to reflect new calling sequence of f2c'd
+ routine gfrefn_. Some header updates were made
+ as well.
+
+ -CSPICE Version 1.0.0, 29-MAR-2008 (NJB)
+
+*/
+
+
+/*
+ This file has dependencies defined in SpiceZfc.h. Include that
+ file if it hasn't already been included.
+*/
+#ifndef HAVE_SPICEF2C_H
+ #include "SpiceZfc.h"
+#endif
+
+
+
+#ifndef HAVE_SPICE_ZAD_H
+
+ #define HAVE_SPICE_ZAD_H
+
+
+
+ /*
+ Prototypes for GF adapters:
+ */
+
+ logical zzadbail_c ( void );
+
+
+ int zzadstep_c ( doublereal * et,
+ doublereal * step );
+
+
+ int zzadrefn_c ( doublereal * t1,
+ doublereal * t2,
+ logical * s1,
+ logical * s2,
+ doublereal * t );
+
+
+ int zzadrepf_c ( void );
+
+
+ int zzadrepi_c ( doublereal * cnfine,
+ char * srcpre,
+ char * srcsuf,
+ ftnlen srcprelen,
+ ftnlen srcsuflen );
+
+
+ int zzadrepu_c ( doublereal * ivbeg,
+ doublereal * ivend,
+ doublereal * et );
+
+
+ int zzadfunc_c ( doublereal * et,
+ doublereal * value );
+
+
+ int zzadqdec_c ( U_fp udfunc,
+ doublereal * et,
+ logical * xbool );
+
+ /*
+ Define the enumerated type
+
+ SpicePassedInFunc
+
+ for names of passed-in functions. Using this type gives
+ us compile-time checking and avoids string comparisons.
+ */
+ enum _SpicePassedInFunc {
+ UDBAIL,
+ UDREFN,
+ UDREPF,
+ UDREPI,
+ UDREPU,
+ UDSTEP,
+ UDFUNC,
+ UDQDEC,
+ };
+
+ typedef enum _SpicePassedInFunc SpicePassedInFunc;
+
+ /*
+ SPICE_N_PASSED_IN_FUNC is the count of SpicePassedInFunc values.
+ */
+ #define SPICE_N_PASSED_IN_FUNC 8
+
+
+ /*
+ CSPICE wrappers supporting passed-in function arguments call
+ the adapter setup interface function once per each such argument;
+ these calls save the function pointers for later use within the
+ f2c'd code that calls passed-in functions. The saved pointers
+ will be used in calls by the adapter functions whose prototypes
+ are declared above.
+
+ Prototypes for adapter setup interface:
+ */
+ void zzadsave_c ( SpicePassedInFunc functionID,
+ void * functionPtr );
+
+ void * zzadget_c ( SpicePassedInFunc functionID );
+
+
+#endif
+
+/*
+End of header file SpiceZad.h
+*/
+
diff --git a/ext/spice/src/cspice/SpiceZdf.h b/ext/spice/src/cspice/SpiceZdf.h
new file mode 100644
index 0000000000..36276051d6
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceZdf.h
@@ -0,0 +1,246 @@
+/*
+
+-Header_File SpiceZdf.h ( CSPICE definitions )
+
+-Abstract
+
+ Define CSPICE data types via typedefs; also define some user-visible
+ enumerated types.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ CSPICE data types
+ =================
+
+ To assist with long-term maintainability of CSPICE, NAIF has elected
+ to use typedefs to represent data types occurring in argument lists
+ and as return values of CSPICE functions. These are:
+
+ SpiceBoolean
+ SpiceChar
+ SpiceDouble
+ SpiceInt
+ ConstSpiceBoolean
+ ConstSpiceChar
+ ConstSpiceDouble
+ ConstSpiceInt
+
+ The SPICE typedefs map in an arguably natural way to ANSI C types:
+
+ SpiceBoolean -> int
+ SpiceChar -> char
+ SpiceDouble -> double
+ SpiceInt -> int or long
+ ConstX -> const X (X = any of the above types)
+
+ The type SpiceInt is a special case: the corresponding type is picked
+ so as to be half the size of a double. On most currently supported
+ platforms, type double occupies 8 bytes and type long occupies 4
+ bytes. Other platforms may require a SpiceInt to map to type int.
+ The Alpha/Digital Unix platform is an example of the latter case.
+
+ While other data types may be used internally in CSPICE, no other
+ types appear in the API.
+
+
+ CSPICE enumerated types
+ =======================
+
+ These are provided to enhance readability of the code.
+
+ Type name Value set
+ --------- ---------
+
+ _Spicestatus { SPICEFAILURE = -1, SPICESUCCESS = 0 }
+
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ B.V. Semenov (JPL)
+ E.D. Wright (JPL)
+
+-Restrictions
+
+ None.
+
+-Version
+
+ -CSPICE Version 6.1.0, 14-MAY-2010 (EDW)(BVS)
+
+ Updated for:
+
+ MAC-OSX-64BIT-INTEL_C
+ SUN-SOLARIS-64BIT-NATIVE_C
+ SUN-SOLARIS-INTEL-64BIT-CC_C
+
+ environments. Added the corresponding tags:
+
+ CSPICE_MAC_OSX_INTEL_64BIT_GCC
+ CSPICE_SUN_SOLARIS_64BIT_NATIVE
+ CSPICE_SUN_SOLARIS_INTEL_64BIT_CC
+
+ tag to the #ifdefs set.
+
+ -CSPICE Version 6.0.0, 21-FEB-2006 (NJB)
+
+ Updated to support the PC Linux 64 bit mode/gcc platform.
+
+ -CSPICE Version 5.0.0, 27-JAN-2003 (NJB)
+
+ Updated to support the Sun Solaris 64 bit mode/gcc platform.
+
+ -CSPICE Version 4.0.0 27-JUL-2002 (NJB)
+
+ Added definition of SpiceDataType.
+
+ -CSPICE Version 3.0.0 18-SEP-1999 (NJB)
+
+ SpiceBoolean implementation changed from enumerated type to
+ typedef mapping to int.
+
+ -CSPICE Version 2.0.0 29-JAN-1999 (NJB)
+
+ Made definition of SpiceInt and ConstSpiceInt platform
+ dependent to accommodate the Alpha/Digital Unix platform.
+
+ Removed definitions of SpiceVoid and ConstSpiceVoid.
+
+ -CSPICE Version 1.0.0 25-OCT-1997 (KRG) (NJB) (EDW)
+*/
+
+ #ifndef HAVE_SPICEDEFS_H
+ #define HAVE_SPICEDEFS_H
+
+ /*
+ Include platform definitions, if they haven't been executed already.
+ */
+ #ifndef HAVE_PLATFORM_MACROS_H
+ #include "SpiceZpl.h"
+ #endif
+
+ /*
+ Basic data types. These are defined to be compatible with the
+ types used by f2c, and so they follow the Fortran notion of what
+ these things are. See the f2c documentation for the details
+ about the choices for the sizes of these types.
+ */
+ typedef char SpiceChar;
+ typedef double SpiceDouble;
+ typedef float SpiceFloat;
+
+
+
+ #if ( defined(CSPICE_ALPHA_DIGITAL_UNIX ) \
+ || defined(CSPICE_SUN_SOLARIS_64BIT_NATIVE) \
+ || defined(CSPICE_SUN_SOLARIS_64BIT_GCC ) \
+ || defined(CSPICE_MAC_OSX_INTEL_64BIT_GCC ) \
+ || defined(CSPICE_SUN_SOLARIS_INTEL_64BIT_CC ) \
+ || defined(CSPICE_PC_LINUX_64BIT_GCC ) )
+
+ typedef int SpiceInt;
+ #else
+ typedef long SpiceInt;
+ #endif
+
+
+ typedef const char ConstSpiceChar;
+ typedef const double ConstSpiceDouble;
+ typedef const float ConstSpiceFloat;
+
+
+ #if ( defined(CSPICE_ALPHA_DIGITAL_UNIX ) \
+ || defined(CSPICE_SUN_SOLARIS_64BIT_NATIVE) \
+ || defined(CSPICE_SUN_SOLARIS_64BIT_GCC ) \
+ || defined(CSPICE_MAC_OSX_INTEL_64BIT_GCC ) \
+ || defined(CSPICE_SUN_SOLARIS_INTEL_64BIT_CC ) \
+ || defined(CSPICE_PC_LINUX_64BIT_GCC ) )
+
+ typedef const int ConstSpiceInt;
+ #else
+ typedef const long ConstSpiceInt;
+ #endif
+
+
+ /*
+ More basic data types. These give mnemonics for some other data
+ types in C that are not used in Fortran written by NAIF or
+ supported by ANSI Fortran 77. These are for use in C functions
+ but should not be passed to any C SPICE wrappers, ``*_c.c''
+ since they are not Fortran compatible.
+ */
+ typedef long SpiceLong;
+ typedef short SpiceShort;
+
+ /*
+ Unsigned data types
+ */
+ typedef unsigned char SpiceUChar;
+ typedef unsigned int SpiceUInt;
+ typedef unsigned long SpiceULong;
+ typedef unsigned short SpiceUShort;
+
+ /*
+ Signed data types
+ */
+ typedef signed char SpiceSChar;
+
+ /*
+ Other basic types
+ */
+ typedef int SpiceBoolean;
+ typedef const int ConstSpiceBoolean;
+
+ #define SPICETRUE 1
+ #define SPICEFALSE 0
+
+
+ enum _Spicestatus { SPICEFAILURE = -1, SPICESUCCESS = 0 };
+
+ typedef enum _Spicestatus SpiceStatus;
+
+
+ enum _SpiceDataType { SPICE_CHR = 0,
+ SPICE_DP = 1,
+ SPICE_INT = 2,
+ SPICE_TIME = 3,
+ SPICE_BOOL = 4 };
+
+
+ typedef enum _SpiceDataType SpiceDataType;
+
+
+#endif
diff --git a/ext/spice/src/cspice/SpiceZfc.h b/ext/spice/src/cspice/SpiceZfc.h
new file mode 100644
index 0000000000..33f541770b
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceZfc.h
@@ -0,0 +1,13228 @@
+/*
+
+-Header_File SpiceZfc.h ( f2c'd SPICELIB prototypes )
+
+-Abstract
+
+ Define prototypes for functions produced by converting Fortran
+ SPICELIB routines to C using f2c.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ B.V. Semenov (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ - CSPICE Version 6.1.0, 14-MAY-2010 (EDW)(BVS)
+
+ Updated for:
+
+ MAC-OSX-64BIT-INTEL_C
+ SUN-SOLARIS-64BIT-NATIVE_C
+ SUN-SOLARIS-INTEL-64BIT-CC_C
+
+ environments. Added the corresponding tags:
+
+ CSPICE_MAC_OSX_INTEL_64BIT_GCC
+ CSPICE_SUN_SOLARIS_64BIT_NATIVE
+ CSPICE_SUN_SOLARIS_INTEL_64BIT_CC
+
+ tag to the #ifdefs set.
+
+ - CSPICE Version 6.0.0, 21-FEB-2006 (NJB)
+
+ Added typedefs for the PC-LINUX-64BIT-GCC_C
+ environment (these are identical to those for the
+ ALPHA-DIGITAL-UNIX_C environment).
+
+ - C-SPICELIB Version 5.0.0, 06-MAR-2005 (NJB)
+
+ Added typedefs for pointers to functions. This change was
+ made to support CSPICE wrappers for geometry finder routines.
+
+ Added typedefs for the SUN-SOLARIS-64BIT-GCC_C
+ environment (these are identical to those for the
+ ALPHA-DIGITAL-UNIX_C environment).
+
+ - C-SPICELIB Version 4.1.0, 24-MAY-2001 (WLT)
+
+ Moved the #ifdef __cplusplus so that it appears after the
+ typedefs. This allows us to more easily wrap CSPICE in a
+ namespace for C++.
+
+ - C-SPICELIB Version 4.0.0, 09-FEB-1999 (NJB)
+
+ Updated to accommodate the Alpha/Digital Unix platform.
+ Also updated to support inclusion in C++ code.
+
+ - C-SPICELIB Version 3.0.0, 02-NOV-1998 (NJB)
+
+ Updated for SPICELIB version N0049.
+
+ - C-SPICELIB Version 2.0.0, 15-SEP-1997 (NJB)
+
+ Changed variable name "typid" to "typid" in prototype
+ for zzfdat_. This was done to enable compilation under
+ Borland C++.
+
+ - C-SPICELIB Version 1.0.0, 15-SEP-1997 (NJB) (KRG)
+
+-Index_Entries
+
+ prototypes of f2c'd SPICELIB functions
+
+*/
+
+
+#ifndef HAVE_SPICEF2C_H
+#define HAVE_SPICEF2C_H
+
+
+
+/*
+ Include Files:
+
+ Many of the prototypes below use data types defined by f2c. We
+ copy here the f2c definitions that occur in prototypes of functions
+ produced by running f2c on Fortran SPICELIB routines.
+
+ The reason we don't simply conditionally include f2c.h itself here
+ is that f2c.h defines macros that conflict with stdlib.h on some
+ systems. It's simpler to just replicate the few typedefs we need.
+*/
+
+#if ( defined( CSPICE_ALPHA_DIGITAL_UNIX ) \
+ || defined( CSPICE_PC_LINUX_64BIT_GCC ) \
+ || defined( CSPICE_MAC_OSX_INTEL_64BIT_GCC ) \
+ || defined( CSPICE_SUN_SOLARIS_INTEL_64BIT_CC ) \
+ || defined( CSPICE_SUN_SOLARIS_64BIT_NATIVE) \
+ || defined( CSPICE_SUN_SOLARIS_64BIT_GCC ) )
+
+ #define VOID void
+
+ typedef VOID H_f;
+ typedef int integer;
+ typedef double doublereal;
+ typedef int logical;
+ typedef int ftnlen;
+
+
+ /*
+ Type H_fp is used for character return type.
+ Type S_fp is used for subroutines.
+ Type U_fp is used for functions of unknown type.
+ */
+ typedef VOID (*H_fp)();
+ typedef doublereal (*D_fp)();
+ typedef doublereal (*E_fp)();
+ typedef int (*S_fp)();
+ typedef int (*U_fp)();
+ typedef integer (*I_fp)();
+ typedef logical (*L_fp)();
+
+#else
+
+ #define VOID void
+
+ typedef VOID H_f;
+ typedef long integer;
+ typedef double doublereal;
+ typedef long logical;
+ typedef long ftnlen;
+
+ /*
+ Type H_fp is used for character return type.
+ Type S_fp is used for subroutines.
+ Type U_fp is used for functions of unknown type.
+ */
+ typedef VOID (*H_fp)();
+ typedef doublereal (*D_fp)();
+ typedef doublereal (*E_fp)();
+ typedef int (*S_fp)();
+ typedef int (*U_fp)();
+ typedef integer (*I_fp)();
+ typedef logical (*L_fp)();
+
+#endif
+
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+/*
+ Function prototypes for functions created by f2c are listed below.
+ See the headers of the Fortran routines for descriptions of the
+ routines' interfaces.
+
+ The functions listed below are those expected to be called by
+ C-SPICELIB wrappers. Prototypes are not currently provided for other
+ f2c'd functions.
+
+*/
+
+/*
+-Prototypes
+*/
+
+extern logical accept_(logical *ok);
+extern logical allowd_(void);
+
+extern logical alltru_(logical *logcls, integer *n);
+
+extern H_f ana_(char *ret_val, ftnlen ret_val_len, char *word, char *case__, ftnlen word_len, ftnlen case_len);
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: replch_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+
+extern int appndc_(char *item, char *cell, ftnlen item_len, ftnlen cell_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int appndd_(doublereal *item, doublereal *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int appndi_(integer *item, integer *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical approx_(doublereal *x, doublereal *y, doublereal *tol);
+
+extern int astrip_(char *instr, char *asciib, char *asciie, char *outstr, ftnlen instr_len, ftnlen asciib_len, ftnlen asciie_len, ftnlen outstr_len);
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int axisar_(doublereal *axis, doublereal *angle, doublereal *r__);
+/*:ref: ident_ 14 1 7 */
+/*:ref: vrotv_ 14 4 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern doublereal b1900_(void);
+
+extern doublereal b1950_(void);
+
+extern logical badkpv_(char *caller, char *name__, char *comp, integer *size, integer *divby, char *type__, ftnlen caller_len, ftnlen name_len, ftnlen comp_len, ftnlen type_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: eqchr_ 12 4 13 13 124 124 */
+
+extern logical bedec_(char *string, ftnlen string_len);
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+/*:ref: beint_ 12 2 13 124 */
+/*:ref: beuns_ 12 2 13 124 */
+
+extern logical beint_(char *string, ftnlen string_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: beuns_ 12 2 13 124 */
+
+extern logical benum_(char *string, ftnlen string_len);
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+/*:ref: bedec_ 12 2 13 124 */
+/*:ref: beint_ 12 2 13 124 */
+
+extern logical beuns_(char *string, ftnlen string_len);
+/*:ref: frstnb_ 4 2 13 124 */
+
+extern int bodc2n_(integer *code, char *name__, logical *found, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzbodc2n_ 14 4 4 13 12 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int bodc2s_(integer *code, char *name__, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzbodc2n_ 14 4 4 13 12 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+
+extern int boddef_(char *name__, integer *code, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzboddef_ 14 3 13 4 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int bodeul_(integer *body, doublereal *et, doublereal *ra, doublereal *dec, doublereal *w, doublereal *lambda);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: pckeul_ 14 6 4 7 12 13 7 124 */
+/*:ref: bodfnd_ 12 3 4 13 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: rpd_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: zzbodbry_ 4 1 4 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: spd_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: m2eul_ 14 7 7 4 4 4 7 7 7 */
+
+extern logical bodfnd_(integer *body, char *item, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int bodmat_(integer *body, doublereal *et, doublereal *tipm);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: pckmat_ 14 5 4 7 4 7 12 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: ccifrm_ 14 7 4 4 4 13 4 12 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzbodbry_ 4 1 4 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: spd_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: bodfnd_ 12 3 4 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: rpd_ 7 0 */
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: twopi_ 7 0 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int bodn2c_(char *name__, integer *code, logical *found, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzbodn2c_ 14 4 13 4 12 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int bods2c_(char *name__, integer *code, logical *found, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzbodn2c_ 14 4 13 4 12 124 */
+/*:ref: beint_ 12 2 13 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int bodvar_(integer *body, char *item, integer *dim, doublereal *values, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: rtpool_ 14 5 13 4 7 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int bodvcd_(integer *bodyid, char *item, integer *maxn, integer *dim, doublereal *values, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+
+extern int bodvrd_(char *bodynm, char *item, integer *maxn, integer *dim, doublereal *values, ftnlen bodynm_len, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+
+extern doublereal brcktd_(doublereal *number, doublereal *end1, doublereal *end2);
+
+extern integer brckti_(integer *number, integer *end1, integer *end2);
+
+extern integer bschoc_(char *value, integer *ndim, char *array, integer *order, ftnlen value_len, ftnlen array_len);
+
+extern integer bschoi_(integer *value, integer *ndim, integer *array, integer *order);
+
+extern integer bsrchc_(char *value, integer *ndim, char *array, ftnlen value_len, ftnlen array_len);
+
+extern integer bsrchd_(doublereal *value, integer *ndim, doublereal *array);
+
+extern integer bsrchi_(integer *value, integer *ndim, integer *array);
+
+extern integer cardc_(char *cell, ftnlen cell_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dechar_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer cardd_(doublereal *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer cardi_(integer *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int cgv2el_(doublereal *center, doublereal *vec1, doublereal *vec2, doublereal *ellips);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: saelgv_ 14 4 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer chbase_(void);
+
+extern int chbder_(doublereal *cp, integer *degp, doublereal *x2s, doublereal *x, integer *nderiv, doublereal *partdp, doublereal *dpdxs);
+
+extern int chbint_(doublereal *cp, integer *degp, doublereal *x2s, doublereal *x, doublereal *p, doublereal *dpdx);
+
+extern int chbval_(doublereal *cp, integer *degp, doublereal *x2s, doublereal *x, doublereal *p);
+
+extern int chckid_(char *class__, integer *maxlen, char *id, ftnlen class_len, ftnlen id_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int chgirf_(integer *refa, integer *refb, doublereal *rotab, char *name__, integer *index, ftnlen name_len);
+extern int irfrot_(integer *refa, integer *refb, doublereal *rotab);
+extern int irfnum_(char *name__, integer *index, ftnlen name_len);
+extern int irfnam_(integer *index, char *name__, ftnlen name_len);
+extern int irfdef_(integer *index);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rotate_ 14 3 7 4 7 */
+/*:ref: wdcnt_ 4 2 13 124 */
+/*:ref: nthwd_ 14 6 13 4 13 4 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: rotmat_ 14 4 7 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: mxmt_ 14 3 7 7 7 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: esrchc_ 4 5 13 4 13 124 124 */
+
+extern int ckbsr_(char *fname, integer *handle, integer *inst, doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *descr, char *segid, logical *found, ftnlen fname_len, ftnlen segid_len);
+extern int cklpf_(char *fname, integer *handle, ftnlen fname_len);
+extern int ckupf_(integer *handle);
+extern int ckbss_(integer *inst, doublereal *sclkdp, doublereal *tol, logical *needav);
+extern int cksns_(integer *handle, doublereal *descr, char *segid, logical *found, ftnlen segid_len);
+extern int ckhave_(logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnktl_ 4 2 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: lnkprv_ 4 2 4 4 */
+/*:ref: dpmin_ 7 0 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafbbs_ 14 1 4 */
+/*:ref: daffpa_ 14 1 12 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: dafgn_ 14 2 13 124 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+
+extern int ckcls_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int ckcov_(char *ck, integer *idcode, logical *needav, char *level, doublereal *tol, char *timsys, doublereal *cover, ftnlen ck_len, ftnlen level_len, ftnlen timsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: ckmeta_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+/*:ref: zzckcv01_ 14 8 4 4 4 4 7 13 7 124 */
+/*:ref: zzckcv02_ 14 8 4 4 4 4 7 13 7 124 */
+/*:ref: zzckcv03_ 14 8 4 4 4 4 7 13 7 124 */
+/*:ref: zzckcv04_ 14 8 4 4 4 4 7 13 7 124 */
+/*:ref: zzckcv05_ 14 9 4 4 4 4 7 7 13 7 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int cke01_(logical *needav, doublereal *record, doublereal *cmat, doublereal *av, doublereal *clkout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: q2m_ 14 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int cke02_(logical *needav, doublereal *record, doublereal *cmat, doublereal *av, doublereal *clkout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vequg_ 14 3 7 4 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: axisar_ 14 3 7 7 7 */
+/*:ref: q2m_ 14 2 7 7 */
+/*:ref: mxmt_ 14 3 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int cke03_(logical *needav, doublereal *record, doublereal *cmat, doublereal *av, doublereal *clkout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: q2m_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: mtxm_ 14 3 7 7 7 */
+/*:ref: raxisa_ 14 3 7 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: axisar_ 14 3 7 7 7 */
+/*:ref: mxmt_ 14 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int cke04_(logical *needav, doublereal *record, doublereal *cmat, doublereal *av, doublereal *clkout);
+/*:ref: chbval_ 14 5 7 4 7 7 7 */
+/*:ref: vhatg_ 14 3 7 4 7 */
+/*:ref: q2m_ 14 2 7 7 */
+
+extern int cke05_(logical *needav, doublereal *record, doublereal *cmat, doublereal *av, doublereal *clkout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vminug_ 14 3 7 4 7 */
+/*:ref: vdistg_ 7 3 7 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: xpsgip_ 14 3 4 4 7 */
+/*:ref: lgrind_ 14 7 4 7 7 7 7 7 7 */
+/*:ref: vnormg_ 7 2 7 4 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vsclg_ 14 4 7 7 4 7 */
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: qdq2av_ 14 3 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: lgrint_ 7 5 4 7 7 7 7 */
+/*:ref: vhatg_ 14 3 7 4 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: hrmint_ 14 7 4 7 7 7 7 7 7 */
+/*:ref: q2m_ 14 2 7 7 */
+
+extern int ckfrot_(integer *inst, doublereal *et, doublereal *rotate, integer *ref, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ckhave_ 14 1 12 */
+/*:ref: ckmeta_ 14 4 4 13 4 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzsclk_ 12 2 4 4 */
+/*:ref: sce2c_ 14 3 4 7 7 */
+/*:ref: ckbss_ 14 4 4 7 7 12 */
+/*:ref: cksns_ 14 5 4 7 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckpfs_ 14 9 4 7 7 7 12 7 7 7 12 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: xpose_ 14 2 7 7 */
+
+extern int ckfxfm_(integer *inst, doublereal *et, doublereal *xform, integer *ref, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ckmeta_ 14 4 4 13 4 124 */
+/*:ref: ckhave_ 14 1 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzsclk_ 12 2 4 4 */
+/*:ref: sce2c_ 14 3 4 7 7 */
+/*:ref: ckbss_ 14 4 4 7 7 12 */
+/*:ref: cksns_ 14 5 4 7 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckpfs_ 14 9 4 7 7 7 12 7 7 7 12 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: rav2xf_ 14 3 7 7 7 */
+/*:ref: invstm_ 14 2 7 7 */
+
+extern int ckgp_(integer *inst, doublereal *sclkdp, doublereal *tol, char *ref, doublereal *cmat, doublereal *clkout, logical *found, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ckbss_ 14 4 4 7 7 12 */
+/*:ref: cksns_ 14 5 4 7 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckpfs_ 14 9 4 7 7 7 12 7 7 7 12 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: ckmeta_ 14 4 4 13 4 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: refchg_ 14 4 4 4 7 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int ckgpav_(integer *inst, doublereal *sclkdp, doublereal *tol, char *ref, doublereal *cmat, doublereal *av, doublereal *clkout, logical *found, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ckbss_ 14 4 4 7 7 12 */
+/*:ref: cksns_ 14 5 4 7 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckpfs_ 14 9 4 7 7 7 12 7 7 7 12 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: ckmeta_ 14 4 4 13 4 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: frmchg_ 14 4 4 4 7 7 */
+/*:ref: xf2rav_ 14 3 7 7 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+
+extern int ckgr01_(integer *handle, doublereal *descr, integer *recno, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int ckgr02_(integer *handle, doublereal *descr, integer *recno, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cknr02_ 14 3 4 7 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int ckgr03_(integer *handle, doublereal *descr, integer *recno, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int ckgr04_(integer *handle, doublereal *descr, integer *recno, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cknr04_ 14 3 4 7 4 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+/*:ref: zzck4d2i_ 14 4 7 4 7 4 */
+
+extern int ckgr05_(integer *handle, doublereal *descr, integer *recno, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int ckmeta_(integer *ckid, char *meta, integer *idcode, ftnlen meta_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: bschoi_ 4 4 4 4 4 4 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: orderi_ 14 3 4 4 4 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int cknr01_(integer *handle, doublereal *descr, integer *nrec);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int cknr02_(integer *handle, doublereal *descr, integer *nrec);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int cknr03_(integer *handle, doublereal *descr, integer *nrec);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int cknr04_(integer *handle, doublereal *descr, integer *nrec);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+
+extern int cknr05_(integer *handle, doublereal *descr, integer *nrec);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int ckobj_(char *ck, integer *ids, ftnlen ck_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int ckopn_(char *name__, char *ifname, integer *ncomch, integer *handle, ftnlen name_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafonw_ 14 10 13 13 4 4 13 4 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ckpfs_(integer *handle, doublereal *descr, doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *cmat, doublereal *av, doublereal *clkout, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: ckr01_ 14 7 4 7 7 7 12 7 12 */
+/*:ref: cke01_ 14 5 12 7 7 7 7 */
+/*:ref: ckr02_ 14 6 4 7 7 7 7 12 */
+/*:ref: cke02_ 14 5 12 7 7 7 7 */
+/*:ref: ckr03_ 14 7 4 7 7 7 12 7 12 */
+/*:ref: cke03_ 14 5 12 7 7 7 7 */
+/*:ref: ckr04_ 14 7 4 7 7 7 12 7 12 */
+/*:ref: cke04_ 14 5 12 7 7 7 7 */
+/*:ref: ckr05_ 14 7 4 7 7 7 12 7 12 */
+/*:ref: cke05_ 14 5 12 7 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ckr01_(integer *handle, doublereal *descr, doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *record, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: lstcld_ 4 3 7 4 7 */
+
+extern int ckr02_(integer *handle, doublereal *descr, doublereal *sclkdp, doublereal *tol, doublereal *record, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: vequg_ 14 3 7 4 7 */
+
+extern int ckr03_(integer *handle, doublereal *descr, doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *record, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: dpmax_ 7 0 */
+
+extern int ckr04_(integer *handle, doublereal *descr, doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *record, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cknr04_ 14 3 4 7 4 */
+/*:ref: sgfrvi_ 14 6 4 7 7 7 4 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+/*:ref: zzck4d2i_ 14 4 7 4 7 4 */
+
+extern int ckr05_(integer *handle, doublereal *descr, doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *record, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int ckw01_(integer *handle, doublereal *begtim, doublereal *endtim, integer *inst, char *ref, logical *avflag, char *segid, integer *nrec, doublereal *sclkdp, doublereal *quats, doublereal *avvs, ftnlen ref_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: vzerog_ 12 2 7 4 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int ckw02_(integer *handle, doublereal *begtim, doublereal *endtim, integer *inst, char *ref, char *segid, integer *nrec, doublereal *start, doublereal *stop, doublereal *quats, doublereal *avvs, doublereal *rates, ftnlen ref_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: vzerog_ 12 2 7 4 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int ckw03_(integer *handle, doublereal *begtim, doublereal *endtim, integer *inst, char *ref, logical *avflag, char *segid, integer *nrec, doublereal *sclkdp, doublereal *quats, doublereal *avvs, integer *nints, doublereal *starts, ftnlen ref_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: vzerog_ 12 2 7 4 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int ckw04a_(integer *handle, integer *npkts, integer *pktsiz, doublereal *pktdat, doublereal *sclkdp);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzck4i2d_ 14 4 4 4 7 7 */
+/*:ref: sgwvpk_ 14 6 4 4 4 7 4 7 */
+
+extern int ckw04b_(integer *handle, doublereal *begtim, integer *inst, char *ref, logical *avflag, char *segid, ftnlen ref_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: sgbwvs_ 14 7 4 7 13 4 7 4 124 */
+
+extern int ckw04e_(integer *handle, doublereal *endtim);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgwes_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafbbs_ 14 1 4 */
+/*:ref: daffpa_ 14 1 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafrs_ 14 1 7 */
+
+extern int ckw05_(integer *handle, integer *subtyp, integer *degree, doublereal *begtim, doublereal *endtim, integer *inst, char *ref, logical *avflag, char *segid, integer *n, doublereal *sclkdp, doublereal *packts, doublereal *rate, integer *nints, doublereal *starts, ftnlen ref_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: bsrchd_ 4 3 7 4 7 */
+/*:ref: vzerog_ 12 2 7 4 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int clearc_(integer *ndim, char *array, ftnlen array_len);
+
+extern int cleard_(integer *ndim, doublereal *array);
+
+extern int cleari_(integer *ndim, integer *array);
+
+extern doublereal clight_(void);
+
+extern int cmprss_(char *delim, integer *n, char *input, char *output, ftnlen delim_len, ftnlen input_len, ftnlen output_len);
+
+extern int conics_(doublereal *elts, doublereal *et, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: prop2b_ 14 4 7 7 7 7 */
+
+extern int convrt_(doublereal *x, char *in, char *out, doublereal *y, ftnlen in_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dpr_ 7 0 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int copyc_(char *cell, char *copy, ftnlen cell_len, ftnlen copy_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: lastpc_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int copyd_(doublereal *cell, doublereal *copy);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int copyi_(integer *cell, integer *copy);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer countc_(integer *unit, integer *bline, integer *eline, char *line, ftnlen line_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: astrip_ 14 8 13 13 13 13 124 124 124 124 */
+
+extern integer cpos_(char *str, char *chars, integer *start, ftnlen str_len, ftnlen chars_len);
+
+extern integer cposr_(char *str, char *chars, integer *start, ftnlen str_len, ftnlen chars_len);
+
+extern int cyacip_(integer *nelt, char *dir, integer *ncycle, char *array, ftnlen dir_len, ftnlen array_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: nbwid_ 4 3 13 4 124 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyadip_(integer *nelt, char *dir, integer *ncycle, doublereal *array, ftnlen dir_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyaiip_(integer *nelt, char *dir, integer *ncycle, integer *array, ftnlen dir_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyclac_(char *array, integer *nelt, char *dir, integer *ncycle, char *out, ftnlen array_len, ftnlen dir_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+/*:ref: nbwid_ 4 3 13 4 124 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyclad_(doublereal *array, integer *nelt, char *dir, integer *ncycle, doublereal *out, ftnlen dir_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyclai_(integer *array, integer *nelt, char *dir, integer *ncycle, integer *out, ftnlen dir_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyclec_(char *instr, char *dir, integer *ncycle, char *outstr, ftnlen instr_len, ftnlen dir_len, ftnlen outstr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: gcd_ 4 2 4 4 */
+
+extern int cyllat_(doublereal *r__, doublereal *longc, doublereal *z__, doublereal *radius, doublereal *long__, doublereal *lat);
+
+extern int cylrec_(doublereal *r__, doublereal *long__, doublereal *z__, doublereal *rectan);
+
+extern int cylsph_(doublereal *r__, doublereal *longc, doublereal *z__, doublereal *radius, doublereal *colat, doublereal *long__);
+
+extern doublereal dacosh_(doublereal *x);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern doublereal dacosn_(doublereal *arg, doublereal *tol);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dafa2b_(char *ascii, char *binary, integer *resv, ftnlen ascii_len, ftnlen binary_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: txtopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: daft2b_ 14 4 4 13 4 124 */
+
+extern int dafac_(integer *handle, integer *n, char *buffer, ftnlen buffer_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+/*:ref: ncpos_ 4 5 13 13 4 124 124 */
+/*:ref: dafarr_ 14 2 4 4 */
+
+extern int dafah_(char *fname, char *ftype, integer *nd, integer *ni, char *ifname, integer *resv, integer *handle, integer *unit, integer *fhset, char *access, ftnlen fname_len, ftnlen ftype_len, ftnlen ifname_len, ftnlen access_len);
+extern int dafopr_(char *fname, integer *handle, ftnlen fname_len);
+extern int dafopw_(char *fname, integer *handle, ftnlen fname_len);
+extern int dafonw_(char *fname, char *ftype, integer *nd, integer *ni, char *ifname, integer *resv, integer *handle, ftnlen fname_len, ftnlen ftype_len, ftnlen ifname_len);
+extern int dafopn_(char *fname, integer *nd, integer *ni, char *ifname, integer *resv, integer *handle, ftnlen fname_len, ftnlen ifname_len);
+extern int dafcls_(integer *handle);
+extern int dafhsf_(integer *handle, integer *nd, integer *ni);
+extern int dafhlu_(integer *handle, integer *unit);
+extern int dafluh_(integer *unit, integer *handle);
+extern int dafhfn_(integer *handle, char *fname, ftnlen fname_len);
+extern int daffnh_(char *fname, integer *handle, ftnlen fname_len);
+extern int dafhof_(integer *fhset);
+extern int dafsih_(integer *handle, char *access, ftnlen access_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: zzddhopn_ 14 7 13 13 13 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zzdafgfr_ 14 11 4 13 4 4 13 4 4 4 12 124 124 */
+/*:ref: zzddhcls_ 14 4 4 13 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: dafrwa_ 14 3 4 4 4 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: zzdafnfr_ 14 12 4 13 4 4 13 4 4 4 13 124 124 124 */
+/*:ref: removi_ 14 2 4 4 */
+/*:ref: zzddhluh_ 14 3 4 4 12 */
+/*:ref: zzddhnfo_ 14 7 4 13 4 4 4 12 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: zzddhfnh_ 14 4 13 4 12 124 */
+/*:ref: copyi_ 14 2 4 4 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: elemi_ 12 2 4 4 */
+
+extern int dafana_(integer *handle, doublereal *sum, char *name__, doublereal *data, integer *n, ftnlen name_len);
+extern int dafbna_(integer *handle, doublereal *sum, char *name__, ftnlen name_len);
+extern int dafada_(doublereal *data, integer *n);
+extern int dafena_(void);
+extern int dafcad_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafhof_ 14 1 4 */
+/*:ref: elemi_ 12 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafhsf_ 14 3 4 4 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: dafhfn_ 14 3 4 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafwda_ 14 4 4 4 4 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafrdr_ 14 6 4 4 4 4 7 12 */
+/*:ref: dafrcr_ 14 4 4 4 13 124 */
+/*:ref: dafwdr_ 14 3 4 4 7 */
+/*:ref: dafwcr_ 14 4 4 4 13 124 */
+/*:ref: dafarw_ 14 3 4 4 4 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: dafrwa_ 14 3 4 4 4 */
+/*:ref: dafwfr_ 14 8 4 4 4 13 4 4 4 124 */
+
+extern int dafarr_(integer *handle, integer *resv);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafarw_ 14 3 4 4 4 */
+/*:ref: dafwdr_ 14 3 4 4 7 */
+/*:ref: dafrdr_ 14 6 4 4 4 4 7 12 */
+/*:ref: dafrcr_ 14 4 4 4 13 124 */
+/*:ref: dafwcr_ 14 4 4 4 13 124 */
+/*:ref: dafwfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafws_ 14 1 7 */
+
+extern int dafb2a_(char *binary, char *ascii, ftnlen binary_len, ftnlen ascii_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: txtopn_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafb2t_ 14 3 13 4 124 */
+
+extern int dafb2t_(char *binary, integer *text, ftnlen binary_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafcls_ 14 1 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafgn_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int dafbt_(char *binfil, integer *xfrlun, ftnlen binfil_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: wrenci_ 14 3 4 4 4 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafgn_ 14 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: wrencd_ 14 3 4 4 7 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int dafdc_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafrrr_ 14 2 4 4 */
+
+extern int dafec_(integer *handle, integer *bufsiz, integer *n, char *buffer, logical *done, ftnlen buffer_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+/*:ref: ncpos_ 4 5 13 13 4 124 124 */
+
+extern int daffa_(integer *handle, doublereal *sum, char *name__, logical *found, ftnlen name_len);
+extern int dafbfs_(integer *handle);
+extern int daffna_(logical *found);
+extern int dafbbs_(integer *handle);
+extern int daffpa_(logical *found);
+extern int dafgs_(doublereal *sum);
+extern int dafgn_(char *name__, ftnlen name_len);
+extern int dafgh_(integer *handle);
+extern int dafrs_(doublereal *sum);
+extern int dafrn_(char *name__, ftnlen name_len);
+extern int dafws_(doublereal *sum);
+extern int dafcs_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: dafhof_ 14 1 4 */
+/*:ref: elemi_ 12 2 4 4 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafgsr_ 14 6 4 4 4 4 7 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: dafhfn_ 14 3 4 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafhsf_ 14 3 4 4 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: dafrcr_ 14 4 4 4 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafwdr_ 14 3 4 4 7 */
+/*:ref: dafwcr_ 14 4 4 4 13 124 */
+
+extern int dafgda_(integer *handle, integer *begin, integer *end, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafarw_ 14 3 4 4 4 */
+/*:ref: dafgdr_ 14 6 4 4 4 4 7 12 */
+/*:ref: cleard_ 14 2 4 7 */
+
+extern int dafps_(integer *nd, integer *ni, doublereal *dc, integer *ic, doublereal *sum);
+extern int dafus_(doublereal *sum, integer *nd, integer *ni, doublereal *dc, integer *ic);
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: movei_ 14 3 4 4 4 */
+
+extern int dafra_(integer *handle, integer *iorder, integer *n);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: isordv_ 12 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafgn_ 14 2 13 124 */
+/*:ref: dafws_ 14 1 7 */
+/*:ref: dafrn_ 14 2 13 124 */
+
+extern int dafrcr_(integer *handle, integer *recno, char *crec, ftnlen crec_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+
+extern int dafrda_(integer *handle, integer *begin, integer *end, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: zzddhisn_ 14 3 4 12 12 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafarw_ 14 3 4 4 4 */
+/*:ref: dafrdr_ 14 6 4 4 4 4 7 12 */
+/*:ref: cleard_ 14 2 4 7 */
+
+extern int dafrfr_(integer *handle, integer *nd, integer *ni, char *ifname, integer *fward, integer *bward, integer *free, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzdafgfr_ 14 11 4 13 4 4 13 4 4 4 12 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int dafrrr_(integer *handle, integer *resv);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafrdr_ 14 6 4 4 4 4 7 12 */
+/*:ref: dafarw_ 14 3 4 4 4 */
+/*:ref: dafwdr_ 14 3 4 4 7 */
+/*:ref: dafrcr_ 14 4 4 4 13 124 */
+/*:ref: dafwcr_ 14 4 4 4 13 124 */
+/*:ref: dafwfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafws_ 14 1 7 */
+
+extern int dafrwa_(integer *recno, integer *wordno, integer *addr__);
+extern int dafarw_(integer *addr__, integer *recno, integer *wordno);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dafrwd_(integer *handle, integer *recno, integer *begin, integer *end, doublereal *drec, doublereal *data, logical *found, integer *reads, integer *reqs);
+extern int dafgdr_(integer *handle, integer *recno, integer *begin, integer *end, doublereal *data, logical *found);
+extern int dafgsr_(integer *handle, integer *recno, integer *begin, integer *end, doublereal *data, logical *found);
+extern int dafrdr_(integer *handle, integer *recno, integer *begin, integer *end, doublereal *data, logical *found);
+extern int dafwdr_(integer *handle, integer *recno, doublereal *drec);
+extern int dafnrr_(integer *reads, integer *reqs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: minai_ 14 4 4 4 4 4 */
+/*:ref: zzdafgdr_ 14 4 4 4 7 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: zzddhrcm_ 14 3 4 4 4 */
+/*:ref: dafhsf_ 14 3 4 4 4 */
+/*:ref: zzdafgsr_ 14 6 4 4 4 4 7 12 */
+/*:ref: zzddhisn_ 14 3 4 12 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int daft2b_(integer *text, char *binary, integer *resv, ftnlen binary_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: idw2at_ 14 6 13 13 13 124 124 124 */
+/*:ref: dafopn_ 14 8 13 4 4 13 4 4 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafcls_ 14 1 4 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafena_ 14 0 */
+
+extern int daftb_(integer *xfrlun, char *binfil, ftnlen binfil_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: idw2at_ 14 6 13 13 13 124 124 124 */
+/*:ref: rdenci_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafonw_ 14 10 13 13 4 4 13 4 4 124 124 124 */
+/*:ref: dafopn_ 14 8 13 4 4 13 4 4 124 124 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: rdencd_ 14 3 4 4 7 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int dafwcr_(integer *handle, integer *recno, char *crec, ftnlen crec_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dafwda_(integer *handle, integer *begin, integer *end, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafarw_ 14 3 4 4 4 */
+/*:ref: dafrdr_ 14 6 4 4 4 4 7 12 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: dafwdr_ 14 3 4 4 7 */
+
+extern int dafwfr_(integer *handle, integer *nd, integer *ni, char *ifname, integer *fward, integer *bward, integer *free, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int dasa2l_(integer *handle, integer *type__, integer *addrss, integer *clbase, integer *clsize, integer *recno, integer *wordno);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: dasham_ 14 3 4 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasrri_ 14 5 4 4 4 4 4 */
+
+extern int dasac_(integer *handle, integer *n, char *buffer, ftnlen buffer_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: dasrfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+/*:ref: dasacr_ 14 2 4 4 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: daswfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+
+extern int dasacr_(integer *handle, integer *n);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: daswbr_ 14 1 4 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: maxai_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: dasioi_ 14 5 13 4 4 4 124 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: dasiod_ 14 5 13 4 4 7 124 */
+/*:ref: dasufs_ 14 9 4 4 4 4 4 4 4 4 4 */
+
+extern int dasacu_(integer *comlun, char *begmrk, char *endmrk, logical *insbln, integer *handle, ftnlen begmrk_len, ftnlen endmrk_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: readln_ 14 4 4 13 12 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: readla_ 14 6 4 4 4 13 12 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: writla_ 14 4 4 13 4 124 */
+/*:ref: dasac_ 14 4 4 4 13 124 */
+
+extern int dasadc_(integer *handle, integer *n, integer *bpos, integer *epos, char *data, ftnlen data_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: daswrc_ 14 4 4 4 13 124 */
+/*:ref: dasurc_ 14 6 4 4 4 4 13 124 */
+/*:ref: dascud_ 14 3 4 4 4 */
+
+extern int dasadd_(integer *handle, integer *n, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: daswrd_ 14 3 4 4 7 */
+/*:ref: dasurd_ 14 5 4 4 4 4 7 */
+/*:ref: dascud_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dasadi_(integer *handle, integer *n, integer *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: daswri_ 14 3 4 4 4 */
+/*:ref: dasuri_ 14 5 4 4 4 4 4 */
+/*:ref: dascud_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dasbt_(char *binfil, integer *xfrlun, ftnlen binfil_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dasopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: dascls_ 14 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: wrenci_ 14 3 4 4 4 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: wrencc_ 14 4 4 4 13 124 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: wrencd_ 14 3 4 4 7 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int dascls_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: dashof_ 14 1 4 */
+/*:ref: elemi_ 12 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasham_ 14 3 4 13 124 */
+/*:ref: daswbr_ 14 1 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dassdr_ 14 1 4 */
+/*:ref: dasllc_ 14 1 4 */
+
+extern int dascud_(integer *handle, integer *type__, integer *nwords);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: maxai_ 14 4 4 4 4 4 */
+/*:ref: dasuri_ 14 5 4 4 4 4 4 */
+/*:ref: dasufs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasrri_ 14 5 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: daswri_ 14 3 4 4 4 */
+
+extern int dasdc_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+/*:ref: dasrcr_ 14 2 4 4 */
+/*:ref: daswfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+
+extern int dasec_(integer *handle, integer *bufsiz, integer *n, char *buffer, logical *done, ftnlen buffer_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: dasrfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int dasecu_(integer *handle, integer *comlun, logical *comnts);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasec_ 14 6 4 4 4 13 12 124 */
+/*:ref: writla_ 14 4 4 13 4 124 */
+
+extern int dasfm_(char *fname, char *ftype, char *ifname, integer *handle, integer *unit, integer *free, integer *lastla, integer *lastrc, integer *lastwd, integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc, integer *fhset, char *access, ftnlen fname_len, ftnlen ftype_len, ftnlen ifname_len, ftnlen access_len);
+extern int dasopr_(char *fname, integer *handle, ftnlen fname_len);
+extern int dasopw_(char *fname, integer *handle, ftnlen fname_len);
+extern int dasonw_(char *fname, char *ftype, char *ifname, integer *ncomr, integer *handle, ftnlen fname_len, ftnlen ftype_len, ftnlen ifname_len);
+extern int dasopn_(char *fname, char *ifname, integer *handle, ftnlen fname_len, ftnlen ifname_len);
+extern int dasops_(integer *handle);
+extern int dasllc_(integer *handle);
+extern int dashfs_(integer *handle, integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc, integer *free, integer *lastla, integer *lastrc, integer *lastwd);
+extern int dasufs_(integer *handle, integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc, integer *free, integer *lastla, integer *lastrc, integer *lastwd);
+extern int dashlu_(integer *handle, integer *unit);
+extern int dasluh_(integer *unit, integer *handle);
+extern int dashfn_(integer *handle, char *fname, ftnlen fname_len);
+extern int dasfnh_(char *fname, integer *handle, ftnlen fname_len);
+extern int dashof_(integer *fhset);
+extern int dassih_(integer *handle, char *access, ftnlen access_len);
+extern int dasham_(integer *handle, char *access, ftnlen access_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: exists_ 12 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzddhppf_ 14 3 4 4 4 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: idw2at_ 14 6 13 13 13 124 124 124 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: dasioi_ 14 5 13 4 4 4 124 */
+/*:ref: maxai_ 14 4 4 4 4 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: zzdasnfr_ 14 11 4 13 13 4 4 4 4 13 124 124 124 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: removi_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: copyi_ 14 2 4 4 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: elemi_ 12 2 4 4 */
+
+extern doublereal dasine_(doublereal *arg, doublereal *tol);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dasioc_(char *action, integer *unit, integer *recno, char *record, ftnlen action_len, ftnlen record_len);
+/*:ref: return_ 12 0 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int dasiod_(char *action, integer *unit, integer *recno, doublereal *record, ftnlen action_len);
+/*:ref: return_ 12 0 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int dasioi_(char *action, integer *unit, integer *recno, integer *record, ftnlen action_len);
+/*:ref: return_ 12 0 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int daslla_(integer *handle, integer *lastc, integer *lastd, integer *lasti);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dasrcr_(integer *handle, integer *n);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: daswbr_ 14 1 4 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: maxai_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: dasioi_ 14 5 13 4 4 4 124 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: dasiod_ 14 5 13 4 4 7 124 */
+/*:ref: dasufs_ 14 9 4 4 4 4 4 4 4 4 4 */
+
+extern int dasrdc_(integer *handle, integer *first, integer *last, integer *bpos, integer *epos, char *data, ftnlen data_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasrrc_ 14 6 4 4 4 4 13 124 */
+
+extern int dasrdd_(integer *handle, integer *first, integer *last, doublereal *data);
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: dasrrd_ 14 5 4 4 4 4 7 */
+/*:ref: failed_ 12 0 */
+
+extern int dasrdi_(integer *handle, integer *first, integer *last, integer *data);
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: dasrri_ 14 5 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+
+extern int dasrfr_(integer *handle, char *idword, char *ifname, integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc, ftnlen idword_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int dasrwr_(integer *handle, integer *recno, char *recc, doublereal *recd, integer *reci, integer *first, integer *last, doublereal *datad, integer *datai, char *datac, ftnlen recc_len, ftnlen datac_len);
+extern int dasrrd_(integer *handle, integer *recno, integer *first, integer *last, doublereal *datad);
+extern int dasrri_(integer *handle, integer *recno, integer *first, integer *last, integer *datai);
+extern int dasrrc_(integer *handle, integer *recno, integer *first, integer *last, char *datac, ftnlen datac_len);
+extern int daswrd_(integer *handle, integer *recno, doublereal *recd);
+extern int daswri_(integer *handle, integer *recno, integer *reci);
+extern int daswrc_(integer *handle, integer *recno, char *recc, ftnlen recc_len);
+extern int dasurd_(integer *handle, integer *recno, integer *first, integer *last, doublereal *datad);
+extern int dasuri_(integer *handle, integer *recno, integer *first, integer *last, integer *datai);
+extern int dasurc_(integer *handle, integer *recno, integer *first, integer *last, char *datac, ftnlen datac_len);
+extern int daswbr_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: lnkxsl_ 14 3 4 4 4 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: lnktl_ 4 2 4 4 */
+/*:ref: dasiod_ 14 5 13 4 4 7 124 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: dasioi_ 14 5 13 4 4 4 124 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+
+extern int dassdr_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: daswbr_ 14 1 4 */
+/*:ref: dasops_ 14 1 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: maxai_ 14 4 4 4 4 4 */
+/*:ref: dasrri_ 14 5 4 4 4 4 4 */
+/*:ref: dasadi_ 14 3 4 4 4 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: dasiod_ 14 5 13 4 4 7 124 */
+/*:ref: dasioi_ 14 5 13 4 4 4 124 */
+/*:ref: dasufs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasllc_ 14 1 4 */
+
+extern int dastb_(integer *xfrlun, char *binfil, ftnlen binfil_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: idw2at_ 14 6 13 13 13 124 124 124 */
+/*:ref: dasonw_ 14 8 13 13 13 4 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: daswfr_ 14 9 4 13 13 4 4 4 4 124 124 */
+/*:ref: dascls_ 14 1 4 */
+/*:ref: rdenci_ 14 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: dasacr_ 14 2 4 4 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: rdencc_ 14 4 4 4 13 124 */
+/*:ref: dasioc_ 14 6 13 4 4 13 124 124 */
+/*:ref: dasadc_ 14 6 4 4 4 4 13 124 */
+/*:ref: rdencd_ 14 3 4 4 7 */
+/*:ref: dasadd_ 14 3 4 4 7 */
+/*:ref: dasadi_ 14 3 4 4 4 */
+
+extern int dasudc_(integer *handle, integer *first, integer *last, integer *bpos, integer *epos, char *data, ftnlen data_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasurc_ 14 6 4 4 4 4 13 124 */
+
+extern int dasudd_(integer *handle, integer *first, integer *last, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasurd_ 14 5 4 4 4 4 7 */
+
+extern int dasudi_(integer *handle, integer *first, integer *last, integer *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasa2l_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasuri_ 14 5 4 4 4 4 4 */
+
+extern int daswfr_(integer *handle, char *idword, char *ifname, integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc, ftnlen idword_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dashfs_ 14 9 4 4 4 4 4 4 4 4 4 */
+/*:ref: dasufs_ 14 9 4 4 4 4 4 4 4 4 4 */
+
+extern doublereal datanh_(doublereal *x);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern doublereal dcbrt_(doublereal *x);
+
+extern int dcyldr_(doublereal *x, doublereal *y, doublereal *z__, doublereal *jacobi);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: reccyl_ 14 4 7 7 7 7 */
+/*:ref: drdcyl_ 14 4 7 7 7 7 */
+/*:ref: invort_ 14 2 7 7 */
+
+extern int delfil_(char *filnam, ftnlen filnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: getlun_ 14 1 4 */
+
+extern int deltet_(doublereal *epoch, char *eptype, doublereal *delta, ftnlen eptype_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern doublereal det_(doublereal *m1);
+
+extern int dgeodr_(doublereal *x, doublereal *y, doublereal *z__, doublereal *re, doublereal *f, doublereal *jacobi);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: recgeo_ 14 6 7 7 7 7 7 7 */
+/*:ref: drdgeo_ 14 6 7 7 7 7 7 7 */
+/*:ref: invort_ 14 2 7 7 */
+
+extern doublereal dhfa_(doublereal *state, doublereal *bodyr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+
+extern int diags2_(doublereal *symmat, doublereal *diag, doublereal *rotate);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rquad_ 14 5 7 7 7 7 7 */
+/*:ref: vhatg_ 14 3 7 4 7 */
+
+extern int diffc_(char *a, char *b, char *c__, ftnlen a_len, ftnlen b_len, ftnlen c_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: excess_ 14 3 4 13 124 */
+
+extern int diffd_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int diffi_(integer *a, integer *b, integer *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dlatdr_(doublereal *x, doublereal *y, doublereal *z__, doublereal *jacobi);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: reclat_ 14 4 7 7 7 7 */
+/*:ref: drdlat_ 14 4 7 7 7 7 */
+/*:ref: invort_ 14 2 7 7 */
+
+extern int dnearp_(doublereal *state, doublereal *a, doublereal *b, doublereal *c__, doublereal *dnear, doublereal *dalt, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vtmv_ 7 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int dp2hx_(doublereal *number, char *string, integer *length, ftnlen string_len);
+/*:ref: int2hx_ 14 4 4 13 4 124 */
+
+extern int dpfmt_(doublereal *x, char *pictur, char *str, ftnlen pictur_len, ftnlen str_len);
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzvststr_ 14 4 7 13 4 124 */
+/*:ref: dpstr_ 14 4 7 4 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: rjust_ 14 4 13 13 124 124 */
+/*:ref: zzvsbstr_ 14 6 4 4 12 13 12 124 */
+/*:ref: ncpos_ 4 5 13 13 4 124 124 */
+
+extern int dpgrdr_(char *body, doublereal *x, doublereal *y, doublereal *z__, doublereal *re, doublereal *f, doublereal *jacobi, ftnlen body_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: plnsns_ 4 1 4 */
+/*:ref: dgeodr_ 14 6 7 7 7 7 7 7 */
+
+extern doublereal dpr_(void);
+
+extern int dpspce_(doublereal *time, doublereal *geophs, doublereal *elems, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: twopi_ 7 0 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: zzdpinit_ 14 6 7 7 7 7 7 7 */
+/*:ref: zzdpper_ 14 6 7 7 7 7 7 7 */
+/*:ref: zzdpsec_ 14 9 7 7 7 7 7 7 7 7 7 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dpstr_(doublereal *x, integer *sigdig, char *string, ftnlen string_len);
+/*:ref: intstr_ 14 3 4 13 124 */
+
+extern int dpstrf_(doublereal *x, integer *sigdig, char *format, char *string, ftnlen format_len, ftnlen string_len);
+/*:ref: dpstr_ 14 4 7 4 13 124 */
+/*:ref: zzvststr_ 14 4 7 13 4 124 */
+/*:ref: zzvsbstr_ 14 6 4 4 12 13 12 124 */
+
+extern int drdcyl_(doublereal *r__, doublereal *long__, doublereal *z__, doublereal *jacobi);
+
+extern int drdgeo_(doublereal *long__, doublereal *lat, doublereal *alt, doublereal *re, doublereal *f, doublereal *jacobi);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int drdlat_(doublereal *r__, doublereal *long__, doublereal *lat, doublereal *jacobi);
+
+extern int drdpgr_(char *body, doublereal *lon, doublereal *lat, doublereal *alt, doublereal *re, doublereal *f, doublereal *jacobi, ftnlen body_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: plnsns_ 4 1 4 */
+/*:ref: drdgeo_ 14 6 7 7 7 7 7 7 */
+
+extern int drdsph_(doublereal *r__, doublereal *colat, doublereal *long__, doublereal *jacobi);
+
+extern int drotat_(doublereal *angle, integer *iaxis, doublereal *dmout);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int dsphdr_(doublereal *x, doublereal *y, doublereal *z__, doublereal *jacobi);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: recsph_ 14 4 7 7 7 7 */
+/*:ref: drdsph_ 14 4 7 7 7 7 */
+/*:ref: invort_ 14 2 7 7 */
+
+extern int ducrss_(doublereal *s1, doublereal *s2, doublereal *sout);
+/*:ref: dvcrss_ 14 3 7 7 7 */
+/*:ref: dvhat_ 14 2 7 7 */
+
+extern int dvcrss_(doublereal *s1, doublereal *s2, doublereal *sout);
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+
+extern doublereal dvdot_(doublereal *s1, doublereal *s2);
+
+extern int dvhat_(doublereal *s1, doublereal *sout);
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+
+extern doublereal dvnorm_(doublereal *state);
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+
+extern doublereal dvsep_(doublereal *s1, doublereal *s2);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dvhat_ 14 2 7 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int dxtrct_(char *keywd, integer *maxwds, char *string, integer *nfound, integer *parsed, doublereal *values, ftnlen keywd_len, ftnlen string_len);
+/*:ref: wdindx_ 4 4 13 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: nblen_ 4 2 13 124 */
+/*:ref: fndnwd_ 14 5 13 4 4 4 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+
+extern int edlimb_(doublereal *a, doublereal *b, doublereal *c__, doublereal *viewpt, doublereal *limb);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: nvc2pl_ 14 3 7 7 7 */
+/*:ref: inedpl_ 14 6 7 7 7 7 7 12 */
+/*:ref: vsclg_ 14 4 7 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int edterm_(char *trmtyp, char *source, char *target, doublereal *et, char *fixfrm, char *abcorr, char *obsrvr, integer *npts, doublereal *trgepc, doublereal *obspos, doublereal *trmpts, ftnlen trmtyp_len, ftnlen source_len, ftnlen target_len, ftnlen fixfrm_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: bodvrd_ 14 7 13 13 4 4 7 124 124 */
+/*:ref: spkpos_ 14 11 13 7 13 13 13 7 7 124 124 124 124 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: zzedterm_ 14 9 13 7 7 7 7 7 4 7 124 */
+
+extern int ekacec_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, char *cvals, logical *isnull, ftnlen column_len, ftnlen cvals_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekad03_ 14 7 4 4 4 4 13 12 124 */
+/*:ref: zzekad06_ 14 8 4 4 4 4 4 13 12 124 */
+
+extern int ekaced_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, doublereal *dvals, logical *isnull, ftnlen column_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekad02_ 14 6 4 4 4 4 7 12 */
+/*:ref: zzekad05_ 14 7 4 4 4 4 4 7 12 */
+
+extern int ekacei_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, integer *ivals, logical *isnull, ftnlen column_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekad01_ 14 6 4 4 4 4 4 12 */
+/*:ref: zzekad04_ 14 7 4 4 4 4 4 4 12 */
+
+extern int ekaclc_(integer *handle, integer *segno, char *column, char *cvals, integer *entszs, logical *nlflgs, integer *rcptrs, integer *wkindx, ftnlen column_len, ftnlen cvals_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzekac03_ 14 8 4 4 4 13 12 4 4 124 */
+/*:ref: zzekac06_ 14 7 4 4 4 13 4 12 124 */
+/*:ref: zzekac09_ 14 7 4 4 4 13 12 4 124 */
+
+extern int ekacld_(integer *handle, integer *segno, char *column, doublereal *dvals, integer *entszs, logical *nlflgs, integer *rcptrs, integer *wkindx, ftnlen column_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzekac02_ 14 7 4 4 4 7 12 4 4 */
+/*:ref: zzekac05_ 14 6 4 4 4 7 4 12 */
+/*:ref: zzekac08_ 14 6 4 4 4 7 12 4 */
+
+extern int ekacli_(integer *handle, integer *segno, char *column, integer *ivals, integer *entszs, logical *nlflgs, integer *rcptrs, integer *wkindx, ftnlen column_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzekac01_ 14 7 4 4 4 4 12 4 4 */
+/*:ref: zzekac04_ 14 6 4 4 4 4 4 12 */
+/*:ref: zzekac07_ 14 6 4 4 4 4 12 4 */
+
+extern int ekappr_(integer *handle, integer *segno, integer *recno);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: ekinsr_ 14 3 4 4 4 */
+
+extern int ekbseg_(integer *handle, char *tabnam, integer *ncols, char *cnames, char *decls, integer *segno, ftnlen tabnam_len, ftnlen cnames_len, ftnlen decls_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: lxdfid_ 14 1 4 */
+/*:ref: chckid_ 14 5 13 4 13 124 124 */
+/*:ref: lxidnt_ 14 6 4 13 4 4 4 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekpdec_ 14 3 13 4 124 */
+/*:ref: zzekstyp_ 4 2 4 4 */
+/*:ref: zzekbs01_ 14 8 4 13 4 13 4 4 124 124 */
+/*:ref: zzekbs02_ 14 8 4 13 4 13 4 4 124 124 */
+
+extern int ekcls_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dascls_ 14 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ekdelr_(integer *handle, integer *segno, integer *recno);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekrbck_ 14 6 13 4 4 4 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekde01_ 14 4 4 4 4 4 */
+/*:ref: zzekde02_ 14 4 4 4 4 4 */
+/*:ref: zzekde03_ 14 4 4 4 4 4 */
+/*:ref: zzekde04_ 14 4 4 4 4 4 */
+/*:ref: zzekde05_ 14 4 4 4 4 4 */
+/*:ref: zzekde06_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: zzektrdl_ 14 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int ekffld_(integer *handle, integer *segno, integer *rcptrs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekff01_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ekfind_(char *query, integer *nmrows, logical *error, char *errmsg, ftnlen query_len, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekqini_ 14 6 4 4 4 13 7 124 */
+/*:ref: zzekscan_ 14 17 13 4 4 4 4 4 4 4 7 13 4 4 12 13 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpars_ 14 19 13 4 4 4 4 4 7 13 4 4 4 13 7 12 13 124 124 124 124 */
+/*:ref: zzeknres_ 14 9 13 4 13 12 13 4 124 124 124 */
+/*:ref: zzektres_ 14 10 13 4 13 7 12 13 4 124 124 124 */
+/*:ref: zzeksemc_ 14 9 13 4 13 12 13 4 124 124 124 */
+/*:ref: eksrch_ 14 8 4 13 7 4 12 13 124 124 */
+
+extern int ekifld_(integer *handle, char *tabnam, integer *ncols, integer *nrows, char *cnames, char *decls, integer *segno, integer *rcptrs, ftnlen tabnam_len, ftnlen cnames_len, ftnlen decls_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ekbseg_ 14 9 4 13 4 13 13 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekif01_ 14 3 4 4 4 */
+/*:ref: zzekif02_ 14 2 4 4 */
+
+extern int ekinsr_(integer *handle, integer *segno, integer *recno);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: filli_ 14 3 4 4 4 */
+/*:ref: ekshdw_ 14 2 4 12 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzektrin_ 14 4 4 4 4 4 */
+/*:ref: zzekrbck_ 14 6 13 4 4 4 4 124 */
+
+extern integer eknseg_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzektrsz_ 4 2 4 4 */
+
+extern int ekopn_(char *fname, char *ifname, integer *ncomch, integer *handle, ftnlen fname_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasonw_ 14 8 13 13 13 4 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekpgin_ 14 1 4 */
+/*:ref: zzekpgan_ 14 4 4 4 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int ekopr_(char *fname, integer *handle, ftnlen fname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dasopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+
+extern int ekops_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dasops_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgin_ 14 1 4 */
+/*:ref: zzekpgan_ 14 4 4 4 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int ekopw_(char *fname, integer *handle, ftnlen fname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dasopw_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+
+extern int ekpsel_(char *query, integer *n, integer *xbegs, integer *xends, char *xtypes, char *xclass, char *tabs, char *cols, logical *error, char *errmsg, ftnlen query_len, ftnlen xtypes_len, ftnlen xclass_len, ftnlen tabs_len, ftnlen cols_len, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekqini_ 14 6 4 4 4 13 7 124 */
+/*:ref: zzekencd_ 14 10 13 4 13 7 12 13 4 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: zzekqsel_ 14 12 4 13 4 4 4 13 4 13 4 124 124 124 */
+/*:ref: zzekqtab_ 14 8 4 13 4 13 13 124 124 124 */
+/*:ref: ekcii_ 14 6 13 4 13 4 124 124 */
+
+extern int ekqmgr_(integer *cindex, integer *elment, char *eqryc, doublereal *eqryd, integer *eqryi, char *fname, integer *row, integer *selidx, char *column, integer *handle, integer *n, char *table, integer *attdsc, integer *ccount, logical *found, integer *nelt, integer *nmrows, logical *semerr, char *errmsg, char *cdata, doublereal *ddata, integer *idata, logical *null, ftnlen eqryc_len, ftnlen fname_len, ftnlen column_len, ftnlen table_len, ftnlen errmsg_len, ftnlen cdata_len);
+extern int eklef_(char *fname, integer *handle, ftnlen fname_len);
+extern int ekuef_(integer *handle);
+extern int ekntab_(integer *n);
+extern int ektnam_(integer *n, char *table, ftnlen table_len);
+extern int ekccnt_(char *table, integer *ccount, ftnlen table_len);
+extern int ekcii_(char *table, integer *cindex, char *column, integer *attdsc, ftnlen table_len, ftnlen column_len);
+extern int eksrch_(integer *eqryi, char *eqryc, doublereal *eqryd, integer *nmrows, logical *semerr, char *errmsg, ftnlen eqryc_len, ftnlen errmsg_len);
+extern int eknelt_(integer *selidx, integer *row, integer *nelt);
+extern int ekgc_(integer *selidx, integer *row, integer *elment, char *cdata, logical *null, logical *found, ftnlen cdata_len);
+extern int ekgd_(integer *selidx, integer *row, integer *elment, doublereal *ddata, logical *null, logical *found);
+extern int ekgi_(integer *selidx, integer *row, integer *elment, integer *idata, logical *null, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: ekopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dascls_ 14 1 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: ekcls_ 14 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: eknseg_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: zzeksinf_ 14 8 4 4 13 4 13 4 124 124 */
+/*:ref: ssizec_ 14 3 4 13 124 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+/*:ref: validc_ 14 4 4 4 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: lnktl_ 4 2 4 4 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: zzekqtab_ 14 8 4 13 4 13 13 124 124 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: appndc_ 14 4 13 13 124 124 */
+/*:ref: appndi_ 14 2 4 4 */
+/*:ref: zzekstop_ 14 1 4 */
+/*:ref: zzeksdec_ 14 1 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekqcnj_ 14 3 4 4 4 */
+/*:ref: zzekqcon_ 14 24 4 13 7 4 4 13 4 13 4 4 13 4 13 4 4 4 4 7 4 124 124 124 124 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzeksupd_ 14 3 4 4 4 */
+/*:ref: zzekkey_ 14 20 4 4 4 4 4 4 4 4 13 4 4 7 4 12 4 4 4 4 12 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekrplk_ 14 4 4 4 4 4 */
+/*:ref: zzekrmch_ 12 15 4 12 4 4 4 4 4 4 4 13 4 4 7 4 124 */
+/*:ref: zzekvmch_ 12 13 4 12 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzekjsqz_ 14 1 4 */
+/*:ref: zzekjoin_ 14 18 4 4 4 12 4 4 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: zzekweed_ 14 3 4 4 4 */
+/*:ref: zzekvset_ 14 2 4 4 */
+/*:ref: zzekqsel_ 14 12 4 13 4 4 4 13 4 13 4 124 124 124 */
+/*:ref: zzekqord_ 14 11 4 13 4 13 4 13 4 4 124 124 124 */
+/*:ref: zzekjsrt_ 14 13 4 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzekvcal_ 14 3 4 4 4 */
+/*:ref: zzekesiz_ 4 4 4 4 4 4 */
+/*:ref: zzekrsc_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: zzekrsd_ 14 8 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrsi_ 14 8 4 4 4 4 4 4 12 12 */
+
+extern int ekrcec_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, char *cvals, logical *isnull, ftnlen column_len, ftnlen cvals_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekrd03_ 14 8 4 4 4 4 4 13 12 124 */
+/*:ref: zzekesiz_ 4 4 4 4 4 4 */
+/*:ref: zzekrd06_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: zzekrd09_ 14 8 4 4 4 4 4 13 12 124 */
+
+extern int ekrced_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, doublereal *dvals, logical *isnull, ftnlen column_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekrd02_ 14 6 4 4 4 4 7 12 */
+/*:ref: zzekesiz_ 4 4 4 4 4 4 */
+/*:ref: zzekrd05_ 14 9 4 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrd08_ 14 6 4 4 4 4 7 12 */
+
+extern int ekrcei_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, integer *ivals, logical *isnull, ftnlen column_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekrd01_ 14 6 4 4 4 4 4 12 */
+/*:ref: zzekesiz_ 4 4 4 4 4 4 */
+/*:ref: zzekrd04_ 14 9 4 4 4 4 4 4 4 12 12 */
+/*:ref: zzekrd07_ 14 6 4 4 4 4 4 12 */
+
+extern int ekshdw_(integer *handle, logical *isshad);
+
+extern int ekssum_(integer *handle, integer *segno, char *tabnam, integer *nrows, integer *ncols, char *cnames, char *dtypes, integer *sizes, integer *strlns, logical *indexd, logical *nullok, ftnlen tabnam_len, ftnlen cnames_len, ftnlen dtypes_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksinf_ 14 8 4 4 13 4 13 4 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ekucec_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, char *cvals, logical *isnull, ftnlen column_len, ftnlen cvals_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: ekshdw_ 14 2 4 12 */
+/*:ref: zzekrbck_ 14 6 13 4 4 4 4 124 */
+/*:ref: zzekue03_ 14 7 4 4 4 4 13 12 124 */
+/*:ref: zzekue06_ 14 8 4 4 4 4 4 13 12 124 */
+
+extern int ekuced_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, doublereal *dvals, logical *isnull, ftnlen column_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: ekshdw_ 14 2 4 12 */
+/*:ref: zzekrbck_ 14 6 13 4 4 4 4 124 */
+/*:ref: zzekue02_ 14 6 4 4 4 4 7 12 */
+/*:ref: zzekue05_ 14 7 4 4 4 4 4 7 12 */
+
+extern int ekucei_(integer *handle, integer *segno, integer *recno, char *column, integer *nvals, integer *ivals, logical *isnull, ftnlen column_len);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekcdsc_ 14 5 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: ekshdw_ 14 2 4 12 */
+/*:ref: zzekrbck_ 14 6 13 4 4 4 4 124 */
+/*:ref: zzekue01_ 14 6 4 4 4 4 4 12 */
+/*:ref: zzekue04_ 14 7 4 4 4 4 4 4 12 */
+
+extern int el2cgv_(doublereal *ellips, doublereal *center, doublereal *smajor, doublereal *sminor);
+/*:ref: vequ_ 14 2 7 7 */
+
+extern logical elemc_(char *item, char *a, ftnlen item_len, ftnlen a_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical elemd_(doublereal *item, doublereal *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bsrchd_ 4 3 7 4 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical elemi_(integer *item, integer *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bsrchi_ 4 3 4 4 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int elltof_(doublereal *ma, doublereal *ecc, doublereal *e);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pi_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: dcbrt_ 7 1 7 */
+
+extern int enchar_(integer *number, char *string, ftnlen string_len);
+extern int dechar_(char *string, integer *number, ftnlen string_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: chbase_ 4 0 */
+
+extern logical eqchr_(char *a, char *b, ftnlen a_len, ftnlen b_len);
+extern logical nechr_(char *a, char *b, ftnlen a_len, ftnlen b_len);
+
+extern int eqncpv_(doublereal *et, doublereal *epoch, doublereal *eqel, doublereal *rapol, doublereal *decpol, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: twopi_ 7 0 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: kepleq_ 7 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vlcom3_ 14 7 7 7 7 7 7 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+
+extern logical eqstr_(char *a, char *b, ftnlen a_len, ftnlen b_len);
+
+extern int erract_(char *op, char *action, ftnlen op_len, ftnlen action_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: getact_ 14 1 4 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: putact_ 14 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int errch_(char *marker, char *string, ftnlen marker_len, ftnlen string_len);
+/*:ref: allowd_ 12 0 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: getlms_ 14 2 13 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: nblen_ 4 2 13 124 */
+/*:ref: putlms_ 14 2 13 124 */
+
+extern int errdev_(char *op, char *device, ftnlen op_len, ftnlen device_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: getdev_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: putdev_ 14 2 13 124 */
+
+extern int errdp_(char *marker, doublereal *dpnum, ftnlen marker_len);
+/*:ref: allowd_ 12 0 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: getlms_ 14 2 13 124 */
+/*:ref: dpstr_ 14 4 7 4 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: putlms_ 14 2 13 124 */
+
+extern int errfnm_(char *marker, integer *unit, ftnlen marker_len);
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int errhan_(char *marker, integer *handle, ftnlen marker_len);
+/*:ref: zzddhnfo_ 14 7 4 13 4 4 4 12 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int errint_(char *marker, integer *integr, ftnlen marker_len);
+/*:ref: allowd_ 12 0 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: getlms_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: putlms_ 14 2 13 124 */
+
+extern int errprt_(char *op, char *list, ftnlen op_len, ftnlen list_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: msgsel_ 12 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: lparse_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: setprt_ 12 5 12 12 12 12 12 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer esrchc_(char *value, integer *ndim, char *array, ftnlen value_len, ftnlen array_len);
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+
+extern int et2lst_(doublereal *et, integer *body, doublereal *long__, char *type__, integer *hr, integer *mn, integer *sc, char *time, char *ampm, ftnlen type_len, ftnlen time_len, ftnlen ampm_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: pgrrec_ 14 8 13 7 7 7 7 7 7 124 */
+/*:ref: reclat_ 14 4 7 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: rmaind_ 14 4 7 7 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: pi_ 7 0 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: dpfmt_ 14 5 7 13 13 124 124 */
+
+extern int et2utc_(doublereal *et, char *format, integer *prec, char *utcstr, ftnlen format_len, ftnlen utcstr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ttrans_ 14 5 13 13 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dpstrf_ 14 6 7 4 13 13 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: unitim_ 7 5 7 13 13 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int etcal_(doublereal *et, char *string, ftnlen string_len);
+/*:ref: spd_ 7 0 */
+/*:ref: intmax_ 4 0 */
+/*:ref: intmin_ 4 0 */
+/*:ref: lstlti_ 4 3 4 4 4 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: dpstrf_ 14 6 7 4 13 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+
+extern int eul2m_(doublereal *angle3, doublereal *angle2, doublereal *angle1, integer *axis3, integer *axis2, integer *axis1, doublereal *r__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rotate_ 14 3 7 4 7 */
+/*:ref: rotmat_ 14 4 7 7 4 7 */
+
+extern int ev2lin_(doublereal *et, doublereal *geophs, doublereal *elems, doublereal *state);
+/*:ref: twopi_ 7 0 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+
+extern logical even_(integer *i__);
+
+extern doublereal exact_(doublereal *number, doublereal *value, doublereal *tol);
+
+extern int excess_(integer *number, char *struct__, ftnlen struct_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical exists_(char *file, ftnlen file_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int expln_(char *msg, char *expl, ftnlen msg_len, ftnlen expl_len);
+
+extern integer fetchc_(integer *nth, char *set, ftnlen set_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer fetchd_(integer *nth, doublereal *set);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer fetchi_(integer *nth, integer *set);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int fillc_(char *value, integer *ndim, char *array, ftnlen value_len, ftnlen array_len);
+
+extern int filld_(doublereal *value, integer *ndim, doublereal *array);
+
+extern int filli_(integer *value, integer *ndim, integer *array);
+
+extern int fn2lun_(char *filnam, integer *lunit, ftnlen filnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int fndlun_(integer *unit);
+extern int reslun_(integer *unit);
+extern int frelun_(integer *unit);
+
+extern int fndnwd_(char *string, integer *start, integer *b, integer *e, ftnlen string_len);
+
+extern int frame_(doublereal *x, doublereal *y, doublereal *z__);
+/*:ref: vhatip_ 14 1 7 */
+
+extern int framex_(char *cname, char *frname, integer *frcode, integer *cent, integer *class__, integer *clssid, logical *found, ftnlen cname_len, ftnlen frname_len);
+extern int namfrm_(char *frname, integer *frcode, ftnlen frname_len);
+extern int frmnam_(integer *frcode, char *frname, ftnlen frname_len);
+extern int frinfo_(integer *frcode, integer *cent, integer *class__, integer *clssid, logical *found);
+extern int cidfrm_(integer *cent, integer *frcode, char *frname, logical *found, ftnlen frname_len);
+extern int cnmfrm_(char *cname, integer *frcode, char *frname, logical *found, ftnlen cname_len, ftnlen frname_len);
+extern int ccifrm_(integer *class__, integer *clssid, integer *frcode, char *frname, integer *cent, logical *found, ftnlen frname_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: zzfdat_ 14 10 4 13 4 4 4 4 4 4 4 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: bschoc_ 4 6 13 4 13 4 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+/*:ref: bschoi_ 4 4 4 4 4 4 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: zzdynbid_ 14 6 13 4 13 4 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzdynvai_ 14 8 13 4 13 4 4 4 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: bodn2c_ 14 4 13 4 12 124 */
+/*:ref: gnpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int frmchg_(integer *frame1, integer *frame2, doublereal *et, doublereal *xform);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: frmget_ 14 5 4 7 7 4 12 */
+/*:ref: zzmsxf_ 14 3 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zznofcon_ 14 7 7 4 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: invstm_ 14 2 7 7 */
+
+extern int frmget_(integer *infrm, doublereal *et, doublereal *xform, integer *outfrm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: tisbod_ 14 5 13 4 7 7 124 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: ckfxfm_ 14 5 4 7 7 4 12 */
+/*:ref: tkfram_ 14 4 4 7 4 12 */
+/*:ref: zzdynfrm_ 14 5 4 4 7 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+
+extern integer frstnb_(char *string, ftnlen string_len);
+
+extern integer frstnp_(char *string, ftnlen string_len);
+
+extern integer frstpc_(char *string, ftnlen string_len);
+
+extern integer gcd_(integer *a, integer *b);
+
+extern int georec_(doublereal *long__, doublereal *lat, doublereal *alt, doublereal *re, doublereal *f, doublereal *rectan);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: surfnm_ 14 5 7 7 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int getelm_(integer *frstyr, char *lines, doublereal *epoch, doublereal *elems, ftnlen lines_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzgetelm_ 14 8 4 13 7 7 12 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int getfat_(char *file, char *arch, char *kertyp, ftnlen file_len, ftnlen arch_len, ftnlen kertyp_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhfnh_ 14 4 13 4 12 124 */
+/*:ref: zzddhnfo_ 14 7 4 13 4 4 4 12 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: dashof_ 14 1 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+/*:ref: idw2at_ 14 6 13 13 13 124 124 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: zzckspk_ 14 3 4 13 124 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int getfov_(integer *instid, integer *room, char *shape, char *frame, doublereal *bsight, integer *n, doublereal *bounds, ftnlen shape_len, ftnlen frame_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: vrotv_ 14 4 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+
+extern int getlun_(integer *unit);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: fndlun_ 14 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int getmsg_(char *option, char *msg, ftnlen option_len, ftnlen msg_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: getsms_ 14 2 13 124 */
+/*:ref: expln_ 14 4 13 13 124 124 */
+/*:ref: getlms_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern logical gfbail_(void);
+
+extern int gfdist_(char *target, char *abcorr, char *obsrvr, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: gfevnt_ 14 28 200 200 13 4 13 13 7 4 12 13 7 7 7 7 12 200 200 200 4 4 7 12 212 7 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfevnt_(U_fp udstep, U_fp udrefn, char *gquant, integer *qnpars, char *qpnams, char *qcpars, doublereal *qdpars, integer *qipars, logical *qlpars, char *op, doublereal *refval, doublereal *tol, doublereal *adjust, doublereal *cnfine, logical *rpt, U_fp udrepi, U_fp udrepu, U_fp udrepf, integer *mw, integer *nw, doublereal *work, logical *bail, L_fp udbail, doublereal *result, ftnlen gquant_len, ftnlen qpnams_len, ftnlen qcpars_len, ftnlen op_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: zzgfspin_ 14 11 13 13 13 13 7 13 124 124 124 124 124 */
+/*:ref: zzgfrel_ 14 26 200 200 200 200 200 200 13 7 7 7 7 4 4 7 12 200 200 200 13 13 12 212 7 124 124 124 */
+/*:ref: zzgfdiin_ 14 7 13 13 13 7 124 124 124 */
+/*:ref: zzgfcslv_ 14 37 13 13 13 13 13 13 13 7 13 13 13 7 7 7 200 200 12 200 200 200 12 212 4 4 7 7 7 124 124 124 124 124 124 124 124 124 124 */
+/*:ref: zzgfrrin_ 14 8 13 13 13 7 7 124 124 124 */
+
+extern int gffove_(char *inst, char *tshape, doublereal *raydir, char *target, char *tframe, char *abcorr, char *obsrvr, doublereal *tol, U_fp udstep, U_fp udrefn, logical *rpt, S_fp udrepi, U_fp udrepu, S_fp udrepf, logical *bail, L_fp udbail, doublereal *cnfine, doublereal *result, ftnlen inst_len, ftnlen tshape_len, ftnlen target_len, ftnlen tframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: zzgffvin_ 14 13 13 13 7 13 13 13 13 124 124 124 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: wncard_ 4 1 7 */
+/*:ref: wnfetd_ 14 4 7 4 7 7 */
+/*:ref: zzgfsolv_ 14 13 200 200 200 12 212 12 7 7 7 7 12 200 7 */
+
+extern int gfocce_(char *occtyp, char *front, char *fshape, char *fframe, char *back, char *bshape, char *bframe, char *abcorr, char *obsrvr, doublereal *tol, U_fp udstep, U_fp udrefn, logical *rpt, S_fp udrepi, U_fp udrepu, S_fp udrepf, logical *bail, L_fp udbail, doublereal *cnfine, doublereal *result, ftnlen occtyp_len, ftnlen front_len, ftnlen fshape_len, ftnlen fframe_len, ftnlen back_len, ftnlen bshape_len, ftnlen bframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzgfocin_ 14 18 13 13 13 13 13 13 13 13 13 124 124 124 124 124 124 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: wncard_ 4 1 7 */
+/*:ref: wnfetd_ 14 4 7 4 7 7 */
+/*:ref: zzgfsolv_ 14 13 200 200 200 12 212 12 7 7 7 7 12 200 7 */
+
+extern int gfoclt_(char *occtyp, char *front, char *fshape, char *fframe, char *back, char *bshape, char *bframe, char *abcorr, char *obsrvr, doublereal *step, doublereal *cnfine, doublereal *result, ftnlen occtyp_len, ftnlen front_len, ftnlen fshape_len, ftnlen fframe_len, ftnlen back_len, ftnlen bshape_len, ftnlen bframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: gfocce_ 14 29 13 13 13 13 13 13 13 13 13 7 200 200 12 200 200 200 12 212 7 7 124 124 124 124 124 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfposc_(char *target, char *frame, char *abcorr, char *obsrvr, char *crdsys, char *coord, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen target_len, ftnlen frame_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen crdsys_len, ftnlen coord_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: gfevnt_ 14 28 200 200 13 4 13 13 7 4 12 13 7 7 7 7 12 200 200 200 4 4 7 12 212 7 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfrefn_(doublereal *t1, doublereal *t2, logical *s1, logical *s2, doublereal *t);
+/*:ref: brcktd_ 7 3 7 7 7 */
+
+extern int gfrfov_(char *inst, doublereal *raydir, char *rframe, char *abcorr, char *obsrvr, doublereal *step, doublereal *cnfine, doublereal *result, ftnlen inst_len, ftnlen rframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: gffove_ 14 24 13 13 7 13 13 13 13 7 200 200 12 200 200 200 12 212 7 7 124 124 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfrprt_(doublereal *window, char *begmss, char *endmss, doublereal *ivbeg, doublereal *ivend, doublereal *time, ftnlen begmss_len, ftnlen endmss_len);
+extern int gfrepi_(doublereal *window, char *begmss, char *endmss, ftnlen begmss_len, ftnlen endmss_len);
+extern int gfrepu_(doublereal *ivbeg, doublereal *ivend, doublereal *time);
+extern int gfrepf_(void);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: wnsumd_ 14 6 7 7 7 7 4 4 */
+/*:ref: zzgftswk_ 14 7 7 7 4 13 13 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: zzgfwkin_ 14 1 7 */
+/*:ref: zzgfwkad_ 14 6 7 4 13 13 124 124 */
+/*:ref: zzgfwkmo_ 14 9 4 7 7 4 13 13 7 124 124 */
+/*:ref: stdio_ 14 3 13 4 124 */
+/*:ref: zzgfdsps_ 14 6 4 13 13 4 124 124 */
+
+extern int gfrr_(char *target, char *abcorr, char *obsrvr, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: gfevnt_ 14 28 200 200 13 4 13 13 7 4 12 13 7 7 7 7 12 200 200 200 4 4 7 12 212 7 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfsep_(char *targ1, char *shape1, char *frame1, char *targ2, char *shape2, char *frame2, char *abcorr, char *obsrvr, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen targ1_len, ftnlen shape1_len, ftnlen frame1_len, ftnlen targ2_len, ftnlen shape2_len, ftnlen frame2_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: gfevnt_ 14 28 200 200 13 4 13 13 7 4 12 13 7 7 7 7 12 200 200 200 4 4 7 12 212 7 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfsntc_(char *target, char *fixref, char *method, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, char *crdsys, char *coord, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen target_len, ftnlen fixref_len, ftnlen method_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len, ftnlen crdsys_len, ftnlen coord_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: gfevnt_ 14 28 200 200 13 4 13 13 7 4 12 13 7 7 7 7 12 200 200 200 4 4 7 12 212 7 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfstep_(doublereal *time, doublereal *step);
+extern int gfsstp_(doublereal *step);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+
+extern int gfsubc_(char *target, char *fixref, char *method, char *abcorr, char *obsrvr, char *crdsys, char *coord, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen target_len, ftnlen fixref_len, ftnlen method_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen crdsys_len, ftnlen coord_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: gfevnt_ 14 28 200 200 13 4 13 13 7 4 12 13 7 7 7 7 12 200 200 200 4 4 7 12 212 7 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gftfov_(char *inst, char *target, char *tshape, char *tframe, char *abcorr, char *obsrvr, doublereal *step, doublereal *cnfine, doublereal *result, ftnlen inst_len, ftnlen target_len, ftnlen tshape_len, ftnlen tframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: gffove_ 14 24 13 13 7 13 13 13 13 7 200 200 12 200 200 200 12 212 7 7 124 124 124 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern int gfuds_(U_fp udfunc, U_fp udqdec, char *relate, doublereal *refval, doublereal *adjust, doublereal *step, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, doublereal *result, ftnlen relate_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: gfsstp_ 14 1 7 */
+/*:ref: zzgfref_ 14 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: zzgfrelx_ 14 26 200 200 200 200 200 214 13 7 7 7 7 4 4 7 12 200 200 200 13 13 12 212 7 124 124 124 */
+/*:ref: gfbail_ 12 :*/
+
+extern doublereal halfpi_(void);
+
+extern int hrmesp_(integer *n, doublereal *first, doublereal *step, doublereal *yvals, doublereal *x, doublereal *work, doublereal *f, doublereal *df);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int hrmint_(integer *n, doublereal *xvals, doublereal *yvals, doublereal *x, doublereal *work, doublereal *f, doublereal *df);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+
+extern int hx2dp_(char *string, doublereal *number, logical *error, char *errmsg, ftnlen string_len, ftnlen errmsg_len);
+/*:ref: dpmin_ 7 0 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: hx2int_ 14 6 13 4 12 13 124 124 */
+
+extern int hx2int_(char *string, integer *number, logical *error, char *errmsg, ftnlen string_len, ftnlen errmsg_len);
+/*:ref: intmin_ 4 0 */
+/*:ref: intmax_ 4 0 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+
+extern int hyptof_(doublereal *ma, doublereal *ecc, doublereal *f);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dcbrt_ 7 1 7 */
+
+extern int ident_(doublereal *matrix);
+
+extern int idw2at_(char *idword, char *arch, char *type__, ftnlen idword_len, ftnlen arch_len, ftnlen type_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+
+extern int illum_(char *target, doublereal *et, char *abcorr, char *obsrvr, doublereal *spoint, doublereal *phase, doublereal *solar, doublereal *emissn, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: surfnm_ 14 5 7 7 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+
+extern int ilumin_(char *method, char *target, doublereal *et, char *fixref, char *abcorr, char *obsrvr, doublereal *spoint, doublereal *trgepc, doublereal *srfvec, doublereal *phase, doublereal *solar, doublereal *emissn, ftnlen method_len, ftnlen target_len, ftnlen fixref_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: surfnm_ 14 5 7 7 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+
+extern int inedpl_(doublereal *a, doublereal *b, doublereal *c__, doublereal *plane, doublereal *ellips, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: pl2psv_ 14 4 7 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: psv2pl_ 14 4 7 7 7 7 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: cgv2el_ 14 4 7 7 7 7 */
+
+extern int inelpl_(doublereal *ellips, doublereal *plane, integer *nxpts, doublereal *xpt1, doublereal *xpt2);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: pl2nvp_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: nvp2pl_ 14 3 7 7 7 */
+/*:ref: vzerog_ 12 2 7 4 */
+/*:ref: vnormg_ 7 2 7 4 */
+/*:ref: vlcom3_ 14 7 7 7 7 7 7 7 7 */
+
+extern int inrypl_(doublereal *vertex, doublereal *dir, doublereal *plane, integer *nxpts, doublereal *xpt);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: smsgnd_ 12 2 7 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+
+extern int inslac_(char *elts, integer *ne, integer *loc, char *array, integer *na, ftnlen elts_len, ftnlen array_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int inslad_(doublereal *elts, integer *ne, integer *loc, doublereal *array, integer *na);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int inslai_(integer *elts, integer *ne, integer *loc, integer *array, integer *na);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int insrtc_(char *item, char *a, ftnlen item_len, ftnlen a_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int insrtd_(doublereal *item, doublereal *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int insrti_(integer *item, integer *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlei_ 4 3 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int inssub_(char *in, char *sub, integer *loc, char *out, ftnlen in_len, ftnlen sub_len, ftnlen out_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int int2hx_(integer *number, char *string, integer *length, ftnlen string_len);
+
+extern int interc_(char *a, char *b, char *c__, ftnlen a_len, ftnlen b_len, ftnlen c_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: excess_ 14 3 4 13 124 */
+
+extern int interd_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int interi_(integer *a, integer *b, integer *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int intord_(integer *n, char *string, ftnlen string_len);
+/*:ref: inttxt_ 14 3 4 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int intstr_(integer *number, char *string, ftnlen string_len);
+
+extern int inttxt_(integer *n, char *string, ftnlen string_len);
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int invert_(doublereal *m1, doublereal *mout);
+/*:ref: det_ 7 1 7 */
+/*:ref: filld_ 14 3 7 4 7 */
+/*:ref: vsclg_ 14 4 7 7 4 7 */
+
+extern int invort_(doublereal *m, doublereal *mit);
+/*:ref: dpmax_ 7 0 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: xpose_ 14 2 7 7 */
+
+extern int invstm_(doublereal *mat, doublereal *invmat);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: xposbl_ 14 5 7 4 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ioerr_(char *action, char *file, integer *iostat, ftnlen action_len, ftnlen file_len);
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+
+extern int irftrn_(char *refa, char *refb, doublereal *rotab, ftnlen refa_len, ftnlen refb_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int iso2utc_(char *tstrng, char *utcstr, char *error, ftnlen tstrng_len, ftnlen utcstr_len, ftnlen error_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical isopen_(char *file, ftnlen file_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern logical isordv_(integer *array, integer *n);
+
+extern integer isrchc_(char *value, integer *ndim, char *array, ftnlen value_len, ftnlen array_len);
+
+extern integer isrchd_(doublereal *value, integer *ndim, doublereal *array);
+
+extern integer isrchi_(integer *value, integer *ndim, integer *array);
+
+extern logical isrot_(doublereal *m, doublereal *ntol, doublereal *dtol);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: det_ 7 1 7 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+
+extern doublereal j1900_(void);
+
+extern doublereal j1950_(void);
+
+extern doublereal j2000_(void);
+
+extern doublereal j2100_(void);
+
+extern int jul2gr_(integer *year, integer *month, integer *day, integer *doy);
+extern int gr2jul_(integer *year, integer *month, integer *day, integer *doy);
+/*:ref: rmaini_ 14 4 4 4 4 4 */
+/*:ref: lstlti_ 4 3 4 4 4 */
+
+extern doublereal jyear_(void);
+
+extern int keeper_(integer *which, char *kind, char *file, integer *count, char *filtyp, integer *handle, char *source, logical *found, ftnlen kind_len, ftnlen file_len, ftnlen filtyp_len, ftnlen source_len);
+extern int furnsh_(char *file, ftnlen file_len);
+extern int ktotal_(char *kind, integer *count, ftnlen kind_len);
+extern int kdata_(integer *which, char *kind, char *file, char *filtyp, char *source, integer *handle, logical *found, ftnlen kind_len, ftnlen file_len, ftnlen filtyp_len, ftnlen source_len);
+extern int kinfo_(char *file, char *filtyp, char *source, integer *handle, logical *found, ftnlen file_len, ftnlen filtyp_len, ftnlen source_len);
+extern int kclear_(void);
+extern int unload_(char *file, ftnlen file_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzldker_ 14 7 13 13 13 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: stpool_ 14 9 13 4 13 13 4 12 124 124 124 */
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: samsub_ 12 8 13 4 4 13 4 4 124 124 */
+/*:ref: repsub_ 14 8 13 4 4 13 13 124 124 124 */
+/*:ref: repmot_ 14 9 13 13 4 13 13 124 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dvpool_ 14 2 13 124 */
+/*:ref: fndnwd_ 14 5 13 4 4 4 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: spkuef_ 14 1 4 */
+/*:ref: ckupf_ 14 1 4 */
+/*:ref: pckuof_ 14 1 4 */
+/*:ref: ekuef_ 14 1 4 */
+/*:ref: clpool_ 14 0 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: ldpool_ 14 2 13 124 */
+/*:ref: spklef_ 14 3 13 4 124 */
+/*:ref: cklpf_ 14 3 13 4 124 */
+/*:ref: pcklof_ 14 3 13 4 124 */
+/*:ref: eklef_ 14 3 13 4 124 */
+
+extern doublereal kepleq_(doublereal *ml, doublereal *h__, doublereal *k);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: kpsolv_ 7 1 7 */
+
+extern doublereal kpsolv_(doublereal *evec);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int kxtrct_(char *keywd, char *terms, integer *nterms, char *string, logical *found, char *substr, ftnlen keywd_len, ftnlen terms_len, ftnlen string_len, ftnlen substr_len);
+/*:ref: wdindx_ 4 4 13 13 124 124 */
+/*:ref: nblen_ 4 2 13 124 */
+/*:ref: fndnwd_ 14 5 13 4 4 4 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: shiftl_ 14 7 13 4 13 13 124 124 124 */
+
+extern integer lastnb_(char *string, ftnlen string_len);
+
+extern integer lastpc_(char *string, ftnlen string_len);
+
+extern int latcyl_(doublereal *radius, doublereal *long__, doublereal *lat, doublereal *r__, doublereal *longc, doublereal *z__);
+
+extern int latrec_(doublereal *radius, doublereal *long__, doublereal *lat, doublereal *rectan);
+
+extern int latsph_(doublereal *radius, doublereal *long__, doublereal *lat, doublereal *rho, doublereal *colat, doublereal *longs);
+/*:ref: halfpi_ 7 0 */
+
+extern int lbuild_(char *items, integer *n, char *delim, char *list, ftnlen items_len, ftnlen delim_len, ftnlen list_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int lcase_(char *in, char *out, ftnlen in_len, ftnlen out_len);
+
+extern doublereal lgresp_(integer *n, doublereal *first, doublereal *step, doublereal *yvals, doublereal *work, doublereal *x);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lgrind_(integer *n, doublereal *xvals, doublereal *yvals, doublereal *work, doublereal *x, doublereal *p, doublereal *dp);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+
+extern doublereal lgrint_(integer *n, doublereal *xvals, doublereal *yvals, doublereal *work, doublereal *x);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+
+extern int ljust_(char *input, char *output, ftnlen input_len, ftnlen output_len);
+
+extern int lnkan_(integer *pool, integer *new__);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lnkfsl_(integer *head, integer *tail, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer lnkhl_(integer *node, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lnkila_(integer *prev, integer *list, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lnkilb_(integer *list, integer *next, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lnkini_(integer *size, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer lnknfn_(integer *pool);
+
+extern integer lnknxt_(integer *node, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer lnkprv_(integer *node, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer lnksiz_(integer *pool);
+
+extern integer lnktl_(integer *node, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lnkxsl_(integer *head, integer *tail, integer *pool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int locati_(integer *id, integer *idsz, integer *list, integer *pool, integer *at, logical *presnt);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnksiz_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: lnkxsl_ 14 3 4 4 4 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+
+extern int locln_(integer *unit, char *bmark, char *emark, char *line, integer *bline, integer *eline, logical *found, ftnlen bmark_len, ftnlen emark_len, ftnlen line_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ltrim_ 4 2 13 124 */
+
+extern int lparse_(char *list, char *delim, integer *nmax, integer *n, char *items, ftnlen list_len, ftnlen delim_len, ftnlen items_len);
+
+extern int lparsm_(char *list, char *delims, integer *nmax, integer *n, char *items, ftnlen list_len, ftnlen delims_len, ftnlen items_len);
+
+extern int lparss_(char *list, char *delims, char *set, ftnlen list_len, ftnlen delims_len, ftnlen set_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: insrtc_ 14 4 13 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: validc_ 14 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern doublereal lspcn_(char *body, doublereal *et, char *abcorr, ftnlen body_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: tipbod_ 14 5 13 4 7 7 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: twovec_ 14 5 7 4 7 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: spkezr_ 14 11 13 7 13 13 13 7 7 124 124 124 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: recrad_ 14 4 7 7 7 7 */
+
+extern integer lstcld_(doublereal *x, integer *n, doublereal *array);
+
+extern integer lstcli_(integer *x, integer *n, integer *array);
+
+extern integer lstlec_(char *string, integer *n, char *array, ftnlen string_len, ftnlen array_len);
+
+extern integer lstled_(doublereal *x, integer *n, doublereal *array);
+
+extern integer lstlei_(integer *x, integer *n, integer *array);
+
+extern integer lstltc_(char *string, integer *n, char *array, ftnlen string_len, ftnlen array_len);
+
+extern integer lstltd_(doublereal *x, integer *n, doublereal *array);
+
+extern integer lstlti_(integer *x, integer *n, integer *array);
+
+extern int ltime_(doublereal *etobs, integer *obs, char *dir, integer *targ, doublereal *ettarg, doublereal *elapsd, ftnlen dir_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: clight_ 7 0 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: failed_ 12 0 */
+
+extern integer ltrim_(char *string, ftnlen string_len);
+/*:ref: frstnb_ 4 2 13 124 */
+
+extern int lun2fn_(integer *lunit, char *filnam, ftnlen filnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int lx4dec_(char *string, integer *first, integer *last, integer *nchar, ftnlen string_len);
+/*:ref: lx4uns_ 14 5 13 4 4 4 124 */
+/*:ref: lx4sgn_ 14 5 13 4 4 4 124 */
+
+extern int lx4num_(char *string, integer *first, integer *last, integer *nchar, ftnlen string_len);
+/*:ref: lx4dec_ 14 5 13 4 4 4 124 */
+/*:ref: lx4sgn_ 14 5 13 4 4 4 124 */
+
+extern int lx4sgn_(char *string, integer *first, integer *last, integer *nchar, ftnlen string_len);
+/*:ref: lx4uns_ 14 5 13 4 4 4 124 */
+
+extern int lx4uns_(char *string, integer *first, integer *last, integer *nchar, ftnlen string_len);
+
+extern int lxname_(char *hdchrs, char *tlchrs, char *string, integer *first, integer *last, integer *idspec, integer *nchar, ftnlen hdchrs_len, ftnlen tlchrs_len, ftnlen string_len);
+extern int lxidnt_(integer *idspec, char *string, integer *first, integer *last, integer *nchar, ftnlen string_len);
+extern int lxdfid_(integer *idspec);
+extern int lxcsid_(char *hdchrs, char *tlchrs, integer *idspec, ftnlen hdchrs_len, ftnlen tlchrs_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: bsrchi_ 4 3 4 4 4 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: validi_ 14 3 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: appndi_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: cardi_ 4 1 4 */
+
+extern int lxqstr_(char *string, char *qchar, integer *first, integer *last, integer *nchar, ftnlen string_len, ftnlen qchar_len);
+
+extern int m2eul_(doublereal *r__, integer *axis3, integer *axis2, integer *axis1, doublereal *angle3, doublereal *angle2, doublereal *angle1);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: isrot_ 12 3 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: mtxm_ 14 3 7 7 7 */
+
+extern int m2q_(doublereal *r__, doublereal *q);
+/*:ref: isrot_ 12 3 7 7 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical matchi_(char *string, char *templ, char *wstr, char *wchr, ftnlen string_len, ftnlen templ_len, ftnlen wstr_len, ftnlen wchr_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: samch_ 12 6 13 4 13 4 124 124 */
+/*:ref: nechr_ 12 4 13 13 124 124 */
+/*:ref: samchi_ 12 6 13 4 13 4 124 124 */
+
+extern logical matchw_(char *string, char *templ, char *wstr, char *wchr, ftnlen string_len, ftnlen templ_len, ftnlen wstr_len, ftnlen wchr_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: samch_ 12 6 13 4 13 4 124 124 */
+
+extern int maxac_(char *array, integer *ndim, char *maxval, integer *loc, ftnlen array_len, ftnlen maxval_len);
+
+extern int maxad_(doublereal *array, integer *ndim, doublereal *maxval, integer *loc);
+
+extern int maxai_(integer *array, integer *ndim, integer *maxval, integer *loc);
+
+extern int mequ_(doublereal *m1, doublereal *mout);
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int mequg_(doublereal *m1, integer *nr, integer *nc, doublereal *mout);
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int minac_(char *array, integer *ndim, char *minval, integer *loc, ftnlen array_len, ftnlen minval_len);
+
+extern int minad_(doublereal *array, integer *ndim, doublereal *minval, integer *loc);
+
+extern int minai_(integer *array, integer *ndim, integer *minval, integer *loc);
+
+extern int movec_(char *arrfrm, integer *ndim, char *arrto, ftnlen arrfrm_len, ftnlen arrto_len);
+
+extern int movei_(integer *arrfrm, integer *ndim, integer *arrto);
+
+extern int mtxm_(doublereal *m1, doublereal *m2, doublereal *mout);
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int mtxmg_(doublereal *m1, doublereal *m2, integer *nc1, integer *nr1r2, integer *nc2, doublereal *mout);
+
+extern int mtxv_(doublereal *matrix, doublereal *vin, doublereal *vout);
+
+extern int mtxvg_(doublereal *m1, doublereal *v2, integer *nc1, integer *nr1r2, doublereal *vout);
+
+extern int mxm_(doublereal *m1, doublereal *m2, doublereal *mout);
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int mxmg_(doublereal *m1, doublereal *m2, integer *row1, integer *col1, integer *col2, doublereal *mout);
+
+extern int mxmt_(doublereal *m1, doublereal *m2, doublereal *mout);
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int mxmtg_(doublereal *m1, doublereal *m2, integer *nr1, integer *nc1c2, integer *nr2, doublereal *mout);
+
+extern int mxv_(doublereal *matrix, doublereal *vin, doublereal *vout);
+
+extern int mxvg_(doublereal *m1, doublereal *v2, integer *nr1, integer *nc1r2, doublereal *vout);
+
+extern integer nblen_(char *string, ftnlen string_len);
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+
+extern integer nbwid_(char *array, integer *nelt, ftnlen array_len);
+
+extern integer ncpos_(char *str, char *chars, integer *start, ftnlen str_len, ftnlen chars_len);
+
+extern integer ncposr_(char *str, char *chars, integer *start, ftnlen str_len, ftnlen chars_len);
+
+extern int nearpt_(doublereal *positn, doublereal *a, doublereal *b, doublereal *c__, doublereal *npoint, doublereal *alt);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: orderd_ 14 3 7 4 4 */
+/*:ref: reordd_ 14 3 4 4 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: approx_ 12 3 7 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: surfnm_ 14 5 7 7 7 7 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+
+extern int nextwd_(char *string, char *next, char *rest, ftnlen string_len, ftnlen next_len, ftnlen rest_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+
+extern logical notru_(logical *logcls, integer *n);
+
+extern int nparsd_(char *string, doublereal *x, char *error, integer *ptr, ftnlen string_len, ftnlen error_len);
+/*:ref: dpmax_ 7 0 */
+/*:ref: zzinssub_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: pi_ 7 0 */
+
+extern int nparsi_(char *string, integer *n, char *error, integer *pnter, ftnlen string_len, ftnlen error_len);
+/*:ref: intmax_ 4 0 */
+/*:ref: intmin_ 4 0 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+
+extern int npedln_(doublereal *a, doublereal *b, doublereal *c__, doublereal *linept, doublereal *linedr, doublereal *pnear, doublereal *dist);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: nvc2pl_ 14 3 7 7 7 */
+/*:ref: inedpl_ 14 6 7 7 7 7 7 12 */
+/*:ref: pjelpl_ 14 3 7 7 7 */
+/*:ref: vprjp_ 14 3 7 7 7 */
+/*:ref: npelpt_ 14 4 7 7 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: vprjpi_ 14 5 7 7 7 7 12 */
+/*:ref: vsclip_ 14 2 7 7 */
+
+extern int npelpt_(doublereal *point, doublereal *ellips, doublereal *pnear, doublereal *dist);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: twovec_ 14 5 7 4 7 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+
+extern int nplnpt_(doublereal *linpt, doublereal *lindir, doublereal *point, doublereal *pnear, doublereal *dist);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vproj_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+
+extern int nthwd_(char *string, integer *nth, char *word, integer *loc, ftnlen string_len, ftnlen word_len);
+
+extern int nvc2pl_(doublereal *normal, doublereal *const__, doublereal *plane);
+/*:ref: return_ 12 0 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int nvp2pl_(doublereal *normal, doublereal *point, doublereal *plane);
+/*:ref: return_ 12 0 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern logical odd_(integer *i__);
+
+extern logical opsgnd_(doublereal *x, doublereal *y);
+
+extern logical opsgni_(integer *x, integer *y);
+
+extern integer ordc_(char *item, char *set, ftnlen item_len, ftnlen set_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer ordd_(doublereal *item, doublereal *set);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bsrchd_ 4 3 7 4 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int orderc_(char *array, integer *ndim, integer *iorder, ftnlen array_len);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int orderd_(doublereal *array, integer *ndim, integer *iorder);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int orderi_(integer *array, integer *ndim, integer *iorder);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern integer ordi_(integer *item, integer *set);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bsrchi_ 4 3 4 4 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int oscelt_(doublereal *state, doublereal *et, doublereal *mu, doublereal *elts);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: exact_ 7 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: pi_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: dacosh_ 7 1 7 */
+
+extern int outmsg_(char *list, ftnlen list_len);
+/*:ref: lparse_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: getdev_ 14 2 13 124 */
+/*:ref: wrline_ 14 4 13 13 124 124 */
+/*:ref: msgsel_ 12 2 13 124 */
+/*:ref: tkvrsn_ 14 4 13 13 124 124 */
+/*:ref: getsms_ 14 2 13 124 */
+/*:ref: expln_ 14 4 13 13 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: getlms_ 14 2 13 124 */
+/*:ref: wdcnt_ 4 2 13 124 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: trcdep_ 14 1 4 */
+/*:ref: trcnam_ 14 3 4 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int packac_(char *in, integer *pack, integer *npack, integer *maxout, integer *nout, char *out, ftnlen in_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int packad_(doublereal *in, integer *pack, integer *npack, integer *maxout, integer *nout, doublereal *out);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int packai_(integer *in, integer *pack, integer *npack, integer *maxout, integer *nout, integer *out);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int parsqs_(char *string, char *qchar, char *value, integer *length, logical *error, char *errmsg, integer *ptr, ftnlen string_len, ftnlen qchar_len, ftnlen value_len, ftnlen errmsg_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int partof_(doublereal *ma, doublereal *d__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dcbrt_ 7 1 7 */
+
+extern int pck03a_(integer *handle, integer *ncsets, doublereal *coeffs, doublereal *epochs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgwfpk_ 14 5 4 4 7 4 7 */
+
+extern int pck03b_(integer *handle, char *segid, integer *body, char *frame, doublereal *first, doublereal *last, integer *chbdeg, ftnlen segid_len, ftnlen frame_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pckpds_ 14 7 4 13 4 7 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: sgbwfs_ 14 8 4 7 13 4 7 4 4 124 */
+
+extern int pck03e_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgwes_ 14 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pckbsr_(char *fname, integer *handle, integer *body, doublereal *et, doublereal *descr, char *ident, logical *found, ftnlen fname_len, ftnlen ident_len);
+extern int pcklof_(char *fname, integer *handle, ftnlen fname_len);
+extern int pckuof_(integer *handle);
+extern int pcksfs_(integer *body, doublereal *et, integer *handle, doublereal *descr, char *ident, logical *found, ftnlen ident_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: lnkprv_ 4 2 4 4 */
+/*:ref: dpmin_ 7 0 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafbbs_ 14 1 4 */
+/*:ref: daffpa_ 14 1 12 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: dafgn_ 14 2 13 124 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: lnktl_ 4 2 4 4 */
+
+extern int pckcls_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int pckcov_(char *pck, integer *idcode, doublereal *cover, ftnlen pck_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int pcke02_(doublereal *et, doublereal *record, doublereal *eulang);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spke02_ 14 3 7 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pcke03_(doublereal *et, doublereal *record, doublereal *rotmat);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chbval_ 14 5 7 4 7 7 7 */
+/*:ref: rpd_ 7 0 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pckeul_(integer *body, doublereal *et, logical *found, char *ref, doublereal *eulang, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: pcksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: irfnam_ 14 3 4 13 124 */
+/*:ref: pckr02_ 14 4 4 7 7 7 */
+/*:ref: pcke02_ 14 3 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pckfrm_(char *pck, integer *ids, ftnlen pck_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int pckmat_(integer *body, doublereal *et, integer *ref, doublereal *tsipm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: pcksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: pckr02_ 14 4 4 7 7 7 */
+/*:ref: pcke02_ 14 3 7 7 7 */
+/*:ref: eul2xf_ 14 5 7 4 4 4 7 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: pckr03_ 14 4 4 7 7 7 */
+/*:ref: pcke03_ 14 3 7 7 7 */
+
+extern int pckopn_(char *name__, char *ifname, integer *ncomch, integer *handle, ftnlen name_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafonw_ 14 10 13 13 4 4 13 4 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pckpds_(integer *body, char *frame, integer *type__, doublereal *first, doublereal *last, doublereal *descr, ftnlen frame_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+
+extern int pckr02_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pckr03_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: sgfrvi_ 14 6 4 7 7 7 4 12 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+
+extern int pckuds_(doublereal *descr, integer *body, integer *frame, integer *type__, doublereal *first, doublereal *last, integer *begin, integer *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pckw02_(integer *handle, integer *body, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *intlen, integer *n, integer *polydg, doublereal *cdata, doublereal *btime, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: chckid_ 14 5 13 4 13 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern integer pcwid_(char *array, integer *nelt, ftnlen array_len);
+
+extern int pgrrec_(char *body, doublereal *lon, doublereal *lat, doublereal *alt, doublereal *re, doublereal *f, doublereal *rectan, ftnlen body_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: plnsns_ 4 1 4 */
+/*:ref: georec_ 14 6 7 7 7 7 7 7 */
+
+extern doublereal pi_(void);
+
+extern int pjelpl_(doublereal *elin, doublereal *plane, doublereal *elout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vprjp_ 14 3 7 7 7 */
+/*:ref: cgv2el_ 14 4 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int pl2nvc_(doublereal *plane, doublereal *normal, doublereal *const__);
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int pl2nvp_(doublereal *plane, doublereal *normal, doublereal *point);
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+
+extern int pl2psv_(doublereal *plane, doublereal *point, doublereal *span1, doublereal *span2);
+/*:ref: pl2nvp_ 14 3 7 7 7 */
+/*:ref: frame_ 14 3 7 7 7 */
+
+extern integer plnsns_(integer *bodid);
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+
+extern int polyds_(doublereal *coeffs, integer *deg, integer *nderiv, doublereal *t, doublereal *p);
+
+extern int pool_(char *kernel, integer *unit, char *name__, char *names, integer *nnames, char *agent, integer *n, doublereal *values, logical *found, logical *update, integer *start, integer *room, char *cvals, integer *ivals, char *type__, char *uwvars, integer *uwptrs, integer *uwpool, char *uwagnt, ftnlen kernel_len, ftnlen name_len, ftnlen names_len, ftnlen agent_len, ftnlen cvals_len, ftnlen type_len, ftnlen uwvars_len, ftnlen uwagnt_len);
+extern int clpool_(void);
+extern int ldpool_(char *kernel, ftnlen kernel_len);
+extern int rtpool_(char *name__, integer *n, doublereal *values, logical *found, ftnlen name_len);
+extern int expool_(char *name__, logical *found, ftnlen name_len);
+extern int wrpool_(integer *unit);
+extern int swpool_(char *agent, integer *nnames, char *names, ftnlen agent_len, ftnlen names_len);
+extern int cvpool_(char *agent, logical *update, ftnlen agent_len);
+extern int gcpool_(char *name__, integer *start, integer *room, integer *n, char *cvals, logical *found, ftnlen name_len, ftnlen cvals_len);
+extern int gdpool_(char *name__, integer *start, integer *room, integer *n, doublereal *values, logical *found, ftnlen name_len);
+extern int gipool_(char *name__, integer *start, integer *room, integer *n, integer *ivals, logical *found, ftnlen name_len);
+extern int dtpool_(char *name__, logical *found, integer *n, char *type__, ftnlen name_len, ftnlen type_len);
+extern int pcpool_(char *name__, integer *n, char *cvals, ftnlen name_len, ftnlen cvals_len);
+extern int pdpool_(char *name__, integer *n, doublereal *values, ftnlen name_len);
+extern int pipool_(char *name__, integer *n, integer *ivals, ftnlen name_len);
+extern int lmpool_(char *cvals, integer *n, ftnlen cvals_len);
+extern int szpool_(char *name__, integer *n, logical *found, ftnlen name_len);
+extern int dvpool_(char *name__, ftnlen name_len);
+extern int gnpool_(char *name__, integer *start, integer *room, integer *n, char *cvals, logical *found, ftnlen name_len, ftnlen cvals_len);
+extern int dwpool_(char *agent, ftnlen agent_len);
+extern int zzvupool_(char *uwvars, integer *uwptrs, integer *uwpool, char *uwagnt, ftnlen uwvars_len, ftnlen uwagnt_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzpini_ 14 27 12 4 4 4 13 13 4 4 4 4 4 4 4 13 4 4 13 13 13 13 124 124 124 124 124 124 124 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: zznwpool_ 14 14 13 13 4 4 13 13 13 13 124 124 124 124 124 124 */
+/*:ref: rdknew_ 14 2 13 124 */
+/*:ref: zzrvar_ 14 13 4 4 13 4 4 7 4 13 13 12 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: elemc_ 12 4 13 13 124 124 */
+/*:ref: cltext_ 14 2 13 124 */
+/*:ref: zzhash_ 4 2 13 124 */
+/*:ref: ioerr_ 14 5 13 13 4 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzgapool_ 14 10 13 13 4 4 13 13 124 124 124 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnktl_ 4 2 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: lstltc_ 4 5 13 4 13 124 124 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: insrtc_ 14 4 13 13 124 124 */
+/*:ref: removc_ 14 4 13 13 124 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: intmin_ 4 0 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: zzgpnm_ 14 15 4 4 13 4 4 7 4 13 13 12 4 4 124 124 124 */
+/*:ref: zzcln_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: zzrvbf_ 14 17 13 4 4 4 4 13 4 4 7 4 13 13 12 124 124 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: matchi_ 12 8 13 13 13 13 124 124 124 124 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: copyc_ 14 4 13 13 124 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+
+extern integer pos_(char *str, char *substr, integer *start, ftnlen str_len, ftnlen substr_len);
+
+extern integer posr_(char *str, char *substr, integer *start, ftnlen str_len, ftnlen substr_len);
+
+extern int prefix_(char *pref, integer *spaces, char *string, ftnlen pref_len, ftnlen string_len);
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: shiftr_ 14 7 13 4 13 13 124 124 124 */
+
+extern doublereal prodad_(doublereal *array, integer *n);
+
+extern integer prodai_(integer *array, integer *n);
+
+extern int prompt_(char *prmpt, char *string, ftnlen prmpt_len, ftnlen string_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int prop2b_(doublereal *gm, doublereal *pvinit, doublereal *dt, doublereal *pvprop);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: brckti_ 4 3 4 4 4 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: stmp03_ 14 5 7 7 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vequg_ 14 3 7 4 7 */
+
+extern int prsdp_(char *string, doublereal *dpval, ftnlen string_len);
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int prsint_(char *string, integer *intval, ftnlen string_len);
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int prtenc_(integer *number, char *string, ftnlen string_len);
+extern int prtdec_(char *string, integer *number, ftnlen string_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical prtpkg_(logical *short__, logical *long__, logical *expl, logical *trace, logical *dfault, char *type__, ftnlen type_len);
+extern logical setprt_(logical *short__, logical *expl, logical *long__, logical *trace, logical *dfault);
+extern logical msgsel_(char *type__, ftnlen type_len);
+/*:ref: getdev_ 14 2 13 124 */
+/*:ref: wrline_ 14 4 13 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+
+extern int psv2pl_(doublereal *point, doublereal *span1, doublereal *span2, doublereal *plane);
+/*:ref: return_ 12 0 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int putact_(integer *action);
+extern int getact_(integer *action);
+
+extern int putdev_(char *device, ftnlen device_len);
+extern int getdev_(char *device, ftnlen device_len);
+
+extern int putlms_(char *msg, ftnlen msg_len);
+extern int getlms_(char *msg, ftnlen msg_len);
+
+extern int putsms_(char *msg, ftnlen msg_len);
+extern int getsms_(char *msg, ftnlen msg_len);
+
+extern int pxform_(char *from, char *to, doublereal *et, doublereal *rotate, ftnlen from_len, ftnlen to_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: refchg_ 14 4 4 4 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int q2m_(doublereal *q, doublereal *r__);
+
+extern int qderiv_(integer *n, doublereal *f0, doublereal *f2, doublereal *delta, doublereal *dfdt);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vlcomg_ 14 6 4 7 7 7 7 7 */
+
+extern int qdq2av_(doublereal *q, doublereal *dq, doublereal *av);
+/*:ref: vhatg_ 14 3 7 4 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: qxq_ 14 3 7 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+
+extern int quote_(char *in, char *left, char *right, char *out, ftnlen in_len, ftnlen left_len, ftnlen right_len, ftnlen out_len);
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+
+extern int qxq_(doublereal *q1, doublereal *q2, doublereal *qout);
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vlcom3_ 14 7 7 7 7 7 7 7 7 */
+
+extern int radrec_(doublereal *range, doublereal *ra, doublereal *dec, doublereal *rectan);
+/*:ref: latrec_ 14 4 7 7 7 7 */
+
+extern int rav2xf_(doublereal *rot, doublereal *av, doublereal *xform);
+/*:ref: mxm_ 14 3 7 7 7 */
+
+extern int raxisa_(doublereal *matrix, doublereal *axis, doublereal *angle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: m2q_ 14 2 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: pi_ 7 0 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+
+extern int rdencc_(integer *unit, integer *n, char *data, ftnlen data_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: hx2int_ 14 6 13 4 12 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int rdencd_(integer *unit, integer *n, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: hx2dp_ 14 6 13 7 12 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int rdenci_(integer *unit, integer *n, integer *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: hx2int_ 14 6 13 4 12 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int rdker_(char *kernel, char *line, integer *number, logical *eof, ftnlen kernel_len, ftnlen line_len);
+extern int rdknew_(char *kernel, ftnlen kernel_len);
+extern int rdkdat_(char *line, logical *eof, ftnlen line_len);
+extern int rdklin_(char *kernel, integer *number, ftnlen kernel_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cltext_ 14 2 13 124 */
+/*:ref: zzsetnnread_ 14 1 12 */
+/*:ref: rdtext_ 14 5 13 13 12 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: failed_ 12 0 */
+
+extern int rdkvar_(char *tabsym, integer *tabptr, doublereal *tabval, char *name__, logical *eof, ftnlen tabsym_len, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: rdkdat_ 14 3 13 12 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: replch_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+/*:ref: sydeld_ 14 6 13 13 4 7 124 124 */
+/*:ref: tparse_ 14 5 13 7 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: syenqd_ 14 7 13 7 13 4 7 124 124 */
+
+extern int rdnbl_(char *file, char *line, logical *eof, ftnlen file_len, ftnlen line_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: rdtext_ 14 5 13 13 12 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int rdtext_(char *file, char *line, logical *eof, ftnlen file_len, ftnlen line_len);
+extern int cltext_(char *file, ftnlen file_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: getlun_ 14 1 4 */
+
+extern int readla_(integer *unit, integer *maxlin, integer *numlin, char *array, logical *eof, ftnlen array_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: readln_ 14 4 4 13 12 124 */
+/*:ref: failed_ 12 0 */
+
+extern int readln_(integer *unit, char *line, logical *eof, ftnlen line_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int reccyl_(doublereal *rectan, doublereal *r__, doublereal *long__, doublereal *z__);
+/*:ref: twopi_ 7 0 */
+
+extern int recgeo_(doublereal *rectan, doublereal *re, doublereal *f, doublereal *long__, doublereal *lat, doublereal *alt);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: surfnm_ 14 5 7 7 7 7 7 */
+/*:ref: reclat_ 14 4 7 7 7 7 */
+
+extern int reclat_(doublereal *rectan, doublereal *radius, doublereal *long__, doublereal *lat);
+
+extern int recpgr_(char *body, doublereal *rectan, doublereal *re, doublereal *f, doublereal *lon, doublereal *lat, doublereal *alt, ftnlen body_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: plnsns_ 4 1 4 */
+/*:ref: recgeo_ 14 6 7 7 7 7 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+
+extern int recrad_(doublereal *rectan, doublereal *range, doublereal *ra, doublereal *dec);
+/*:ref: reclat_ 14 4 7 7 7 7 */
+/*:ref: twopi_ 7 0 */
+
+extern int recsph_(doublereal *rectan, doublereal *r__, doublereal *colat, doublereal *long__);
+
+extern int refchg_(integer *frame1, integer *frame2, doublereal *et, doublereal *rotate);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ident_ 14 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: rotget_ 14 5 4 7 7 4 12 */
+/*:ref: zzrxr_ 14 3 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zznofcon_ 14 7 7 4 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: xpose_ 14 2 7 7 */
+
+extern int remlac_(integer *ne, integer *loc, char *array, integer *na, ftnlen array_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int remlad_(integer *ne, integer *loc, doublereal *array, integer *na);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int remlai_(integer *ne, integer *loc, integer *array, integer *na);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int removc_(char *item, char *a, ftnlen item_len, ftnlen a_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int removd_(doublereal *item, doublereal *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: bsrchd_ 4 3 7 4 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int removi_(integer *item, integer *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: bsrchi_ 4 3 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int remsub_(char *in, integer *left, integer *right, char *out, ftnlen in_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int reordc_(integer *iorder, integer *ndim, char *array, ftnlen array_len);
+
+extern int reordd_(integer *iorder, integer *ndim, doublereal *array);
+
+extern int reordi_(integer *iorder, integer *ndim, integer *array);
+
+extern int reordl_(integer *iorder, integer *ndim, logical *array);
+
+extern int replch_(char *instr, char *old, char *new__, char *outstr, ftnlen instr_len, ftnlen old_len, ftnlen new_len, ftnlen outstr_len);
+
+extern int replwd_(char *instr, integer *nth, char *new__, char *outstr, ftnlen instr_len, ftnlen new_len, ftnlen outstr_len);
+/*:ref: nthwd_ 14 6 13 4 13 4 124 124 */
+/*:ref: fndnwd_ 14 5 13 4 4 4 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int repmc_(char *in, char *marker, char *value, char *out, ftnlen in_len, ftnlen marker_len, ftnlen value_len, ftnlen out_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: zzrepsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int repmct_(char *in, char *marker, integer *value, char *case__, char *out, ftnlen in_len, ftnlen marker_len, ftnlen case_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: inttxt_ 14 3 4 13 124 */
+/*:ref: lcase_ 14 4 13 13 124 124 */
+/*:ref: repsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int repmd_(char *in, char *marker, doublereal *value, integer *sigdig, char *out, ftnlen in_len, ftnlen marker_len, ftnlen out_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: dpstr_ 14 4 7 4 13 124 */
+/*:ref: zzrepsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int repmf_(char *in, char *marker, doublereal *value, integer *sigdig, char *format, char *out, ftnlen in_len, ftnlen marker_len, ftnlen format_len, ftnlen out_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: dpstrf_ 14 6 7 4 13 13 124 124 */
+/*:ref: zzrepsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int repmi_(char *in, char *marker, integer *value, char *out, ftnlen in_len, ftnlen marker_len, ftnlen out_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: zzrepsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int repmot_(char *in, char *marker, integer *value, char *case__, char *out, ftnlen in_len, ftnlen marker_len, ftnlen case_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: intord_ 14 3 4 13 124 */
+/*:ref: lcase_ 14 4 13 13 124 124 */
+/*:ref: repsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int repsub_(char *in, integer *left, integer *right, char *string, char *out, ftnlen in_len, ftnlen string_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+
+extern int reset_(void);
+/*:ref: seterr_ 12 1 12 */
+/*:ref: putsms_ 14 2 13 124 */
+/*:ref: putlms_ 14 2 13 124 */
+/*:ref: accept_ 12 1 12 */
+
+extern logical return_(void);
+/*:ref: getact_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+
+extern int rjust_(char *input, char *output, ftnlen input_len, ftnlen output_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int rmaind_(doublereal *num, doublereal *denom, doublereal *q, doublereal *rem);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int rmaini_(integer *num, integer *denom, integer *q, integer *rem);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int rmdupc_(integer *nelt, char *array, ftnlen array_len);
+/*:ref: shellc_ 14 3 4 13 124 */
+
+extern int rmdupd_(integer *nelt, doublereal *array);
+/*:ref: shelld_ 14 2 4 7 */
+
+extern int rmdupi_(integer *nelt, integer *array);
+/*:ref: shelli_ 14 2 4 4 */
+
+extern int rotate_(doublereal *angle, integer *iaxis, doublereal *mout);
+
+extern int rotget_(integer *infrm, doublereal *et, doublereal *rotate, integer *outfrm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: tipbod_ 14 5 13 4 7 7 124 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckfrot_ 14 5 4 7 7 4 12 */
+/*:ref: tkfram_ 14 4 4 7 4 12 */
+/*:ref: zzdynrot_ 14 5 4 4 7 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int rotmat_(doublereal *m1, doublereal *angle, integer *iaxis, doublereal *mout);
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int rotvec_(doublereal *v1, doublereal *angle, integer *iaxis, doublereal *vout);
+
+extern doublereal rpd_(void);
+
+extern int rquad_(doublereal *a, doublereal *b, doublereal *c__, doublereal *root1, doublereal *root2);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern integer rtrim_(char *string, ftnlen string_len);
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int saelgv_(doublereal *vec1, doublereal *vec2, doublereal *smajor, doublereal *sminor);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: diags2_ 14 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+
+extern logical samch_(char *str1, integer *l1, char *str2, integer *l2, ftnlen str1_len, ftnlen str2_len);
+
+extern logical samchi_(char *str1, integer *l1, char *str2, integer *l2, ftnlen str1_len, ftnlen str2_len);
+/*:ref: eqchr_ 12 4 13 13 124 124 */
+
+extern logical sameai_(integer *a1, integer *a2, integer *ndim);
+
+extern logical samsbi_(char *str1, integer *b1, integer *e1, char *str2, integer *b2, integer *e2, ftnlen str1_len, ftnlen str2_len);
+/*:ref: nechr_ 12 4 13 13 124 124 */
+
+extern logical samsub_(char *str1, integer *b1, integer *e1, char *str2, integer *b2, integer *e2, ftnlen str1_len, ftnlen str2_len);
+
+extern int sc01_(integer *sc, char *clkstr, doublereal *ticks, doublereal *sclkdp, doublereal *et, ftnlen clkstr_len);
+extern int sctk01_(integer *sc, char *clkstr, doublereal *ticks, ftnlen clkstr_len);
+extern int scfm01_(integer *sc, doublereal *ticks, char *clkstr, ftnlen clkstr_len);
+extern int scte01_(integer *sc, doublereal *sclkdp, doublereal *et);
+extern int scet01_(integer *sc, doublereal *et, doublereal *sclkdp);
+extern int scec01_(integer *sc, doublereal *et, doublereal *sclkdp);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: scli01_ 14 6 13 4 4 4 4 124 */
+/*:ref: scld01_ 14 6 13 4 4 4 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: lparsm_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dpstrf_ 14 6 7 4 13 13 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: unitim_ 7 5 7 13 13 124 124 */
+
+extern int scanit_(char *string, integer *start, integer *room, integer *nmarks, char *marks, integer *mrklen, integer *pnters, integer *ntokns, integer *ident, integer *beg, integer *end, ftnlen string_len, ftnlen marks_len);
+extern int scanpr_(integer *nmarks, char *marks, integer *mrklen, integer *pnters, ftnlen marks_len);
+extern int scan_(char *string, char *marks, integer *mrklen, integer *pnters, integer *room, integer *start, integer *ntokns, integer *ident, integer *beg, integer *end, ftnlen string_len, ftnlen marks_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: rmdupc_ 14 3 4 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: ncpos_ 4 5 13 13 4 124 124 */
+
+extern int scanrj_(integer *ids, integer *n, integer *ntokns, integer *ident, integer *beg, integer *end);
+/*:ref: isrchi_ 4 3 4 4 4 */
+
+extern int scardc_(integer *card, char *cell, ftnlen cell_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dechar_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: enchar_ 14 3 4 13 124 */
+
+extern int scardd_(integer *card, doublereal *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int scardi_(integer *card, integer *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int scdecd_(integer *sc, doublereal *sclkdp, char *sclkch, ftnlen sclkch_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: scpart_ 14 4 4 4 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: scfmt_ 14 4 4 7 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+
+extern int sce2c_(integer *sc, doublereal *et, doublereal *sclkdp);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sctype_ 4 1 4 */
+/*:ref: scec01_ 14 3 4 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sce2s_(integer *sc, doublereal *et, char *sclkch, ftnlen sclkch_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sce2t_ 14 3 4 7 7 */
+/*:ref: scdecd_ 14 4 4 7 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sce2t_(integer *sc, doublereal *et, doublereal *sclkdp);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sctype_ 4 1 4 */
+/*:ref: scet01_ 14 3 4 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int scencd_(integer *sc, char *sclkch, doublereal *sclkdp, ftnlen sclkch_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+/*:ref: sctiks_ 14 4 4 13 7 124 */
+/*:ref: scpart_ 14 4 4 4 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+
+extern int scfmt_(integer *sc, doublereal *ticks, char *clkstr, ftnlen clkstr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sctype_ 4 1 4 */
+/*:ref: scfm01_ 14 4 4 7 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sclu01_(char *name__, integer *sc, integer *maxnv, integer *n, integer *ival, doublereal *dval, ftnlen name_len);
+extern int scli01_(char *name__, integer *sc, integer *maxnv, integer *n, integer *ival, ftnlen name_len);
+extern int scld01_(char *name__, integer *sc, integer *maxnv, integer *n, doublereal *dval, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: repmd_ 14 8 13 13 7 4 13 124 124 124 */
+
+extern int scpars_(integer *sc, char *sclkch, logical *error, char *msg, doublereal *sclkdp, ftnlen sclkch_len, ftnlen msg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+/*:ref: sctype_ 4 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: scps01_ 14 7 4 13 12 13 7 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: scpart_ 14 4 4 4 7 7 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+
+extern int scpart_(integer *sc, integer *nparts, doublereal *pstart, doublereal *pstop);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: scld01_ 14 6 13 4 4 4 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int scps01_(integer *sc, char *clkstr, logical *error, char *msg, doublereal *ticks, ftnlen clkstr_len, ftnlen msg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: scli01_ 14 6 13 4 4 4 4 124 */
+/*:ref: scld01_ 14 6 13 4 4 4 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lparsm_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+
+extern int scs2e_(integer *sc, char *sclkch, doublereal *et, ftnlen sclkch_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: scencd_ 14 4 4 13 7 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sct2e_(integer *sc, doublereal *sclkdp, doublereal *et);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sctype_ 4 1 4 */
+/*:ref: scte01_ 14 3 4 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sctiks_(integer *sc, char *clkstr, doublereal *ticks, ftnlen clkstr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sctype_ 4 1 4 */
+/*:ref: sctk01_ 14 4 4 13 7 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sctran_(char *clknam, integer *clkid, logical *found, ftnlen clknam_len);
+extern int scn2id_(char *clknam, integer *clkid, logical *found, ftnlen clknam_len);
+extern int scid2n_(integer *clkid, char *clknam, logical *found, ftnlen clknam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: posr_ 4 5 13 13 4 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: bodn2c_ 14 4 13 4 12 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern integer sctype_(integer *sc);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: scli01_ 14 6 13 4 4 4 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sdiffc_(char *a, char *b, char *c__, ftnlen a_len, ftnlen b_len, ftnlen c_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: excess_ 14 3 4 13 124 */
+
+extern int sdiffd_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sdiffi_(integer *a, integer *b, integer *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical setc_(char *a, char *op, char *b, ftnlen a_len, ftnlen op_len, ftnlen b_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern logical setd_(doublereal *a, char *op, doublereal *b, ftnlen op_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern logical seterr_(logical *status);
+extern logical failed_(void);
+
+extern logical seti_(integer *a, char *op, integer *b, ftnlen op_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int setmsg_(char *msg, ftnlen msg_len);
+/*:ref: allowd_ 12 0 */
+/*:ref: putlms_ 14 2 13 124 */
+
+extern int sgfcon_(integer *handle, doublereal *descr, integer *first, integer *last, doublereal *values);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int sgfpkt_(integer *handle, doublereal *descr, integer *first, integer *last, doublereal *values, integer *ends);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int sgfref_(integer *handle, doublereal *descr, integer *first, integer *last, doublereal *values);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int sgfrvi_(integer *handle, doublereal *descr, doublereal *x, doublereal *value, integer *indx, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+
+extern int sgmeta_(integer *handle, doublereal *descr, integer *mnemon, integer *value);
+/*:ref: return_ 12 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafhsf_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int sgseqw_(integer *handle, doublereal *descr, char *segid, integer *nconst, doublereal *const__, integer *npkts, integer *pktsiz, doublereal *pktdat, integer *nrefs, doublereal *refdat, integer *idxtyp, ftnlen segid_len);
+extern int sgbwfs_(integer *handle, doublereal *descr, char *segid, integer *nconst, doublereal *const__, integer *pktsiz, integer *idxtyp, ftnlen segid_len);
+extern int sgbwvs_(integer *handle, doublereal *descr, char *segid, integer *nconst, doublereal *const__, integer *idxtyp, ftnlen segid_len);
+extern int sgwfpk_(integer *handle, integer *npkts, doublereal *pktdat, integer *nrefs, doublereal *refdat);
+extern int sgwvpk_(integer *handle, integer *npkts, integer *pktsiz, doublereal *pktdat, integer *nrefs, doublereal *refdat);
+extern int sgwes_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: dafhsf_ 14 3 4 4 4 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafcad_ 14 1 4 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafena_ 14 0 */
+
+extern int sharpr_(doublereal *rot);
+/*:ref: vhatip_ 14 1 7 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+
+extern int shellc_(integer *ndim, char *array, ftnlen array_len);
+/*:ref: swapc_ 14 4 13 13 124 124 */
+
+extern int shelld_(integer *ndim, doublereal *array);
+/*:ref: swapd_ 14 2 7 7 */
+
+extern int shelli_(integer *ndim, integer *array);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int shiftc_(char *in, char *dir, integer *nshift, char *fillc, char *out, ftnlen in_len, ftnlen dir_len, ftnlen fillc_len, ftnlen out_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: shiftl_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: shiftr_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int shiftl_(char *in, integer *nshift, char *fillc, char *out, ftnlen in_len, ftnlen fillc_len, ftnlen out_len);
+
+extern int shiftr_(char *in, integer *nshift, char *fillc, char *out, ftnlen in_len, ftnlen fillc_len, ftnlen out_len);
+
+extern int sigdgt_(char *in, char *out, ftnlen in_len, ftnlen out_len);
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+
+extern int sigerr_(char *msg, ftnlen msg_len);
+/*:ref: getact_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: seterr_ 12 1 12 */
+/*:ref: putsms_ 14 2 13 124 */
+/*:ref: freeze_ 14 0 */
+/*:ref: outmsg_ 14 2 13 124 */
+/*:ref: accept_ 12 1 12 */
+/*:ref: byebye_ 14 2 13 124 */
+
+extern int sincpt_(char *method, char *target, doublereal *et, char *fixref, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, doublereal *spoint, doublereal *trgepc, doublereal *srfvec, logical *found, ftnlen method_len, ftnlen target_len, ftnlen fixref_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: dasine_ 7 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: npedln_ 14 7 7 7 7 7 7 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: vhatip_ 14 1 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+
+extern integer sizec_(char *cell, ftnlen cell_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dechar_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer sized_(doublereal *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer sizei_(integer *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical smsgnd_(doublereal *x, doublereal *y);
+
+extern logical smsgni_(integer *x, integer *y);
+
+extern logical somfls_(logical *logcls, integer *n);
+
+extern logical somtru_(logical *logcls, integer *n);
+
+extern int spca2b_(char *text, char *binary, ftnlen text_len, ftnlen binary_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: txtopr_ 14 3 13 4 124 */
+/*:ref: spct2b_ 14 3 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spcac_(integer *handle, integer *unit, char *bmark, char *emark, ftnlen bmark_len, ftnlen emark_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: locln_ 14 10 4 13 13 13 4 4 12 124 124 124 */
+/*:ref: countc_ 4 5 4 4 4 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafarr_ 14 2 4 4 */
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern int spcb2a_(char *binary, char *text, ftnlen binary_len, ftnlen text_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: txtopn_ 14 3 13 4 124 */
+/*:ref: spcb2t_ 14 3 13 4 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spcb2t_(char *binary, integer *unit, ftnlen binary_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafb2t_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: spcec_ 14 2 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int spcdc_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: dafrrr_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spcec_(integer *handle, integer *unit);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafsih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int spcopn_(char *spc, char *ifname, integer *handle, ftnlen spc_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafopn_ 14 8 13 4 4 13 4 4 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spcrfl_(integer *handle, char *line, logical *eoc, ftnlen line_len);
+extern int spcrnl_(char *line, logical *eoc, ftnlen line_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafrfr_ 14 8 4 4 4 13 4 4 4 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+
+extern int spct2b_(integer *unit, char *binary, ftnlen binary_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: daft2b_ 14 4 4 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: dafopw_ 14 3 13 4 124 */
+/*:ref: spcac_ 14 6 4 4 13 13 124 124 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern doublereal spd_(void);
+
+extern int sphcyl_(doublereal *radius, doublereal *colat, doublereal *slong, doublereal *r__, doublereal *long__, doublereal *z__);
+
+extern int sphlat_(doublereal *r__, doublereal *colat, doublereal *longs, doublereal *radius, doublereal *long__, doublereal *lat);
+/*:ref: halfpi_ 7 0 */
+
+extern int sphrec_(doublereal *r__, doublereal *colat, doublereal *long__, doublereal *rectan);
+
+extern doublereal sphsd_(doublereal *radius, doublereal *long1, doublereal *lat1, doublereal *long2, doublereal *lat2);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+
+extern int spk14a_(integer *handle, integer *ncsets, doublereal *coeffs, doublereal *epochs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgwfpk_ 14 5 4 4 7 4 7 */
+
+extern int spk14b_(integer *handle, char *segid, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, integer *chbdeg, ftnlen segid_len, ftnlen frame_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: sgbwfs_ 14 8 4 7 13 4 7 4 4 124 */
+
+extern int spk14e_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgwes_ 14 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkacs_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: spkaps_ 14 11 4 7 13 13 7 7 7 7 7 124 124 */
+
+extern int spkapo_(integer *targ, doublereal *et, char *ref, doublereal *sobs, char *abcorr, doublereal *ptarg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: spkgps_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+
+extern int spkapp_(integer *targ, doublereal *et, char *ref, doublereal *sobs, char *abcorr, doublereal *starg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+
+extern int spkaps_(integer *targ, doublereal *et, char *ref, char *abcorr, doublereal *stobs, doublereal *accobs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: spkltc_ 14 10 4 7 13 13 7 7 7 7 124 124 */
+/*:ref: zzstelab_ 14 6 12 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int spkbsr_(char *fname, integer *handle, integer *body, doublereal *et, doublereal *descr, char *ident, logical *found, ftnlen fname_len, ftnlen ident_len);
+extern int spklef_(char *fname, integer *handle, ftnlen fname_len);
+extern int spkuef_(integer *handle);
+extern int spksfs_(integer *body, doublereal *et, integer *handle, doublereal *descr, char *ident, logical *found, ftnlen ident_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: lnkprv_ 4 2 4 4 */
+/*:ref: dpmin_ 7 0 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafbbs_ 14 1 4 */
+/*:ref: daffpa_ 14 1 12 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: dafgn_ 14 2 13 124 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: lnktl_ 4 2 4 4 */
+
+extern int spkcls_(integer *handle);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int spkcov_(char *spk, integer *idcode, doublereal *cover, ftnlen spk_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int spke01_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int spke02_(doublereal *et, doublereal *record, doublereal *xyzdot);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chbint_ 14 6 7 4 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke03_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chbval_ 14 5 7 4 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke05_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: prop2b_ 14 4 7 7 7 7 */
+/*:ref: pi_ 7 0 */
+/*:ref: vlcomg_ 14 6 4 7 7 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke08_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: xposeg_ 14 4 7 4 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: lgresp_ 7 6 4 7 7 7 7 7 */
+
+extern int spke09_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: xposeg_ 14 4 7 4 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: lgrint_ 7 5 4 7 7 7 7 */
+
+extern int spke10_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: pi_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: spd_ 7 0 */
+/*:ref: ev2lin_ 14 4 7 7 7 7 */
+/*:ref: dpspce_ 14 4 7 7 7 7 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: zzmobliq_ 14 3 7 7 7 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vlcomg_ 14 6 4 7 7 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: zzeprcss_ 14 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke12_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: hrmesp_ 14 8 4 7 7 7 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke13_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: hrmint_ 14 7 4 7 7 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke14_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chbval_ 14 5 7 4 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spke15_(doublereal *et, doublereal *recin, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vhatip_ 14 1 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: dpr_ 7 0 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: prop2b_ 14 4 7 7 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: pi_ 7 0 */
+/*:ref: vrotv_ 14 4 7 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int spke17_(doublereal *et, doublereal *recin, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqncpv_ 14 6 7 7 7 7 7 7 */
+
+extern int spke18_(doublereal *et, doublereal *record, doublereal *state);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: xpsgip_ 14 3 4 4 7 */
+/*:ref: lgrint_ 7 5 4 7 7 7 7 */
+/*:ref: hrmint_ 14 7 4 7 7 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int spkez_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *starg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: spkacs_ 14 10 4 7 13 13 4 7 7 7 124 124 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: spkltc_ 14 10 4 7 13 13 7 7 7 7 124 124 */
+/*:ref: frmchg_ 14 4 4 4 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+
+extern int spkezp_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *ptarg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: eqchr_ 12 4 13 13 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: spkgps_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: spkapo_ 14 9 4 7 13 7 13 7 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: refchg_ 14 4 4 4 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+
+extern int spkezr_(char *targ, doublereal *et, char *ref, char *abcorr, char *obs, doublereal *starg, doublereal *lt, ftnlen targ_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen obs_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzbodn2c_ 14 4 13 4 12 124 */
+/*:ref: beint_ 12 2 13 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+
+extern int spkgeo_(integer *targ, doublereal *et, char *ref, integer *obs, doublereal *state, doublereal *lt, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: frmchg_ 14 4 4 4 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: vaddg_ 14 4 7 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+
+extern int spkgps_(integer *targ, doublereal *et, char *ref, integer *obs, doublereal *pos, doublereal *lt, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: refchg_ 14 4 4 4 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+
+extern int spkltc_(integer *targ, doublereal *et, char *ref, char *abcorr, doublereal *stobs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int spkobj_(char *spk, integer *ids, ftnlen spk_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafopr_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: dafcls_ 14 1 4 */
+
+extern int spkopa_(char *file, integer *handle, ftnlen file_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: exists_ 12 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafopw_ 14 3 13 4 124 */
+
+extern int spkopn_(char *name__, char *ifname, integer *ncomch, integer *handle, ftnlen name_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafonw_ 14 10 13 13 4 4 13 4 4 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkpds_(integer *body, integer *center, char *frame, integer *type__, doublereal *first, doublereal *last, doublereal *descr, ftnlen frame_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+
+extern int spkpos_(char *targ, doublereal *et, char *ref, char *abcorr, char *obs, doublereal *ptarg, doublereal *lt, ftnlen targ_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen obs_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzbodn2c_ 14 4 13 4 12 124 */
+/*:ref: beint_ 12 2 13 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+
+extern int spkpv_(integer *handle, doublereal *descr, doublereal *et, char *ref, doublereal *state, integer *center, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: frmchg_ 14 4 4 4 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkpvn_(integer *handle, doublereal *descr, doublereal *et, integer *ref, doublereal *state, integer *center);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: spkr01_ 14 4 4 7 7 7 */
+/*:ref: spke01_ 14 3 7 7 7 */
+/*:ref: spkr02_ 14 4 4 7 7 7 */
+/*:ref: spke02_ 14 3 7 7 7 */
+/*:ref: spkr03_ 14 4 4 7 7 7 */
+/*:ref: spke03_ 14 3 7 7 7 */
+/*:ref: spkr05_ 14 4 4 7 7 7 */
+/*:ref: spke05_ 14 3 7 7 7 */
+/*:ref: spkr08_ 14 4 4 7 7 7 */
+/*:ref: spke08_ 14 3 7 7 7 */
+/*:ref: spkr09_ 14 4 4 7 7 7 */
+/*:ref: spke09_ 14 3 7 7 7 */
+/*:ref: spkr10_ 14 4 4 7 7 7 */
+/*:ref: spke10_ 14 3 7 7 7 */
+/*:ref: spkr12_ 14 4 4 7 7 7 */
+/*:ref: spke12_ 14 3 7 7 7 */
+/*:ref: spkr13_ 14 4 4 7 7 7 */
+/*:ref: spke13_ 14 3 7 7 7 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: spkr14_ 14 4 4 7 7 7 */
+/*:ref: spke14_ 14 3 7 7 7 */
+/*:ref: spkr15_ 14 4 4 7 7 7 */
+/*:ref: spke15_ 14 3 7 7 7 */
+/*:ref: spkr17_ 14 4 4 7 7 7 */
+/*:ref: spke17_ 14 3 7 7 7 */
+/*:ref: spkr18_ 14 4 4 7 7 7 */
+/*:ref: spke18_ 14 3 7 7 7 */
+
+extern int spkr01_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkr02_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkr03_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkr05_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int spkr08_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: odd_ 12 1 4 */
+
+extern int spkr09_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+/*:ref: odd_ 12 1 4 */
+
+extern int spkr10_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: sgfrvi_ 14 6 4 7 7 7 4 12 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkr12_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkr08_ 14 4 4 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkr13_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkr09_ 14 4 4 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkr14_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: sgfrvi_ 14 6 4 7 7 7 4 12 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+
+extern int spkr15_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int spkr17_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int spkr18_(integer *handle, doublereal *descr, doublereal *et, doublereal *record);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: lstltd_ 4 3 7 4 7 */
+
+extern int spks01_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spks02_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spks03_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spks05_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spks08_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+
+extern int spks09_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+
+extern int spks10_(integer *srchan, doublereal *srcdsc, integer *dsthan, doublereal *dstdsc, char *dstsid, ftnlen dstsid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: sgbwfs_ 14 8 4 7 13 4 7 4 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgfrvi_ 14 6 4 7 7 7 4 12 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sgmeta_ 14 4 4 7 4 4 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+/*:ref: sgfref_ 14 5 4 7 4 4 7 */
+/*:ref: sgwfpk_ 14 5 4 4 7 4 7 */
+/*:ref: sgwes_ 14 1 4 */
+
+extern int spks12_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spks08_ 14 5 4 4 4 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spks13_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spks09_ 14 5 4 4 4 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spks14_(integer *srchan, doublereal *srcdsc, integer *dsthan, doublereal *dstdsc, char *dstsid, ftnlen dstsid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: irfnam_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgfcon_ 14 5 4 7 4 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sgfrvi_ 14 6 4 7 7 7 4 12 */
+/*:ref: spk14b_ 14 10 4 13 4 4 13 7 7 4 124 124 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+/*:ref: sgfref_ 14 5 4 7 4 4 7 */
+/*:ref: spk14a_ 14 4 4 4 7 7 */
+/*:ref: spk14e_ 14 1 4 */
+
+extern int spks15_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+
+extern int spks17_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: dafada_ 14 2 7 4 */
+
+extern int spks18_(integer *handle, integer *baddr, integer *eaddr, doublereal *begin, doublereal *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+
+extern int spkssb_(integer *targ, doublereal *et, char *ref, doublereal *starg, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spksub_(integer *handle, doublereal *descr, char *ident, doublereal *begin, doublereal *end, integer *newh, ftnlen ident_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: spks01_ 14 5 4 4 4 7 7 */
+/*:ref: dafena_ 14 0 */
+/*:ref: spks02_ 14 5 4 4 4 7 7 */
+/*:ref: spks03_ 14 5 4 4 4 7 7 */
+/*:ref: spks05_ 14 5 4 4 4 7 7 */
+/*:ref: spks08_ 14 5 4 4 4 7 7 */
+/*:ref: spks09_ 14 5 4 4 4 7 7 */
+/*:ref: spks10_ 14 6 4 7 4 7 13 124 */
+/*:ref: spks12_ 14 5 4 4 4 7 7 */
+/*:ref: spks13_ 14 5 4 4 4 7 7 */
+/*:ref: spks14_ 14 6 4 7 4 7 13 124 */
+/*:ref: spks15_ 14 5 4 4 4 7 7 */
+/*:ref: spks17_ 14 5 4 4 4 7 7 */
+/*:ref: spks18_ 14 5 4 4 4 7 7 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int spkuds_(doublereal *descr, integer *body, integer *center, integer *frame, integer *type__, doublereal *first, doublereal *last, integer *begin, integer *end);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int spkw01_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, integer *n, doublereal *dlines, doublereal *epochs, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw02_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *intlen, integer *n, integer *polydg, doublereal *cdata, doublereal *btime, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: chckid_ 14 5 13 4 13 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw03_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *intlen, integer *n, integer *polydg, doublereal *cdata, doublereal *btime, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: chckid_ 14 5 13 4 13 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw05_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *gm, integer *n, doublereal *states, doublereal *epochs, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw08_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, integer *degree, integer *n, doublereal *states, doublereal *epoch1, doublereal *step, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw09_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, integer *degree, integer *n, doublereal *states, doublereal *epochs, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw10_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *consts, integer *n, doublereal *elems, doublereal *epochs, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sgbwfs_ 14 8 4 7 13 4 7 4 4 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: zzwahr_ 14 2 7 7 */
+/*:ref: sgwfpk_ 14 5 4 4 7 4 7 */
+/*:ref: sgwes_ 14 1 4 */
+
+extern int spkw12_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, integer *degree, integer *n, doublereal *states, doublereal *epoch1, doublereal *step, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw13_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, integer *degree, integer *n, doublereal *states, doublereal *epochs, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: even_ 12 1 4 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw15_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *epoch, doublereal *tp, doublereal *pa, doublereal *p, doublereal *ecc, doublereal *j2flg, doublereal *pv, doublereal *gm, doublereal *j2, doublereal *radius, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: dpr_ 7 0 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw17_(integer *handle, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, doublereal *epoch, doublereal *eqel, doublereal *rapol, doublereal *decpol, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: spkpds_ 14 8 4 4 13 4 7 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int spkw18_(integer *handle, integer *subtyp, integer *body, integer *center, char *frame, doublereal *first, doublereal *last, char *segid, integer *degree, integer *n, doublereal *packts, doublereal *epochs, ftnlen frame_len, ftnlen segid_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: dafbna_ 14 4 4 7 13 124 */
+/*:ref: dafada_ 14 2 7 4 */
+/*:ref: dafena_ 14 0 */
+
+extern int srfrec_(integer *body, doublereal *long__, doublereal *lat, doublereal *rectan);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int srfxpt_(char *method, char *target, doublereal *et, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, doublereal *spoint, doublereal *dist, doublereal *trgepc, doublereal *obspos, logical *found, ftnlen method_len, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: eqchr_ 12 4 13 13 124 124 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: dasine_ 7 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: npedln_ 14 7 7 7 7 7 7 7 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: touchd_ 7 1 7 */
+
+extern int ssizec_(integer *size, char *cell, ftnlen cell_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: enchar_ 14 3 4 13 124 */
+
+extern int ssized_(integer *size, doublereal *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int ssizei_(integer *size, integer *cell);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int stcc01_(char *catfnm, char *tabnam, logical *istyp1, char *errmsg, ftnlen catfnm_len, ftnlen tabnam_len, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ekopr_ 14 3 13 4 124 */
+/*:ref: eknseg_ 4 1 4 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ekssum_ 14 14 4 4 13 4 4 13 13 4 4 12 12 124 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: nblen_ 4 2 13 124 */
+/*:ref: ekcls_ 14 1 4 */
+
+extern int stcf01_(char *catnam, doublereal *westra, doublereal *eastra, doublereal *sthdec, doublereal *nthdec, integer *nstars, ftnlen catnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dpr_ 7 0 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: repmd_ 14 8 13 13 7 4 13 124 124 124 */
+/*:ref: ekfind_ 14 6 13 4 12 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int stcg01_(integer *index, doublereal *ra, doublereal *dec, doublereal *rasig, doublereal *decsig, integer *catnum, char *sptype, doublereal *vmag, ftnlen sptype_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ekgd_ 14 6 4 4 4 7 12 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ekgi_ 14 6 4 4 4 4 12 12 */
+/*:ref: ekgc_ 14 7 4 4 4 13 12 12 124 */
+/*:ref: rpd_ 7 0 */
+
+extern int stcl01_(char *catfnm, char *tabnam, integer *handle, ftnlen catfnm_len, ftnlen tabnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: stcc01_ 14 7 13 13 12 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eklef_ 14 3 13 4 124 */
+
+extern int stdio_(char *name__, integer *unit, ftnlen name_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int stelab_(doublereal *pobj, doublereal *vobs, doublereal *appobj);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vrotv_ 14 4 7 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int stlabx_(doublereal *pobj, doublereal *vobs, doublereal *corpos);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int stmp03_(doublereal *x, doublereal *c0, doublereal *c1, doublereal *c2, doublereal *c3);
+/*:ref: dpmax_ 7 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int stpool_(char *item, integer *nth, char *contin, char *string, integer *size, logical *found, ftnlen item_len, ftnlen contin_len, ftnlen string_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int str2et_(char *string, doublereal *et, ftnlen string_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: timdef_ 14 6 13 13 13 124 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: zzutcpm_ 14 7 13 4 7 7 4 12 124 */
+/*:ref: tpartv_ 14 15 13 7 4 13 13 12 12 12 13 13 124 124 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: ttrans_ 14 5 13 13 7 124 124 */
+/*:ref: tchckd_ 14 2 13 124 */
+/*:ref: tparch_ 14 2 13 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: tcheck_ 14 9 7 13 12 13 12 13 124 124 124 */
+/*:ref: texpyr_ 14 1 4 */
+/*:ref: jul2gr_ 14 4 4 4 4 4 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: dpfmt_ 14 5 7 13 13 124 124 */
+/*:ref: gr2jul_ 14 4 4 4 4 4 */
+
+extern int subpnt_(char *method, char *target, doublereal *et, char *fixref, char *abcorr, char *obsrvr, doublereal *spoint, doublereal *trgepc, doublereal *srfvec, ftnlen method_len, ftnlen target_len, ftnlen fixref_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: lparse_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: touchd_ 7 1 7 */
+
+extern int subpt_(char *method, char *target, doublereal *et, char *abcorr, char *obsrvr, doublereal *spoint, doublereal *alt, ftnlen method_len, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vdist_ 7 2 7 7 */
+
+extern int subslr_(char *method, char *target, doublereal *et, char *fixref, char *abcorr, char *obsrvr, doublereal *spoint, doublereal *trgepc, doublereal *srfvec, ftnlen method_len, ftnlen target_len, ftnlen fixref_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: lparse_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: touchd_ 7 1 7 */
+
+extern int subsol_(char *method, char *target, doublereal *et, char *abcorr, char *obsrvr, doublereal *spoint, ftnlen method_len, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: ltime_ 14 7 7 4 13 4 7 7 124 */
+/*:ref: spkpos_ 14 11 13 7 13 13 13 7 7 124 124 124 124 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+
+extern int suffix_(char *suff, integer *spaces, char *string, ftnlen suff_len, ftnlen string_len);
+/*:ref: lastnb_ 4 2 13 124 */
+
+extern doublereal sumad_(doublereal *array, integer *n);
+
+extern integer sumai_(integer *array, integer *n);
+
+extern int surfnm_(doublereal *a, doublereal *b, doublereal *c__, doublereal *point, doublereal *normal);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vhatip_ 14 1 7 */
+
+extern int surfpt_(doublereal *positn, doublereal *u, doublereal *a, doublereal *b, doublereal *c__, doublereal *point, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int surfpv_(doublereal *stvrtx, doublereal *stdir, doublereal *a, doublereal *b, doublereal *c__, doublereal *stx, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: surfpt_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dvhat_ 14 2 7 7 */
+/*:ref: surfnm_ 14 5 7 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: vlcom3_ 14 7 7 7 7 7 7 7 7 */
+
+extern int swapac_(integer *n, integer *locn, integer *m, integer *locm, char *array, ftnlen array_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: swapc_ 14 4 13 13 124 124 */
+/*:ref: cyacip_ 14 6 4 13 4 13 124 124 */
+
+extern int swapad_(integer *n, integer *locn, integer *m, integer *locm, doublereal *array);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: swapd_ 14 2 7 7 */
+/*:ref: cyadip_ 14 5 4 13 4 7 124 */
+
+extern int swapai_(integer *n, integer *locn, integer *m, integer *locm, integer *array);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: swapi_ 14 2 4 4 */
+/*:ref: cyaiip_ 14 5 4 13 4 4 124 */
+
+extern int swapc_(char *a, char *b, ftnlen a_len, ftnlen b_len);
+
+extern int swapd_(doublereal *a, doublereal *b);
+
+extern int swapi_(integer *a, integer *b);
+
+extern int sxform_(char *from, char *to, doublereal *et, doublereal *xform, ftnlen from_len, ftnlen to_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frmchg_ 14 4 4 4 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sydelc_(char *name__, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sydeld_(char *name__, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: remlad_ 14 4 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sydeli_(char *name__, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer sydimc_(char *name__, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer sydimd_(char *name__, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer sydimi_(char *name__, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sydupc_(char *name__, char *copy, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen copy_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sydupd_(char *name__, char *copy, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen copy_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: remlad_ 14 4 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sydupi_(char *name__, char *copy, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen copy_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syenqc_(char *name__, char *value, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen value_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sysetc_ 14 9 13 13 13 4 13 124 124 124 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syenqd_(char *name__, doublereal *value, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sysetd_ 14 7 13 7 13 4 7 124 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: inslad_ 14 5 7 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syenqi_(char *name__, integer *value, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: syseti_ 14 7 13 4 13 4 4 124 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syfetc_(integer *nth, char *tabsym, integer *tabptr, char *tabval, char *name__, logical *found, ftnlen tabsym_len, ftnlen tabval_len, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syfetd_(integer *nth, char *tabsym, integer *tabptr, doublereal *tabval, char *name__, logical *found, ftnlen tabsym_len, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syfeti_(integer *nth, char *tabsym, integer *tabptr, integer *tabval, char *name__, logical *found, ftnlen tabsym_len, ftnlen name_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sygetc_(char *name__, char *tabsym, integer *tabptr, char *tabval, integer *n, char *values, logical *found, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len, ftnlen values_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sygetd_(char *name__, char *tabsym, integer *tabptr, doublereal *tabval, integer *n, doublereal *values, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sygeti_(char *name__, char *tabsym, integer *tabptr, integer *tabval, integer *n, integer *values, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int synthc_(char *name__, integer *nth, char *tabsym, integer *tabptr, char *tabval, char *value, logical *found, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len, ftnlen value_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int synthd_(char *name__, integer *nth, char *tabsym, integer *tabptr, doublereal *tabval, doublereal *value, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int synthi_(char *name__, integer *nth, char *tabsym, integer *tabptr, integer *tabval, integer *value, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syordc_(char *name__, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: shellc_ 14 3 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syordd_(char *name__, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: shelld_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syordi_(char *name__, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: shelli_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sypopc_(char *name__, char *tabsym, integer *tabptr, char *tabval, char *value, logical *found, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len, ftnlen value_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sypopd_(char *name__, char *tabsym, integer *tabptr, doublereal *tabval, doublereal *value, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlad_ 14 4 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sypopi_(char *name__, char *tabsym, integer *tabptr, integer *tabval, integer *value, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sypshc_(char *name__, char *value, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen value_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sysetc_ 14 9 13 13 13 4 13 124 124 124 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sypshd_(char *name__, doublereal *value, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sysetd_ 14 7 13 7 13 4 7 124 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: inslad_ 14 5 7 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sypshi_(char *name__, integer *value, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: syseti_ 14 7 13 4 13 4 4 124 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syputc_(char *name__, char *values, integer *n, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen values_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+
+extern int syputd_(char *name__, doublereal *values, integer *n, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: remlad_ 14 4 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: inslad_ 14 5 7 4 4 7 4 */
+
+extern int syputi_(char *name__, integer *values, integer *n, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+
+extern int syrenc_(char *old, char *new__, char *tabsym, integer *tabptr, char *tabval, ftnlen old_len, ftnlen new_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sydelc_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: swapac_ 14 6 4 4 4 4 13 124 */
+/*:ref: swapai_ 14 5 4 4 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syrend_(char *old, char *new__, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen old_len, ftnlen new_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sydeld_ 14 6 13 13 4 7 124 124 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: swapad_ 14 5 4 4 4 4 7 */
+/*:ref: swapac_ 14 6 4 4 4 4 13 124 */
+/*:ref: swapai_ 14 5 4 4 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syreni_(char *old, char *new__, char *tabsym, integer *tabptr, integer *tabval, ftnlen old_len, ftnlen new_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sydeli_ 14 6 13 13 4 4 124 124 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: swapai_ 14 5 4 4 4 4 4 */
+/*:ref: swapac_ 14 6 4 4 4 4 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syselc_(char *name__, integer *begin, integer *end, char *tabsym, integer *tabptr, char *tabval, char *values, logical *found, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len, ftnlen values_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syseld_(char *name__, integer *begin, integer *end, char *tabsym, integer *tabptr, doublereal *tabval, doublereal *values, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syseli_(char *name__, integer *begin, integer *end, char *tabsym, integer *tabptr, integer *tabval, integer *values, logical *found, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sysetc_(char *name__, char *value, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen value_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlac_ 14 5 4 4 13 4 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sysetd_(char *name__, doublereal *value, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlad_ 14 4 4 4 7 4 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: inslad_ 14 5 7 4 4 7 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int syseti_(char *name__, integer *value, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: lstlec_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: remlai_ 14 4 4 4 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: inslac_ 14 7 13 4 4 13 4 124 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: inslai_ 14 5 4 4 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sytrnc_(char *name__, integer *i__, integer *j, char *tabsym, integer *tabptr, char *tabval, ftnlen name_len, ftnlen tabsym_len, ftnlen tabval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: swapc_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sytrnd_(char *name__, integer *i__, integer *j, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: swapd_ 14 2 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int sytrni_(char *name__, integer *i__, integer *j, char *tabsym, integer *tabptr, integer *tabval, ftnlen name_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: sumai_ 4 2 4 4 */
+/*:ref: swapi_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int tcheck_(doublereal *tvec, char *type__, logical *mods, char *modify, logical *ok, char *error, ftnlen type_len, ftnlen modify_len, ftnlen error_len);
+extern int tparch_(char *type__, ftnlen type_len);
+extern int tchckd_(char *type__, ftnlen type_len);
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: repmd_ 14 8 13 13 7 4 13 124 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+
+extern int texpyr_(integer *year);
+extern int tsetyr_(integer *year);
+
+extern int timdef_(char *action, char *item, char *value, ftnlen action_len, ftnlen item_len, ftnlen value_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: zzutcpm_ 14 7 13 4 7 7 4 12 124 */
+
+extern int timout_(doublereal *et, char *pictur, char *output, ftnlen pictur_len, ftnlen output_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: scanpr_ 14 5 4 13 4 4 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: scan_ 14 12 13 13 4 4 4 4 4 4 4 4 124 124 */
+/*:ref: timdef_ 14 6 13 13 13 124 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: zzutcpm_ 14 7 13 4 7 7 4 12 124 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: scanrj_ 14 6 4 4 4 4 4 4 */
+/*:ref: unitim_ 7 5 7 13 13 124 124 */
+/*:ref: spd_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: j1950_ 7 0 */
+/*:ref: brckti_ 4 3 4 4 4 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: dpfmt_ 14 5 7 13 13 124 124 */
+/*:ref: ttrans_ 14 5 13 13 7 124 124 */
+/*:ref: gr2jul_ 14 4 4 4 4 4 */
+/*:ref: jul2gr_ 14 4 4 4 4 4 */
+/*:ref: rmaind_ 14 4 7 7 7 7 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: lcase_ 14 4 13 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int tipbod_(char *ref, integer *body, doublereal *et, doublereal *tipm, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irftrn_ 14 5 13 13 7 124 124 */
+/*:ref: bodmat_ 14 3 4 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int tisbod_(char *ref, integer *body, doublereal *et, doublereal *tsipm, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: pckmat_ 14 5 4 7 4 7 12 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: ccifrm_ 14 7 4 4 4 13 4 12 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzbodbry_ 4 1 4 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: spd_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: bodfnd_ 12 3 4 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: rpd_ 7 0 */
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: twopi_ 7 0 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: failed_ 12 0 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: eul2xf_ 14 5 7 4 4 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+
+extern int tkfram_(integer *id, doublereal *rot, integer *frame, logical *found);
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnktl_ 4 2 4 4 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: locati_ 14 6 4 4 4 4 4 12 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: dwpool_ 14 2 13 124 */
+/*:ref: ident_ 14 1 7 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: frmnam_ 14 3 4 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: badkpv_ 12 10 13 13 13 4 4 13 124 124 124 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: sharpr_ 14 1 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: vhatg_ 14 3 7 4 7 */
+/*:ref: q2m_ 14 2 7 7 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+
+extern int tkvrsn_(char *item, char *verstr, ftnlen item_len, ftnlen verstr_len);
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+
+extern int tostdo_(char *line, ftnlen line_len);
+/*:ref: stdio_ 14 3 13 4 124 */
+/*:ref: writln_ 14 3 13 4 124 */
+
+extern H_f touchc_(char *ret_val, ftnlen ret_val_len, char *string, ftnlen string_len);
+
+extern doublereal touchd_(doublereal *dp);
+
+extern integer touchi_(integer *int__);
+
+extern logical touchl_(logical *log__);
+
+extern int tparse_(char *string, doublereal *sp2000, char *error, ftnlen string_len, ftnlen error_len);
+/*:ref: tpartv_ 14 15 13 7 4 13 13 12 12 12 13 13 124 124 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: j2000_ 7 0 */
+/*:ref: spd_ 7 0 */
+/*:ref: tcheck_ 14 9 7 13 12 13 12 13 124 124 124 */
+/*:ref: texpyr_ 14 1 4 */
+/*:ref: rmaini_ 14 4 4 4 4 4 */
+
+extern int tpartv_(char *string, doublereal *tvec, integer *ntvec, char *type__, char *modify, logical *mods, logical *yabbrv, logical *succes, char *pictur, char *error, ftnlen string_len, ftnlen type_len, ftnlen modify_len, ftnlen pictur_len, ftnlen error_len);
+/*:ref: zztpats_ 12 6 4 4 13 13 124 124 */
+/*:ref: zztokns_ 12 4 13 13 124 124 */
+/*:ref: zzcmbt_ 12 5 13 13 12 124 124 */
+/*:ref: zzsubt_ 12 5 13 13 12 124 124 */
+/*:ref: zzrept_ 12 5 13 13 12 124 124 */
+/*:ref: zzremt_ 12 2 13 124 */
+/*:ref: zzist_ 12 2 13 124 */
+/*:ref: zznote_ 12 4 13 4 4 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzunpck_ 12 11 13 12 7 4 13 13 13 124 124 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: zzvalt_ 12 6 13 4 4 13 124 124 */
+/*:ref: zzgrep_ 12 2 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: zzispt_ 12 4 13 4 4 124 */
+/*:ref: zzinssub_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+
+extern int tpictr_(char *sample, char *pictur, logical *ok, char *error, ftnlen sample_len, ftnlen pictur_len, ftnlen error_len);
+/*:ref: tpartv_ 14 15 13 7 4 13 13 12 12 12 13 13 124 124 124 124 124 */
+
+extern doublereal trace_(doublereal *matrix);
+
+extern doublereal traceg_(doublereal *matrix, integer *ndim);
+
+extern int trcpkg_(integer *depth, integer *index, char *module, char *trace, char *name__, ftnlen module_len, ftnlen trace_len, ftnlen name_len);
+extern int chkin_(char *module, ftnlen module_len);
+extern int chkout_(char *module, ftnlen module_len);
+extern int trcdep_(integer *depth);
+extern int trcmxd_(integer *depth);
+extern int trcnam_(integer *index, char *name__, ftnlen name_len);
+extern int qcktrc_(char *trace, ftnlen trace_len);
+extern int freeze_(void);
+extern int trcoff_(void);
+/*:ref: wrline_ 14 4 13 13 124 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+/*:ref: getdev_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: getact_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int ttrans_(char *from, char *to, doublereal *tvec, ftnlen from_len, ftnlen to_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spd_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: ssizec_ 14 3 4 13 124 */
+/*:ref: insrtc_ 14 4 13 13 124 124 */
+/*:ref: orderc_ 14 4 13 4 4 124 */
+/*:ref: reordc_ 14 4 4 4 13 124 */
+/*:ref: reordi_ 14 3 4 4 4 */
+/*:ref: reordl_ 14 3 4 4 12 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: rmaini_ 14 4 4 4 4 4 */
+/*:ref: lstlei_ 4 3 4 4 4 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: rmaind_ 14 4 7 7 7 7 */
+/*:ref: elemc_ 12 4 13 13 124 124 */
+/*:ref: unitim_ 7 5 7 13 13 124 124 */
+/*:ref: lstled_ 4 3 7 4 7 */
+/*:ref: lstlti_ 4 3 4 4 4 */
+
+extern doublereal twopi_(void);
+
+extern int twovec_(doublereal *axdef, integer *indexa, doublereal *plndef, integer *indexp, doublereal *mout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int twovxf_(doublereal *axdef, integer *indexa, doublereal *plndef, integer *indexp, doublereal *xform);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zztwovxf_ 14 5 7 4 7 4 7 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int txtopn_(char *fname, integer *unit, ftnlen fname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int txtopr_(char *fname, integer *unit, ftnlen fname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern doublereal tyear_(void);
+
+extern int ucase_(char *in, char *out, ftnlen in_len, ftnlen out_len);
+
+extern int ucrss_(doublereal *v1, doublereal *v2, doublereal *vout);
+/*:ref: vnorm_ 7 1 7 */
+
+extern int uddc_(U_fp udfunc, doublereal *x, doublereal *dx, logical *isdecr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: uddf_ 14 4 200 7 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int uddf_(S_fp udfunc, doublereal *x, doublereal *dx, doublereal *deriv);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+
+extern int unionc_(char *a, char *b, char *c__, ftnlen a_len, ftnlen b_len, ftnlen c_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: excess_ 14 3 4 13 124 */
+
+extern int uniond_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int unioni_(integer *a, integer *b, integer *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: scardi_ 14 2 4 4 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern doublereal unitim_(doublereal *epoch, char *insys, char *outsys, ftnlen insys_len, ftnlen outsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spd_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: validc_ 14 4 4 4 13 124 */
+/*:ref: ssizec_ 14 3 4 13 124 */
+/*:ref: unionc_ 14 6 13 13 13 124 124 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: somfls_ 12 2 12 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: insrtc_ 14 4 13 13 124 124 */
+/*:ref: setc_ 12 6 13 13 13 124 124 124 */
+/*:ref: elemc_ 12 4 13 13 124 124 */
+
+extern int unorm_(doublereal *v1, doublereal *vout, doublereal *vmag);
+/*:ref: vnorm_ 7 1 7 */
+
+extern int unormg_(doublereal *v1, integer *ndim, doublereal *vout, doublereal *vmag);
+/*:ref: vnormg_ 7 2 7 4 */
+
+extern int utc2et_(char *utcstr, doublereal *et, ftnlen utcstr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: tpartv_ 14 15 13 7 4 13 13 12 12 12 13 13 124 124 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: tcheck_ 14 9 7 13 12 13 12 13 124 124 124 */
+/*:ref: texpyr_ 14 1 4 */
+/*:ref: ttrans_ 14 5 13 13 7 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int vadd_(doublereal *v1, doublereal *v2, doublereal *vout);
+
+extern int vaddg_(doublereal *v1, doublereal *v2, integer *ndim, doublereal *vout);
+
+extern int validc_(integer *size, integer *n, char *a, ftnlen a_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rmdupc_ 14 3 4 13 124 */
+/*:ref: ssizec_ 14 3 4 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+
+extern int validd_(integer *size, integer *n, doublereal *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rmdupd_ 14 2 4 7 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: scardd_ 14 2 4 7 */
+
+extern int validi_(integer *size, integer *n, integer *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rmdupi_ 14 2 4 4 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: scardi_ 14 2 4 4 */
+
+extern int vcrss_(doublereal *v1, doublereal *v2, doublereal *vout);
+
+extern doublereal vdist_(doublereal *v1, doublereal *v2);
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+
+extern doublereal vdistg_(doublereal *v1, doublereal *v2, integer *ndim);
+
+extern doublereal vdot_(doublereal *v1, doublereal *v2);
+
+extern doublereal vdotg_(doublereal *v1, doublereal *v2, integer *ndim);
+
+extern int vequ_(doublereal *vin, doublereal *vout);
+
+extern int vequg_(doublereal *vin, integer *ndim, doublereal *vout);
+
+extern int vhat_(doublereal *v1, doublereal *vout);
+/*:ref: vnorm_ 7 1 7 */
+
+extern int vhatg_(doublereal *v1, integer *ndim, doublereal *vout);
+/*:ref: vnormg_ 7 2 7 4 */
+
+extern int vhatip_(doublereal *v);
+/*:ref: vnorm_ 7 1 7 */
+
+extern int vlcom_(doublereal *a, doublereal *v1, doublereal *b, doublereal *v2, doublereal *sum);
+
+extern int vlcom3_(doublereal *a, doublereal *v1, doublereal *b, doublereal *v2, doublereal *c__, doublereal *v3, doublereal *sum);
+
+extern int vlcomg_(integer *n, doublereal *a, doublereal *v1, doublereal *b, doublereal *v2, doublereal *sum);
+
+extern int vminug_(doublereal *vin, integer *ndim, doublereal *vout);
+
+extern int vminus_(doublereal *v1, doublereal *vout);
+
+extern doublereal vnorm_(doublereal *v1);
+
+extern doublereal vnormg_(doublereal *v1, integer *ndim);
+
+extern int vpack_(doublereal *x, doublereal *y, doublereal *z__, doublereal *v);
+
+extern int vperp_(doublereal *a, doublereal *b, doublereal *p);
+/*:ref: vproj_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+
+extern int vprjp_(doublereal *vin, doublereal *plane, doublereal *vout);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int vprjpi_(doublereal *vin, doublereal *projpl, doublereal *invpl, doublereal *vout, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: dpmax_ 7 0 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int vproj_(doublereal *a, doublereal *b, doublereal *p);
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+
+extern int vprojg_(doublereal *a, doublereal *b, integer *ndim, doublereal *p);
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: vsclg_ 14 4 7 7 4 7 */
+
+extern doublereal vrel_(doublereal *v1, doublereal *v2);
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+
+extern doublereal vrelg_(doublereal *v1, doublereal *v2, integer *ndim);
+/*:ref: vdistg_ 7 3 7 7 4 */
+/*:ref: vnormg_ 7 2 7 4 */
+
+extern int vrotv_(doublereal *v, doublereal *axis, doublereal *theta, doublereal *r__);
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vproj_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+
+extern int vscl_(doublereal *s, doublereal *v1, doublereal *vout);
+
+extern int vsclg_(doublereal *s, doublereal *v1, integer *ndim, doublereal *vout);
+
+extern int vsclip_(doublereal *s, doublereal *v);
+
+extern doublereal vsep_(doublereal *v1, doublereal *v2);
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: pi_ 7 0 */
+
+extern doublereal vsepg_(doublereal *v1, doublereal *v2, integer *ndim);
+/*:ref: vnormg_ 7 2 7 4 */
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: pi_ 7 0 */
+
+extern int vsub_(doublereal *v1, doublereal *v2, doublereal *vout);
+
+extern int vsubg_(doublereal *v1, doublereal *v2, integer *ndim, doublereal *vout);
+
+extern doublereal vtmv_(doublereal *v1, doublereal *matrix, doublereal *v2);
+
+extern doublereal vtmvg_(doublereal *v1, doublereal *matrix, doublereal *v2, integer *nrow, integer *ncol);
+
+extern int vupack_(doublereal *v, doublereal *x, doublereal *y, doublereal *z__);
+
+extern logical vzero_(doublereal *v);
+
+extern logical vzerog_(doublereal *v, integer *ndim);
+
+extern integer wdcnt_(char *string, ftnlen string_len);
+
+extern integer wdindx_(char *string, char *word, ftnlen string_len, ftnlen word_len);
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: frstnb_ 4 2 13 124 */
+
+extern integer wncard_(doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: even_ 12 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wncomd_(doublereal *left, doublereal *right, doublereal *window, doublereal *result);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+/*:ref: failed_ 12 0 */
+
+extern int wncond_(doublereal *left, doublereal *right, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: wnexpd_ 14 3 7 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wndifd_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: copyd_ 14 2 7 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern logical wnelmd_(doublereal *point, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnexpd_(doublereal *left, doublereal *right, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnextd_(char *side, doublereal *window, ftnlen side_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnfetd_(doublereal *window, integer *n, doublereal *left, doublereal *right);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnfild_(doublereal *small, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnfltd_(doublereal *small, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical wnincd_(doublereal *left, doublereal *right, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wninsd_(doublereal *left, doublereal *right, doublereal *window);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+
+extern int wnintd_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical wnreld_(doublereal *a, char *op, doublereal *b, ftnlen op_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: wnincd_ 12 3 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnsumd_(doublereal *window, doublereal *meas, doublereal *avg, doublereal *stddev, integer *short__, integer *long__);
+/*:ref: return_ 12 0 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: even_ 12 1 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnunid_(doublereal *a, doublereal *b, doublereal *c__);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: excess_ 14 3 4 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wnvald_(integer *size, integer *n, doublereal *a);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+
+extern int wrencc_(integer *unit, integer *n, char *data, ftnlen data_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wrencd_(integer *unit, integer *n, doublereal *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dp2hx_ 14 4 7 13 4 124 */
+
+extern int wrenci_(integer *unit, integer *n, integer *data);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: int2hx_ 14 4 4 13 4 124 */
+
+extern int writla_(integer *numlin, char *array, integer *unit, ftnlen array_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: writln_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+
+extern int writln_(char *line, integer *unit, ftnlen line_len);
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wrkvar_(integer *unit, char *name__, char *dirctv, char *tabsym, integer *tabptr, doublereal *tabval, ftnlen name_len, ftnlen dirctv_len, ftnlen tabsym_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sydimd_ 4 6 13 13 4 7 124 124 */
+/*:ref: synthd_ 14 9 13 4 13 4 7 7 12 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: rjust_ 14 4 13 13 124 124 */
+/*:ref: ioerr_ 14 5 13 13 4 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int wrline_(char *device, char *line, ftnlen device_len, ftnlen line_len);
+extern int clline_(char *device, ftnlen device_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: fndlun_ 14 1 4 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+
+extern int xf2eul_(doublereal *xform, integer *axisa, integer *axisb, integer *axisc, doublereal *eulang, logical *unique);
+extern int eul2xf_(doublereal *eulang, integer *axisa, integer *axisb, integer *axisc, doublereal *xform);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: m2eul_ 14 7 7 4 4 4 7 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: mxmt_ 14 3 7 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+
+extern int xf2rav_(doublereal *xform, doublereal *rot, doublereal *av);
+/*:ref: mtxm_ 14 3 7 7 7 */
+
+extern int xposbl_(doublereal *bmat, integer *nrow, integer *ncol, integer *bsize, doublereal *btmat);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int xpose_(doublereal *m1, doublereal *mout);
+
+extern int xposeg_(doublereal *matrix, integer *nrow, integer *ncol, doublereal *xposem);
+
+extern int xpsgip_(integer *nrow, integer *ncol, doublereal *matrix);
+
+extern int zzascii_(char *file, char *line, logical *check, char *termin, ftnlen file_len, ftnlen line_len, ftnlen termin_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzasryel_(char *extrem, doublereal *ellips, doublereal *vertex, doublereal *dir, doublereal *angle, doublereal *extpt, ftnlen extrem_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: psv2pl_ 14 4 7 7 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: vprjp_ 14 3 7 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: inrypl_ 14 5 7 7 7 4 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vlcom3_ 14 7 7 7 7 7 7 7 7 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: swapd_ 14 2 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+
+extern int zzbodblt_(integer *room, char *names, char *nornam, integer *codes, integer *nvals, char *device, char *reqst, ftnlen names_len, ftnlen nornam_len, ftnlen device_len, ftnlen reqst_len);
+extern int zzbodget_(integer *room, char *names, char *nornam, integer *codes, integer *nvals, ftnlen names_len, ftnlen nornam_len);
+extern int zzbodlst_(char *device, char *reqst, ftnlen device_len, ftnlen reqst_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzidmap_ 14 3 4 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: movec_ 14 5 13 4 13 124 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: wrline_ 14 4 13 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: orderi_ 14 3 4 4 4 */
+/*:ref: orderc_ 14 4 13 4 4 124 */
+
+extern integer zzbodbry_(integer *body);
+
+extern int zzbodini_(char *names, char *nornam, integer *codes, integer *nvals, integer *ordnom, integer *ordcod, integer *nocds, ftnlen names_len, ftnlen nornam_len);
+/*:ref: orderc_ 14 4 13 4 4 124 */
+/*:ref: orderi_ 14 3 4 4 4 */
+
+extern int zzbodker_(char *names, char *nornam, integer *codes, integer *nvals, integer *ordnom, integer *ordcod, integer *nocds, logical *extker, ftnlen names_len, ftnlen nornam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: orderc_ 14 4 13 4 4 124 */
+/*:ref: zzbodini_ 14 9 13 13 4 4 4 4 4 124 124 */
+
+extern int zzbodtrn_(char *name__, integer *code, logical *found, ftnlen name_len);
+extern int zzbodn2c_(char *name__, integer *code, logical *found, ftnlen name_len);
+extern int zzbodc2n_(integer *code, char *name__, logical *found, ftnlen name_len);
+extern int zzboddef_(char *name__, integer *code, ftnlen name_len);
+extern int zzbodkik_(void);
+extern int zzbodrst_(void);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzbodget_ 14 7 4 13 13 4 4 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzbodini_ 14 9 13 13 4 4 4 4 4 124 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: zzbodker_ 14 10 13 13 4 4 4 4 4 12 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: bschoc_ 4 6 13 4 13 4 124 124 */
+/*:ref: bschoi_ 4 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int zzbodvcd_(integer *bodyid, char *item, integer *maxn, integer *dim, doublereal *values, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+
+extern int zzck4d2i_(doublereal *dpcoef, integer *nsets, doublereal *parcod, integer *i__);
+
+extern int zzck4i2d_(integer *i__, integer *nsets, doublereal *parcod, doublereal *dpcoef);
+
+extern int zzckcv01_(integer *handle, integer *arrbeg, integer *arrend, integer *sclkid, doublereal *tol, char *timsys, doublereal *schedl, ftnlen timsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+
+extern int zzckcv02_(integer *handle, integer *arrbeg, integer *arrend, integer *sclkid, doublereal *tol, char *timsys, doublereal *schedl, ftnlen timsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+
+extern int zzckcv03_(integer *handle, integer *arrbeg, integer *arrend, integer *sclkid, doublereal *tol, char *timsys, doublereal *schedl, ftnlen timsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: errhan_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+
+extern int zzckcv04_(integer *handle, integer *arrbeg, integer *arrend, integer *sclkid, doublereal *tol, char *timsys, doublereal *schedl, ftnlen timsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: intmax_ 4 0 */
+/*:ref: dafps_ 14 5 4 4 7 4 7 */
+/*:ref: cknr04_ 14 3 4 7 4 */
+/*:ref: sgfpkt_ 14 6 4 7 4 4 7 4 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+
+extern int zzckcv05_(integer *handle, integer *arrbeg, integer *arrend, integer *sclkid, doublereal *dc, doublereal *tol, char *timsys, doublereal *schedl, ftnlen timsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+/*:ref: errint_ 14 3 13 7 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+
+extern int zzckspk_(integer *handle, char *ckspk, ftnlen ckspk_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dafhsf_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dafbfs_ 14 1 4 */
+/*:ref: daffna_ 14 1 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: dafgs_ 14 1 7 */
+/*:ref: dafus_ 14 5 7 4 4 7 4 */
+/*:ref: zzsizeok_ 14 6 4 4 4 4 12 4 */
+/*:ref: dafgda_ 14 4 4 4 4 7 */
+
+extern int zzcln_(integer *lookat, integer *nameat, integer *namlst, integer *datlst, integer *nmpool, integer *chpool, integer *dppool);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzcorepc_(char *abcorr, doublereal *et, doublereal *lt, doublereal *etcorr, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzcorsxf_(logical *xmit, doublereal *dlt, doublereal *xform, doublereal *corxfm);
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+
+extern int zzcputim_(doublereal *tvec);
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzdafgdr_(integer *handle, integer *recno, doublereal *dprec, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhnfo_ 14 7 4 13 4 4 4 12 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzxlated_ 14 5 4 13 4 7 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int zzdafgfr_(integer *handle, char *idword, integer *nd, integer *ni, char *ifname, integer *fward, integer *bward, integer *free, logical *found, ftnlen idword_len, ftnlen ifname_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhnfo_ 14 7 4 13 4 4 4 12 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzxlatei_ 14 5 4 13 4 4 124 */
+
+extern int zzdafgsr_(integer *handle, integer *recno, integer *nd, integer *ni, doublereal *dprec, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhnfo_ 14 7 4 13 4 4 4 12 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzddhhlu_ 14 5 4 13 12 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzxlated_ 14 5 4 13 4 7 124 */
+/*:ref: zzxlatei_ 14 5 4 13 4 4 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int zzdafnfr_(integer *lun, char *idword, integer *nd, integer *ni, char *ifname, integer *fward, integer *bward, integer *free, char *format, ftnlen idword_len, ftnlen ifname_len, ftnlen format_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzftpstr_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzdasnfr_(integer *lun, char *idword, char *ifname, integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc, char *format, ftnlen idword_len, ftnlen ifname_len, ftnlen format_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzftpstr_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer zzddhclu_(logical *utlck, integer *nut);
+
+extern int zzddhf2h_(char *fname, integer *ftabs, integer *ftamh, integer *ftarc, integer *ftbff, integer *fthan, char *ftnam, integer *ftrtm, integer *nft, integer *utcst, integer *uthan, logical *utlck, integer *utlun, integer *nut, logical *exists, logical *opened, integer *handle, logical *found, ftnlen fname_len, ftnlen ftnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zzddhgtu_ 14 6 4 4 12 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzddhrmu_ 14 7 4 4 4 4 12 4 4 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int zzddhgsd_(char *class__, integer *id, char *label, ftnlen class_len, ftnlen label_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+
+extern int zzddhgtu_(integer *utcst, integer *uthan, logical *utlck, integer *utlun, integer *nut, integer *uindex);
+/*:ref: return_ 12 0 */
+/*:ref: getlun_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: orderi_ 14 3 4 4 4 */
+/*:ref: frelun_ 14 1 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzddhini_(integer *natbff, integer *supbff, integer *numsup, char *stramh, char *strarc, char *strbff, ftnlen stramh_len, ftnlen strarc_len, ftnlen strbff_len);
+/*:ref: return_ 12 0 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: nextwd_ 14 6 13 13 13 124 124 124 */
+
+extern int zzddhivf_(char *nsum, integer *bff, logical *found, ftnlen nsum_len);
+
+extern int zzddhman_(logical *lock, char *arch, char *fname, char *method, integer *handle, integer *unit, integer *intamh, integer *intarc, integer *intbff, logical *native, logical *found, logical *kill, ftnlen arch_len, ftnlen fname_len, ftnlen method_len);
+extern int zzddhopn_(char *fname, char *method, char *arch, integer *handle, ftnlen fname_len, ftnlen method_len, ftnlen arch_len);
+extern int zzddhcls_(integer *handle, char *arch, logical *kill, ftnlen arch_len);
+extern int zzddhhlu_(integer *handle, char *arch, logical *lock, integer *unit, ftnlen arch_len);
+extern int zzddhunl_(integer *handle, char *arch, ftnlen arch_len);
+extern int zzddhnfo_(integer *handle, char *fname, integer *intarc, integer *intbff, integer *intamh, logical *found, ftnlen fname_len);
+extern int zzddhisn_(integer *handle, logical *native, logical *found);
+extern int zzddhfnh_(char *fname, integer *handle, logical *found, ftnlen fname_len);
+extern int zzddhluh_(integer *unit, integer *handle, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzddhini_ 14 9 4 4 4 13 13 13 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzpltchk_ 14 1 12 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: zzddhclu_ 4 2 12 4 */
+/*:ref: zzddhf2h_ 14 20 13 4 4 4 4 4 13 4 4 4 4 12 4 4 12 12 4 12 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: bsrchi_ 4 3 4 4 4 */
+/*:ref: zzddhrcm_ 14 3 4 4 4 */
+/*:ref: zzddhgtu_ 14 6 4 4 12 4 4 4 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: zzddhppf_ 14 3 4 4 4 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zzddhrmu_ 14 7 4 4 4 4 12 4 4 */
+/*:ref: frelun_ 14 1 4 */
+
+extern int zzddhppf_(integer *unit, integer *arch, integer *bff);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzftpstr_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: idw2at_ 14 6 13 13 13 124 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: zzftpchk_ 14 3 13 12 124 */
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzddhivf_ 14 4 13 4 12 124 */
+
+extern int zzddhrcm_(integer *nut, integer *utcst, integer *reqcnt);
+/*:ref: intmax_ 4 0 */
+
+extern int zzddhrmu_(integer *uindex, integer *nft, integer *utcst, integer *uthan, logical *utlck, integer *utlun, integer *nut);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: reslun_ 14 1 4 */
+
+extern int zzdynbid_(char *frname, integer *frcode, char *item, integer *idcode, ftnlen frname_len, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+
+extern int zzdynfid_(char *frname, integer *frcode, char *item, integer *idcode, ftnlen frname_len, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: beint_ 12 2 13 124 */
+/*:ref: prsint_ 14 3 13 4 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+
+extern int zzdynfr0_(integer *infram, integer *center, doublereal *et, doublereal *xform, integer *basfrm);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: bodn2c_ 14 4 13 4 12 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: frmnam_ 14 3 4 13 124 */
+/*:ref: zzdynfid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzdynvac_ 14 9 13 4 13 4 4 13 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzdynoad_ 14 9 13 4 13 4 4 7 12 124 124 */
+/*:ref: zzdynoac_ 14 10 13 4 13 4 4 13 12 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: zzeprc76_ 14 2 7 7 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: zzenut80_ 14 2 7 7 */
+/*:ref: mxmg_ 14 6 7 7 4 4 4 7 */
+/*:ref: zzmobliq_ 14 3 7 7 7 */
+/*:ref: eul2xf_ 14 5 7 4 4 4 7 */
+/*:ref: zzfrmch1_ 14 4 4 4 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzdynbid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzspkez1_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzspkzp1_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vminug_ 14 3 7 4 7 */
+/*:ref: dnearp_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: zzspksb1_ 14 5 4 7 13 7 124 */
+/*:ref: zzdynvad_ 14 8 13 4 13 4 4 7 124 124 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: zztwovxf_ 14 5 7 4 7 4 7 */
+/*:ref: zzdynvai_ 14 8 13 4 13 4 4 4 124 124 */
+/*:ref: polyds_ 14 5 7 4 4 7 7 */
+
+extern int zzdynfrm_(integer *infram, integer *center, doublereal *et, doublereal *xform, integer *basfrm);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: bodn2c_ 14 4 13 4 12 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: frmnam_ 14 3 4 13 124 */
+/*:ref: zzdynfid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzdynvac_ 14 9 13 4 13 4 4 13 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzdynoad_ 14 9 13 4 13 4 4 7 12 124 124 */
+/*:ref: zzdynoac_ 14 10 13 4 13 4 4 13 12 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: zzeprc76_ 14 2 7 7 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: zzenut80_ 14 2 7 7 */
+/*:ref: mxmg_ 14 6 7 7 4 4 4 7 */
+/*:ref: zzmobliq_ 14 3 7 7 7 */
+/*:ref: eul2xf_ 14 5 7 4 4 4 7 */
+/*:ref: zzfrmch0_ 14 4 4 4 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzdynbid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzspkez0_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzspkzp0_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vminug_ 14 3 7 4 7 */
+/*:ref: dnearp_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: zzspksb0_ 14 5 4 7 13 7 124 */
+/*:ref: zzdynvad_ 14 8 13 4 13 4 4 7 124 124 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: zztwovxf_ 14 5 7 4 7 4 7 */
+/*:ref: zzdynvai_ 14 8 13 4 13 4 4 4 124 124 */
+/*:ref: polyds_ 14 5 7 4 4 7 7 */
+
+extern int zzdynoac_(char *frname, integer *frcode, char *item, integer *maxn, integer *n, char *values, logical *found, ftnlen frname_len, ftnlen item_len, ftnlen values_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+
+extern int zzdynoad_(char *frname, integer *frcode, char *item, integer *maxn, integer *n, doublereal *values, logical *found, ftnlen frname_len, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+
+extern int zzdynrot_(integer *infram, integer *center, doublereal *et, doublereal *rotate, integer *basfrm);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: bodn2c_ 14 4 13 4 12 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: frmnam_ 14 3 4 13 124 */
+/*:ref: zzdynfid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzdynvac_ 14 9 13 4 13 4 4 13 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzdynoad_ 14 9 13 4 13 4 4 7 12 124 124 */
+/*:ref: zzdynoac_ 14 10 13 4 13 4 4 13 12 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: zzeprc76_ 14 2 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: zzenut80_ 14 2 7 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: zzmobliq_ 14 3 7 7 7 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: zzrefch0_ 14 4 4 4 7 7 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzdynbid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzspkzp0_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzspkez0_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: zzspksb0_ 14 5 4 7 13 7 124 */
+/*:ref: zzdynvad_ 14 8 13 4 13 4 4 7 124 124 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: twovec_ 14 5 7 4 7 4 7 */
+/*:ref: zzdynvai_ 14 8 13 4 13 4 4 4 124 124 */
+/*:ref: polyds_ 14 5 7 4 4 7 7 */
+
+extern int zzdynrt0_(integer *infram, integer *center, doublereal *et, doublereal *rotate, integer *basfrm);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: bodn2c_ 14 4 13 4 12 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: frmnam_ 14 3 4 13 124 */
+/*:ref: zzdynfid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzdynvac_ 14 9 13 4 13 4 4 13 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzdynoad_ 14 9 13 4 13 4 4 7 12 124 124 */
+/*:ref: zzdynoac_ 14 10 13 4 13 4 4 13 12 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: zzeprc76_ 14 2 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: zzenut80_ 14 2 7 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: zzmobliq_ 14 3 7 7 7 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+/*:ref: zzrefch1_ 14 4 4 4 7 7 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzdynbid_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzspkzp1_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzspkez1_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: cidfrm_ 14 5 4 4 13 12 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: nearpt_ 14 6 7 7 7 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: zzspksb1_ 14 5 4 7 13 7 124 */
+/*:ref: zzdynvad_ 14 8 13 4 13 4 4 7 124 124 */
+/*:ref: convrt_ 14 6 7 13 13 7 124 124 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: twovec_ 14 5 7 4 7 4 7 */
+/*:ref: zzdynvai_ 14 8 13 4 13 4 4 4 124 124 */
+/*:ref: polyds_ 14 5 7 4 4 7 7 */
+
+extern int zzdynvac_(char *frname, integer *frcode, char *item, integer *maxn, integer *n, char *values, ftnlen frname_len, ftnlen item_len, ftnlen values_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gcpool_ 14 8 13 4 4 4 13 12 124 124 */
+
+extern int zzdynvad_(char *frname, integer *frcode, char *item, integer *maxn, integer *n, doublereal *values, ftnlen frname_len, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gdpool_ 14 7 13 4 4 4 7 12 124 */
+
+extern int zzdynvai_(char *frname, integer *frcode, char *item, integer *maxn, integer *n, integer *values, ftnlen frname_len, ftnlen item_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: gipool_ 14 7 13 4 4 4 4 12 124 */
+
+extern int zzedterm_(char *type__, doublereal *a, doublereal *b, doublereal *c__, doublereal *srcrad, doublereal *srcpos, integer *npts, doublereal *trmpts, ftnlen type_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: frame_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: twopi_ 7 0 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: nvp2pl_ 14 3 7 7 7 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+
+extern int zzekac01_(integer *handle, integer *segdsc, integer *coldsc, integer *ivals, logical *nlflgs, integer *rcptrs, integer *wkindx);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzekordi_ 14 5 4 12 12 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: zzektr1s_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzekac02_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dvals, logical *nlflgs, integer *rcptrs, integer *wkindx);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: zzekpgwd_ 14 3 4 4 7 */
+/*:ref: zzekordd_ 14 5 7 12 12 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: zzektr1s_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzekac03_(integer *handle, integer *segdsc, integer *coldsc, char *cvals, logical *nlflgs, integer *rcptrs, integer *wkindx, ftnlen cvals_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: prtenc_ 14 3 4 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: prtdec_ 14 3 13 4 124 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: zzekordc_ 14 6 13 12 12 4 4 124 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: zzektr1s_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzekac04_(integer *handle, integer *segdsc, integer *coldsc, integer *ivals, integer *entszs, logical *nlflgs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+
+extern int zzekac05_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dvals, integer *entszs, logical *nlflgs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: zzekpgwd_ 14 3 4 4 7 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+
+extern int zzekac06_(integer *handle, integer *segdsc, integer *coldsc, char *cvals, integer *entszs, logical *nlflgs, ftnlen cvals_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: prtenc_ 14 3 4 13 124 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+
+extern int zzekac07_(integer *handle, integer *segdsc, integer *coldsc, integer *ivals, logical *nlflgs, integer *wkindx);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekacps_ 14 6 4 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekordi_ 14 5 4 12 12 4 4 */
+/*:ref: zzekwpai_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzekwpal_ 14 6 4 4 4 12 4 4 */
+
+extern int zzekac08_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dvals, logical *nlflgs, integer *wkindx);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekacps_ 14 6 4 4 4 4 4 4 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: zzekpgwd_ 14 3 4 4 7 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekordd_ 14 5 7 12 12 4 4 */
+/*:ref: zzekwpai_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzekwpal_ 14 6 4 4 4 12 4 4 */
+
+extern int zzekac09_(integer *handle, integer *segdsc, integer *coldsc, char *cvals, logical *nlflgs, integer *wkindx, ftnlen cvals_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekacps_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekordc_ 14 6 13 12 12 4 4 124 */
+/*:ref: zzekwpai_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzekwpal_ 14 6 4 4 4 12 4 4 */
+
+extern int zzekacps_(integer *handle, integer *segdsc, integer *type__, integer *n, integer *p, integer *base);
+/*:ref: zzekpgan_ 14 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+/*:ref: zzektrap_ 14 4 4 4 4 4 */
+
+extern int zzekad01_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *ival, logical *isnull);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzekiii1_ 14 6 4 4 4 4 4 12 */
+
+extern int zzekad02_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, doublereal *dval, logical *isnull);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: dasudd_ 14 4 4 4 4 7 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzekiid1_ 14 6 4 4 4 7 4 12 */
+
+extern int zzekad03_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, char *cval, logical *isnull, ftnlen cval_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: zzeksei_ 14 3 4 4 4 */
+/*:ref: dasudc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekiic1_ 14 7 4 4 4 13 4 12 124 */
+
+extern int zzekad04_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *nvals, integer *ivals, logical *isnull);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+
+extern int zzekad05_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *nvals, doublereal *dvals, logical *isnull);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: dasudd_ 14 4 4 4 4 7 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+
+extern int zzekad06_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *nvals, char *cvals, logical *isnull, ftnlen cvals_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzeksei_ 14 3 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: dasudc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+
+extern int zzekaps_(integer *handle, integer *segdsc, integer *type__, logical *new__, integer *p, integer *base);
+/*:ref: zzekpgan_ 14 4 4 4 4 4 */
+/*:ref: zzekpgal_ 14 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzeksfwd_ 14 4 4 4 4 4 */
+/*:ref: zzektrap_ 14 4 4 4 4 4 */
+
+extern int zzekbs01_(integer *handle, char *tabnam, integer *ncols, char *cnames, integer *cdscrs, integer *segno, ftnlen tabnam_len, ftnlen cnames_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgan_ 14 4 4 4 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: eknseg_ 4 1 4 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: zzekcix1_ 14 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzektrap_ 14 4 4 4 4 4 */
+
+extern int zzekbs02_(integer *handle, char *tabnam, integer *ncols, char *cnames, integer *cdscrs, integer *segno, ftnlen tabnam_len, ftnlen cnames_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgan_ 14 4 4 4 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: eknseg_ 4 1 4 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzektrap_ 14 4 4 4 4 4 */
+
+extern int zzekcchk_(char *query, integer *eqryi, char *eqryc, integer *ntab, char *tablst, char *alslst, integer *base, logical *error, char *errmsg, integer *errptr, ftnlen query_len, ftnlen eqryc_len, ftnlen tablst_len, ftnlen alslst_len, ftnlen errmsg_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: ekccnt_ 14 3 13 4 124 */
+/*:ref: ekcii_ 14 6 13 4 13 4 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+
+extern int zzekcdsc_(integer *handle, integer *segdsc, char *column, integer *coldsc, ftnlen column_len);
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekcix1_(integer *handle, integer *coldsc);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrit_ 14 2 4 4 */
+
+extern int zzekcnam_(integer *handle, integer *coldsc, char *column, ftnlen column_len);
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+
+extern int zzekde01_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekixdl_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzekde02_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekixdl_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzekde03_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekixdl_ 14 4 4 4 4 4 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekgfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzekde04_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekgfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzekde05_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekgfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzekde06_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekgfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: zzekdps_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzekdps_(integer *handle, integer *segdsc, integer *type__, integer *p);
+/*:ref: zzekpgfr_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzektrls_ 4 3 4 4 4 */
+/*:ref: zzektrdl_ 14 3 4 4 4 */
+
+extern integer zzekecmp_(integer *hans, integer *sgdscs, integer *cldscs, integer *rows, integer *elts);
+/*:ref: zzekrsi_ 14 8 4 4 4 4 4 4 12 12 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrsd_ 14 8 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrsc_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+
+extern int zzekencd_(char *query, integer *eqryi, char *eqryc, doublereal *eqryd, logical *error, char *errmsg, integer *errptr, ftnlen query_len, ftnlen eqryc_len, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekqini_ 14 6 4 4 4 13 7 124 */
+/*:ref: zzekscan_ 14 17 13 4 4 4 4 4 4 4 7 13 4 4 12 13 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpars_ 14 19 13 4 4 4 4 4 7 13 4 4 4 13 7 12 13 124 124 124 124 */
+/*:ref: zzeknres_ 14 9 13 4 13 12 13 4 124 124 124 */
+/*:ref: zzektres_ 14 10 13 4 13 7 12 13 4 124 124 124 */
+/*:ref: zzeksemc_ 14 9 13 4 13 12 13 4 124 124 124 */
+
+extern int zzekerc1_(integer *handle, integer *segdsc, integer *coldsc, char *ckey, integer *recptr, logical *null, integer *prvidx, integer *prvptr, ftnlen ckey_len);
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrsz_ 4 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzekerd1_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dkey, integer *recptr, logical *null, integer *prvidx, integer *prvptr);
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrsz_ 4 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzekeri1_(integer *handle, integer *segdsc, integer *coldsc, integer *ikey, integer *recptr, logical *null, integer *prvidx, integer *prvptr);
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrsz_ 4 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern integer zzekesiz_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: zzeksz04_ 4 4 4 4 4 4 */
+/*:ref: zzeksz05_ 4 4 4 4 4 4 */
+/*:ref: zzeksz06_ 4 4 4 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekff01_(integer *handle, integer *segno, integer *rcptrs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzektrit_ 14 2 4 4 */
+/*:ref: zzektr1s_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzekfrx_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *pos);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekrsc_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: zzekrsd_ 14 8 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrsi_ 14 8 4 4 4 4 4 4 12 12 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: zzeklerc_ 14 9 4 4 4 13 4 12 4 4 124 */
+/*:ref: zzeklerd_ 14 8 4 4 4 7 4 12 4 4 */
+/*:ref: zzekleri_ 14 8 4 4 4 4 4 12 4 4 */
+
+extern int zzekgcdp_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *datptr);
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzekgei_(integer *handle, integer *addrss, integer *ival);
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: prtdec_ 14 3 13 4 124 */
+
+extern int zzekgfwd_(integer *handle, integer *type__, integer *p, integer *fward);
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzekglnk_(integer *handle, integer *type__, integer *p, integer *nlinks);
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzekgrcp_(integer *handle, integer *recptr, integer *ptr);
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzekgrs_(integer *handle, integer *recptr, integer *status);
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzekif01_(integer *handle, integer *segno, integer *rcptrs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: zzekstop_ 14 1 4 */
+/*:ref: zzeksdec_ 14 1 4 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekif02_(integer *handle, integer *segno);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekaps_ 14 6 4 4 4 12 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekiic1_(integer *handle, integer *segdsc, integer *coldsc, char *ckey, integer *recptr, logical *null, ftnlen ckey_len);
+/*:ref: failed_ 12 0 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzeklerc_ 14 9 4 4 4 13 4 12 4 4 124 */
+/*:ref: zzektrin_ 14 4 4 4 4 4 */
+
+extern int zzekiid1_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dkey, integer *recptr, logical *null);
+/*:ref: failed_ 12 0 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzeklerd_ 14 8 4 4 4 7 4 12 4 4 */
+/*:ref: zzektrin_ 14 4 4 4 4 4 */
+
+extern int zzekiii1_(integer *handle, integer *segdsc, integer *coldsc, integer *ikey, integer *recptr, logical *null);
+/*:ref: failed_ 12 0 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekleri_ 14 8 4 4 4 4 4 12 4 4 */
+/*:ref: zzektrin_ 14 4 4 4 4 4 */
+
+extern integer zzekille_(integer *handle, integer *segdsc, integer *coldsc, integer *nrows, integer *dtype, char *cval, doublereal *dval, integer *ival, ftnlen cval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekllec_ 14 7 4 4 4 13 4 4 124 */
+/*:ref: zzeklled_ 14 6 4 4 4 7 4 4 */
+/*:ref: zzekllei_ 14 6 4 4 4 4 4 4 */
+
+extern integer zzekillt_(integer *handle, integer *segdsc, integer *coldsc, integer *nrows, integer *dtype, char *cval, doublereal *dval, integer *ival, ftnlen cval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzeklltc_ 14 7 4 4 4 13 4 4 124 */
+/*:ref: zzeklltd_ 14 6 4 4 4 7 4 4 */
+/*:ref: zzekllti_ 14 6 4 4 4 4 4 4 */
+
+extern int zzekinqc_(char *value, integer *length, integer *lexbeg, integer *lexend, integer *eqryi, char *eqryc, integer *descr, ftnlen value_len, ftnlen eqryc_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+
+extern int zzekinqn_(doublereal *value, integer *type__, integer *lexbeg, integer *lexend, integer *eqryi, doublereal *eqryd, integer *descr);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+
+extern int zzekixdl_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekfrx_ 14 5 4 4 4 4 4 */
+/*:ref: zzektrdl_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int zzekixlk_(integer *handle, integer *coldsc, integer *key, integer *recptr);
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekjoin_(integer *jbase1, integer *jbase2, integer *njcnst, logical *active, integer *cpidx1, integer *clidx1, integer *elts1, integer *ops, integer *cpidx2, integer *clidx2, integer *elts2, integer *sthan, integer *stsdsc, integer *stdtpt, integer *dtpool, integer *dtdscs, integer *jbase3, integer *nrows);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: zzekstop_ 14 1 4 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzeksupd_ 14 3 4 4 4 */
+/*:ref: zzekjprp_ 14 23 4 4 4 4 4 4 4 4 4 4 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzekjnxt_ 14 2 12 4 */
+
+extern int zzekjsqz_(integer *jrsbas);
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzeksupd_ 14 3 4 4 4 */
+
+extern int zzekjsrt_(integer *njrs, integer *ubases, integer *norder, integer *otabs, integer *ocols, integer *oelts, integer *senses, integer *sthan, integer *stsdsc, integer *stdtpt, integer *dtpool, integer *dtdscs, integer *ordbas);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: zzekvset_ 14 2 4 4 */
+/*:ref: zzekvcal_ 14 3 4 4 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: zzekrsc_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: zzekrsd_ 14 8 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrsi_ 14 8 4 4 4 4 4 4 12 12 */
+/*:ref: zzekvcmp_ 12 15 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: swapi_ 14 2 4 4 */
+/*:ref: zzekstop_ 14 1 4 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzeksupd_ 14 3 4 4 4 */
+
+extern int zzekjtst_(integer *segvec, integer *jbase1, integer *nt1, integer *rb1, integer *nr1, integer *jbase2, integer *nt2, integer *rb2, integer *nr2, integer *njcnst, logical *active, integer *cpidx1, integer *clidx1, integer *elts1, integer *ops, integer *cpidx2, integer *clidx2, integer *elts2, integer *sthan, integer *stsdsc, integer *stdtpt, integer *dtpool, integer *dtdscs, logical *found, integer *rowvec);
+extern int zzekjprp_(integer *segvec, integer *jbase1, integer *nt1, integer *rb1, integer *nr1, integer *jbase2, integer *nt2, integer *rb2, integer *nr2, integer *njcnst, logical *active, integer *cpidx1, integer *clidx1, integer *elts1, integer *ops, integer *cpidx2, integer *clidx2, integer *elts2, integer *sthan, integer *stsdsc, integer *stdtpt, integer *dtpool, integer *dtdscs);
+extern int zzekjnxt_(logical *found, integer *rowvec);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: zzekstop_ 14 1 4 */
+/*:ref: zzekspsh_ 14 2 4 4 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: zzeksupd_ 14 3 4 4 4 */
+/*:ref: zzekjsrt_ 14 13 4 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzekrcmp_ 12 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzekvmch_ 12 13 4 12 4 4 4 4 4 4 4 4 4 4 4 */
+
+extern int zzekkey_(integer *handle, integer *segdsc, integer *nrows, integer *ncnstr, integer *clidxs, integer *dsclst, integer *ops, integer *dtypes, char *chrbuf, integer *cbegs, integer *cends, doublereal *dvals, integer *ivals, logical *active, integer *key, integer *keydsc, integer *begidx, integer *endidx, logical *found, ftnlen chrbuf_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: zzekillt_ 4 9 4 4 4 4 4 13 7 4 124 */
+/*:ref: zzekille_ 4 9 4 4 4 4 4 13 7 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ordi_ 4 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+
+extern int zzeklerc_(integer *handle, integer *segdsc, integer *coldsc, char *ckey, integer *recptr, logical *null, integer *prvidx, integer *prvptr, ftnlen ckey_len);
+/*:ref: failed_ 12 0 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekerc1_ 14 9 4 4 4 13 4 12 4 4 124 */
+
+extern int zzeklerd_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dkey, integer *recptr, logical *null, integer *prvidx, integer *prvptr);
+/*:ref: failed_ 12 0 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekerd1_ 14 8 4 4 4 7 4 12 4 4 */
+
+extern int zzekleri_(integer *handle, integer *segdsc, integer *coldsc, integer *ikey, integer *recptr, logical *null, integer *prvidx, integer *prvptr);
+/*:ref: failed_ 12 0 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekeri1_ 14 8 4 4 4 4 4 12 4 4 */
+
+extern int zzekllec_(integer *handle, integer *segdsc, integer *coldsc, char *ckey, integer *prvloc, integer *prvptr, ftnlen ckey_len);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzeklled_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dkey, integer *prvloc, integer *prvptr);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzekllei_(integer *handle, integer *segdsc, integer *coldsc, integer *ikey, integer *prvloc, integer *prvptr);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzeklltc_(integer *handle, integer *segdsc, integer *coldsc, char *ckey, integer *prvloc, integer *prvptr, ftnlen ckey_len);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzeklltd_(integer *handle, integer *segdsc, integer *coldsc, doublereal *dkey, integer *prvloc, integer *prvptr);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzekllti_(integer *handle, integer *segdsc, integer *coldsc, integer *ikey, integer *prvloc, integer *prvptr);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekixlk_ 14 4 4 4 4 4 */
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern int zzekmloc_(integer *handle, integer *segno, integer *page, integer *base);
+/*:ref: eknseg_ 4 1 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+
+extern int zzeknres_(char *query, integer *eqryi, char *eqryc, logical *error, char *errmsg, integer *errptr, ftnlen query_len, ftnlen eqryc_len, ftnlen errmsg_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekqtab_ 14 8 4 13 4 13 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: ekntab_ 14 1 4 */
+/*:ref: ektnam_ 14 3 4 13 124 */
+/*:ref: ekccnt_ 14 3 13 4 124 */
+/*:ref: zzekcchk_ 14 15 13 4 13 4 13 13 4 12 13 4 124 124 124 124 124 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+
+extern int zzeknrml_(char *query, integer *ntoken, integer *lxbegs, integer *lxends, integer *tokens, integer *values, doublereal *numvls, char *chrbuf, integer *chbegs, integer *chends, integer *eqryi, char *eqryc, doublereal *eqryd, logical *error, char *prserr, ftnlen query_len, ftnlen chrbuf_len, ftnlen eqryc_len, ftnlen prserr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektloc_ 14 7 4 4 4 4 4 4 12 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: zzekinqn_ 14 7 7 4 4 4 4 7 4 */
+/*:ref: zzekinqc_ 14 9 13 4 4 4 4 13 4 124 124 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: lnkhl_ 4 2 4 4 */
+/*:ref: lnkprv_ 4 2 4 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: lnkilb_ 14 3 4 4 4 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnktl_ 4 2 4 4 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: appndi_ 14 2 4 4 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+
+extern int zzekordc_(char *cvals, logical *nullok, logical *nlflgs, integer *nvals, integer *iorder, ftnlen cvals_len);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int zzekordd_(doublereal *dvals, logical *nullok, logical *nlflgs, integer *nvals, integer *iorder);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int zzekordi_(integer *ivals, logical *nullok, logical *nlflgs, integer *nvals, integer *iorder);
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int zzekpage_(integer *handle, integer *type__, integer *addrss, char *stat, integer *p, char *pagec, doublereal *paged, integer *pagei, integer *base, integer *value, ftnlen stat_len, ftnlen pagec_len);
+extern int zzekpgin_(integer *handle);
+extern int zzekpgan_(integer *handle, integer *type__, integer *p, integer *base);
+extern int zzekpgal_(integer *handle, integer *type__, integer *p, integer *base);
+extern int zzekpgfr_(integer *handle, integer *type__, integer *p);
+extern int zzekpgrc_(integer *handle, integer *p, char *pagec, ftnlen pagec_len);
+extern int zzekpgrd_(integer *handle, integer *p, doublereal *paged);
+extern int zzekpgri_(integer *handle, integer *p, integer *pagei);
+extern int zzekpgwc_(integer *handle, integer *p, char *pagec, ftnlen pagec_len);
+extern int zzekpgwd_(integer *handle, integer *p, doublereal *paged);
+extern int zzekpgwi_(integer *handle, integer *p, integer *pagei);
+extern int zzekpgbs_(integer *type__, integer *p, integer *base);
+extern int zzekpgpg_(integer *type__, integer *addrss, integer *p, integer *base);
+extern int zzekpgst_(integer *handle, char *stat, integer *value, ftnlen stat_len);
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: fillc_ 14 5 13 4 13 124 124 */
+/*:ref: filld_ 14 3 7 4 7 */
+/*:ref: filli_ 14 3 4 4 4 */
+/*:ref: dasadi_ 14 3 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: dasadc_ 14 6 4 4 4 4 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasadd_ 14 3 4 4 7 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: prtdec_ 14 3 13 4 124 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: prtenc_ 14 3 4 13 124 */
+/*:ref: dasudc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: dasudd_ 14 4 4 4 4 7 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int zzekpars_(char *query, integer *ntoken, integer *lxbegs, integer *lxends, integer *tokens, integer *values, doublereal *numvls, char *chrbuf, integer *chbegs, integer *chends, integer *eqryi, char *eqryc, doublereal *eqryd, logical *error, char *prserr, ftnlen query_len, ftnlen chrbuf_len, ftnlen eqryc_len, ftnlen prserr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekqini_ 14 6 4 4 4 13 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektloc_ 14 7 4 4 4 4 4 4 12 */
+/*:ref: zzekinqc_ 14 9 13 4 4 4 4 13 4 124 124 */
+/*:ref: appndi_ 14 2 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: zzeknrml_ 14 19 13 4 4 4 4 4 7 13 4 4 4 13 7 12 13 124 124 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+
+extern int zzekpcol_(char *qcol, integer *eqryi, char *eqryc, char *table, char *alias, integer *tabidx, char *column, integer *colidx, logical *error, char *errmsg, ftnlen qcol_len, ftnlen eqryc_len, ftnlen table_len, ftnlen alias_len, ftnlen column_len, ftnlen errmsg_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekscan_ 14 17 13 4 4 4 4 4 4 4 7 13 4 4 12 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzekqtab_ 14 8 4 13 4 13 13 124 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: ekccnt_ 14 3 13 4 124 */
+/*:ref: ekcii_ 14 6 13 4 13 4 124 124 */
+
+extern int zzekpdec_(char *decl, integer *pardsc, ftnlen decl_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: lparsm_ 14 8 13 13 4 4 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+
+extern int zzekpgch_(integer *handle, char *access, ftnlen access_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dassih_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+
+extern int zzekqcnj_(integer *eqryi, integer *n, integer *size);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzekqcon_(integer *eqryi, char *eqryc, doublereal *eqryd, integer *n, integer *cnstyp, char *ltname, integer *ltidx, char *lcname, integer *lcidx, integer *opcode, char *rtname, integer *rtidx, char *rcname, integer *rcidx, integer *dtype, integer *cbeg, integer *cend, doublereal *dval, integer *ival, ftnlen eqryc_len, ftnlen ltname_len, ftnlen lcname_len, ftnlen rtname_len, ftnlen rcname_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzekqini_(integer *isize, integer *dsize, integer *eqryi, char *eqryc, doublereal *eqryd, ftnlen eqryc_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: appndi_ 14 2 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+
+extern int zzekqord_(integer *eqryi, char *eqryc, integer *n, char *table, integer *tabidx, char *column, integer *colidx, integer *sense, ftnlen eqryc_len, ftnlen table_len, ftnlen column_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzekqsel_(integer *eqryi, char *eqryc, integer *n, integer *lxbeg, integer *lxend, char *table, integer *tabidx, char *column, integer *colidx, ftnlen eqryc_len, ftnlen table_len, ftnlen column_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzekqtab_(integer *eqryi, char *eqryc, integer *n, char *table, char *alias, ftnlen eqryc_len, ftnlen table_len, ftnlen alias_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzekrbck_(char *action, integer *handle, integer *segdsc, integer *coldsc, integer *recno, ftnlen action_len);
+
+extern logical zzekrcmp_(integer *op, integer *ncols, integer *han1, integer *sgdsc1, integer *cdlst1, integer *row1, integer *elts1, integer *han2, integer *sgdsc2, integer *cdlst2, integer *row2, integer *elts2);
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekecmp_ 4 5 4 4 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekrd01_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *ival, logical *isnull);
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzekrd02_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, doublereal *dval, logical *isnull);
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int zzekrd03_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *cvlen, char *cval, logical *isnull, ftnlen cval_len);
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int zzekrd04_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *beg, integer *end, integer *ivals, logical *isnull, logical *found);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekgfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int zzekrd05_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *beg, integer *end, doublereal *dvals, logical *isnull, logical *found);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekgfwd_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int zzekrd06_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *beg, integer *end, char *cvals, logical *isnull, logical *found, ftnlen cvals_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+
+extern int zzekrd07_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *ival, logical *isnull);
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+
+extern int zzekrd08_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, doublereal *dval, logical *isnull);
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+
+extern int zzekrd09_(integer *handle, integer *segdsc, integer *coldsc, integer *recno, integer *cvlen, char *cval, logical *isnull, ftnlen cval_len);
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+
+extern int zzekreqi_(integer *eqryi, char *name__, integer *value, ftnlen name_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical zzekrmch_(integer *ncnstr, logical *active, integer *handle, integer *segdsc, integer *cdscrs, integer *row, integer *elts, integer *ops, integer *vtypes, char *chrbuf, integer *cbegs, integer *cends, doublereal *dvals, integer *ivals, ftnlen chrbuf_len);
+/*:ref: zzekscmp_ 12 12 4 4 4 4 4 4 4 13 7 4 12 124 */
+
+extern integer zzekrp2n_(integer *handle, integer *segno, integer *recptr);
+/*:ref: zzeksdsc_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrls_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekrplk_(integer *handle, integer *segdsc, integer *n, integer *recptr);
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekrsc_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *eltidx, integer *cvlen, char *cval, logical *isnull, logical *found, ftnlen cval_len);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrd03_ 14 8 4 4 4 4 4 13 12 124 */
+/*:ref: zzekrd06_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: zzekrd09_ 14 8 4 4 4 4 4 13 12 124 */
+
+extern int zzekrsd_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *eltidx, doublereal *dval, logical *isnull, logical *found);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrd02_ 14 6 4 4 4 4 7 12 */
+/*:ref: zzekrd05_ 14 9 4 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrd08_ 14 6 4 4 4 4 7 12 */
+
+extern int zzekrsi_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *eltidx, integer *ival, logical *isnull, logical *found);
+/*:ref: zzekcnam_ 14 4 4 4 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekrd01_ 14 6 4 4 4 4 4 12 */
+/*:ref: zzekrd04_ 14 9 4 4 4 4 4 4 4 12 12 */
+/*:ref: zzekrd07_ 14 6 4 4 4 4 4 12 */
+
+extern int zzeksca_(integer *n, integer *beg, integer *end, integer *idata, integer *top);
+extern int zzekstop_(integer *top);
+extern int zzekspsh_(integer *n, integer *idata);
+extern int zzekspop_(integer *n, integer *idata);
+extern int zzeksdec_(integer *n);
+extern int zzeksupd_(integer *beg, integer *end, integer *idata);
+extern int zzeksrd_(integer *beg, integer *end, integer *idata);
+extern int zzekscln_(void);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasops_ 14 1 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: daslla_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: dasadi_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: daswbr_ 14 1 4 */
+/*:ref: dasllc_ 14 1 4 */
+
+extern int zzekscan_(char *query, integer *maxntk, integer *maxnum, integer *ntoken, integer *tokens, integer *lxbegs, integer *lxends, integer *values, doublereal *numvls, char *chrbuf, integer *chbegs, integer *chends, logical *scnerr, char *errmsg, ftnlen query_len, ftnlen chrbuf_len, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: lxcsid_ 14 5 13 13 4 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lxqstr_ 14 7 13 13 4 4 4 124 124 */
+/*:ref: parsqs_ 14 11 13 13 13 4 12 13 4 124 124 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: lx4num_ 14 5 13 4 4 4 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: beint_ 12 2 13 124 */
+/*:ref: lxidnt_ 14 6 4 13 4 4 4 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: frstpc_ 4 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int zzekscdp_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *datptr);
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern logical zzekscmp_(integer *op, integer *handle, integer *segdsc, integer *coldsc, integer *row, integer *eltidx, integer *dtype, char *cval, doublereal *dval, integer *ival, logical *null, ftnlen cval_len);
+/*:ref: zzekrsc_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzekrsd_ 14 8 4 4 4 4 4 7 12 12 */
+/*:ref: zzekrsi_ 14 8 4 4 4 4 4 4 12 12 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: matchi_ 12 8 13 13 13 13 124 124 124 124 */
+
+extern int zzeksdsc_(integer *handle, integer *segno, integer *segdsc);
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzeksei_(integer *handle, integer *addrss, integer *ival);
+/*:ref: prtenc_ 14 3 4 13 124 */
+/*:ref: dasudc_ 14 7 4 4 4 4 4 13 124 */
+
+extern int zzeksemc_(char *query, integer *eqryi, char *eqryc, logical *error, char *errmsg, integer *errptr, ftnlen query_len, ftnlen eqryc_len, ftnlen errmsg_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekqtab_ 14 8 4 13 4 13 13 124 124 124 */
+/*:ref: ekcii_ 14 6 13 4 13 4 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+
+extern int zzeksfwd_(integer *handle, integer *type__, integer *p, integer *fward);
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzeksei_ 14 3 4 4 4 */
+/*:ref: dasudd_ 14 4 4 4 4 7 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzeksinf_(integer *handle, integer *segno, char *tabnam, integer *segdsc, char *cnames, integer *cdscrs, ftnlen tabnam_len, ftnlen cnames_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: eknseg_ 4 1 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzekmloc_ 14 4 4 4 4 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdc_ 14 7 4 4 4 4 4 13 124 */
+
+extern int zzekslnk_(integer *handle, integer *type__, integer *p, integer *nlinks);
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzeksei_ 14 3 4 4 4 */
+/*:ref: dasudd_ 14 4 4 4 4 7 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzeksrcp_(integer *handle, integer *recptr, integer *recno);
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzeksrs_(integer *handle, integer *recptr, integer *status);
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern integer zzekstyp_(integer *ncols, integer *cdscrs);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer zzeksz04_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern integer zzeksz05_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasrdd_ 14 4 4 4 4 7 */
+
+extern integer zzeksz06_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekgei_ 14 3 4 4 4 */
+
+extern int zzektcnv_(char *timstr, doublereal *et, logical *error, char *errmsg, ftnlen timstr_len, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: posr_ 4 5 13 13 4 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: scn2id_ 14 4 13 4 12 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: scpars_ 14 7 4 13 12 13 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: sct2e_ 14 3 4 7 7 */
+/*:ref: tpartv_ 14 15 13 7 4 13 13 12 12 12 13 13 124 124 124 124 124 */
+/*:ref: str2et_ 14 3 13 7 124 */
+
+extern int zzektloc_(integer *tokid, integer *kwcode, integer *ntoken, integer *tokens, integer *values, integer *loc, logical *found);
+
+extern int zzektr13_(integer *handle, integer *tree);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgal_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+
+extern int zzektr1s_(integer *handle, integer *tree, integer *size, integer *values);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzektrsz_ 4 2 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: zzekpgal_ 14 4 4 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+
+extern int zzektr23_(integer *handle, integer *tree, integer *left, integer *right, integer *parent, integer *pkidx, logical *overfl);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgal_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+
+extern int zzektr31_(integer *handle, integer *tree);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzekpgfr_ 14 3 4 4 4 */
+
+extern int zzektr32_(integer *handle, integer *tree, integer *left, integer *middle, integer *right, integer *parent, integer *lpkidx, logical *undrfl);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzekpgfr_ 14 3 4 4 4 */
+
+extern int zzektrap_(integer *handle, integer *tree, integer *value, integer *key);
+/*:ref: zzektrsz_ 4 2 4 4 */
+/*:ref: zzektrin_ 14 4 4 4 4 4 */
+
+extern int zzektrbn_(integer *handle, integer *tree, integer *left, integer *right, integer *parent, integer *pkidx);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrnk_ 4 3 4 4 4 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzektrrk_ 14 7 4 4 4 4 4 4 4 */
+
+extern integer zzektrbs_(integer *node);
+/*:ref: zzekpgbs_ 14 3 4 4 4 */
+
+extern int zzektrdl_(integer *handle, integer *tree, integer *key);
+/*:ref: zzektrud_ 14 5 4 4 4 4 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrlk_ 14 8 4 4 4 4 4 4 4 4 */
+/*:ref: zzektrsb_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: zzektrnk_ 4 3 4 4 4 */
+/*:ref: zzektrpi_ 14 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzektrrk_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: zzektrbn_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzektrki_ 14 5 4 4 4 4 4 */
+/*:ref: zzektr32_ 14 8 4 4 4 4 4 4 4 12 */
+/*:ref: zzektr31_ 14 2 4 4 */
+
+extern int zzektrdp_(integer *handle, integer *tree, integer *key, integer *ptr);
+/*:ref: zzektrlk_ 14 8 4 4 4 4 4 4 4 4 */
+
+extern int zzektres_(char *query, integer *eqryi, char *eqryc, doublereal *eqryd, logical *error, char *errmsg, integer *errptr, ftnlen query_len, ftnlen eqryc_len, ftnlen errmsg_len);
+/*:ref: zzekreqi_ 14 4 4 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekqtab_ 14 8 4 13 4 13 13 124 124 124 */
+/*:ref: ekcii_ 14 6 13 4 13 4 124 124 */
+/*:ref: zzektcnv_ 14 6 13 7 12 13 124 124 */
+/*:ref: zzekinqn_ 14 7 7 4 4 4 4 7 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekweqi_ 14 4 13 4 4 124 */
+
+extern int zzektrfr_(integer *handle, integer *tree);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgfr_ 14 3 4 4 4 */
+
+extern int zzektrin_(integer *handle, integer *tree, integer *key, integer *value);
+/*:ref: zzektrui_ 14 5 4 4 4 4 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrlk_ 14 8 4 4 4 4 4 4 4 4 */
+/*:ref: zzektrpi_ 14 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: zzektrnk_ 4 3 4 4 4 */
+/*:ref: zzektrbn_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzektrki_ 14 5 4 4 4 4 4 */
+/*:ref: zzektr23_ 14 7 4 4 4 4 4 4 12 */
+/*:ref: zzektr13_ 14 2 4 4 */
+
+extern int zzektrit_(integer *handle, integer *tree);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgal_ 14 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzektrki_(integer *handle, integer *tree, integer *nodkey, integer *n, integer *key);
+/*:ref: zzektrlk_ 14 8 4 4 4 4 4 4 4 4 */
+/*:ref: zzektrnk_ 4 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzektrlk_(integer *handle, integer *tree, integer *key, integer *idx, integer *node, integer *noffst, integer *level, integer *value);
+/*:ref: dasham_ 14 3 4 13 124 */
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lstlei_ 4 3 4 4 4 */
+
+extern integer zzektrls_(integer *handle, integer *tree, integer *ival);
+/*:ref: zzektrsz_ 4 2 4 4 */
+/*:ref: zzektrdp_ 14 4 4 4 4 4 */
+
+extern integer zzektrnk_(integer *handle, integer *tree, integer *node);
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzektrpi_(integer *handle, integer *tree, integer *key, integer *parent, integer *pkey, integer *poffst, integer *lpidx, integer *lpkey, integer *lsib, integer *rpidx, integer *rpkey, integer *rsib);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lstlei_ 4 3 4 4 4 */
+
+extern int zzektrrk_(integer *handle, integer *tree, integer *left, integer *right, integer *parent, integer *pkidx, integer *nrot);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+
+extern int zzektrsb_(integer *handle, integer *tree, integer *key, integer *lsib, integer *lkey, integer *rsib, integer *rkey);
+/*:ref: zzektrpi_ 14 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern integer zzektrsz_(integer *handle, integer *tree);
+/*:ref: zzektrbs_ 4 1 4 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+
+extern int zzektrud_(integer *handle, integer *tree, integer *key, integer *trgkey, logical *undrfl);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzektrlk_ 14 8 4 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrpi_ 14 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzektrui_(integer *handle, integer *tree, integer *key, integer *value, logical *overfl);
+/*:ref: zzekpgri_ 14 3 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: zzektrlk_ 14 8 4 4 4 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzektrpi_ 14 12 4 4 4 4 4 4 4 4 4 4 4 4 */
+
+extern int zzekue01_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *ival, logical *isnull);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekixdl_ 14 4 4 4 4 4 */
+/*:ref: zzekiii1_ 14 6 4 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: zzekad01_ 14 6 4 4 4 4 4 12 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int zzekue02_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, doublereal *dval, logical *isnull);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekpgch_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dasrdi_ 14 4 4 4 4 4 */
+/*:ref: zzekixdl_ 14 4 4 4 4 4 */
+/*:ref: zzekiid1_ 14 6 4 4 4 7 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzekpgpg_ 14 4 4 4 4 4 */
+/*:ref: zzekglnk_ 14 4 4 4 4 4 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: dasudi_ 14 4 4 4 4 4 */
+/*:ref: dasudd_ 14 4 4 4 4 7 */
+/*:ref: zzekad02_ 14 6 4 4 4 4 7 12 */
+/*:ref: zzekrp2n_ 4 3 4 4 4 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+
+extern int zzekue03_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, char *cval, logical *isnull, ftnlen cval_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekde03_ 14 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekad03_ 14 7 4 4 4 4 13 12 124 */
+
+extern int zzekue04_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *nvals, integer *ivals, logical *isnull);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekde04_ 14 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekad04_ 14 7 4 4 4 4 4 4 12 */
+
+extern int zzekue05_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *nvals, doublereal *dvals, logical *isnull);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekde05_ 14 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekad05_ 14 7 4 4 4 4 4 7 12 */
+
+extern int zzekue06_(integer *handle, integer *segdsc, integer *coldsc, integer *recptr, integer *nvals, char *cvals, logical *isnull, ftnlen cvals_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekde06_ 14 4 4 4 4 4 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekad06_ 14 8 4 4 4 4 4 13 12 124 */
+
+extern int zzekvadr_(integer *njrs, integer *bases, integer *rwvidx, integer *rwvbas, integer *sgvbas);
+extern int zzekvset_(integer *njrs, integer *bases);
+extern int zzekvcal_(integer *rwvidx, integer *rwvbas, integer *sgvbas);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzekstop_ 14 1 4 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: lstlei_ 4 3 4 4 4 */
+
+extern logical zzekvcmp_(integer *op, integer *ncols, integer *tabs, integer *cols, integer *elts, integer *senses, integer *sthan, integer *stsdsc, integer *stdtpt, integer *dtpool, integer *dtdscs, integer *sgvec1, integer *rwvec1, integer *sgvec2, integer *rwvec2);
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekecmp_ 4 5 4 4 4 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern logical zzekvmch_(integer *ncnstr, logical *active, integer *lhans, integer *lsdscs, integer *lcdscs, integer *lrows, integer *lelts, integer *ops, integer *rhans, integer *rsdscs, integer *rcdscs, integer *rrows, integer *relts);
+/*:ref: movei_ 14 3 4 4 4 */
+/*:ref: zzekecmp_ 4 5 4 4 4 4 4 */
+/*:ref: zzekrsc_ 14 10 4 4 4 4 4 4 13 12 12 124 */
+/*:ref: dashlu_ 14 2 4 4 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errfnm_ 14 3 13 4 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: matchi_ 12 8 13 13 13 13 124 124 124 124 */
+
+extern int zzekweed_(integer *njrs, integer *bases, integer *nrows);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekvset_ 14 2 4 4 */
+/*:ref: zzeksrd_ 14 3 4 4 4 */
+/*:ref: sameai_ 12 3 4 4 4 */
+/*:ref: zzeksupd_ 14 3 4 4 4 */
+/*:ref: zzekjsqz_ 14 1 4 */
+
+extern int zzekweqi_(char *name__, integer *value, integer *eqryi, ftnlen name_len);
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekwpac_(integer *handle, integer *segdsc, integer *nvals, integer *l, char *cvals, integer *p, integer *base, ftnlen cvals_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzekacps_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+
+extern int zzekwpai_(integer *handle, integer *segdsc, integer *nvals, integer *ivals, integer *p, integer *base);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekacps_ 14 6 4 4 4 4 4 4 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: zzekpgwi_ 14 3 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzekwpal_(integer *handle, integer *segdsc, integer *nvals, logical *lvals, integer *p, integer *base);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzekacps_ 14 6 4 4 4 4 4 4 */
+/*:ref: zzekpgwc_ 14 4 4 4 13 124 */
+/*:ref: zzekslnk_ 14 4 4 4 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzelvupy_(doublereal *ellips, doublereal *vertex, doublereal *axis, integer *n, doublereal *bounds, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: saelgv_ 14 4 7 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cgv2el_ 14 4 7 7 7 7 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: pi_ 7 0 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: repmot_ 14 9 13 13 4 13 13 124 124 124 124 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: nvp2pl_ 14 3 7 7 7 */
+/*:ref: inrypl_ 14 5 7 7 7 4 7 */
+/*:ref: zzwind_ 4 4 7 4 7 7 */
+/*:ref: psv2pl_ 14 4 7 7 7 7 */
+/*:ref: inelpl_ 14 5 7 7 4 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int zzenut80_(doublereal *et, doublereal *nutxf);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzwahr_ 14 2 7 7 */
+/*:ref: zzmobliq_ 14 3 7 7 7 */
+/*:ref: eul2xf_ 14 5 7 4 4 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzeprc76_(doublereal *et, doublereal *precxf);
+/*:ref: jyear_ 7 0 */
+/*:ref: rpd_ 7 0 */
+/*:ref: eul2xf_ 14 5 7 4 4 4 7 */
+
+extern int zzeprcss_(doublereal *et, doublereal *precm);
+/*:ref: jyear_ 7 0 */
+/*:ref: rpd_ 7 0 */
+/*:ref: eul2m_ 14 7 7 7 7 4 4 4 7 */
+
+extern int zzfdat_(integer *ncount, char *name__, integer *idcode, integer *center, integer *type__, integer *typid, integer *norder, integer *corder, integer *centrd, ftnlen name_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnam_ 14 3 4 13 124 */
+/*:ref: orderc_ 14 4 13 4 4 124 */
+/*:ref: orderi_ 14 3 4 4 4 */
+
+extern int zzfovaxi_(char *inst, integer *n, doublereal *bounds, doublereal *axis, ftnlen inst_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: zzhullax_ 14 5 13 4 7 7 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: vhatip_ 14 1 7 */
+
+extern int zzfrmch0_(integer *frame1, integer *frame2, doublereal *et, doublereal *xform);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzfrmgt0_ 14 5 4 7 7 4 12 */
+/*:ref: zzmsxf_ 14 3 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zznofcon_ 14 7 7 4 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: invstm_ 14 2 7 7 */
+
+extern int zzfrmch1_(integer *frame1, integer *frame2, doublereal *et, doublereal *xform);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzfrmgt1_ 14 5 4 7 7 4 12 */
+/*:ref: zzmsxf_ 14 3 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zznofcon_ 14 7 7 4 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: invstm_ 14 2 7 7 */
+
+extern int zzfrmgt0_(integer *infrm, doublereal *et, doublereal *xform, integer *outfrm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: tisbod_ 14 5 13 4 7 7 124 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: ckfxfm_ 14 5 4 7 7 4 12 */
+/*:ref: tkfram_ 14 4 4 7 4 12 */
+/*:ref: zzdynfr0_ 14 5 4 4 7 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+
+extern int zzfrmgt1_(integer *infrm, doublereal *et, doublereal *xform, integer *outfrm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: tisbod_ 14 5 13 4 7 7 124 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: ckfxfm_ 14 5 4 7 7 4 12 */
+/*:ref: tkfram_ 14 4 4 7 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: failed_ 12 0 */
+
+extern int zzftpchk_(char *string, logical *ftperr, ftnlen string_len);
+/*:ref: zzftpstr_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: zzrbrkst_ 14 10 13 13 13 13 4 12 124 124 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+
+extern int zzftpstr_(char *tstcom, char *lend, char *rend, char *delim, ftnlen tstcom_len, ftnlen lend_len, ftnlen rend_len, ftnlen delim_len);
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+
+extern int zzgapool_(char *varnam, char *wtvars, integer *wtptrs, integer *wtpool, char *wtagnt, char *agtset, ftnlen varnam_len, ftnlen wtvars_len, ftnlen wtagnt_len, ftnlen agtset_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: scardc_ 14 3 4 13 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: cardc_ 4 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: validc_ 14 4 4 4 13 124 */
+/*:ref: sizec_ 4 2 13 124 */
+
+extern int zzgetbff_(integer *bffid);
+
+extern int zzgetelm_(integer *frstyr, char *lines, doublereal *epoch, doublereal *elems, logical *ok, char *error, ftnlen lines_len, ftnlen error_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: rpd_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: repmd_ 14 8 13 13 7 4 13 124 124 124 */
+/*:ref: ttrans_ 14 5 13 13 7 124 124 */
+
+extern int zzgfcoq_(char *vecdef, char *method, integer *trgid, doublereal *et, char *ref, char *abcorr, integer *obsid, char *dref, doublereal *dvec, char *crdsys, integer *ctrid, doublereal *re, doublereal *f, char *crdnam, doublereal *value, logical *found, ftnlen vecdef_len, ftnlen method_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen dref_len, ftnlen crdsys_len, ftnlen crdnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: bodc2s_ 14 3 4 13 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: subpnt_ 14 14 13 13 7 13 13 13 7 7 7 124 124 124 124 124 */
+/*:ref: sincpt_ 14 18 13 13 7 13 13 13 13 7 7 7 7 12 124 124 124 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: reclat_ 14 4 7 7 7 7 */
+/*:ref: recrad_ 14 4 7 7 7 7 */
+/*:ref: recsph_ 14 4 7 7 7 7 */
+/*:ref: reccyl_ 14 4 7 7 7 7 */
+/*:ref: recgeo_ 14 6 7 7 7 7 7 7 */
+/*:ref: recpgr_ 14 8 13 7 7 7 7 7 7 124 */
+
+extern int zzgfcost_(char *vecdef, char *method, integer *trgid, doublereal *et, char *ref, char *abcorr, integer *obsid, char *dref, integer *dctr, doublereal *dvec, doublereal *radii, doublereal *state, logical *found, ftnlen vecdef_len, ftnlen method_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen dref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzgfssob_ 14 11 13 4 7 13 13 4 7 7 124 124 124 */
+/*:ref: zzgfssin_ 14 16 13 4 7 13 13 4 13 4 7 7 7 12 124 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzgfcou_(char *vecdef, char *method, char *target, doublereal *et, char *ref, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, char *crdsys, char *crdnam, doublereal *refval, logical *decres, logical *lssthn, doublereal *crdval, logical *crdfnd, ftnlen vecdef_len, ftnlen method_len, ftnlen target_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len, ftnlen crdsys_len, ftnlen crdnam_len);
+extern int zzgfcoin_(char *vecdef, char *method, char *target, char *ref, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, char *crdsys, char *crdnam, doublereal *refval, ftnlen vecdef_len, ftnlen method_len, ftnlen target_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len, ftnlen crdsys_len, ftnlen crdnam_len);
+extern int zzgfcour_(doublereal *refval);
+extern int zzgfcog_(doublereal *et, doublereal *crdval);
+extern int zzgfcolt_(doublereal *et, logical *lssthn);
+extern int zzgfcodc_(doublereal *et, logical *decres);
+extern int zzgfcoex_(doublereal *et, logical *crdfnd);
+extern int zzgfcocg_(doublereal *et, doublereal *crdval);
+extern int zzgfcosg_(doublereal *et, doublereal *crdval);
+extern int zzgfcocl_(doublereal *et, logical *lssthn);
+extern int zzgfcosl_(doublereal *et, logical *lssthn);
+extern int zzgfcocd_(doublereal *et, logical *decres);
+extern int zzgfcosd_(doublereal *et, logical *decres);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzvalcor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: bodc2s_ 14 3 4 13 124 */
+/*:ref: recpgr_ 14 8 13 7 7 7 7 7 7 124 */
+/*:ref: pi_ 7 0 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: zzgfcoq_ 14 23 13 13 4 7 13 13 4 13 7 13 4 7 7 13 7 12 124 124 124 124 124 124 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: zzgfcost_ 14 18 13 13 4 7 13 13 4 13 4 7 7 7 12 124 124 124 124 124 */
+/*:ref: zzgfcprx_ 14 7 7 13 7 7 4 4 124 */
+/*:ref: reclat_ 14 4 7 7 7 7 */
+/*:ref: recrad_ 14 4 7 7 7 7 */
+/*:ref: recsph_ 14 4 7 7 7 7 */
+/*:ref: reccyl_ 14 4 7 7 7 7 */
+/*:ref: recgeo_ 14 6 7 7 7 7 7 7 */
+
+extern int zzgfcprx_(doublereal *state, char *corsys, doublereal *re, doublereal *f, integer *sense, integer *cdsign, ftnlen corsys_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: recgeo_ 14 6 7 7 7 7 7 7 */
+/*:ref: latrec_ 14 4 7 7 7 7 */
+/*:ref: vpack_ 14 4 7 7 7 7 */
+/*:ref: vhatip_ 14 1 7 */
+/*:ref: zzrtnmat_ 14 2 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+
+extern int zzgfcslv_(char *vecdef, char *method, char *target, char *ref, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, char *crdsys, char *crdnam, char *relate, doublereal *refval, doublereal *tol, doublereal *adjust, U_fp udstep, U_fp udrefn, logical *rpt, S_fp udrepi, U_fp udrepu, S_fp udrepf, logical *bail, L_fp udbail, integer *mw, integer *nw, doublereal *work, doublereal *cnfine, doublereal *result, ftnlen vecdef_len, ftnlen method_len, ftnlen target_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len, ftnlen crdsys_len, ftnlen crdnam_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: zzgfcoin_ 14 20 13 13 13 13 13 13 13 7 13 13 7 124 124 124 124 124 124 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: wncard_ 4 1 7 */
+/*:ref: wnfetd_ 14 4 7 4 7 7 */
+/*:ref: zzgfsolv_ 14 13 200 200 200 12 212 12 7 7 7 7 12 200 7 */
+/*:ref: wncond_ 14 3 7 7 7 */
+/*:ref: copyd_ 14 2 7 7 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: zzgflong_ 14 37 13 13 13 13 13 13 13 7 13 13 13 7 7 7 200 200 12 214 200 214 12 212 4 4 7 7 7 124 124 124 124 124 124 124 124 124 124 */
+/*:ref: zzgfrel_ 14 26 200 200 200 200 200 200 13 7 7 7 7 4 4 7 12 214 200 214 13 13 12 212 7 124 124 124 */
+
+extern int zzgfdiq_(integer *targid, doublereal *et, char *abcorr, integer *obsid, doublereal *dist, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vnorm_ 7 1 7 */
+
+extern int zzgfdiu_(char *target, char *abcorr, char *obsrvr, doublereal *refval, doublereal *et, logical *decres, logical *lssthn, doublereal *dist, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+extern int zzgfdiin_(char *target, char *abcorr, char *obsrvr, doublereal *refval, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+extern int zzgfdiur_(doublereal *refval);
+extern int zzgfdidc_(doublereal *et, logical *decres);
+extern int zzgfdigq_(doublereal *et, doublereal *dist);
+extern int zzgfdilt_(doublereal *et, logical *lssthn);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzvalcor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: zzgfdiq_ 14 6 4 7 13 4 7 124 */
+
+extern int zzgfdsps_(integer *nlead, char *string, char *fmt, integer *ntrail, ftnlen string_len, ftnlen fmt_len);
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzgffvu_(char *inst, char *tshape, doublereal *raydir, char *target, char *tframe, char *abcorr, char *obsrvr, doublereal *time, logical *vistat, ftnlen inst_len, ftnlen tshape_len, ftnlen target_len, ftnlen tframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+extern int zzgffvin_(char *inst, char *tshape, doublereal *raydir, char *target, char *tframe, char *abcorr, char *obsrvr, ftnlen inst_len, ftnlen tshape_len, ftnlen target_len, ftnlen tframe_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+extern int zzgffvst_(doublereal *time, logical *vistat);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzvalcor_ 14 3 13 12 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: getfov_ 14 9 4 4 13 13 7 4 7 124 124 */
+/*:ref: zzfovaxi_ 14 5 13 4 7 7 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: dpr_ 7 0 */
+/*:ref: nvc2pl_ 14 3 7 7 7 */
+/*:ref: vrotv_ 14 4 7 7 7 7 */
+/*:ref: inrypl_ 14 5 7 7 7 4 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: frame_ 14 3 7 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: edlimb_ 14 5 7 7 7 7 7 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: cgv2el_ 14 4 7 7 7 7 */
+/*:ref: zzelvupy_ 14 6 7 7 7 4 7 12 */
+/*:ref: zzocced_ 4 5 7 7 7 7 7 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: zzwind2d_ 4 3 4 7 7 */
+
+extern int zzgflong_(char *vecdef, char *method, char *target, char *ref, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, char *crdsys, char *crdnam, char *relate, doublereal *refval, doublereal *tol, doublereal *adjust, U_fp udstep, U_fp udrefn, logical *rpt, U_fp udrepi, U_fp udrepu, U_fp udrepf, logical *bail, L_fp udbail, integer *mw, integer *nw, doublereal *work, doublereal *cnfine, doublereal *result, ftnlen vecdef_len, ftnlen method_len, ftnlen target_len, ftnlen ref_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len, ftnlen crdsys_len, ftnlen crdnam_len, ftnlen relate_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: zzgfcoin_ 14 20 13 13 13 13 13 13 13 7 13 13 7 124 124 124 124 124 124 124 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: wncard_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: copyd_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: bodc2s_ 14 3 4 13 124 */
+/*:ref: recpgr_ 14 8 13 7 7 7 7 7 7 124 */
+/*:ref: pi_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: zzgfrel_ 14 26 200 200 200 200 214 200 13 7 7 7 7 4 4 7 12 200 200 200 13 13 12 212 7 124 124 124 */
+/*:ref: zzgfcosg_ 14 2 7 7 */
+/*:ref: zzgfcocg_ 14 2 7 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: smsgnd_ 12 2 7 7 */
+/*:ref: wninsd_ 14 3 7 7 7 */
+/*:ref: wndifd_ 14 3 7 7 7 */
+/*:ref: zzgfcog_ 14 2 7 7 */
+/*:ref: wnunid_ 14 3 7 7 7 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: wnintd_ 14 3 7 7 7 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: lnknxt_ 4 2 4 4 */
+/*:ref: elemi_ 12 2 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+
+extern int zzgfocu_(char *occtyp, char *front, char *fshape, char *fframe, char *back, char *bshape, char *bframe, char *obsrvr, char *abcorr, doublereal *time, logical *ocstat, ftnlen occtyp_len, ftnlen front_len, ftnlen fshape_len, ftnlen fframe_len, ftnlen back_len, ftnlen bshape_len, ftnlen bframe_len, ftnlen obsrvr_len, ftnlen abcorr_len);
+extern int zzgfocin_(char *occtyp, char *front, char *fshape, char *fframe, char *back, char *bshape, char *bframe, char *obsrvr, char *abcorr, ftnlen occtyp_len, ftnlen front_len, ftnlen fshape_len, ftnlen fframe_len, ftnlen back_len, ftnlen bshape_len, ftnlen bframe_len, ftnlen obsrvr_len, ftnlen abcorr_len);
+extern int zzgfocst_(doublereal *time, logical *ocstat);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: zzvalcor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: minad_ 14 4 7 4 7 4 */
+/*:ref: maxad_ 14 4 7 4 7 4 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: zzcorepc_ 14 5 13 7 7 7 124 */
+/*:ref: pxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: zzocced_ 4 5 7 7 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: dasine_ 7 2 7 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: sincpt_ 14 18 13 13 7 13 13 13 13 7 7 7 7 12 124 124 124 124 124 124 */
+
+extern int zzgfref_(doublereal *refval);
+/*:ref: zzholdd_ 14 3 13 7 124 */
+
+extern int zzgfrel_(U_fp udstep, U_fp udrefn, U_fp udqdec, U_fp udcond, S_fp udfunc, S_fp udqref, char *relate, doublereal *refval, doublereal *tol, doublereal *adjust, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, logical *rpt, S_fp udrepi, U_fp udrepu, S_fp udrepf, char *rptpre, char *rptsuf, logical *bail, L_fp udbail, doublereal *result, ftnlen relate_len, ftnlen rptpre_len, ftnlen rptsuf_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: copyd_ 14 2 7 7 */
+/*:ref: wnexpd_ 14 3 7 7 7 */
+/*:ref: wncard_ 4 1 7 */
+/*:ref: wnfetd_ 14 4 7 4 7 7 */
+/*:ref: zzgfsolv_ 14 13 200 200 200 12 212 12 7 7 7 7 12 200 7 */
+/*:ref: wnextd_ 14 3 13 7 124 */
+/*:ref: zzgfwsts_ 14 5 7 7 13 7 124 */
+/*:ref: wnintd_ 14 3 7 7 7 */
+/*:ref: wndifd_ 14 3 7 7 7 */
+/*:ref: zzwninsd_ 14 5 7 7 13 7 124 */
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int zzgfrelx_(U_fp udstep, U_fp udrefn, U_fp udqdec, U_fp udcond, S_fp udfunc, S_fp udqref, char *relate, doublereal *refval, doublereal *tol, doublereal *adjust, doublereal *cnfine, integer *mw, integer *nw, doublereal *work, logical *rpt, S_fp udrepi, U_fp udrepu, S_fp udrepf, char *rptpre, char *rptsuf, logical *bail, L_fp udbail, doublereal *result, ftnlen relate_len, ftnlen rptpre_len, ftnlen rptsuf_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: copyd_ 14 2 7 7 */
+/*:ref: wnexpd_ 14 3 7 7 7 */
+/*:ref: wncard_ 4 1 7 */
+/*:ref: wnfetd_ 14 4 7 4 7 7 */
+/*:ref: zzgfsolvx_ 14 14 214 200 200 200 12 212 12 7 7 7 7 12 200 7 */
+/*:ref: wnextd_ 14 3 13 7 124 */
+/*:ref: zzgfwsts_ 14 5 7 7 13 7 124 */
+/*:ref: wnintd_ 14 3 7 7 7 */
+/*:ref: wndifd_ 14 3 7 7 7 */
+/*:ref: zzwninsd_ 14 5 7 7 13 7 124 */
+/*:ref: swapi_ 14 2 4 4 */
+
+extern int zzgfrpwk_(integer *unit, doublereal *total, doublereal *freq, integer *tcheck, char *begin, char *end, doublereal *incr, ftnlen begin_len, ftnlen end_len);
+extern int zzgftswk_(doublereal *total, doublereal *freq, integer *tcheck, char *begin, char *end, ftnlen begin_len, ftnlen end_len);
+extern int zzgfwkin_(doublereal *incr);
+extern int zzgfwkad_(doublereal *freq, integer *tcheck, char *begin, char *end, ftnlen begin_len, ftnlen end_len);
+extern int zzgfwkun_(integer *unit);
+extern int zzgfwkmo_(integer *unit, doublereal *total, doublereal *freq, integer *tcheck, char *begin, char *end, doublereal *incr, ftnlen begin_len, ftnlen end_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: stdio_ 14 3 13 4 124 */
+/*:ref: zzcputim_ 14 1 7 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: zzgfdsps_ 14 6 4 13 13 4 124 124 */
+/*:ref: writln_ 14 3 13 4 124 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: dpfmt_ 14 5 7 13 13 124 124 */
+
+extern int zzgfrrq_(doublereal *et, integer *targ, integer *obs, char *abcorr, doublereal *value, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dvnorm_ 7 1 7 */
+
+extern int zzgfrru_(char *target, char *abcorr, char *obsrvr, doublereal *refval, doublereal *et, doublereal *dt, logical *decres, logical *lssthn, doublereal *rvl, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+extern int zzgfrrin_(char *target, char *abcorr, char *obsrvr, doublereal *refval, doublereal *dt, ftnlen target_len, ftnlen abcorr_len, ftnlen obsrvr_len);
+extern int zzgfrrur_(doublereal *refval);
+extern int zzgfrrdc_(doublereal *et, logical *decres);
+extern int zzgfrrgq_(doublereal *et, doublereal *rvl);
+extern int zzgfrrlt_(doublereal *et, logical *lssthn);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzvalcor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: dvhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: zzgfrrq_ 14 6 7 4 4 13 7 124 */
+
+extern int zzgfsolv_(S_fp udcond, S_fp udstep, S_fp udrefn, logical *bail, L_fp udbail, logical *cstep, doublereal *step, doublereal *start, doublereal *finish, doublereal *tol, logical *rpt, S_fp udrepu, doublereal *result);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: zzwninsd_ 14 5 7 7 13 7 124 */
+
+extern int zzgfsolvx_(U_fp udfunc, S_fp udcond, S_fp udstep, S_fp udrefn, logical *bail, L_fp udbail, logical *cstep, doublereal *step, doublereal *start, doublereal *finish, doublereal *tol, logical *rpt, S_fp udrepu, doublereal *result);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: touchd_ 7 1 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: brcktd_ 7 3 7 7 7 */
+/*:ref: zzwninsd_ 14 5 7 7 13 7 124 */
+
+extern int zzgfspq_(doublereal *et, integer *targ1, integer *targ2, doublereal *r1, doublereal *r2, integer *obs, char *abcorr, char *ref, doublereal *value, ftnlen abcorr_len, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: spkezp_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: dasine_ 7 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: vsep_ 7 2 7 7 */
+
+extern int zzgfspu_(char *of, char *from, char *shape, char *frame, doublereal *refval, doublereal *et, char *abcorr, logical *decres, logical *lssthn, doublereal *sep, ftnlen of_len, ftnlen from_len, ftnlen shape_len, ftnlen frame_len, ftnlen abcorr_len);
+extern int zzgfspin_(char *of, char *from, char *shape, char *frame, doublereal *refval, char *abcorr, ftnlen of_len, ftnlen from_len, ftnlen shape_len, ftnlen frame_len, ftnlen abcorr_len);
+extern int zzgfspur_(doublereal *refval);
+extern int zzgfspdc_(doublereal *et, logical *decres);
+extern int zzgfgsep_(doublereal *et, doublereal *sep);
+extern int zzgfsplt_(doublereal *et, logical *lssthn);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: return_ 12 0 */
+/*:ref: bods2c_ 14 4 13 4 12 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: zzvalcor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: zzgftreb_ 14 2 4 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: spkez_ 14 9 4 7 13 13 4 7 7 124 124 */
+/*:ref: dvsep_ 7 2 7 7 */
+/*:ref: dhfa_ 7 2 7 7 */
+/*:ref: zzgfspq_ 14 11 7 4 4 7 7 4 13 13 7 124 124 */
+
+extern int zzgfssin_(char *method, integer *trgid, doublereal *et, char *fixref, char *abcorr, integer *obsid, char *dref, integer *dctr, doublereal *dvec, doublereal *radii, doublereal *state, logical *found, ftnlen method_len, ftnlen fixref_len, ftnlen abcorr_len, ftnlen dref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bodc2s_ 14 3 4 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: sxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vminug_ 14 3 7 4 7 */
+/*:ref: surfpv_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: spkacs_ 14 10 4 7 13 13 4 7 7 7 124 124 */
+/*:ref: zzcorsxf_ 14 4 12 7 7 7 */
+/*:ref: sincpt_ 14 18 13 13 7 13 13 13 13 7 7 7 7 12 124 124 124 124 124 124 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: vaddg_ 14 4 7 7 4 7 */
+/*:ref: zzstelab_ 14 6 12 7 7 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: clight_ 7 0 */
+
+extern int zzgfssob_(char *method, integer *trgid, doublereal *et, char *fixref, char *abcorr, integer *obsid, doublereal *radii, doublereal *state, ftnlen method_len, ftnlen fixref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bodc2s_ 14 3 4 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: failed_ 12 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: spkgeo_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vminug_ 14 3 7 4 7 */
+/*:ref: dnearp_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: surfpv_ 14 7 7 7 7 7 7 7 12 */
+/*:ref: subpnt_ 14 14 13 13 7 13 13 13 7 7 7 124 124 124 124 124 */
+/*:ref: spkssb_ 14 5 4 7 13 7 124 */
+/*:ref: sxform_ 14 6 13 13 7 7 124 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: vscl_ 14 3 7 7 7 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: zzcorsxf_ 14 4 12 7 7 7 */
+/*:ref: invstm_ 14 2 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: vaddg_ 14 4 7 7 4 7 */
+/*:ref: zzstelab_ 14 6 12 7 7 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: clight_ 7 0 */
+
+extern int zzgftreb_(integer *body, doublereal *axes);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: bodvcd_ 14 6 4 13 4 4 7 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzgfudlt_(S_fp udfunc, doublereal *et, logical *isless);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: zzholdd_ 14 3 13 7 124 */
+
+extern int zzgfwsts_(doublereal *wndw1, doublereal *wndw2, char *inclsn, doublereal *wndw3, ftnlen inclsn_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: ssized_ 14 2 4 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: scardd_ 14 2 4 7 */
+
+extern int zzgpnm_(integer *namlst, integer *nmpool, char *names, integer *datlst, integer *dppool, doublereal *dpvals, integer *chpool, char *chvals, char *varnam, logical *found, integer *lookat, integer *nameat, ftnlen names_len, ftnlen chvals_len, ftnlen varnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzhash_ 4 2 13 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzholdd_(char *op, doublereal *value, ftnlen op_len);
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int zzhullax_(char *inst, integer *n, doublereal *bounds, doublereal *axis, ftnlen inst_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vcrss_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: pi_ 7 0 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vhatip_ 14 1 7 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: reclat_ 14 4 7 7 7 7 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: vrotv_ 14 4 7 7 7 7 */
+
+extern int zzidmap_(integer *bltcod, char *bltnam, ftnlen bltnam_len);
+
+extern int zzinssub_(char *in, char *sub, integer *loc, char *out, ftnlen in_len, ftnlen sub_len, ftnlen out_len);
+
+extern int zzldker_(char *file, char *nofile, char *filtyp, integer *handle, ftnlen file_len, ftnlen nofile_len, ftnlen filtyp_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: exists_ 12 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: getfat_ 14 6 13 13 13 124 124 124 */
+/*:ref: spklef_ 14 3 13 4 124 */
+/*:ref: cklpf_ 14 3 13 4 124 */
+/*:ref: pcklof_ 14 3 13 4 124 */
+/*:ref: tkvrsn_ 14 4 13 13 124 124 */
+/*:ref: eklef_ 14 3 13 4 124 */
+/*:ref: ldpool_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzbodkik_ 14 0 */
+
+extern int zzmkpc_(char *pictur, integer *b, integer *e, char *mark, char *pattrn, ftnlen pictur_len, ftnlen mark_len, ftnlen pattrn_len);
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: zzrepsub_ 14 8 13 4 4 13 13 124 124 124 */
+
+extern int zzmobliq_(doublereal *et, doublereal *mob, doublereal *dmob);
+/*:ref: jyear_ 7 0 */
+/*:ref: rpd_ 7 0 */
+
+extern int zzmsxf_(doublereal *matrix, integer *n, doublereal *output);
+
+extern int zznofcon_(doublereal *et, integer *frame1, integer *endp1, integer *frame2, integer *endp2, char *errmsg, ftnlen errmsg_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: frmnam_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: repmf_ 14 10 13 13 7 4 13 13 124 124 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: ckmeta_ 14 4 4 13 4 124 */
+/*:ref: zzsclk_ 12 2 4 4 */
+
+extern int zznrddp_(doublereal *ao, doublereal *elems, doublereal *em, doublereal *omgasm, doublereal *omgdot, doublereal *t, doublereal *xinc, doublereal *xll, doublereal *xlldot, doublereal *xn, doublereal *xnodes, doublereal *xnodot, doublereal *xnodp);
+extern int zzdpinit_(doublereal *ao, doublereal *xlldot, doublereal *omgdot, doublereal *xnodot, doublereal *xnodp, doublereal *elems);
+extern int zzdpsec_(doublereal *xll, doublereal *omgasm, doublereal *xnodes, doublereal *em, doublereal *xinc, doublereal *xn, doublereal *t, doublereal *elems, doublereal *omgdot);
+extern int zzdpper_(doublereal *t, doublereal *em, doublereal *xinc, doublereal *omgasm, doublereal *xnodes, doublereal *xll);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pi_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: j2000_ 7 0 */
+/*:ref: spd_ 7 0 */
+/*:ref: j1950_ 7 0 */
+/*:ref: zzsecprt_ 14 12 4 7 7 7 7 7 7 7 7 7 7 7 */
+
+extern int zznwpool_(char *varnam, char *wtvars, integer *wtptrs, integer *wtpool, char *wtagnt, char *agtwrk, char *notify, char *agents, ftnlen varnam_len, ftnlen wtvars_len, ftnlen wtagnt_len, ftnlen agtwrk_len, ftnlen notify_len, ftnlen agents_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzgapool_ 14 10 13 13 4 4 13 13 124 124 124 124 */
+/*:ref: unionc_ 14 6 13 13 13 124 124 124 */
+/*:ref: copyc_ 14 4 13 13 124 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern integer zzocced_(doublereal *viewpt, doublereal *centr1, doublereal *semax1, doublereal *centr2, doublereal *semax2);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: unorm_ 14 3 7 7 7 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: isrot_ 12 3 7 7 7 */
+/*:ref: det_ 7 1 7 */
+/*:ref: mtxv_ 14 3 7 7 7 */
+/*:ref: dasine_ 7 2 7 7 */
+/*:ref: failed_ 12 0 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: edlimb_ 14 5 7 7 7 7 7 */
+/*:ref: el2cgv_ 14 4 7 7 7 7 */
+/*:ref: psv2pl_ 14 4 7 7 7 7 */
+/*:ref: vprjp_ 14 3 7 7 7 */
+/*:ref: vdist_ 7 2 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: halfpi_ 7 0 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: mxm_ 14 3 7 7 7 */
+/*:ref: saelgv_ 14 4 7 7 7 7 */
+/*:ref: cgv2el_ 14 4 7 7 7 7 */
+/*:ref: zzasryel_ 14 7 13 7 7 7 7 7 124 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: pi_ 7 0 */
+
+extern integer zzphsh_(char *word, integer *m, integer *m2, ftnlen word_len);
+extern integer zzshsh_(integer *m);
+extern integer zzhash_(char *word, ftnlen word_len);
+extern integer zzhash2_(char *word, integer *m2, ftnlen word_len);
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzpini_(logical *first, integer *maxvar, integer *maxval, integer *maxlin, char *begdat, char *begtxt, integer *nmpool, integer *dppool, integer *chpool, integer *namlst, integer *datlst, integer *maxagt, integer *mxnote, char *wtvars, integer *wtptrs, integer *wtpool, char *wtagnt, char *agents, char *active, char *notify, ftnlen begdat_len, ftnlen begtxt_len, ftnlen wtvars_len, ftnlen wtagnt_len, ftnlen agents_len, ftnlen active_len, ftnlen notify_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzshsh_ 4 1 4 */
+/*:ref: touchi_ 4 1 4 */
+/*:ref: lnkini_ 14 2 4 4 */
+/*:ref: ssizec_ 14 3 4 13 124 */
+/*:ref: cleari_ 14 2 4 4 */
+/*:ref: clearc_ 14 3 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzplatfm_(char *key, char *value, ftnlen key_len, ftnlen value_len);
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: ljust_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+
+extern int zzpltchk_(logical *ok);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: zzgetbff_ 14 1 4 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzprscor_(char *abcorr, logical *attblk, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: orderc_ 14 4 13 4 4 124 */
+/*:ref: reordc_ 14 4 4 4 13 124 */
+/*:ref: reordl_ 14 3 4 4 12 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: bsrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzrbrkst_(char *string, char *lftend, char *rgtend, char *substr, integer *length, logical *bkpres, ftnlen string_len, ftnlen lftend_len, ftnlen rgtend_len, ftnlen substr_len);
+/*:ref: posr_ 4 5 13 13 4 124 124 */
+
+extern int zzrefch0_(integer *frame1, integer *frame2, doublereal *et, doublereal *rotate);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ident_ 14 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzrotgt0_ 14 5 4 7 7 4 12 */
+/*:ref: zzrxr_ 14 3 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zznofcon_ 14 7 7 4 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: xpose_ 14 2 7 7 */
+
+extern int zzrefch1_(integer *frame1, integer *frame2, doublereal *et, doublereal *rotate);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ident_ 14 1 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzrotgt1_ 14 5 4 7 7 4 12 */
+/*:ref: zzrxr_ 14 3 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: zznofcon_ 14 7 7 4 4 4 4 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: xpose_ 14 2 7 7 */
+
+extern int zzrepsub_(char *in, integer *left, integer *right, char *string, char *out, ftnlen in_len, ftnlen string_len, ftnlen out_len);
+/*:ref: sumai_ 4 2 4 4 */
+
+extern logical zzrept_(char *sub, char *replac, logical *l2r, ftnlen sub_len, ftnlen replac_len);
+/*:ref: zzsubt_ 12 5 13 13 12 124 124 */
+/*:ref: zzremt_ 12 2 13 124 */
+
+extern int zzrotgt0_(integer *infrm, doublereal *et, doublereal *rotate, integer *outfrm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: tipbod_ 14 5 13 4 7 7 124 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckfrot_ 14 5 4 7 7 4 12 */
+/*:ref: tkfram_ 14 4 4 7 4 12 */
+/*:ref: zzdynrt0_ 14 5 4 4 7 7 4 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzrotgt1_(integer *infrm, doublereal *et, doublereal *rotate, integer *outfrm, logical *found);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: tipbod_ 14 5 13 4 7 7 124 */
+/*:ref: xpose_ 14 2 7 7 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: ckfrot_ 14 5 4 7 7 4 12 */
+/*:ref: tkfram_ 14 4 4 7 4 12 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+
+extern int zzrtnmat_(doublereal *v, doublereal *m);
+/*:ref: return_ 12 0 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: vhat_ 14 2 7 7 */
+
+extern int zzrvar_(integer *namlst, integer *nmpool, char *names, integer *datlst, integer *dppool, doublereal *dpvals, integer *chpool, char *chvals, char *varnam, logical *eof, ftnlen names_len, ftnlen chvals_len, ftnlen varnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: rdkdat_ 14 3 13 12 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: rdklin_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: lastpc_ 4 2 13 124 */
+/*:ref: zzhash_ 4 2 13 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: zzcln_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: tparse_ 14 5 13 7 13 124 124 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+
+extern int zzrvbf_(char *buffer, integer *bsize, integer *linnum, integer *namlst, integer *nmpool, char *names, integer *datlst, integer *dppool, doublereal *dpvals, integer *chpool, char *chvals, char *varnam, logical *eof, ftnlen buffer_len, ftnlen names_len, ftnlen chvals_len, ftnlen varnam_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: lastpc_ 4 2 13 124 */
+/*:ref: zzhash_ 4 2 13 124 */
+/*:ref: lnknfn_ 4 1 4 */
+/*:ref: lnkan_ 14 2 4 4 */
+/*:ref: lnkila_ 14 3 4 4 4 */
+/*:ref: lnkfsl_ 14 3 4 4 4 */
+/*:ref: zzcln_ 14 7 4 4 4 4 4 4 4 */
+/*:ref: tparse_ 14 5 13 7 13 124 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+
+extern int zzrxr_(doublereal *matrix, integer *n, doublereal *output);
+/*:ref: ident_ 14 1 7 */
+
+extern logical zzsclk_(integer *ckid, integer *sclkid);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: ssizei_ 14 2 4 4 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: elemi_ 12 2 4 4 */
+/*:ref: cvpool_ 14 3 13 12 124 */
+/*:ref: cardi_ 4 1 4 */
+/*:ref: sizei_ 4 1 4 */
+/*:ref: insrti_ 14 2 4 4 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: swpool_ 14 5 13 4 13 124 124 */
+/*:ref: dtpool_ 14 6 13 12 4 13 124 124 */
+/*:ref: removi_ 14 2 4 4 */
+
+extern int zzsecprt_(integer *isynfl, doublereal *dg, doublereal *del, doublereal *xni, doublereal *omegao, doublereal *atime, doublereal *omgdot, doublereal *xli, doublereal *xfact, doublereal *xldot, doublereal *xndot, doublereal *xnddt);
+
+extern int zzsizeok_(integer *size, integer *psize, integer *dsize, integer *offset, logical *ok, integer *n);
+/*:ref: rmaini_ 14 4 4 4 4 4 */
+
+extern int zzspkac0_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzspkgo0_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: zzspkas0_ 14 11 4 7 13 13 7 7 7 7 7 124 124 */
+
+extern int zzspkac1_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: zzspkgo1_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: zzspkas1_ 14 11 4 7 13 13 7 7 7 7 7 124 124 */
+
+extern int zzspkap0_(integer *targ, doublereal *et, char *ref, doublereal *sobs, char *abcorr, doublereal *starg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspksb0_ 14 5 4 7 13 7 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+
+extern int zzspkap1_(integer *targ, doublereal *et, char *ref, doublereal *sobs, char *abcorr, doublereal *starg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspksb1_ 14 5 4 7 13 7 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+
+extern int zzspkas0_(integer *targ, doublereal *et, char *ref, char *abcorr, doublereal *stobs, doublereal *accobs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspklt0_ 14 10 4 7 13 13 7 7 7 7 124 124 */
+/*:ref: zzstelab_ 14 6 12 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int zzspkas1_(integer *targ, doublereal *et, char *ref, char *abcorr, doublereal *stobs, doublereal *accobs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspklt1_ 14 10 4 7 13 13 7 7 7 7 124 124 */
+/*:ref: zzstelab_ 14 6 12 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+
+extern int zzspkez0_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *starg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: zzspkgo0_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzspkac0_ 14 10 4 7 13 13 4 7 7 7 124 124 */
+/*:ref: zzspksb0_ 14 5 4 7 13 7 124 */
+/*:ref: zzspklt0_ 14 10 4 7 13 13 7 7 7 7 124 124 */
+/*:ref: zzfrmch0_ 14 4 4 4 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+
+extern int zzspkez1_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *starg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzspkgo1_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: zzspkac1_ 14 10 4 7 13 13 4 7 7 7 124 124 */
+/*:ref: zzspksb1_ 14 5 4 7 13 7 124 */
+/*:ref: zzspklt1_ 14 10 4 7 13 13 7 7 7 7 124 124 */
+/*:ref: zzfrmch1_ 14 4 4 4 7 7 */
+/*:ref: vsclip_ 14 2 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+
+extern int zzspkgo0_(integer *targ, doublereal *et, char *ref, integer *obs, doublereal *state, doublereal *lt, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: zzfrmch0_ 14 4 4 4 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: vaddg_ 14 4 7 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+
+extern int zzspkgo1_(integer *targ, doublereal *et, char *ref, integer *obs, doublereal *state, doublereal *lt, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: zzfrmch1_ 14 4 4 4 7 7 */
+/*:ref: mxvg_ 14 5 7 7 4 4 7 */
+/*:ref: vaddg_ 14 4 7 7 4 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+
+extern int zzspkgp0_(integer *targ, doublereal *et, char *ref, integer *obs, doublereal *pos, doublereal *lt, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: zzrefch0_ 14 4 4 4 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+
+extern int zzspkgp1_(integer *targ, doublereal *et, char *ref, integer *obs, doublereal *pos, doublereal *lt, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: frstnp_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: spksfs_ 14 7 4 7 4 7 13 12 124 */
+/*:ref: spkpvn_ 14 6 4 7 7 4 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: irfrot_ 14 3 4 4 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+/*:ref: zzrefch1_ 14 4 4 4 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: isrchi_ 4 3 4 4 4 */
+/*:ref: bodc2n_ 14 4 4 13 12 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: intstr_ 14 3 4 13 124 */
+/*:ref: etcal_ 14 3 7 13 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+
+extern int zzspklt0_(integer *targ, doublereal *et, char *ref, char *abcorr, doublereal *stobs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspkgo0_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int zzspklt1_(integer *targ, doublereal *et, char *ref, char *abcorr, doublereal *stobs, doublereal *starg, doublereal *lt, doublereal *dlt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspkgo1_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+
+extern int zzspkpa0_(integer *targ, doublereal *et, char *ref, doublereal *sobs, char *abcorr, doublereal *ptarg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspkgp0_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+
+extern int zzspkpa1_(integer *targ, doublereal *et, char *ref, doublereal *sobs, char *abcorr, doublereal *ptarg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: cmprss_ 14 7 13 4 13 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: odd_ 12 1 4 */
+/*:ref: irfnum_ 14 3 13 4 124 */
+/*:ref: zzspkgp1_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: stlabx_ 14 3 7 7 7 */
+/*:ref: stelab_ 14 3 7 7 7 */
+
+extern int zzspksb0_(integer *targ, doublereal *et, char *ref, doublereal *starg, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzspkgo0_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzspksb1_(integer *targ, doublereal *et, char *ref, doublereal *starg, ftnlen ref_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzspkgo1_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: chkout_ 14 2 13 124 */
+
+extern int zzspkzp0_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *ptarg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: eqchr_ 12 4 13 13 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: zzspkgp0_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: zzspksb0_ 14 5 4 7 13 7 124 */
+/*:ref: zzspkpa0_ 14 9 4 7 13 7 13 7 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzrefch0_ 14 4 4 4 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+
+extern int zzspkzp1_(integer *targ, doublereal *et, char *ref, char *abcorr, integer *obs, doublereal *ptarg, doublereal *lt, ftnlen ref_len, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: namfrm_ 14 3 13 4 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: frinfo_ 14 5 4 4 4 4 12 */
+/*:ref: ltrim_ 4 2 13 124 */
+/*:ref: eqchr_ 12 4 13 13 124 124 */
+/*:ref: eqstr_ 12 4 13 13 124 124 */
+/*:ref: zzspkgp1_ 14 7 4 7 13 4 7 7 124 */
+/*:ref: zzspksb1_ 14 5 4 7 13 7 124 */
+/*:ref: zzspkpa1_ 14 9 4 7 13 7 13 7 7 124 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: zzrefch1_ 14 4 4 4 7 7 */
+/*:ref: mxv_ 14 3 7 7 7 */
+
+extern int zzstelab_(logical *xmit, doublereal *accobs, doublereal *vobs, doublereal *starg, doublereal *scorr, doublereal *dscorr);
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: dvhat_ 14 2 7 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vnorm_ 7 1 7 */
+/*:ref: clight_ 7 0 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: vhat_ 14 2 7 7 */
+/*:ref: vlcom_ 14 5 7 7 7 7 7 */
+/*:ref: vlcom3_ 14 7 7 7 7 7 7 7 7 */
+/*:ref: vadd_ 14 3 7 7 7 */
+/*:ref: qderiv_ 14 5 4 7 7 7 7 */
+
+extern logical zztime_(char *string, char *transl, char *letter, char *error, char *pic, doublereal *tvec, integer *b, integer *e, logical *l2r, logical *yabbrv, ftnlen string_len, ftnlen transl_len, ftnlen letter_len, ftnlen error_len, ftnlen pic_len);
+extern logical zzcmbt_(char *string, char *letter, logical *l2r, ftnlen string_len, ftnlen letter_len);
+extern logical zzgrep_(char *string, ftnlen string_len);
+extern logical zzispt_(char *string, integer *b, integer *e, ftnlen string_len);
+extern logical zzist_(char *letter, ftnlen letter_len);
+extern logical zznote_(char *letter, integer *b, integer *e, ftnlen letter_len);
+extern logical zzremt_(char *letter, ftnlen letter_len);
+extern logical zzsubt_(char *string, char *transl, logical *l2r, ftnlen string_len, ftnlen transl_len);
+extern logical zztokns_(char *string, char *error, ftnlen string_len, ftnlen error_len);
+extern logical zzunpck_(char *string, logical *yabbrv, doublereal *tvec, integer *e, char *transl, char *pic, char *error, ftnlen string_len, ftnlen transl_len, ftnlen pic_len, ftnlen error_len);
+extern logical zzvalt_(char *string, integer *b, integer *e, char *letter, ftnlen string_len, ftnlen letter_len);
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pos_ 4 5 13 13 4 124 124 */
+/*:ref: posr_ 4 5 13 13 4 124 124 */
+/*:ref: zzrepsub_ 14 8 13 4 4 13 13 124 124 124 */
+/*:ref: cpos_ 4 5 13 13 4 124 124 */
+/*:ref: rtrim_ 4 2 13 124 */
+/*:ref: lx4uns_ 14 5 13 4 4 4 124 */
+/*:ref: zzinssub_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: prefix_ 14 5 13 4 13 124 124 */
+/*:ref: repmi_ 14 7 13 13 4 13 124 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: samsbi_ 12 8 13 4 4 13 4 4 124 124 */
+/*:ref: samchi_ 12 6 13 4 13 4 124 124 */
+/*:ref: suffix_ 14 5 13 4 13 124 124 */
+/*:ref: repmc_ 14 8 13 13 13 13 124 124 124 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: zzmkpc_ 14 8 13 4 4 13 13 124 124 124 */
+/*:ref: nparsi_ 14 6 13 4 13 4 124 124 */
+
+extern logical zztpats_(integer *room, integer *nknown, char *known, char *meanng, ftnlen known_len, ftnlen meanng_len);
+/*:ref: orderc_ 14 4 13 4 4 124 */
+/*:ref: reordc_ 14 4 4 4 13 124 */
+
+extern int zztwovxf_(doublereal *axdef, integer *indexa, doublereal *plndef, integer *indexp, doublereal *xform);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: dvhat_ 14 2 7 7 */
+/*:ref: ducrss_ 14 3 7 7 7 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: cleard_ 14 2 4 7 */
+/*:ref: vzero_ 12 1 7 */
+
+extern int zzutcpm_(char *string, integer *start, doublereal *hoff, doublereal *moff, integer *last, logical *succes, ftnlen string_len);
+/*:ref: lx4uns_ 14 5 13 4 4 4 124 */
+/*:ref: nparsd_ 14 6 13 7 13 4 124 124 */
+/*:ref: samch_ 12 6 13 4 13 4 124 124 */
+
+extern int zzvalcor_(char *abcorr, logical *attblk, ftnlen abcorr_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzprscor_ 14 3 13 12 124 */
+/*:ref: failed_ 12 0 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+
+extern int zzvstrng_(doublereal *x, char *fill, integer *from, integer *to, logical *rnd, integer *expont, char *substr, logical *did, ftnlen fill_len, ftnlen substr_len);
+extern int zzvststr_(doublereal *x, char *fill, integer *expont, ftnlen fill_len);
+extern int zzvsbstr_(integer *from, integer *to, logical *rnd, char *substr, logical *did, ftnlen substr_len);
+/*:ref: dpstr_ 14 4 7 4 13 124 */
+
+extern int zzwahr_(doublereal *et, doublereal *dvnut);
+/*:ref: pi_ 7 0 */
+/*:ref: twopi_ 7 0 */
+/*:ref: spd_ 7 0 */
+
+extern integer zzwind_(doublereal *plane, integer *n, doublereal *vertcs, doublereal *point);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: pl2nvc_ 14 3 7 7 7 */
+/*:ref: vzero_ 12 1 7 */
+/*:ref: vdot_ 7 2 7 7 */
+/*:ref: vminus_ 14 2 7 7 */
+/*:ref: vequ_ 14 2 7 7 */
+/*:ref: vsub_ 14 3 7 7 7 */
+/*:ref: vperp_ 14 3 7 7 7 */
+/*:ref: vsep_ 7 2 7 7 */
+/*:ref: ucrss_ 14 3 7 7 7 */
+/*:ref: twopi_ 7 0 */
+
+extern integer zzwind2d_(integer *n, doublereal *vertcs, doublereal *point);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: vsubg_ 14 4 7 7 4 7 */
+/*:ref: vsepg_ 7 3 7 7 4 */
+/*:ref: vdotg_ 7 3 7 7 4 */
+/*:ref: moved_ 14 3 7 4 7 */
+/*:ref: twopi_ 7 0 */
+
+extern int zzwninsd_(doublereal *left, doublereal *right, char *context, doublereal *window, ftnlen context_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: sized_ 4 1 7 */
+/*:ref: cardd_ 4 1 7 */
+/*:ref: lastnb_ 4 2 13 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errdp_ 14 3 13 7 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: scardd_ 14 2 4 7 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+extern int zzxlated_(integer *inbff, char *input, integer *space, doublereal *output, ftnlen input_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: intmin_ 4 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+/*:ref: moved_ 14 3 7 4 7 */
+
+extern int zzxlatei_(integer *inbff, char *input, integer *space, integer *output, ftnlen input_len);
+/*:ref: return_ 12 0 */
+/*:ref: chkin_ 14 2 13 124 */
+/*:ref: zzddhgsd_ 14 5 13 4 13 124 124 */
+/*:ref: zzplatfm_ 14 4 13 13 124 124 */
+/*:ref: ucase_ 14 4 13 13 124 124 */
+/*:ref: isrchc_ 4 5 13 4 13 124 124 */
+/*:ref: setmsg_ 14 2 13 124 */
+/*:ref: errch_ 14 4 13 13 124 124 */
+/*:ref: sigerr_ 14 2 13 124 */
+/*:ref: chkout_ 14 2 13 124 */
+/*:ref: intmin_ 4 0 */
+/*:ref: errint_ 14 3 13 4 124 */
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
+
diff --git a/ext/spice/src/cspice/SpiceZim.h b/ext/spice/src/cspice/SpiceZim.h
new file mode 100644
index 0000000000..ee8d96ebc6
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceZim.h
@@ -0,0 +1,1358 @@
+/*
+
+-Header_File SpiceZim.h ( CSPICE interface macros )
+
+-Abstract
+
+ Define interface macros to be called in place of CSPICE
+ user-interface-level functions. These macros are generally used
+ to compensate for compiler deficiencies.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Particulars
+
+ This header file defines interface macros to be called in place of
+ CSPICE user-interface-level functions. Currently, the sole purpose
+ of these macros is to implement automatic type casting under some
+ environments that generate compile-time warnings without the casts.
+ The typical case that causes a problem is a function argument list
+ containing an input formal argument of type
+
+ const double [3][3]
+
+ Under some compilers, a non-const actual argument supplied in a call
+ to such a function will generate a spurious warning due to the
+ "mismatched" type. These macros generate type casts that will
+ make such compilers happy.
+
+ Examples of compilers that generate warnings of this type are
+
+ gcc version 2.2.2, hosted on NeXT workstations running
+ NeXTStep 3.3
+
+ Sun C compiler, version 4.2, running under Solaris.
+
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 11.0.0, 09-MAR-2009 (NJB) (EDW)
+
+ Added macros for
+
+ dvsep_c
+ gfevnt_c
+ gffove_c
+ gfrfov_c
+ gfsntc_c
+ surfpv_c
+
+
+ -CSPICE Version 10.0.0, 19-FEB-2008 (NJB) (EDW)
+
+ Added macros for
+
+ ilumin_c
+ spkaps_c
+ spkltc_c
+
+ -CSPICE Version 9.0.0, 31-OCT-2005 (NJB)
+
+ Added macros for
+
+ qdq2av_c
+ qxq_c
+
+ -CSPICE Version 8.0.0, 23-FEB-2004 (NJB)
+
+ Added macro for
+
+ dafrs_c
+
+
+ -CSPICE Version 7.0.0, 23-FEB-2004 (EDW)
+
+ Added macro for
+
+ srfxpt_c
+
+ -CSPICE Version 6.0.1, 25-FEB-2003 (EDW) (NJB)
+
+ Remove duplicate macro definitions for ekaced_c and
+ ekacei_c. Visual Studio errored out when compiling
+ code that included SpiceZim.h.
+
+ Added macro for
+
+ dasac_c
+
+ -CSPICE Version 6.0.0, 17-AUG-2002 (NJB)
+
+ Added macros for
+
+ bschoc_c
+ bschoi_c
+ bsrchc_c
+ bsrchd_c
+ bsrchi_c
+ esrchc_c
+ isordv_c
+ isrchc_c
+ isrchd_c
+ isrchi_c
+ lstltc_c
+ lstltd_c
+ lstlti_c
+ lstlec_c
+ lstled_c
+ lstlei_c
+ orderc_c
+ orderd_c
+ orderi_c
+ reordc_c
+ reordd_c
+ reordi_c
+ reordl_c
+ spkw18_c
+
+ -CSPICE Version 5.0.0, 28-AUG-2001 (NJB)
+
+ Added macros for
+
+ conics_c
+ illum_c
+ invort_c
+ pdpool_c
+ prop2b_c
+ q2m_c
+ spkuds_c
+ xposeg_c
+
+ -CSPICE Version 4.0.0, 22-MAR-2000 (NJB)
+
+ Added macros for
+
+ spkw12_c
+ spkw13_c
+
+ -CSPICE Version 3.0.0, 27-AUG-1999 (NJB) (EDW)
+
+ Fixed cut & paste error in macro nvp2pl_c.
+
+ Added macros for
+
+ axisar_c
+ cgv2el_c
+ dafps_c
+ dafus_c
+ diags2_c
+ dvdot_c
+ dvhat_c
+ edlimb_c
+ ekacli_c
+ ekacld_c
+ ekacli_c
+ eul2xf_c
+ el2cgv_c
+ getelm_c
+ inedpl_c
+ isrot_c
+ mequ_c
+ npedln_c
+ nplnpt_c
+ rav2xf_c
+ raxisa_c
+ saelgv_c
+ spk14a_c
+ spkapo_c
+ spkapp_c
+ spkw02_c
+ spkw03_c
+ spkw05_c
+ spkw08_c
+ spkw09_c
+ spkw10_c
+ spkw15_c
+ spkw17_c
+ sumai_c
+ trace_c
+ vadd_g
+ vhatg_c
+ vlcomg_c
+ vminug_c
+ vrel_c
+ vrelg_c
+ vsepg_c
+ vtmv_c
+ vtmvg_c
+ vupack_c
+ vzerog_c
+ xf2eul_c
+ xf2rav_c
+
+ -CSPICE Version 2.0.0, 07-MAR-1999 (NJB)
+
+ Added macros for
+
+ inrypl_c
+ nvc2pl_c
+ nvp2pl_c
+ pl2nvc_c
+ pl2nvp_c
+ pl2psv_c
+ psv2pl_c
+ vprjp_c
+ vprjpi_c
+
+ -CSPICE Version 1.0.0, 24-JAN-1999 (NJB) (EDW)
+
+
+-Index_Entries
+
+ interface macros for CSPICE functions
+
+*/
+
+
+/*
+Include Files:
+*/
+
+
+#ifndef HAVE_SPICEDEFS_H
+#include "SpiceZdf.h"
+#endif
+
+#ifndef HAVE_SPICEIFMACROS_H
+#define HAVE_SPICEIFMACROS_H
+
+
+/*
+Macros used to abbreviate type casts:
+*/
+
+ #define CONST_BOOL ( ConstSpiceBoolean * )
+ #define CONST_ELLIPSE ( ConstSpiceEllipse * )
+ #define CONST_IVEC ( ConstSpiceInt * )
+ #define CONST_MAT ( ConstSpiceDouble (*) [3] )
+ #define CONST_MAT2 ( ConstSpiceDouble (*) [2] )
+ #define CONST_MAT6 ( ConstSpiceDouble (*) [6] )
+ #define CONST_PLANE ( ConstSpicePlane * )
+ #define CONST_VEC3 ( ConstSpiceDouble (*) [3] )
+ #define CONST_VEC4 ( ConstSpiceDouble (*) [4] )
+ #define CONST_STR ( ConstSpiceChar * )
+ #define CONST_VEC ( ConstSpiceDouble * )
+ #define CONST_VOID ( const void * )
+
+/*
+Macros that substitute for function calls:
+*/
+
+ #define axisar_c( axis, angle, r ) \
+ \
+ ( axisar_c( CONST_VEC(axis), (angle), (r) ) )
+
+
+ #define bschoc_c( value, ndim, lenvals, array, order ) \
+ \
+ ( bschoc_c ( CONST_STR(value), (ndim), (lenvals), \
+ CONST_VOID(array), CONST_IVEC(order) ) )
+
+
+ #define bschoi_c( value, ndim, array, order ) \
+ \
+ ( bschoi_c ( (value) , (ndim), \
+ CONST_IVEC(array), CONST_IVEC(order) ) )
+
+
+ #define bsrchc_c( value, ndim, lenvals, array ) \
+ \
+ ( bsrchc_c ( CONST_STR(value), (ndim), (lenvals), \
+ CONST_VOID(array) ) )
+
+
+ #define bsrchd_c( value, ndim, array ) \
+ \
+ ( bsrchd_c( (value), (ndim), CONST_VEC(array) ) )
+
+
+ #define bsrchi_c( value, ndim, array ) \
+ \
+ ( bsrchi_c( (value), (ndim), CONST_IVEC(array) ) )
+
+
+ #define ckw01_c( handle, begtim, endtim, inst, ref, avflag, \
+ segid, nrec, sclkdp, quats, avvs ) \
+ \
+ ( ckw01_c ( (handle), (begtim), (endtim), \
+ (inst), CONST_STR(ref), (avflag), \
+ CONST_STR(segid), (nrec), \
+ CONST_VEC(sclkdp), CONST_VEC4(quats), \
+ CONST_VEC3(avvs) ) )
+
+
+ #define ckw02_c( handle, begtim, endtim, inst, ref, segid, \
+ nrec, start, stop, quats, avvs, rates ) \
+ \
+ ( ckw02_c ( (handle), (begtim), (endtim), \
+ (inst), CONST_STR(ref), \
+ CONST_STR(segid), (nrec), \
+ CONST_VEC(start), CONST_VEC(stop), \
+ CONST_VEC4(quats), CONST_VEC3(avvs), \
+ CONST_VEC(rates) ) )
+
+
+ #define ckw03_c( handle, begtim, endtim, inst, ref, avflag, \
+ segid, nrec, sclkdp, quats, avvs, nints, \
+ starts ) \
+ \
+ ( ckw03_c ( (handle), (begtim), (endtim), \
+ (inst), CONST_STR(ref), (avflag), \
+ CONST_STR(segid), (nrec), \
+ CONST_VEC(sclkdp), CONST_VEC4(quats), \
+ CONST_VEC3(avvs), (nints), \
+ CONST_VEC(starts) ) )
+
+
+ #define ckw05_c( handle, subtyp, degree, begtim, endtim, inst, \
+ ref, avflag, segid, n, sclkdp, packts, \
+ rate, nints, starts ) \
+ \
+ ( ckw05_c ( (handle), (subtyp), (degree), \
+ (begtim), (endtim), \
+ (inst), CONST_STR(ref), (avflag), \
+ CONST_STR(segid), (n), \
+ CONST_VEC(sclkdp), CONST_VOID(packts), \
+ (rate), (nints), \
+ CONST_VEC(starts) ) )
+
+
+ #define cgv2el_c( center, vec1, vec2, ellipse ) \
+ \
+ ( cgv2el_c( CONST_VEC(center), CONST_VEC(vec1), \
+ CONST_VEC(vec2), (ellipse) ) )
+
+
+ #define conics_c( elts, et, state ) \
+ \
+ ( conics_c( CONST_VEC(elts), (et), (state) ) )
+
+
+ #define dafps_c( nd, ni, dc, ic, sum ) \
+ \
+ ( dafps_c ( (nd), (ni), CONST_VEC(dc), CONST_IVEC(ic), \
+ (sum) ) )
+
+
+ #define dafrs_c( sum ) \
+ \
+ ( dafrs_c ( CONST_VEC( sum ) ) )
+
+
+ #define dafus_c( sum, nd, ni, dc, ic ) \
+ \
+ ( dafus_c ( CONST_VEC(sum), (nd), (ni), (dc), (ic) ) )
+
+
+ #define dasac_c( handle, n, buflen, buffer ) \
+ \
+ ( dasac_c ( (handle), (n), (buflen), CONST_VOID(buffer) ) )
+
+
+ #define det_c( m1 ) \
+ \
+ ( det_c ( CONST_MAT(m1) ) )
+
+
+ #define diags2_c( symmat, diag, rotate ) \
+ \
+ ( diags2_c ( CONST_MAT2(symmat), (diag), (rotate) ) )
+
+
+
+ #define dvdot_c( s1, s2 ) \
+ \
+ ( dvdot_c ( CONST_VEC(s1), CONST_VEC(s2) ) )
+
+
+ #define dvhat_c( v1, v2 ) \
+ \
+ ( dvhat_c ( CONST_VEC(v1), (v2) ) )
+
+
+ #define dvsep_c( s1, s2 ) \
+ \
+ ( dvsep_c ( CONST_VEC(s1), CONST_VEC(s2) ) )
+
+
+ #define edlimb_c( a, b, c, viewpt, limb ) \
+ \
+ ( edlimb_c( (a), (b), (c), CONST_VEC(viewpt), (limb) ) )
+
+
+ #define ekacec_c( handle, segno, recno, column, nvals, vallen, \
+ cvals, isnull ) \
+ \
+ ( ekacec_c( (handle), (segno), (recno), CONST_STR(column), \
+ (nvals), (vallen), CONST_VOID(cvals), \
+ (isnull) ) )
+
+
+ #define ekaced_c( handle, segno, recno, column, nvals, \
+ dvals, isnull ) \
+ \
+ ( ekaced_c( (handle), (segno), (recno), CONST_STR(column), \
+ (nvals), CONST_VEC(dvals), (isnull) ) )
+
+
+ #define ekacei_c( handle, segno, recno, column, nvals, \
+ ivals, isnull ) \
+ \
+ ( ekacei_c( (handle), (segno), (recno), CONST_STR(column), \
+ (nvals), CONST_IVEC(ivals), (isnull) ) )
+
+
+ #define ekaclc_c( handle, segno, column, vallen, cvals, entszs, \
+ nlflgs, rcptrs, wkindx ) \
+ \
+ ( ekaclc_c( (handle), (segno), (column), (vallen), \
+ CONST_VOID(cvals), CONST_IVEC(entszs), \
+ CONST_BOOL(nlflgs), CONST_IVEC(rcptrs), \
+ (wkindx) ) )
+
+
+ #define ekacld_c( handle, segno, column, dvals, entszs, nlflgs, \
+ rcptrs, wkindx ) \
+ \
+ ( ekacld_c( (handle), (segno), (column), \
+ CONST_VEC(dvals), CONST_IVEC(entszs), \
+ CONST_BOOL(nlflgs), CONST_IVEC(rcptrs), \
+ (wkindx) ) )
+
+
+ #define ekacli_c( handle, segno, column, ivals, entszs, nlflgs, \
+ rcptrs, wkindx ) \
+ \
+ ( ekacli_c( (handle), (segno), (column), \
+ CONST_IVEC(ivals), CONST_IVEC(entszs), \
+ CONST_BOOL(nlflgs), CONST_IVEC(rcptrs), \
+ (wkindx) ) )
+
+
+ #define ekbseg_c( handle, tabnam, ncols, cnmlen, cnames, declen, \
+ decls, segno ) \
+ \
+ ( ekbseg_c( (handle), (tabnam), (ncols), (cnmlen), \
+ CONST_VOID(cnames), (declen), \
+ CONST_VOID(decls), (segno) ) )
+
+
+ #define ekifld_c( handle, tabnam, ncols, nrows, cnmlen, cnames, \
+ declen, decls, segno, rcptrs ) \
+ \
+ ( ekifld_c( (handle), (tabnam), (ncols), (nrows), (cnmlen), \
+ CONST_VOID(cnames), (declen), \
+ CONST_VOID(decls), (segno), (rcptrs) ) )
+
+
+ #define ekucec_c( handle, segno, recno, column, nvals, vallen, \
+ cvals, isnull ) \
+ \
+ ( ekucec_c( (handle), (segno), (recno), CONST_STR(column), \
+ (nvals), (vallen), CONST_VOID(cvals), \
+ (isnull) ) )
+
+ #define ekuced_c( handle, segno, recno, column, nvals, \
+ dvals, isnull ) \
+ \
+ ( ekuced_c( (handle), (segno), (recno), CONST_STR(column), \
+ (nvals), CONST_VOID(dvals), (isnull) ) )
+
+
+ #define ekucei_c( handle, segno, recno, column, nvals, \
+ ivals, isnull ) \
+ \
+ ( ekucei_c( (handle), (segno), (recno), CONST_STR(column), \
+ (nvals), CONST_VOID(ivals), (isnull) ) )
+
+
+ #define el2cgv_c( ellipse, center, smajor, sminor ) \
+ \
+ ( el2cgv_c( CONST_ELLIPSE(ellipse), (center), \
+ (smajor), (sminor) ) )
+
+
+ #define esrchc_c( value, ndim, lenvals, array ) \
+ \
+ ( esrchc_c ( CONST_STR(value), (ndim), (lenvals), \
+ CONST_VOID(array) ) )
+
+
+ #define eul2xf_c( eulang, axisa, axisb, axisc, xform ) \
+ \
+ ( eul2xf_c ( CONST_VEC(eulang), (axisa), (axisb), (axisc), \
+ (xform) ) )
+
+
+ #define getelm_c( frstyr, lineln, lines, epoch, elems ) \
+ \
+ ( getelm_c ( (frstyr), (lineln), CONST_VOID(lines), \
+ (epoch), (elems) ) )
+
+
+ #define gfevnt_c( udstep, udrefn, gquant, qnpars, lenvals, \
+ qpnams, qcpars, qdpars, qipars, qlpars, \
+ op, refval, tol, adjust, rpt, \
+ udrepi, udrepu, udrepf, nintvls, \
+ bail, udbail, cnfine, result ) \
+ \
+ ( gfevnt_c( (udstep), (udrefn), (gquant), \
+ (qnpars), (lenvals), CONST_VOID(qpnams),\
+ CONST_VOID(qcpars), (qdpars), (qipars), \
+ (qlpars), (op), (refval), \
+ (tol), (adjust), (rpt), \
+ (udrepi), (udrepu), (udrepf), \
+ (nintvls), (bail), \
+ (udbail), (cnfine), (result) ) )
+
+
+ #define gffove_c( inst, tshape, raydir, target, tframe, \
+ abcorr, obsrvr, tol, udstep, udrefn, \
+ rpt, udrepi, udrepu, udrepf, bail, \
+ udbail, cnfine, result ) \
+ \
+ ( gffove_c( (inst), (tshape), CONST_VEC(raydir), \
+ (target), (tframe), (abcorr), \
+ (obsrvr), (tol), (udstep), \
+ (udrefn), (rpt), (udrepi), \
+ (udrepu), (udrepf), (bail), \
+ (udbail), (cnfine), (result) ) )
+
+
+ #define gfrfov_c( inst, raydir, rframe, abcorr, obsrvr, \
+ step, cnfine, result ) \
+ \
+ ( gfrfov_c( (inst), CONST_VEC(raydir), (rframe), \
+ (abcorr), (obsrvr), (step), \
+ (cnfine), (result) ) )
+
+
+ #define gfsntc_c( target, fixref, method, abcorr, obsrvr, \
+ dref, dvec, crdsys, coord, relate, \
+ refval, adjust, step, nintvls, cnfine, \
+ result ) \
+ \
+ ( gfsntc_c( (target), (fixref), (method), \
+ (abcorr), (obsrvr), (dref), \
+ CONST_VEC(dvec), (crdsys), (coord), \
+ (relate), (refval), (adjust), \
+ (step), (nintvls), (cnfine), (result) ) )
+
+
+ #define illum_c( target, et, abcorr, obsrvr, \
+ spoint, phase, solar, emissn ) \
+ \
+ ( illum_c ( (target), (et), (abcorr), (obsrvr), \
+ CONST_VEC(spoint), (phase), (solar), (emissn) ) )
+
+
+ #define ilumin_c( method, target, et, fixref, \
+ abcorr, obsrvr, spoint, trgepc, \
+ srfvec, phase, solar, emissn ) \
+ \
+ ( ilumin_c ( (method), (target), (et), (fixref), \
+ (abcorr), (obsrvr), CONST_VEC(spoint), (trgepc), \
+ (srfvec), (phase), (solar), (emissn) ) )
+
+
+ #define inedpl_c( a, b, c, plane, ellipse, found ) \
+ \
+ ( inedpl_c ( (a), (b), (c), \
+ CONST_PLANE(plane), (ellipse), (found) ) )
+
+
+ #define inrypl_c( vertex, dir, plane, nxpts, xpt ) \
+ \
+ ( inrypl_c ( CONST_VEC(vertex), CONST_VEC(dir), \
+ CONST_PLANE(plane), (nxpts), (xpt) ) )
+
+
+ #define invert_c( m1, m2 ) \
+ \
+ ( invert_c ( CONST_MAT(m1), (m2) ) )
+
+
+ #define invort_c( m, mit ) \
+ \
+ ( invort_c ( CONST_MAT(m), (mit) ) )
+
+
+ #define isordv_c( array, n ) \
+ \
+ ( isordv_c ( CONST_IVEC(array), (n) ) )
+
+
+ #define isrchc_c( value, ndim, lenvals, array ) \
+ \
+ ( isrchc_c ( CONST_STR(value), (ndim), (lenvals), \
+ CONST_VOID(array) ) )
+
+ #define isrchd_c( value, ndim, array ) \
+ \
+ ( isrchd_c( (value), (ndim), CONST_VEC(array) ) )
+
+
+ #define isrchi_c( value, ndim, array ) \
+ \
+ ( isrchi_c( (value), (ndim), CONST_IVEC(array) ) )
+
+
+ #define isrot_c( m, ntol, dtol ) \
+ \
+ ( isrot_c ( CONST_MAT(m), (ntol), (dtol) ) )
+
+
+ #define lmpool_c( cvals, lenvals, n ) \
+ \
+ ( lmpool_c( CONST_VOID(cvals), (lenvals), (n) ) )
+
+
+ #define lstltc_c( value, ndim, lenvals, array ) \
+ \
+ ( lstltc_c ( CONST_STR(value), (ndim), (lenvals), \
+ CONST_VOID(array) ) )
+
+
+ #define lstled_c( value, ndim, array ) \
+ \
+ ( lstled_c( (value), (ndim), CONST_VEC(array) ) )
+
+
+ #define lstlei_c( value, ndim, array ) \
+ \
+ ( lstlei_c( (value), (ndim), CONST_IVEC(array) ) )
+
+
+ #define lstlec_c( value, ndim, lenvals, array ) \
+ \
+ ( lstlec_c ( CONST_STR(value), (ndim), (lenvals), \
+ CONST_VOID(array) ) )
+
+
+ #define lstltd_c( value, ndim, array ) \
+ \
+ ( lstltd_c( (value), (ndim), CONST_VEC(array) ) )
+
+
+ #define lstlti_c( value, ndim, array ) \
+ \
+ ( lstlti_c( (value), (ndim), CONST_IVEC(array) ) )
+
+
+ #define m2eul_c( r, axis3, axis2, axis1, \
+ angle3, angle2, angle1 ) \
+ \
+ ( m2eul_c ( CONST_MAT(r), (axis3), (axis2), (axis1), \
+ (angle3), (angle2), (angle1) ) )
+
+ #define m2q_c( r, q ) \
+ \
+ ( m2q_c ( CONST_MAT(r), (q) ) )
+
+
+ #define mequ_c( m1, m2 ) \
+ \
+ ( mequ_c ( CONST_MAT(m1), m2 ) )
+
+
+ #define mequg_c( m1, nr, nc, mout ) \
+ \
+ ( mequg_c ( CONST_MAT(m1), (nr), (nc), mout ) )
+
+
+ #define mtxm_c( m1, m2, mout ) \
+ \
+ ( mtxm_c ( CONST_MAT(m1), CONST_MAT(m2), (mout) ) )
+
+
+ #define mtxmg_c( m1, m2, ncol1, nr1r2, ncol2, mout ) \
+ \
+ ( mtxmg_c ( CONST_MAT(m1), CONST_MAT(m2), \
+ (ncol1), (nr1r2), (ncol2), (mout) ) )
+
+
+ #define mtxv_c( m1, vin, vout ) \
+ \
+ ( mtxv_c ( CONST_MAT(m1), CONST_VEC(vin), (vout) ) )
+
+
+ #define mtxvg_c( m1, v2, nrow1, nc1r2, vout ) \
+ \
+ ( mtxvg_c( CONST_VOID(m1), CONST_VOID(v2), \
+ (nrow1), (nc1r2), (vout) ) )
+
+ #define mxm_c( m1, m2, mout ) \
+ \
+ ( mxm_c ( CONST_MAT(m1), CONST_MAT(m2), (mout) ) )
+
+
+ #define mxmg_c( m1, m2, row1, col1, col2, mout ) \
+ \
+ ( mxmg_c ( CONST_VOID(m1), CONST_VOID(m2), \
+ (row1), (col1), (col2), (mout) ) )
+
+
+ #define mxmt_c( m1, m2, mout ) \
+ \
+ ( mxmt_c ( CONST_MAT(m1), CONST_MAT(m2), (mout) ) )
+
+
+ #define mxmtg_c( m1, m2, nrow1, nc1c2, nrow2, mout ) \
+ \
+ ( mxmtg_c ( CONST_VOID(m1), CONST_VOID(m2), \
+ (nrow1), (nc1c2), \
+ (nrow2), (mout) ) )
+
+
+ #define mxv_c( m1, vin, vout ) \
+ \
+ ( mxv_c ( CONST_MAT(m1), CONST_VEC(vin), (vout) ) )
+
+
+ #define mxvg_c( m1, v2, nrow1, nc1r2, vout ) \
+ \
+ ( mxvg_c( CONST_VOID(m1), CONST_VOID(v2), \
+ (nrow1), (nc1r2), (vout) ) )
+
+ #define nearpt_c( positn, a, b, c, npoint, alt ) \
+ \
+ ( nearpt_c ( CONST_VEC(positn), (a), (b), (c), \
+ (npoint), (alt) ) )
+
+
+ #define npedln_c( a, b, c, linept, linedr, pnear, dist ) \
+ \
+ ( npedln_c ( (a), (b), (c), \
+ CONST_VEC(linept), CONST_VEC(linedr), \
+ (pnear), (dist) ) )
+
+
+ #define nplnpt_c( linpt, lindir, point, pnear, dist ) \
+ \
+ ( nplnpt_c ( CONST_VEC(linpt), CONST_VEC(lindir), \
+ CONST_VEC(point), (pnear), (dist ) ) )
+
+
+ #define nvc2pl_c( normal, constant, plane ) \
+ \
+ ( nvc2pl_c ( CONST_VEC(normal), (constant), (plane) ) )
+
+
+ #define nvp2pl_c( normal, point, plane ) \
+ \
+ ( nvp2pl_c( CONST_VEC(normal), CONST_VEC(point), (plane) ) )
+
+
+ #define orderc_c( lenvals, array, ndim, iorder ) \
+ \
+ ( orderc_c ( (lenvals), CONST_VOID(array), (ndim), (iorder)) )
+
+
+ #define orderd_c( array, ndim, iorder ) \
+ \
+ ( orderd_c ( CONST_VEC(array), (ndim), (iorder) ) )
+
+
+ #define orderi_c( array, ndim, iorder ) \
+ \
+ ( orderi_c ( CONST_IVEC(array), (ndim), (iorder) ) )
+
+
+ #define oscelt_c( state, et, mu, elts ) \
+ \
+ ( oscelt_c ( CONST_VEC(state), (et), (mu), (elts) ) )
+
+
+ #define pcpool_c( name, n, lenvals, cvals ) \
+ \
+ ( pcpool_c ( (name), (n), (lenvals), CONST_VOID(cvals) ) )
+
+
+ #define pdpool_c( name, n, dvals ) \
+ \
+ ( pdpool_c ( (name), (n), CONST_VEC(dvals) ) )
+
+
+ #define pipool_c( name, n, ivals ) \
+ \
+ ( pipool_c ( (name), (n), CONST_IVEC(ivals) ) )
+
+
+ #define pl2nvc_c( plane, normal, constant ) \
+ \
+ ( pl2nvc_c ( CONST_PLANE(plane), (normal), (constant) ) )
+
+
+ #define pl2nvp_c( plane, normal, point ) \
+ \
+ ( pl2nvp_c ( CONST_PLANE(plane), (normal), (point) ) )
+
+
+ #define pl2psv_c( plane, point, span1, span2 ) \
+ \
+ ( pl2psv_c( CONST_PLANE(plane), (point), (span1), (span2) ) )
+
+
+ #define prop2b_c( gm, pvinit, dt, pvprop ) \
+ \
+ ( prop2b_c ( (gm), CONST_VEC(pvinit), (dt), (pvprop) ) )
+
+
+ #define psv2pl_c( point, span1, span2, plane ) \
+ \
+ ( psv2pl_c ( CONST_VEC(point), CONST_VEC(span1), \
+ CONST_VEC(span2), (plane) ) )
+
+
+ #define qdq2av_c( q, dq, av ) \
+ \
+ ( qdq2av_c ( CONST_VEC(q), CONST_VEC(dq), (av) ) )
+
+
+ #define q2m_c( q, r ) \
+ \
+ ( q2m_c ( CONST_VEC(q), (r) ) )
+
+
+ #define qxq_c( q1, q2, qout ) \
+ \
+ ( qxq_c ( CONST_VEC(q1), CONST_VEC(q2), (qout) ) )
+
+
+ #define rav2xf_c( rot, av, xform ) \
+ \
+ ( rav2xf_c ( CONST_MAT(rot), CONST_VEC(av), (xform) ) )
+
+
+ #define raxisa_c( matrix, axis, angle ) \
+ \
+ ( raxisa_c ( CONST_MAT(matrix), (axis), (angle) ) );
+
+
+ #define reccyl_c( rectan, r, lon, z ) \
+ \
+ ( reccyl_c ( CONST_VEC(rectan), (r), (lon), (z) ) )
+
+
+ #define recgeo_c( rectan, re, f, lon, lat, alt ) \
+ \
+ ( recgeo_c ( CONST_VEC(rectan), (re), (f), \
+ (lon), (lat), (alt) ) )
+
+ #define reclat_c( rectan, r, lon, lat ) \
+ \
+ ( reclat_c ( CONST_VEC(rectan), (r), (lon), (lat) ) )
+
+
+ #define recrad_c( rectan, radius, ra, dec ) \
+ \
+ ( recrad_c ( CONST_VEC(rectan), (radius), (ra), (dec) ) )
+
+
+ #define recsph_c( rectan, r, colat, lon ) \
+ \
+ ( recsph_c ( CONST_VEC(rectan), (r), (colat), (lon) ) )
+
+
+ #define reordd_c( iorder, ndim, array ) \
+ \
+ ( reordd_c ( CONST_IVEC(iorder), (ndim), (array) ) )
+
+
+ #define reordi_c( iorder, ndim, array ) \
+ \
+ ( reordi_c ( CONST_IVEC(iorder), (ndim), (array) ) )
+
+
+ #define reordl_c( iorder, ndim, array ) \
+ \
+ ( reordl_c ( CONST_IVEC(iorder), (ndim), (array) ) )
+
+
+ #define rotmat_c( m1, angle, iaxis, mout ) \
+ \
+ ( rotmat_c ( CONST_MAT(m1), (angle), (iaxis), (mout) ) )
+
+
+ #define rotvec_c( v1, angle, iaxis, vout ) \
+ \
+ ( rotvec_c ( CONST_VEC(v1), (angle), (iaxis), (vout) ) )
+
+
+ #define saelgv_c( vec1, vec2, smajor, sminor ) \
+ \
+ ( saelgv_c ( CONST_VEC(vec1), CONST_VEC(vec2), \
+ (smajor), (sminor) ) )
+
+
+ #define spk14a_c( handle, ncsets, coeffs, epochs ) \
+ \
+ ( spk14a_c ( (handle), (ncsets), \
+ CONST_VEC(coeffs), CONST_VEC(epochs) ) )
+
+
+ #define spkapo_c( targ, et, ref, sobs, abcorr, ptarg, lt ) \
+ \
+ ( spkapo_c ( (targ), (et), (ref), CONST_VEC(sobs), \
+ (abcorr), (ptarg), (lt) ) )
+
+
+ #define spkapp_c( targ, et, ref, sobs, abcorr, starg, lt ) \
+ \
+ ( spkapp_c ( (targ), (et), (ref), CONST_VEC(sobs), \
+ (abcorr), (starg), (lt) ) )
+
+
+ #define spkaps_c( targ, et, ref, abcorr, sobs, \
+ accobs, starg, lt, dlt ) \
+ \
+ ( spkaps_c ( (targ), (et), (ref), (abcorr), \
+ CONST_VEC(sobs), CONST_VEC(accobs), \
+ (starg), (lt), (dlt) ) )
+
+
+ #define spkltc_c( targ, et, ref, abcorr, sobs, starg, lt, dlt ) \
+ \
+ ( spkltc_c ( (targ), (et), (ref), (abcorr), \
+ CONST_VEC(sobs), (starg), (lt), (dlt) ) )
+
+
+ #define spkuds_c( descr, body, center, frame, type, \
+ first, last, begin, end ) \
+ \
+ ( spkuds_c ( CONST_VEC(descr), (body), (center), (frame), \
+ (type), (first), (last), (begin), (end) ) )
+
+
+ #define spkw02_c( handle, body, center, frame, first, last, \
+ segid, intlen, n, polydg, cdata, btime ) \
+ \
+ ( spkw02_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (intlen), \
+ (n), (polydg), CONST_VEC(cdata), (btime) ) )
+
+
+ #define spkw03_c( handle, body, center, frame, first, last, \
+ segid, intlen, n, polydg, cdata, btime ) \
+ \
+ ( spkw03_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (intlen), \
+ (n), (polydg), CONST_VEC(cdata), (btime) ) )
+
+
+
+ #define spkw05_c( handle, body, center, frame, first, last, \
+ segid, gm, n, states, epochs ) \
+ \
+ ( spkw05_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (gm), \
+ (n), \
+ CONST_MAT6(states), CONST_VEC(epochs) ) )
+
+
+ #define spkw08_c( handle, body, center, frame, first, last, \
+ segid, degree, n, states, epoch1, step ) \
+ \
+ ( spkw08_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (degree), \
+ (n), CONST_MAT6(states), (epoch1), \
+ (step) ) )
+
+
+ #define spkw09_c( handle, body, center, frame, first, last, \
+ segid, degree, n, states, epochs ) \
+ \
+ ( spkw09_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (degree), (n), \
+ CONST_MAT6(states), CONST_VEC(epochs) ) )
+
+
+ #define spkw10_c( handle, body, center, frame, first, last, \
+ segid, consts, n, elems, epochs ) \
+ \
+ ( spkw10_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), CONST_VEC(consts), \
+ (n), CONST_VEC(elems), CONST_VEC(epochs)) )
+
+
+ #define spkw12_c( handle, body, center, frame, first, last, \
+ segid, degree, n, states, epoch0, step ) \
+ \
+ ( spkw12_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (degree), \
+ (n), CONST_MAT6(states), (epoch0), \
+ (step) ) )
+
+
+ #define spkw13_c( handle, body, center, frame, first, last, \
+ segid, degree, n, states, epochs ) \
+ \
+ ( spkw13_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (degree), (n), \
+ CONST_MAT6(states), CONST_VEC(epochs) ) )
+
+
+
+
+
+ #define spkw15_c( handle, body, center, frame, first, last, \
+ segid, epoch, tp, pa, p, ecc, \
+ j2flg, pv, gm, j2, radius ) \
+ \
+ ( spkw15_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (epoch), \
+ CONST_VEC(tp), CONST_VEC(pa), \
+ (p), (ecc), (j2flg), CONST_VEC(pv), \
+ (gm), (j2), (radius) ) )
+
+
+ #define spkw17_c( handle, body, center, frame, first, last, \
+ segid, epoch, eqel, rapol, decpol ) \
+ \
+ ( spkw17_c ( (handle), (body), (center), (frame), \
+ (first), (last), (segid), (epoch), \
+ CONST_VEC(eqel), (rapol), (decpol) ) )
+
+
+
+ #define spkw18_c( handle, subtyp, body, center, frame, first, \
+ last, segid, degree, n, packts, epochs ) \
+ \
+ ( spkw18_c ( (handle), (subtyp), (body), (center), (frame), \
+ (first), (last), (segid), (degree), (n), \
+ CONST_VOID(packts), CONST_VEC(epochs) ) )
+
+
+ #define srfxpt_c( method, target, et, abcorr, obsrvr, dref, \
+ dvec, spoint, dist, trgepc, obspos, found ) \
+ \
+ ( srfxpt_c ( (method), (target), (et), (abcorr), (obsrvr), \
+ (dref), CONST_VEC(dvec), (spoint), (dist), \
+ (trgepc), (obspos), (found) ) )
+
+
+ #define stelab_c( pobj, vobj, appobj ) \
+ \
+ ( stelab_c ( CONST_VEC(pobj), CONST_VEC(vobj), (appobj) ) )
+
+
+ #define sumad_c( array, n ) \
+ \
+ ( sumad_c ( CONST_VEC(array), (n) ) )
+
+
+ #define sumai_c( array, n ) \
+ \
+ ( sumai_c ( CONST_IVEC(array), (n) ) )
+
+
+ #define surfnm_c( a, b, c, point, normal ) \
+ \
+ ( surfnm_c ( (a), (b), (c), CONST_VEC(point), (normal) ) )
+
+
+ #define surfpt_c( positn, u, a, b, c, point, found ) \
+ \
+ ( surfpt_c ( CONST_VEC(positn), CONST_VEC(u), \
+ (a), (b), (c), \
+ (point), (found) ) )
+
+
+ #define surfpv_c( stvrtx, stdir, a, b, c, stx, found ) \
+ \
+ ( surfpv_c ( CONST_VEC(stvrtx), CONST_VEC(stdir), \
+ (a), (b), (c), \
+ (stx), (found) ) )
+
+
+ #define swpool_c( agent, nnames, lenvals, names ) \
+ \
+ ( swpool_c( CONST_STR(agent), (nnames), \
+ (lenvals), CONST_VOID(names) ) )
+
+
+ #define trace_c( m1 ) \
+ \
+ ( trace_c ( CONST_MAT(m1) ) )
+
+
+ #define twovec_c( axdef, indexa, plndef, indexp, mout ) \
+ \
+ ( twovec_c ( CONST_VEC(axdef), (indexa), \
+ CONST_VEC(plndef), (indexp), (mout) ) )
+
+
+ #define ucrss_c( v1, v2, vout ) \
+ \
+ ( ucrss_c ( CONST_VEC(v1), CONST_VEC(v2), (vout) ) )
+
+
+ #define unorm_c( v1, vout, vmag ) \
+ \
+ ( unorm_c ( CONST_VEC(v1), (vout), (vmag) ) )
+
+
+ #define unormg_c( v1, ndim, vout, vmag ) \
+ \
+ ( unormg_c ( CONST_VEC(v1), (ndim), (vout), (vmag) ) )
+
+
+ #define vadd_c( v1, v2, vout ) \
+ \
+ ( vadd_c ( CONST_VEC(v1), CONST_VEC(v2), (vout) ) )
+
+
+ #define vaddg_c( v1, v2, ndim,vout ) \
+ \
+ ( vaddg_c ( CONST_VEC(v1), CONST_VEC(v2), (ndim), (vout) ) )
+
+
+ #define vcrss_c( v1, v2, vout ) \
+ \
+ ( vcrss_c ( CONST_VEC(v1), CONST_VEC(v2), (vout) ) )
+
+
+ #define vdist_c( v1, v2 ) \
+ \
+ ( vdist_c ( CONST_VEC(v1), CONST_VEC(v2) ) )
+
+
+ #define vdistg_c( v1, v2, ndim ) \
+ \
+ ( vdistg_c ( CONST_VEC(v1), CONST_VEC(v2), (ndim) ) )
+
+
+ #define vdot_c( v1, v2 ) \
+ \
+ ( vdot_c ( CONST_VEC(v1), CONST_VEC(v2) ) )
+
+
+ #define vdotg_c( v1, v2, ndim ) \
+ \
+ ( vdotg_c ( CONST_VEC(v1), CONST_VEC(v2), (ndim) ) )
+
+
+ #define vequ_c( vin, vout ) \
+ \
+ ( vequ_c ( CONST_VEC(vin), (vout) ) )
+
+
+ #define vequg_c( vin, ndim, vout ) \
+ \
+ ( vequg_c ( CONST_VEC(vin), (ndim), (vout) ) )
+
+
+ #define vhat_c( v1, vout ) \
+ \
+ ( vhat_c ( CONST_VEC(v1), (vout) ) )
+
+
+ #define vhatg_c( v1, ndim, vout ) \
+ \
+ ( vhatg_c ( CONST_VEC(v1), (ndim), (vout) ) )
+
+
+ #define vlcom3_c( a, v1, b, v2, c, v3, sum ) \
+ \
+ ( vlcom3_c ( (a), CONST_VEC(v1), \
+ (b), CONST_VEC(v2), \
+ (c), CONST_VEC(v3), (sum) ) )
+
+
+ #define vlcom_c( a, v1, b, v2, sum ) \
+ \
+ ( vlcom_c ( (a), CONST_VEC(v1), \
+ (b), CONST_VEC(v2), (sum) ) )
+
+
+ #define vlcomg_c( n, a, v1, b, v2, sum ) \
+ \
+ ( vlcomg_c ( (n), (a), CONST_VEC(v1), \
+ (b), CONST_VEC(v2), (sum) ) )
+
+
+ #define vminug_c( v1, ndim, vout ) \
+ \
+ ( vminug_c ( CONST_VEC(v1), (ndim), (vout) ) )
+
+
+ #define vminus_c( v1, vout ) \
+ \
+ ( vminus_c ( CONST_VEC(v1), (vout) ) )
+
+
+ #define vnorm_c( v1 ) \
+ \
+ ( vnorm_c ( CONST_VEC(v1) ) )
+
+
+ #define vnormg_c( v1, ndim ) \
+ \
+ ( vnormg_c ( CONST_VEC(v1), (ndim) ) )
+
+
+ #define vperp_c( a, b, p ) \
+ \
+ ( vperp_c ( CONST_VEC(a), CONST_VEC(b), (p) ) )
+
+
+ #define vprjp_c( vin, plane, vout ) \
+ \
+ ( vprjp_c ( CONST_VEC(vin), CONST_PLANE(plane), (vout) ) )
+
+
+ #define vprjpi_c( vin, projpl, invpl, vout, found ) \
+ \
+ ( vprjpi_c( CONST_VEC(vin), CONST_PLANE(projpl), \
+ CONST_PLANE(invpl), (vout), (found) ) )
+
+
+ #define vproj_c( a, b, p ) \
+ \
+ ( vproj_c ( CONST_VEC(a), CONST_VEC(b), (p) ) )
+
+
+ #define vrel_c( v1, v2 ) \
+ \
+ ( vrel_c ( CONST_VEC(v1), CONST_VEC(v2) ) )
+
+
+ #define vrelg_c( v1, v2, ndim ) \
+ \
+ ( vrelg_c ( CONST_VEC(v1), CONST_VEC(v2), (ndim) ) )
+
+
+ #define vrotv_c( v, axis, theta, r ) \
+ \
+ ( vrotv_c ( CONST_VEC(v), CONST_VEC(axis), (theta), (r) ) )
+
+
+ #define vscl_c( s, v1, vout ) \
+ \
+ ( vscl_c ( (s), CONST_VEC(v1), (vout) ) )
+
+
+ #define vsclg_c( s, v1, ndim, vout ) \
+ \
+ ( vsclg_c ( (s), CONST_VEC(v1), (ndim), (vout) ) )
+
+
+ #define vsep_c( v1, v2 ) \
+ \
+ ( vsep_c ( CONST_VEC(v1), CONST_VEC(v2) ) )
+
+
+ #define vsepg_c( v1, v2, ndim) \
+ \
+ ( vsepg_c ( CONST_VEC(v1), CONST_VEC(v2), ndim ) )
+
+
+ #define vsub_c( v1, v2, vout ) \
+ \
+ ( vsub_c ( CONST_VEC(v1), CONST_VEC(v2), (vout) ) )
+
+
+ #define vsubg_c( v1, v2, ndim, vout ) \
+ \
+ ( vsubg_c ( CONST_VEC(v1), CONST_VEC(v2), \
+ (ndim), (vout) ) )
+
+ #define vtmv_c( v1, mat, v2 ) \
+ \
+ ( vtmv_c ( CONST_VEC(v1), CONST_MAT(mat), CONST_VEC(v2) ) )
+
+
+ #define vtmvg_c( v1, mat, v2, nrow, ncol ) \
+ \
+ ( vtmvg_c ( CONST_VOID(v1), CONST_VOID(mat), CONST_VOID(v2), \
+ (nrow), (ncol) ) )
+
+
+ #define vupack_c( v, x, y, z ) \
+ \
+ ( vupack_c ( CONST_VEC(v), (x), (y), (z) ) )
+
+
+ #define vzero_c( v1 ) \
+ \
+ ( vzero_c ( CONST_VEC(v1) ) )
+
+
+ #define vzerog_c( v1, ndim ) \
+ \
+ ( vzerog_c ( CONST_VEC(v1), (ndim) ) )
+
+
+ #define xf2eul_c( xform, axisa, axisb, axisc, eulang, unique ) \
+ \
+ ( xf2eul_c( CONST_MAT6(xform), (axisa), (axisb), (axisc), \
+ (eulang), (unique) ) )
+
+
+ #define xf2rav_c( xform, rot, av ) \
+ \
+ ( xf2rav_c( CONST_MAT6(xform), (rot), (av) ) )
+
+
+ #define xpose6_c( m1, mout ) \
+ \
+ ( xpose6_c ( CONST_MAT6(m1), (mout) ) )
+
+
+ #define xpose_c( m1, mout ) \
+ \
+ ( xpose_c ( CONST_MAT(m1), (mout) ) )
+
+
+ #define xposeg_c( matrix, nrow, ncol, mout ) \
+ \
+ ( xposeg_c ( CONST_VOID(matrix), (nrow), (ncol), (mout) ) )
+
+
+#endif
diff --git a/ext/spice/src/cspice/SpiceZmc.h b/ext/spice/src/cspice/SpiceZmc.h
new file mode 100644
index 0000000000..df694a602e
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceZmc.h
@@ -0,0 +1,975 @@
+/*
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+*/
+
+/*
+ CSPICE private macro file.
+
+-Particulars
+
+ Current list of macros (spelling counts)
+
+ BLANK
+ C2F_MAP_CELL
+ C2F_MAP_CELL2
+ C2F_MAP_CELL3
+ CELLINIT
+ CELLINIT2
+ CELLINIT3
+ CELLISSETCHK
+ CELLISSETCHK2
+ CELLISSETCHK2_VAL
+ CELLISSETCHK3
+ CELLISSETCHK3_VAL
+ CELLISSETCHK_VAL
+ CELLMATCH2
+ CELLMATCH2_VAL
+ CELLMATCH3
+ CELLMATCH3_VAL
+ CELLTYPECHK
+ CELLTYPECHK2
+ CELLTYPECHK2_VAL
+ CELLTYPECHK3
+ CELLTYPECHK3_VAL
+ CELLTYPECHK_VAL
+ CHKFSTR
+ CHKFSTR_VAL
+ CHKOSTR
+ CHKOSTR_VAL
+ CHKPTR
+ Constants
+ Even
+ F2C_MAP_CELL
+ Index values
+ MOVED
+ MOVEI
+ MaxAbs
+ MaxVal
+ MinAbs
+ MinVal
+ Odd
+ SpiceError
+ TolOrFail
+
+-Restrictions
+
+ This is a private macro file for use within CSPICE.
+ Do not use or alter any entry. Or else!
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 4.2.0, 16-FEB-2005 (NJB)
+
+ Bug fix: in the macro C2F_MAP_CELL, error checking has been
+ added after the sequence of calls to ssizec_ and scardc_.
+ If either of these routines signals an error, the dynamically
+ allocated memory for the "Fortran cell" is freed.
+
+ -CSPICE Version 4.1.0, 06-DEC-2002 (NJB)
+
+ Bug fix: added previous missing, bracketing parentheses to
+ references to input cell pointer argument in macro
+ CELLINIT.
+
+ Changed CELLINIT macro so it no longer initializes to zero
+ length all strings in data array of a character cell. Instead,
+ strings are terminated with a null in their final element.
+
+ -CSPICE Version 4.0.0, 22-AUG-2002 (NJB)
+
+ Added macro definitions to support CSPICE cells and sets:
+
+ C2F_MAP_CELL
+ C2F_MAP_CELL2
+ C2F_MAP_CELL3
+ CELLINIT
+ CELLINIT2
+ CELLINIT3
+ CELLISSETCHK
+ CELLISSETCHK2
+ CELLISSETCHK2_VAL
+ CELLISSETCHK3
+ CELLISSETCHK3_VAL
+ CELLISSETCHK_VAL
+ CELLMATCH2
+ CELLMATCH2_VAL
+ CELLMATCH3
+ CELLMATCH3_VAL
+ CELLTYPECHK
+ CELLTYPECHK2
+ CELLTYPECHK2_VAL
+ CELLTYPECHK3
+ CELLTYPECHK3_VAL
+ CELLTYPECHK_VAL
+ F2C_MAP_CELL
+
+ -CSPICE Version 3.0.0, 09-JAN-1998 (NJB)
+
+ Added output string check macros CHKOSTR and CHKOSTR_VAL.
+ Removed variable name arguments from macros
+
+ CHKPTR
+ CHKPTR_VAL
+ CHKFSTR
+ CHKRSTR_VAL
+
+ The strings containing names of the checked variables are now
+ generated from the variables themselves via the # operator.
+
+ -CSPICE Version 2.0.0, 03-DEC-1997 (NJB)
+
+ Added pointer check macro CHKPTR and Fortran string check macro
+ CHKFSTR.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (EDW)
+*/
+
+
+
+#include
+#include
+#include "SpiceZdf.h"
+
+
+#define MOVED( arrfrm, ndim, arrto ) \
+ \
+ ( memmove ( (void*) (arrto) , \
+ (void*) (arrfrm), \
+ sizeof (SpiceDouble) * (ndim) ) )
+
+
+
+
+
+#define MOVEI( arrfrm, ndim, arrto ) \
+ \
+ ( memmove ( (void*) (arrto) , \
+ (void*) (arrfrm), \
+ sizeof (SpiceInt) * (ndim) ) )
+
+
+
+
+
+/*
+Define a tolerance test for those pesky double precision reals.
+True if the difference is less than the tolerance, false otherwise.
+The tolerance refers to a percentage. x, y and tol should be declared
+double. All values are assumed to be non-zero. Okay?
+*/
+
+#define TolOrFail( x, y, tol ) \
+ \
+ ( fabs( x-y ) < ( tol * fabs(x) ) )
+
+
+
+
+
+/*
+Simple error output through standard SPICE error system . Set the error
+message and the type
+*/
+
+#define SpiceError( errmsg, errtype ) \
+ \
+ { \
+ setmsg_c ( errmsg ); \
+ sigerr_c ( errtype ); \
+ }
+
+
+
+
+
+
+/*
+Return a value which is the maximum/minimum of the absolute values of
+two values.
+*/
+
+#define MaxAbs(a,b) ( fabs(a) >= fabs(b) ? fabs(a) : fabs(b) )
+#define MinAbs(a,b) ( fabs(a) < fabs(b) ? fabs(a) : fabs(b) )
+
+
+
+
+
+/*
+Return a value which is the maximum/minimum value of two values.
+*/
+
+#define MaxVal(A,B) ( (A) >= (B) ? (A) : (B) )
+#define MinVal(A,B) ( (A) < (B) ? (A) : (B) )
+
+
+
+
+
+/*
+Determine whether a value is even or odd
+*/
+#define Even( x ) ( ( (x) & 1 ) == 0 )
+#define Odd ( x ) ( ( (x) & 1 ) != 0 )
+
+
+
+
+
+/*
+Array indexes for vectors.
+*/
+
+#define SpiceX 0
+#define SpiceY 1
+#define SpiceZ 2
+#define SpiceVx 3
+#define SpiceVy 4
+#define SpiceVz 5
+
+
+
+
+/*
+Physical constants and dates.
+*/
+
+#define B1900 2415020.31352
+#define J1900 2415020.0
+#define JYEAR 31557600.0
+#define TYEAR 31556925.9747
+#define J1950 2433282.5
+#define SPD 86400.0
+#define B1950 2433282.42345905
+#define J2100 2488070.0
+#define CLIGHT 299792.458
+#define J2000 2451545.0
+
+
+
+
+
+/*
+Common literal values.
+*/
+
+#define NULLCHAR ( (SpiceChar ) 0 )
+#define NULLCPTR ( (SpiceChar * ) 0 )
+#define BLANK ( (SpiceChar ) ' ' )
+
+
+
+/*
+Macro CHKPTR is used for checking for a null pointer. CHKPTR uses
+the constants
+
+ CHK_STANDARD
+ CHK_DISCOVER
+ CHK_REMAIN
+
+to control tracing behavior. Values and meanings are:
+
+ CHK_STANDARD Standard tracing. If an error
+ is found, signal it, check out
+ and return.
+
+ CHK_DISCOVER Discovery check-in. If an
+ error is found, check in, signal
+ the error, check out, and return.
+
+ CHK_REMAIN If an error is found, signal it.
+ Do not check out or return. This
+ would allow the caller to clean up
+ before returning, if necessary.
+ In such cases the caller must test
+ failed_c() after the macro call.
+
+CHKPTR should be used in void functions. In non-void functions,
+use CHKPTR_VAL, which is defined below.
+
+*/
+
+#define CHK_STANDARD 1
+#define CHK_DISCOVER 2
+#define CHK_REMAIN 3
+
+#define CHKPTR( errHandling, modname, pointer ) \
+ \
+ if ( (void *)(pointer) == (void *)0 ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Pointer \"#\" is null; a non-null " \
+ "pointer is required." ); \
+ errch_c ( "#", (#pointer) ); \
+ sigerr_c ( "SPICE(NULLPOINTER)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return; \
+ } \
+ }
+
+
+#define CHKPTR_VAL( errHandling, modname, pointer, retval ) \
+ \
+ if ( (void *)(pointer) == (void *)0 ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Pointer \"#\" is null; a non-null " \
+ "pointer is required." ); \
+ errch_c ( "#", (#pointer) ); \
+ sigerr_c ( "SPICE(NULLPOINTER)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return ( retval ); \
+ } \
+ }
+
+
+/*
+Macro CHKFSTR checks strings that are to be passed to Fortran or
+f2c'd Fortran routines. Such strings must have non-zero length,
+and their pointers must be non-null.
+
+CHKFSTR should be used in void functions. In non-void functions,
+use CHKFSTR_VAL, which is defined below.
+*/
+
+#define CHKFSTR( errHandling, modname, string ) \
+ \
+ CHKPTR ( errHandling, modname, string ); \
+ \
+ if ( ( (void *)string != (void *)0 ) \
+ && ( strlen(string) == 0 ) ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "String \"#\" has length zero." ); \
+ errch_c ( "#", (#string) ); \
+ sigerr_c ( "SPICE(EMPTYSTRING)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return; \
+ } \
+ }
+
+#define CHKFSTR_VAL( errHandling, modname, string, retval ) \
+ \
+ CHKPTR_VAL( errHandling, modname, string, retval); \
+ \
+ if ( ( (void *)string != (void *)0 ) \
+ && ( strlen(string) == 0 ) ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "String \"#\" has length zero." ); \
+ errch_c ( "#", (#string) ); \
+ sigerr_c ( "SPICE(EMPTYSTRING)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return ( retval ); \
+ } \
+ }
+
+
+/*
+Macro CHKOSTR checks output string pointers and the associated
+string length values supplied as input arguments. Output string
+pointers must be non-null, and the string lengths must be at
+least 2, so Fortran routine can write at least one character to
+the output string, and so a null terminator can be appended.
+CHKOSTR should be used in void functions. In non-void functions,
+use CHKOSTR_VAL, which is defined below.
+*/
+
+#define CHKOSTR( errHandling, modname, string, length ) \
+ \
+ CHKPTR ( errHandling, modname, string ); \
+ \
+ if ( ( (void *)string != (void *)0 ) \
+ && ( length < 2 ) ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "String \"#\" has length #; must be >= 2." ); \
+ errch_c ( "#", (#string) ); \
+ errint_c ( "#", (length) ); \
+ sigerr_c ( "SPICE(STRINGTOOSHORT)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return; \
+ } \
+ }
+
+
+#define CHKOSTR_VAL( errHandling, modname, string, length, retval ) \
+ \
+ CHKPTR_VAL( errHandling, modname, string, retval ); \
+ \
+ if ( ( (void *)string != (void *)0 ) \
+ && ( length < 2 ) ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "String \"#\" has length #; must be >= 2." ); \
+ errch_c ( "#", (#string) ); \
+ errint_c ( "#", (length) ); \
+ sigerr_c ( "SPICE(STRINGTOOSHORT)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return ( retval ); \
+ } \
+ }
+
+
+ /*
+ Definitions for Cells and Sets
+ */
+
+
+ /*
+ Cell initialization macros
+ */
+ #define CELLINIT( cellPtr ) \
+ \
+ if ( !( (cellPtr)->init ) ) \
+ { \
+ if ( (cellPtr)->dtype == SPICE_CHR ) \
+ { \
+ /* \
+ Make sure all elements of the data array, including \
+ the control area, start off null-terminated. We place \
+ the null character in the final element of each string, \
+ so as to avoid wiping out data that may have been \
+ assigned to the data array prior to initialization. \
+ */ \
+ SpiceChar * sPtr; \
+ SpiceInt i; \
+ SpiceInt nmax; \
+ \
+ nmax = SPICE_CELL_CTRLSZ + (cellPtr)->size; \
+ \
+ for ( i = 1; i <= nmax; i++ ) \
+ { \
+ sPtr = (SpiceChar *)((cellPtr)->base) \
+ + i * (cellPtr)->length \
+ - 1; \
+ \
+ *sPtr = NULLCHAR; \
+ } \
+ } \
+ else \
+ { \
+ zzsynccl_c ( C2F, (cellPtr) ); \
+ } \
+ \
+ (cellPtr)->init = SPICETRUE; \
+ }
+
+
+ #define CELLINIT2( cellPtr1, cellPtr2 ) \
+ \
+ CELLINIT ( cellPtr1 ); \
+ CELLINIT ( cellPtr2 );
+
+
+ #define CELLINIT3( cellPtr1, cellPtr2, cellPtr3 ) \
+ \
+ CELLINIT ( cellPtr1 ); \
+ CELLINIT ( cellPtr2 ); \
+ CELLINIT ( cellPtr3 );
+
+
+ /*
+ Data type checking macros:
+ */
+ #define CELLTYPECHK( errHandling, modname, dType, cellPtr1 ) \
+ \
+ if ( (cellPtr1)->dtype != (dType) ) \
+ { \
+ SpiceChar * typstr[3] = \
+ { \
+ "character", "double precision", "integer" \
+ }; \
+ \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Data type of # is #; expected type " \
+ "is #." ); \
+ errch_c ( "#", (#cellPtr1) ); \
+ errch_c ( "#", typstr[ (cellPtr1)->dtype ] ); \
+ errch_c ( "#", typstr[ dType ] ); \
+ sigerr_c ( "SPICE(TYPEMISMATCH)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return; \
+ } \
+ }
+
+
+ #define CELLTYPECHK_VAL( errHandling, modname, \
+ dType, cellPtr1, retval ) \
+ \
+ if ( (cellPtr1)->dtype != (dType) ) \
+ { \
+ SpiceChar * typstr[3] = \
+ { \
+ "character", "double precision", "integer" \
+ }; \
+ \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Data type of # is #; expected type " \
+ "is #." ); \
+ errch_c ( "#", (#cellPtr1) ); \
+ errch_c ( "#", typstr[ (cellPtr1)->dtype ] ); \
+ errch_c ( "#", typstr[ dType ] ); \
+ sigerr_c ( "SPICE(TYPEMISMATCH)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return (retval); \
+ } \
+ }
+
+
+ #define CELLTYPECHK2( errHandling, modname, dtype, \
+ cellPtr1, cellPtr2 ) \
+ \
+ CELLTYPECHK( errHandling, modname, dtype, cellPtr1 ); \
+ CELLTYPECHK( errHandling, modname, dtype, cellPtr2 );
+
+
+
+ #define CELLTYPECHK2_VAL( errHandling, modname, dtype, \
+ cellPtr1, cellPtr2, retval ) \
+ \
+ CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr1, \
+ retval ); \
+ CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr2, \
+ retval );
+
+
+
+ #define CELLTYPECHK3( errHandling, modname, dtype, \
+ cellPtr1, cellPtr2, cellPtr3 ) \
+ \
+ CELLTYPECHK( errHandling, modname, dtype, cellPtr1 ); \
+ CELLTYPECHK( errHandling, modname, dtype, cellPtr2 ); \
+ CELLTYPECHK( errHandling, modname, dtype, cellPtr3 );
+
+
+ #define CELLTYPECHK3_VAL( errHandling, modname, dtype, \
+ cellPtr1, cellPtr2, cellPtr3, \
+ retval ) \
+ \
+ CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr1, \
+ retval ); \
+ CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr2, \
+ retval ); \
+ CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr3 \
+ retval );
+
+
+
+ #define CELLMATCH2( errHandling, modname, cellPtr1, cellPtr2 ) \
+ \
+ if ( (cellPtr1)->dtype != (cellPtr2)->dtype ) \
+ { \
+ SpiceChar * typstr[3] = \
+ { \
+ "character", "double precision", "integer" \
+ }; \
+ \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Data type of # is #; data type of # " \
+ "is #, but types must match." ); \
+ errch_c ( "#", (#cellPtr1) ); \
+ errch_c ( "#", typstr[ (cellPtr1)->dtype ] ); \
+ errch_c ( "#", (#cellPtr2) ); \
+ errch_c ( "#", typstr[ (cellPtr2)->dtype ] ); \
+ sigerr_c ( "SPICE(TYPEMISMATCH)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return; \
+ } \
+ }
+
+ #define CELLMATCH2_VAL( errHandling, modname, \
+ cellPtr1, cellPtr2, retval ) \
+ \
+ if ( (cellPtr1)->dtype != (cellPtr2)->dtype ) \
+ { \
+ SpiceChar * typstr[3] = \
+ { \
+ "character", "double precision", "integer" \
+ }; \
+ \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Data type of # is #; data type of # " \
+ "is #, but types must match." ); \
+ errch_c ( "#", (#cellPtr1) ); \
+ errch_c ( "#", typstr [ (cellPtr1)->dtype ] ); \
+ errch_c ( "#", (#cellPtr2) ); \
+ errch_c ( "#", typstr [ (cellPtr2)->dtype ] ); \
+ sigerr_c ( "SPICE(TYPEMISMATCH)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return ( retval ); \
+ } \
+ }
+
+
+ #define CELLMATCH3( errHandling, modname, \
+ cellPtr1, cellPtr2, cellPtr3 ) \
+ \
+ CELLMATCH2 ( errHandling, modname, cellPtr1, cellPtr2 ); \
+ CELLMATCH2 ( errHandling, modname, cellPtr2, cellPtr3 );
+
+
+
+
+ #define CELLMATCH3_VAL( errHandling, modname, cellPtr1, \
+ cellPtr2, cellPtr3, retval ) \
+ \
+ CELLMATCH2_VAL ( errHandling, modname, \
+ cellPtr1, cellPtr2, retval ); \
+ \
+ CELLMATCH2_VAL ( errHandling, modname, \
+ cellPtr2, cellPtr3, retval );
+
+ /*
+ Set checking macros:
+ */
+ #define CELLISSETCHK( errHandling, modname, cellPtr1 ) \
+ \
+ if ( !(cellPtr1)->isSet ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Cell # must be sorted and have unique " \
+ "values in order to be a CSPICE set. " \
+ "The isSet flag in this cell is SPICEFALSE, " \
+ "indicating the cell may have been modified " \
+ "by a routine that doesn't preserve these " \
+ "properties." ); \
+ errch_c ( "#", (#cellPtr1) ); \
+ sigerr_c ( "SPICE(NOTASET)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return; \
+ } \
+ }
+
+
+ #define CELLISSETCHK_VAL( errHandling, modname, \
+ cellPtr1, retval ) \
+ \
+ if ( !(cellPtr1)->isSet ) \
+ { \
+ if ( (errHandling) == CHK_DISCOVER ) \
+ { \
+ chkin_c ( modname ); \
+ } \
+ \
+ setmsg_c ( "Cell # must be sorted and have unique " \
+ "values in order to be a CSPICE set. " \
+ "The isSet flag in this cell is SPICEFALSE, " \
+ "indicating the cell may have been modified " \
+ "by a routine that doesn't preserve these " \
+ "properties." ); \
+ errch_c ( "#", (#cellPtr1) ); \
+ sigerr_c ( "SPICE(NOTASET)" ); \
+ \
+ if ( ( (errHandling) == CHK_DISCOVER ) \
+ || ( (errHandling) == CHK_STANDARD ) ) \
+ { \
+ chkout_c ( modname ); \
+ return (retval); \
+ } \
+ }
+
+
+ #define CELLISSETCHK2( errHandling, modname, \
+ cellPtr1, cellPtr2 ) \
+ \
+ CELLISSETCHK( errHandling, modname, cellPtr1 ); \
+ CELLISSETCHK( errHandling, modname, cellPtr2 );
+
+
+
+ #define CELLISSETCHK2_VAL( errHandling, modname, \
+ cellPtr1, cellPtr2, retval ) \
+ \
+ CELLISSETCHK_VAL( errHandling, modname, cellPtr1, retval ); \
+ CELLISSETCHK_VAL( errHandling, modname, cellPtr2, retval ); \
+
+
+
+ #define CELLISSETCHK3( errHandling, modname, \
+ cellPtr1, cellPtr2, cellPtr3 ) \
+ \
+ CELLISSETCHK ( errHandling, modname, cellPtr1 ); \
+ CELLISSETCHK ( errHandling, modname, cellPtr2 ); \
+ CELLISSETCHK ( errHandling, modname, cellPtr3 );
+
+
+ #define CELLISSETCHK3_VAL( errHandling, modname, cellPtr1, \
+ cellPtr2, cellPtr3, retval ) \
+ \
+ CELLISSETCHK_VAL ( errHandling, modname, cellPtr1, retval ); \
+ CELLISSETCHK_VAL ( errHandling, modname, cellPtr2, retval ); \
+ CELLISSETCHK_VAL ( errHandling, modname, cellPtr3, retval );
+
+
+ /*
+ C-to-Fortran and Fortran-to-C character cell translation macros:
+ */
+
+ /*
+ Macros that map one or more character C cells to dynamically
+ allocated Fortran-style character cells:
+ */
+ #define C2F_MAP_CELL( caller, CCell, fCell, fLen ) \
+ \
+ { \
+ /* \
+ fCell and fLen are to be passed by reference, as if this \
+ macro were a function. \
+ \
+ \
+ Caution: dynamically allocates array fCell, which is to be \
+ freed by caller! \
+ */ \
+ SpiceInt ndim; \
+ SpiceInt lenvals; \
+ \
+ \
+ ndim = (CCell)->size + SPICE_CELL_CTRLSZ; \
+ lenvals = (CCell)->length; \
+ \
+ C2F_MapFixStrArr ( (caller), ndim, lenvals, \
+ (CCell)->base, (fLen), (fCell) ); \
+ \
+ if ( !failed_c() ) \
+ { \
+ /* \
+ Explicitly set the control area info in the Fortran cell.\
+ */ \
+ ssizec_ ( ( integer * ) &((CCell)->size), \
+ ( char * ) *(fCell), \
+ ( ftnlen ) *(fLen) ); \
+ \
+ scardc_ ( ( integer * ) &((CCell)->card), \
+ ( char * ) *(fCell), \
+ ( ftnlen ) *(fLen) ); \
+ \
+ if ( failed_c() ) \
+ { \
+ /* \
+ Setting size or cardinality of the Fortran cell \
+ can fail, for example if the cell's string length \
+ is too short. \
+ */ \
+ free ( *(fCell) ); \
+ } \
+ } \
+ }
+
+
+ #define C2F_MAP_CELL2( caller, CCell1, fCell1, fLen1, \
+ CCell2, fCell2, fLen2 ) \
+ \
+ { \
+ C2F_MAP_CELL( caller, CCell1, fCell1, fLen1 ); \
+ \
+ if ( !failed_c() ) \
+ { \
+ C2F_MAP_CELL( caller, CCell2, fCell2, fLen2 ); \
+ \
+ if ( failed_c() ) \
+ { \
+ free ( *(fCell1) ); \
+ } \
+ } \
+ }
+
+
+ #define C2F_MAP_CELL3( caller, CCell1, fCell1, fLen1, \
+ CCell2, fCell2, fLen2, \
+ CCell3, fCell3, fLen3 ) \
+ \
+ { \
+ C2F_MAP_CELL2( caller, CCell1, fCell1, fLen1, \
+ CCell2, fCell2, fLen2 ); \
+ \
+ if ( !failed_c() ) \
+ { \
+ C2F_MAP_CELL( caller, CCell3, fCell3, fLen3 ); \
+ \
+ if ( failed_c() ) \
+ { \
+ free ( *(fCell1) ); \
+ free ( *(fCell2) ); \
+ } \
+ } \
+ }
+
+
+
+ /*
+ Macro that maps a Fortran-style character cell to a C cell
+ (Note: this macro frees the Fortran cell):
+ */
+
+ #define F2C_MAP_CELL( fCell, fLen, CCell ) \
+ \
+ { \
+ SpiceInt card; \
+ SpiceInt lenvals; \
+ SpiceInt ndim; \
+ SpiceInt nBytes; \
+ SpiceInt size; \
+ void * array; \
+ \
+ ndim = (CCell)->size + SPICE_CELL_CTRLSZ; \
+ lenvals = (CCell)->length; \
+ array = (CCell)->base; \
+ \
+ /* \
+ Capture the size and cardinality of the Fortran cell. \
+ */ \
+ if ( !failed_c() ) \
+ { \
+ size = sizec_ ( ( char * ) (fCell), \
+ ( ftnlen ) fLen ); \
+ \
+ card = cardc_ ( ( char * ) (fCell), \
+ ( ftnlen ) fLen ); \
+ } \
+ \
+ \
+ /* \
+ Copy the Fortran array into the output array. \
+ */ \
+ \
+ nBytes = ndim * fLen * sizeof(SpiceChar); \
+ memmove ( array, fCell, nBytes ); \
+ /* \
+ Convert the output array from Fortran to C style. \
+ */ \
+ F2C_ConvertTrStrArr ( ndim, lenvals, (SpiceChar *)array ); \
+ \
+ /* \
+ Sync the size and cardinality of the C cell. \
+ */ \
+ if ( !failed_c() ) \
+ { \
+ (CCell)->size = size; \
+ (CCell)->card = card; \
+ } \
+ }
+
+
+
+/*
+ End of header SpiceZmc.h
+*/
diff --git a/ext/spice/src/cspice/SpiceZpl.h b/ext/spice/src/cspice/SpiceZpl.h
new file mode 100644
index 0000000000..1413202b69
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceZpl.h
@@ -0,0 +1,109 @@
+/*
+
+-Header_File SpiceZpl.h ( CSPICE platform macros )
+
+-Abstract
+
+ Define macros identifying the host platform for which this
+ version of CSPICE is targeted.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Particulars
+
+ This header file defines macros that enable CSPICE code to be
+ compiled conditionally based on the identity of the host platform.
+
+ The macros defined here ARE visible in the macro name space of
+ any file that includes SpiceUsr.h. The names are prefixed with
+ the string CSPICE_ to help prevent conflicts with macros defined
+ by users' applications.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ B.V. Semenov (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 2.2.0, 14-MAY-2010 (EDW)(BVS)
+
+ Updated for the:
+
+ MAC-OSX-64BIT-INTEL_C
+ PC-64BIT-MS_C
+ SUN-SOLARIS-64BIT-NATIVE_C
+ SUN-SOLARIS-INTEL-64BIT-CC_C
+ SUN-SOLARIS-INTEL-CC_C
+
+ environments.
+
+ -CSPICE Version 2.1.0, 15-NOV-2006 (BVS)
+
+ Updated for MAC-OSX-INTEL_C environment.
+
+ -CSPICE Version 2.0.0, 21-FEB-2006 (NJB)
+
+ Updated for PC-LINUX-64BIT-GCC_C environment.
+
+ -CSPICE Version 1.3.0, 06-MAR-2005 (NJB)
+
+ Updated for SUN-SOLARIS-64BIT-GCC_C environment.
+
+ -CSPICE Version 1.2.0, 03-JAN-2005 (BVS)
+
+ Updated for PC-CYGWIN_C environment.
+
+ -CSPICE Version 1.1.0, 27-JUL-2002 (BVS)
+
+ Updated for MAC-OSX-NATIVE_C environment.
+
+ -CSPICE Version 1.0.0, 26-FEB-1999 (NJB) (EDW)
+
+-Index_Entries
+
+ platform ID defines for CSPICE
+
+*/
+
+
+#ifndef HAVE_PLATFORM_MACROS_H
+#define HAVE_PLATFORM_MACROS_H
+
+
+ #define CSPICE_PC_LINUX_64BIT_GCC
+
+#endif
+
diff --git a/ext/spice/src/cspice/SpiceZpr.h b/ext/spice/src/cspice/SpiceZpr.h
new file mode 100644
index 0000000000..b4d672e98c
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceZpr.h
@@ -0,0 +1,3853 @@
+/*
+
+-Header_File SpiceZpr.h ( CSPICE prototypes )
+
+-Abstract
+
+ Define prototypes for CSPICE user-interface-level functions.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Particulars
+
+ This is the header file containing prototypes for CSPICE user-level
+ C routines. Prototypes for the underlying f2c'd SPICELIB routines
+ are contained in the separate header file SpiceZfc. However, those
+ routines are not part of the official CSPICE API.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ W.L. Taber (JPL)
+ F.S. Turner (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 12.12.0, 19-FEB-2010 (EDW) (NJB)
+
+ Added prototypes for
+
+ bodc2s_c
+ dafgsr_c
+ dafrfr_c
+ dp2hx_c
+ ducrss_c
+ dvcrss_c
+ dvnorm_c
+ gfrr_c
+ gfuds_c
+ hx2dp_c
+ uddc_c
+ uddf_c
+
+ -CSPICE Version 12.11.0, 29-MAR-2009 (EDW) (NJB)
+
+ Added prototypes for
+
+ dvsep_c
+ gfbail_c
+ gfclrh_c
+ gfdist_c
+ gfevnt_c
+ gffove_c
+ gfinth_c
+ gfocce_c
+ gfoclt_c
+ gfposc_c
+ gfrefn_c
+ gfrepf_c
+ gfrepi_c
+ gfrepu_c
+ gfrfov_c
+ gfsep_c
+ gfseth_c
+ gfsntc_c
+ gfsstp_c
+ gfstep_c
+ gfsubc_c
+ gftfov_c
+ surfpv_c
+ zzgfgeth_c
+ zzgfsavh_c
+
+ -CSPICE Version 12.10.0, 30-JAN-2008 (EDW) (NJB)
+
+ Added prototypes for:
+
+ ilumin_c
+ pckcov_c
+ pckfrm_c
+ sincpt_c
+ spkacs_c
+ spkaps_c
+ spkltc_c
+ subpnt_c
+ subslr_c
+ wncard_c
+
+ -CSPICE Version 12.9.0, 16-NOV-2006 (NJB)
+
+ Bug fix: corrected prototype for vhatg_c.
+
+ Renamed wnfild_c and wnfltd_c arguments `small' to 'smal' for
+ compatibility with MS Visual C++.
+
+ Added prototypes for
+
+ dafac_c
+ dafdc_c
+ dafec_c
+ dafgda_c
+ dascls_c
+ dasopr_c
+ kclear_c
+
+ -CSPICE Version 12.8.0, 07-NOV-2005 (NJB)
+
+ Added prototypes for
+
+ bodvcd_c
+ qdq2av_c
+ qxq_c
+ srfrec_c
+
+ -CSPICE Version 12.7.0, 06-JAN-2004 (NJB)
+
+ Added prototypes for
+
+ bods2c_c
+ ckcov_c
+ ckobj_c
+ dafopw_c
+ dafrs_c
+ dpgrdr_c
+ drdpgr_c
+ lspcn_c
+ pgrrec_c
+ recpgr_c
+ spkcov_c
+ spkobj_c
+
+ -CSPICE Version 12.6.0, 24-FEB-2003 (NJB)
+
+ Added prototype for
+
+ bodvrd_c
+ deltet_c
+ srfxpt_c
+
+ -CSPICE Version 12.5.0, 14-MAY-2003 (NJB)
+
+ Removed prototype for getcml_.
+
+
+ -CSPICE Version 12.4.0, 25-FEB-2003 (NJB)
+
+ Added prototypes for
+
+ dasac_c
+ dasec_c
+ et2lst_c
+
+ -CSPICE Version 12.3.0, 03-SEP-2002 (NJB)
+
+ Added prototypes for
+
+ appndc_c
+ appndd_c
+ appndi_c
+ bschoc_c
+ bschoi_c
+ bsrchc_c
+ bsrchd_c
+ bsrchi_c
+ card_c
+ ckw05_c
+ copy_c
+ cpos_c
+ cposr_c
+ diff_c
+ elemc_c
+ elemd_c
+ elemi_c
+ esrchc_c
+ insrtc_c
+ insrtd_c
+ insrti_c
+ inter_c
+ isordv_c
+ isrchc_c
+ isrchd_c
+ isrchi_c
+ lparss_c
+ lstlec_c
+ lstled_c
+ lstlei_c
+ lstltc_c
+ lstltd_c
+ lstlti_c
+ lx4dec_c
+ lx4num_c
+ lx4sgn_c
+ lx4uns_c
+ lxqstr_c
+ ncpos_c
+ ncposr_c
+ ordc_c
+ ordd_c
+ ordi_c
+ orderc_c
+ orderd_c
+ orderi_c
+ pos_c
+ posr_c
+ prefix_c
+ remove_c
+ reordc_c
+ reordd_c
+ reordi_c
+ reordl_c
+ removc_c
+ removd_c
+ removi_c
+ repmc_c
+ repmct_c
+ repmd_c
+ repmf_c
+ repmi_c
+ repmot_c
+ scard_c
+ sdiff_c
+ set_c
+ shellc_c
+ shelld_c
+ shelli_c
+ size_c
+ scard_c
+ spkw18_c
+ ssize_c
+ union_c
+ valid_c
+ wncomd_c
+ wncond_c
+ wndifd_c
+ wnelmd_c
+ wnexpd_c
+ wnextd_c
+ wnfetd_c
+ wnfild_c
+ wnfltd_c
+ wnincd_c
+ wninsd_c
+ wnintd_c
+ wnreld_c
+ wnsumd_c
+ wnunid_c
+ wnvald_c
+ zzsynccl_c
+
+
+ -CSPICE Version 12.2.0, 23-OCT-2001 (NJB)
+
+ Added prototypes for
+
+ badkpv_c
+ dcyldr_c
+ dgeodr_c
+ dlatdr_c
+ drdcyl_c
+ drdgeo_c
+ drdlat_c
+ drdsph_c
+ dsphdr_c
+ ekacec_c
+ ekaced_c
+ ekacei_c
+ ekappr_c
+ ekbseg_c
+ ekccnt_c
+ ekcii_c
+ ekdelr_c
+ ekinsr_c
+ ekntab_c
+ ekrcec_c
+ ekrced_c
+ ekrcei_c
+ ektnam_c
+ ekucec_c
+ ekuced_c
+ ekucei_c
+ inelpl_c
+ invort_c
+ kxtrct_c
+
+ Added const qualifier to input array arguments of
+
+ conics_c
+ illum_c
+ pdpool_c
+ prop2b_c
+ q2m_c
+ spkuds_c
+ xposeg_c
+
+ Added const qualifier to the return value of
+
+ tkvrsn_c
+
+ -CSPICE Version 12.1.0, 12-APR-2000 (FST)
+
+ Added prototype for
+
+ getfov_c
+
+ -CSPICE Version 12.0.0, 22-MAR-2000 (NJB)
+
+ Added prototypes for
+
+ lparse_c
+ lparsm_c
+ spkw12_c
+ spkw13_c
+
+
+ -CSPICE Version 11.1.0, 17-DEC-1999 (WLT)
+
+ Added prototype for
+
+ dafrda_c
+
+ -CSPICE Version 11.0.0, 07-OCT-1999 (NJB) (EDW)
+
+ Changed ekaclc_c, ekacld_c, ekacli_c prototypes to make input
+ pointers const-qualified where appropriate.
+
+ Changed prompt_c prototype to accommodate memory leak bug fix.
+
+ Changed ekpsel_c prototype to be consistent with other interfaces
+ having string array outputs.
+
+ Added prototypes for
+
+ axisar_c
+ brcktd_c
+ brckti_c
+ cidfrm_c
+ cgv2el_c
+ clpool_c
+ cmprss_c
+ cnmfrm_c
+ convrt_c
+ cvpool_c
+ dafbbs_c
+ dafbfs_c
+ dafcls_c
+ dafcs_c
+ daffna_c
+ daffpa_c
+ dafgh_c
+ dafgn_c
+ dafgs_c
+ dafopr_c
+ dafps_c
+ dafus_c
+ diags2_c
+ dtpool_c
+ dvdot_c
+ dvhat_c
+ dvpool_c
+ edlimb_c
+ ekops_c
+ ekopw_c
+ eul2xf_c
+ ftncls_c
+ furnsh_c
+ getmsg_c
+ getelm_c
+ gnpool_c
+ ident_c
+ illum_c
+ inedpl_c
+ kdata_c
+ kinfo_c
+ ktotal_c
+ lmpool_c
+ matchi_c
+ matchw_c
+ maxd_c
+ maxi_c
+ mequ_c
+ mind_c
+ mini_c
+ moved_
+ npedln_c
+ npelpt_c
+ nplnpt_c
+ pcpool_c
+ pdpool_c
+ pipool_c
+ pjelpl_c
+ pxform_c
+ rav2xf_c
+ raxisa_c
+ rquad_c
+ saelgv_c
+ spk14a_c
+ spk14b_c
+ spk14e_c
+ spkapp_c
+ spkapo_c
+ spkcls_c
+ spkezp_c
+ spkgps_c
+ spkopn_c
+ spkpds_c
+ spkpos_c
+ spkssb_c
+ spksub_c
+ spkuds_c
+ spkw02_c
+ spkw03_c
+ spkw05_c
+ spkw08_c
+ spkw09_c
+ spkw10_c
+ spkw15_c
+ spkw17_c
+ stpool_c
+ subpt_c
+ subsol_c
+ swpool_c
+ szpool_c
+ tparse_c
+ trace_c
+ unload_c
+ vaddg_c
+ vhatg_c
+ vlcomg_c
+ vminug_c
+ vrel_c
+ vrelg_c
+ vsepg_c
+ vtmv_c
+ vtmvg_c
+ vzerog_c
+ xf2eul_c
+ xf2rav_c
+ xposeg_c
+
+
+ -CSPICE Version 10.0.0, 09-MAR-1999 (NJB)
+
+ Added prototypes for
+
+ frame_c
+ inrypl_c
+ nvc2pl_c
+ nvp2pl_c
+ pl2nvc_c
+ pl2nvp_c
+ pl2psv_c
+ psv2pl_c
+ sce2c_c
+ vprjp_c
+ vprjpi_c
+
+ Now conditionally includes SpiceEll.h and SpicePln.h.
+
+
+ -CSPICE Version 9.0.0, 25-FEB-1999 (NJB)
+
+ Added prototypes for
+
+ eknseg_c
+ eknelt_c
+ ekpsel_c
+ ekssum_c
+
+ Now conditionally includes SpiceEK.h.
+
+
+ -CSPICE Version 8.0.0, 20-OCT-1998 (NJB)
+
+ Added const qualifier to all input matrix and vector arguments.
+
+ Added prototypes for
+
+ det_c
+ dpmax_c
+ dpmax_
+ dpmin_c
+ dpmin_
+ frinfo_c
+ frmnam_c
+ getfat_c
+ intmax_c
+ intmax_
+ intmin_c
+ intmin_
+ invert_c
+ namfrm_c
+ vrotv_c
+ vsclg_c
+
+
+ -CSPICE Version 7.0.0, 02-APR-1998 (EDW)
+
+ Added prototypes for
+
+ mequg_c
+ unormg_g
+ vdistg_c
+ vdotg_c
+ vequg_c
+ vnormg_c
+
+ -CSPICE Version 6.0.0, 31-MAR-1998 (NJB)
+
+ Added prototypes for
+
+ ekaclc_c
+ ekacld_c
+ ekacli_c
+ ekcls_c
+ ekffld_c
+ ekfind_c
+ ekgc_c
+ ekgd_c
+ ekgi_c
+ ekifld_c
+ eklef_c
+ ekopr_c
+ ekopn_c
+ ekuef_c
+
+ -CSPICE Version 5.0.1, 05-MAR-1998 (EDW)
+
+ Remove some non printing characters.
+
+ -CSPICE Version 5.0.0, 03-MAR-1998 (NJB)
+
+ Added prototypes for
+
+ etcal_c
+ ltime_c
+ stelab_c
+ tpictr_c
+ twovec_c
+ vsubg_c
+
+ -CSPICE Version 4.0.0, 11-FEB-1998 (EDW)
+
+ Added prototypes for
+
+ timdef_c
+ tsetyr_c
+
+
+ -CSPICE Version 3.0.0, 02-FEB-1998 (NJB)
+
+ Added prototypes for
+
+ pckuof_c
+ tipbod_c
+
+ Type SpiceVoid was replaced with void.
+
+ -CSPICE Version 2.0.0, 06-JAN-1998 (NJB)
+
+ Changed all input-only character pointers to type ConstSpiceChar.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB) (KRG) (EDW)
+
+-Index_Entries
+
+ prototypes of CSPICE functions
+
+*/
+
+
+/*
+Include Files:
+*/
+
+
+#ifndef HAVE_SPICEDEFS_H
+#include "SpiceZdf.h"
+#endif
+
+#ifndef HAVE_SPICE_EK_H
+#include "SpiceEK.h"
+#endif
+
+#ifndef HAVE_SPICE_PLANES_H
+#include "SpicePln.h"
+#endif
+
+#ifndef HAVE_SPICE_ELLIPSES_H
+#include "SpiceEll.h"
+#endif
+
+#ifndef HAVE_SPICE_CELLS_H
+#include "SpiceCel.h"
+#endif
+
+#ifndef HAVE_SPICE_SPK_H
+#include "SpiceSPK.h"
+#endif
+
+#ifndef HAVE_SPICEWRAPPERS_H
+#define HAVE_SPICEWRAPPERS_H
+
+
+
+
+/*
+ Function prototypes for CSPICE functions are listed below.
+ Each prototype is accompanied by a function abstract and brief I/O
+ description.
+
+ See the headers of the C wrappers for detailed descriptions of the
+ routines' interfaces.
+
+ The list below should be maintained in alphabetical order.
+*/
+
+ void appndc_c ( ConstSpiceChar * item,
+ SpiceCell * cell );
+
+
+ void appndd_c ( SpiceDouble item,
+ SpiceCell * cell );
+
+
+ void appndi_c ( SpiceInt item,
+ SpiceCell * cell );
+
+
+ void axisar_c ( ConstSpiceDouble axis [3],
+ SpiceDouble angle,
+ SpiceDouble r [3][3] );
+
+
+ SpiceBoolean badkpv_c ( ConstSpiceChar *caller,
+ ConstSpiceChar *name,
+ ConstSpiceChar *comp,
+ SpiceInt size,
+ SpiceInt divby,
+ SpiceChar type );
+
+
+ void bodc2n_c ( SpiceInt code,
+ SpiceInt namelen,
+ SpiceChar * name,
+ SpiceBoolean * found );
+
+
+ void bodc2s_c ( SpiceInt code,
+ SpiceInt lenout,
+ SpiceChar * name );
+
+ void boddef_c ( ConstSpiceChar * name,
+ SpiceInt code );
+
+
+ SpiceBoolean bodfnd_c ( SpiceInt body,
+ ConstSpiceChar * item );
+
+
+ void bodn2c_c ( ConstSpiceChar * name,
+ SpiceInt * code,
+ SpiceBoolean * found );
+
+
+ void bods2c_c ( ConstSpiceChar * name,
+ SpiceInt * code,
+ SpiceBoolean * found );
+
+
+ void bodvar_c ( SpiceInt body,
+ ConstSpiceChar * item,
+ SpiceInt * dim ,
+ SpiceDouble * values );
+
+
+ void bodvcd_c ( SpiceInt body,
+ ConstSpiceChar * item,
+ SpiceInt maxn,
+ SpiceInt * dim ,
+ SpiceDouble * values );
+
+
+ void bodvrd_c ( ConstSpiceChar * body,
+ ConstSpiceChar * item,
+ SpiceInt maxn,
+ SpiceInt * dim ,
+ SpiceDouble * values );
+
+
+ SpiceDouble brcktd_c ( SpiceDouble number,
+ SpiceDouble end1,
+ SpiceDouble end2 );
+
+
+ SpiceInt brckti_c ( SpiceInt number,
+ SpiceInt end1,
+ SpiceInt end2 );
+
+
+ SpiceInt bschoc_c ( ConstSpiceChar * value,
+ SpiceInt ndim,
+ SpiceInt lenvals,
+ const void * array,
+ ConstSpiceInt * order );
+
+
+ SpiceInt bschoi_c ( SpiceInt value,
+ SpiceInt ndim,
+ ConstSpiceInt * array,
+ ConstSpiceInt * order );
+
+
+ SpiceInt bsrchc_c ( ConstSpiceChar * value,
+ SpiceInt ndim,
+ SpiceInt lenvals,
+ const void * array );
+
+
+ SpiceInt bsrchd_c ( SpiceDouble value,
+ SpiceInt ndim,
+ ConstSpiceDouble * array );
+
+
+ SpiceInt bsrchi_c ( SpiceInt value,
+ SpiceInt ndim,
+ ConstSpiceInt * array );
+
+
+ SpiceDouble b1900_c ( void );
+
+
+ SpiceDouble b1950_c ( void );
+
+
+ SpiceInt card_c ( SpiceCell * cell );
+
+
+ void cgv2el_c ( ConstSpiceDouble center[3],
+ ConstSpiceDouble vec1 [3],
+ ConstSpiceDouble vec2 [3],
+ SpiceEllipse * ellipse );
+
+
+ void chkin_c ( ConstSpiceChar * module );
+
+
+ void chkout_c ( ConstSpiceChar * module );
+
+
+ void cidfrm_c ( SpiceInt cent,
+ SpiceInt lenout,
+ SpiceInt * frcode,
+ SpiceChar * frname,
+ SpiceBoolean * found );
+
+
+ void ckcls_c ( SpiceInt handle );
+
+
+ void ckcov_c ( ConstSpiceChar * ck,
+ SpiceInt idcode,
+ SpiceBoolean needav,
+ ConstSpiceChar * level,
+ SpiceDouble tol,
+ ConstSpiceChar * timsys,
+ SpiceCell * cover );
+
+
+ void ckobj_c ( ConstSpiceChar * ck,
+ SpiceCell * ids );
+
+
+ void ckgp_c ( SpiceInt inst,
+ SpiceDouble sclkdp,
+ SpiceDouble tol,
+ ConstSpiceChar * ref,
+ SpiceDouble cmat[3][3],
+ SpiceDouble * clkout,
+ SpiceBoolean * found );
+
+
+ void ckgpav_c ( SpiceInt inst,
+ SpiceDouble sclkdp,
+ SpiceDouble tol,
+ ConstSpiceChar * ref,
+ SpiceDouble cmat[3][3],
+ SpiceDouble av[3],
+ SpiceDouble * clkout,
+ SpiceBoolean * found );
+
+
+ void cklpf_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void ckopn_c ( ConstSpiceChar * name,
+ ConstSpiceChar * ifname,
+ SpiceInt ncomch,
+ SpiceInt * handle );
+
+
+ void ckupf_c ( SpiceInt handle );
+
+
+ void ckw01_c ( SpiceInt handle,
+ SpiceDouble begtime,
+ SpiceDouble endtime,
+ SpiceInt inst,
+ ConstSpiceChar * ref,
+ SpiceBoolean avflag,
+ ConstSpiceChar * segid,
+ SpiceInt nrec,
+ ConstSpiceDouble sclkdp [],
+ ConstSpiceDouble quats [][4],
+ ConstSpiceDouble avvs [][3] );
+
+
+ void ckw02_c ( SpiceInt handle,
+ SpiceDouble begtim,
+ SpiceDouble endtim,
+ SpiceInt inst,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * segid,
+ SpiceInt nrec,
+ ConstSpiceDouble start [],
+ ConstSpiceDouble stop [],
+ ConstSpiceDouble quats [][4],
+ ConstSpiceDouble avvs [][3],
+ ConstSpiceDouble rates [] );
+
+
+ void ckw03_c ( SpiceInt handle,
+ SpiceDouble begtim,
+ SpiceDouble endtim,
+ SpiceInt inst,
+ ConstSpiceChar * ref,
+ SpiceBoolean avflag,
+ ConstSpiceChar * segid,
+ SpiceInt nrec,
+ ConstSpiceDouble sclkdp [],
+ ConstSpiceDouble quats [][4],
+ ConstSpiceDouble avvs [][3],
+ SpiceInt nints,
+ ConstSpiceDouble starts [] );
+
+
+ void ckw05_c ( SpiceInt handle,
+ SpiceCK05Subtype subtyp,
+ SpiceInt degree,
+ SpiceDouble begtim,
+ SpiceDouble endtim,
+ SpiceInt inst,
+ ConstSpiceChar * ref,
+ SpiceBoolean avflag,
+ ConstSpiceChar * segid,
+ SpiceInt n,
+ ConstSpiceDouble sclkdp[],
+ const void * packets,
+ SpiceDouble rate,
+ SpiceInt nints,
+ ConstSpiceDouble starts[] );
+
+
+ SpiceDouble clight_c ( void );
+
+
+ void clpool_c ( void );
+
+
+ void cmprss_c ( SpiceChar delim,
+ SpiceInt n,
+ ConstSpiceChar * input,
+ SpiceInt lenout,
+ SpiceChar * output );
+
+
+ void cnmfrm_c ( ConstSpiceChar * cname,
+ SpiceInt lenout,
+ SpiceInt * frcode,
+ SpiceChar * frname,
+ SpiceBoolean * found );
+
+
+ void conics_c ( ConstSpiceDouble elts[8],
+ SpiceDouble et,
+ SpiceDouble state[6] );
+
+
+ void convrt_c ( SpiceDouble x,
+ ConstSpiceChar * in,
+ ConstSpiceChar * out,
+ SpiceDouble * y );
+
+
+ void copy_c ( SpiceCell * a,
+ SpiceCell * b );
+
+
+
+ SpiceInt cpos_c ( ConstSpiceChar * str,
+ ConstSpiceChar * chars,
+ SpiceInt start );
+
+
+ SpiceInt cposr_c ( ConstSpiceChar * str,
+ ConstSpiceChar * chars,
+ SpiceInt start );
+
+
+ void cvpool_c ( ConstSpiceChar * agent,
+ SpiceBoolean * update );
+
+
+ void cyllat_c ( SpiceDouble r,
+ SpiceDouble lonc,
+ SpiceDouble z,
+ SpiceDouble * radius,
+ SpiceDouble * lon,
+ SpiceDouble * lat );
+
+
+ void cylrec_c ( SpiceDouble r,
+ SpiceDouble lon,
+ SpiceDouble z,
+ SpiceDouble rectan[3] );
+
+
+ void cylsph_c ( SpiceDouble r,
+ SpiceDouble lonc,
+ SpiceDouble z,
+ SpiceDouble * radius,
+ SpiceDouble * colat,
+ SpiceDouble * lon );
+
+
+ void dafac_c ( SpiceInt handle,
+ SpiceInt n,
+ SpiceInt lenvals,
+ const void * buffer );
+
+
+ void dafbbs_c ( SpiceInt handle );
+
+
+ void dafbfs_c ( SpiceInt handle );
+
+
+ void dafcls_c ( SpiceInt handle );
+
+
+ void dafcs_c ( SpiceInt handle );
+
+
+ void dafdc_c ( SpiceInt handle );
+
+
+ void dafec_c ( SpiceInt handle,
+ SpiceInt bufsiz,
+ SpiceInt lenout,
+ SpiceInt * n,
+ void * buffer,
+ SpiceBoolean * done );
+
+
+ void daffna_c ( SpiceBoolean * found );
+
+
+ void daffpa_c ( SpiceBoolean * found );
+
+
+ void dafgda_c ( SpiceInt handle,
+ SpiceInt begin,
+ SpiceInt end,
+ SpiceDouble * data );
+
+
+ void dafgh_c ( SpiceInt * handle );
+
+
+ void dafgn_c ( SpiceInt lenout,
+ SpiceChar * name );
+
+
+ void dafgs_c ( SpiceDouble sum[] );
+
+
+ void dafgsr_c ( SpiceInt handle,
+ SpiceInt recno,
+ SpiceInt begin,
+ SpiceInt end,
+ SpiceDouble * data,
+ SpiceBoolean * found );
+
+
+ void dafopr_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void dafopw_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void dafps_c ( SpiceInt nd,
+ SpiceInt ni,
+ ConstSpiceDouble dc [],
+ ConstSpiceInt ic [],
+ SpiceDouble sum [] );
+
+
+ void dafrda_c ( SpiceInt handle,
+ SpiceInt begin,
+ SpiceInt end,
+ SpiceDouble * data );
+
+
+
+ void dafrfr_c ( SpiceInt handle,
+ SpiceInt lenout,
+ SpiceInt * nd,
+ SpiceInt * ni,
+ SpiceChar * ifname,
+ SpiceInt * fward,
+ SpiceInt * bward,
+ SpiceInt * free );
+
+
+
+ void dafrs_c ( ConstSpiceDouble * sum );
+
+
+ void dafus_c ( ConstSpiceDouble sum [],
+ SpiceInt nd,
+ SpiceInt ni,
+ SpiceDouble dc [],
+ SpiceInt ic [] );
+
+
+ void dasac_c ( SpiceInt handle,
+ SpiceInt n,
+ SpiceInt buflen,
+ const void * buffer );
+
+
+ void dascls_c ( SpiceInt handle );
+
+
+ void dasec_c ( SpiceInt handle,
+ SpiceInt bufsiz,
+ SpiceInt buflen,
+ SpiceInt * n,
+ void * buffer,
+ SpiceBoolean * done );
+
+
+ void dasopr_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void dcyldr_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble jacobi[3][3] );
+
+
+ void deltet_c ( SpiceDouble epoch,
+ ConstSpiceChar * eptype,
+ SpiceDouble * delta );
+
+
+ SpiceDouble det_c ( ConstSpiceDouble m1[3][3] );
+
+
+ void diags2_c ( ConstSpiceDouble symmat [2][2],
+ SpiceDouble diag [2][2],
+ SpiceDouble rotate [2][2] );
+
+
+ void diff_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ void dgeodr_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble jacobi[3][3] );
+
+
+ void dlatdr_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble jacobi[3][3] );
+
+ void dp2hx_c ( SpiceDouble number,
+ SpiceInt lenout,
+ SpiceChar * string,
+ SpiceInt * length
+ );
+
+ void dpgrdr_c ( ConstSpiceChar * body,
+ SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble jacobi[3][3] );
+
+
+ SpiceDouble dpmax_c ( void );
+
+
+ SpiceDouble dpmax_ ( void );
+
+
+ SpiceDouble dpmin_c ( void );
+
+
+ SpiceDouble dpmin_ ( void );
+
+
+ SpiceDouble dpr_c ( void );
+
+
+ void drdcyl_c ( SpiceDouble r,
+ SpiceDouble lon,
+ SpiceDouble z,
+ SpiceDouble jacobi[3][3] );
+
+
+ void drdgeo_c ( SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble alt,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble jacobi[3][3] );
+
+
+ void drdlat_c ( SpiceDouble r,
+ SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble jacobi[3][3] );
+
+
+ void drdpgr_c ( ConstSpiceChar * body,
+ SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble alt,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble jacobi[3][3] );
+
+
+ void drdsph_c ( SpiceDouble r,
+ SpiceDouble colat,
+ SpiceDouble lon,
+ SpiceDouble jacobi[3][3] );
+
+
+ void dsphdr_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble jacobi[3][3] );
+
+
+ void dtpool_c ( ConstSpiceChar * name,
+ SpiceBoolean * found,
+ SpiceInt * n,
+ SpiceChar type [1] );
+
+
+ void ducrss_c ( ConstSpiceDouble s1 [6],
+ ConstSpiceDouble s2 [6],
+ SpiceDouble sout[6] );
+
+
+ void dvcrss_c ( ConstSpiceDouble s1 [6],
+ ConstSpiceDouble s2 [6],
+ SpiceDouble sout[6] );
+
+
+ SpiceDouble dvdot_c ( ConstSpiceDouble s1 [6],
+ ConstSpiceDouble s2 [6] );
+
+
+ void dvhat_c ( ConstSpiceDouble s1 [6],
+ SpiceDouble sout[6] );
+
+ SpiceDouble dvnorm_c ( ConstSpiceDouble state[6] );
+
+ void dvpool_c ( ConstSpiceChar * name );
+
+
+ SpiceDouble dvsep_c ( ConstSpiceDouble * s1,
+ ConstSpiceDouble * s2 );
+
+
+ void edlimb_c ( SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ ConstSpiceDouble viewpt[3],
+ SpiceEllipse * limb );
+
+
+ void ekacec_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt nvals,
+ SpiceInt vallen,
+ const void * cvals,
+ SpiceBoolean isnull );
+
+
+ void ekaced_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt nvals,
+ ConstSpiceDouble * dvals,
+ SpiceBoolean isnull );
+
+
+ void ekacei_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt nvals,
+ ConstSpiceInt * ivals,
+ SpiceBoolean isnull );
+
+
+ void ekaclc_c ( SpiceInt handle,
+ SpiceInt segno,
+ ConstSpiceChar * column,
+ SpiceInt vallen,
+ const void * cvals,
+ ConstSpiceInt * entszs,
+ ConstSpiceBoolean * nlflgs,
+ ConstSpiceInt * rcptrs,
+ SpiceInt * wkindx );
+
+
+ void ekacld_c ( SpiceInt handle,
+ SpiceInt segno,
+ ConstSpiceChar * column,
+ ConstSpiceDouble * dvals,
+ ConstSpiceInt * entszs,
+ ConstSpiceBoolean * nlflgs,
+ ConstSpiceInt * rcptrs,
+ SpiceInt * wkindx );
+
+
+ void ekacli_c ( SpiceInt handle,
+ SpiceInt segno,
+ ConstSpiceChar * column,
+ ConstSpiceInt * ivals,
+ ConstSpiceInt * entszs,
+ ConstSpiceBoolean * nlflgs,
+ ConstSpiceInt * rcptrs,
+ SpiceInt * wkindx );
+
+
+ void ekappr_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt * recno );
+
+
+ void ekbseg_c ( SpiceInt handle,
+ ConstSpiceChar * tabnam,
+ SpiceInt ncols,
+ SpiceInt cnmlen,
+ const void * cnames,
+ SpiceInt declen,
+ const void * decls,
+ SpiceInt * segno );
+
+
+ void ekccnt_c ( ConstSpiceChar * table,
+ SpiceInt * ccount );
+
+
+ void ekcii_c ( ConstSpiceChar * table,
+ SpiceInt cindex,
+ SpiceInt lenout,
+ SpiceChar * column,
+ SpiceEKAttDsc * attdsc );
+
+
+ void ekcls_c ( SpiceInt handle );
+
+
+ void ekdelr_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno );
+
+
+ void ekffld_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt * rcptrs );
+
+
+ void ekfind_c ( ConstSpiceChar * query,
+ SpiceInt lenout,
+ SpiceInt * nmrows,
+ SpiceBoolean * error,
+ SpiceChar * errmsg );
+
+
+ void ekgc_c ( SpiceInt selidx,
+ SpiceInt row,
+ SpiceInt elment,
+ SpiceInt lenout,
+ SpiceChar * cdata,
+ SpiceBoolean * null,
+ SpiceBoolean * found );
+
+
+ void ekgd_c ( SpiceInt selidx,
+ SpiceInt row,
+ SpiceInt elment,
+ SpiceDouble * ddata,
+ SpiceBoolean * null,
+ SpiceBoolean * found );
+
+
+ void ekgi_c ( SpiceInt selidx,
+ SpiceInt row,
+ SpiceInt elment,
+ SpiceInt * idata,
+ SpiceBoolean * null,
+ SpiceBoolean * found );
+
+
+ void ekifld_c ( SpiceInt handle,
+ ConstSpiceChar * tabnam,
+ SpiceInt ncols,
+ SpiceInt nrows,
+ SpiceInt cnmlen,
+ const void * cnames,
+ SpiceInt declen,
+ const void * decls,
+ SpiceInt * segno,
+ SpiceInt * rcptrs );
+
+
+ void ekinsr_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno );
+
+
+ void eklef_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ SpiceInt eknelt_c ( SpiceInt selidx,
+ SpiceInt row );
+
+
+ SpiceInt eknseg_c ( SpiceInt handle );
+
+
+ void ekntab_c ( SpiceInt * n );
+
+
+ void ekopn_c ( ConstSpiceChar * fname,
+ ConstSpiceChar * ifname,
+ SpiceInt ncomch,
+ SpiceInt * handle );
+
+
+ void ekopr_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void ekops_c ( SpiceInt * handle );
+
+
+ void ekopw_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void ekpsel_c ( ConstSpiceChar * query,
+ SpiceInt msglen,
+ SpiceInt tablen,
+ SpiceInt collen,
+ SpiceInt * n,
+ SpiceInt * xbegs,
+ SpiceInt * xends,
+ SpiceEKDataType * xtypes,
+ SpiceEKExprClass * xclass,
+ void * tabs,
+ void * cols,
+ SpiceBoolean * error,
+ SpiceChar * errmsg );
+
+
+ void ekrcec_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt lenout,
+ SpiceInt * nvals,
+ void * cvals,
+ SpiceBoolean * isnull );
+
+
+ void ekrced_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt * nvals,
+ SpiceDouble * dvals,
+ SpiceBoolean * isnull );
+
+
+ void ekrcei_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt * nvals,
+ SpiceInt * ivals,
+ SpiceBoolean * isnull );
+
+
+ void ekssum_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceEKSegSum * segsum );
+
+
+ void ektnam_c ( SpiceInt n,
+ SpiceInt lenout,
+ SpiceChar * table );
+
+
+ void ekucec_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt nvals,
+ SpiceInt vallen,
+ const void * cvals,
+ SpiceBoolean isnull );
+
+
+ void ekuced_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt nvals,
+ ConstSpiceDouble * dvals,
+ SpiceBoolean isnull );
+
+
+ void ekucei_c ( SpiceInt handle,
+ SpiceInt segno,
+ SpiceInt recno,
+ ConstSpiceChar * column,
+ SpiceInt nvals,
+ ConstSpiceInt * ivals,
+ SpiceBoolean isnull );
+
+
+ void ekuef_c ( SpiceInt handle );
+
+
+ SpiceBoolean elemc_c ( ConstSpiceChar * item,
+ SpiceCell * set );
+
+
+ SpiceBoolean elemd_c ( SpiceDouble item,
+ SpiceCell * set );
+
+
+ SpiceBoolean elemi_c ( SpiceInt item,
+ SpiceCell * set );
+
+
+ SpiceBoolean eqstr_c ( ConstSpiceChar * a,
+ ConstSpiceChar * b );
+
+
+ void el2cgv_c ( ConstSpiceEllipse * ellipse,
+ SpiceDouble center[3],
+ SpiceDouble smajor[3],
+ SpiceDouble sminor[3] );
+
+
+ void erract_c ( ConstSpiceChar * operation,
+ SpiceInt lenout,
+ SpiceChar * action );
+
+
+ void errch_c ( ConstSpiceChar * marker,
+ ConstSpiceChar * string );
+
+
+ void errdev_c ( ConstSpiceChar * operation,
+ SpiceInt lenout,
+ SpiceChar * device );
+
+
+ void errdp_c ( ConstSpiceChar * marker,
+ SpiceDouble number );
+
+
+ void errint_c ( ConstSpiceChar * marker,
+ SpiceInt number );
+
+
+ void errprt_c ( ConstSpiceChar * operation,
+ SpiceInt lenout,
+ SpiceChar * list );
+
+
+ SpiceInt esrchc_c ( ConstSpiceChar * value,
+ SpiceInt ndim,
+ SpiceInt lenvals,
+ const void * array );
+
+
+ void etcal_c ( SpiceDouble et,
+ SpiceInt lenout,
+ SpiceChar * string );
+
+
+ void et2lst_c ( SpiceDouble et,
+ SpiceInt body,
+ SpiceDouble lon,
+ ConstSpiceChar * type,
+ SpiceInt timlen,
+ SpiceInt ampmlen,
+ SpiceInt * hr,
+ SpiceInt * mn,
+ SpiceInt * sc,
+ SpiceChar * time,
+ SpiceChar * ampm );
+
+
+ void et2utc_c ( SpiceDouble et ,
+ ConstSpiceChar * format,
+ SpiceInt prec,
+ SpiceInt lenout,
+ SpiceChar * utcstr );
+
+
+ void eul2m_c ( SpiceDouble angle3,
+ SpiceDouble angle2,
+ SpiceDouble angle1,
+ SpiceInt axis3,
+ SpiceInt axis2,
+ SpiceInt axis1,
+ SpiceDouble r [3][3] );
+
+
+ void eul2xf_c ( ConstSpiceDouble eulang[6],
+ SpiceInt axisa,
+ SpiceInt axisb,
+ SpiceInt axisc,
+ SpiceDouble xform [6][6] );
+
+
+ SpiceBoolean exists_c ( ConstSpiceChar * name );
+
+
+ void expool_c ( ConstSpiceChar * name,
+ SpiceBoolean * found );
+
+
+ SpiceBoolean failed_c ( void );
+
+
+ void frame_c ( SpiceDouble x[3],
+ SpiceDouble y[3],
+ SpiceDouble z[3] );
+
+
+ void frinfo_c ( SpiceInt frcode,
+ SpiceInt * cent,
+ SpiceInt * clss,
+ SpiceInt * clssid,
+ SpiceBoolean * found );
+
+
+ void frmnam_c ( SpiceInt frcode,
+ SpiceInt lenout,
+ SpiceChar * frname );
+
+
+ void ftncls_c ( SpiceInt unit );
+
+
+ void furnsh_c ( ConstSpiceChar * file );
+
+
+ void gcpool_c ( ConstSpiceChar * name,
+ SpiceInt start,
+ SpiceInt room,
+ SpiceInt lenout,
+ SpiceInt * n,
+ void * cvals,
+ SpiceBoolean * found );
+
+
+ void gdpool_c ( ConstSpiceChar * name,
+ SpiceInt start,
+ SpiceInt room,
+ SpiceInt * n,
+ SpiceDouble * values,
+ SpiceBoolean * found );
+
+
+ void georec_c ( SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble alt,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble rectan[3] );
+
+
+ void getcml_c ( SpiceInt * argc,
+ SpiceChar *** argv );
+
+
+ void getelm_c ( SpiceInt frstyr,
+ SpiceInt lineln,
+ const void * lines,
+ SpiceDouble * epoch,
+ SpiceDouble * elems );
+
+
+ void getfat_c ( ConstSpiceChar * file,
+ SpiceInt arclen,
+ SpiceInt typlen,
+ SpiceChar * arch,
+ SpiceChar * type );
+
+
+ void getfov_c ( SpiceInt instid,
+ SpiceInt room,
+ SpiceInt shapelen,
+ SpiceInt framelen,
+ SpiceChar * shape,
+ SpiceChar * frame,
+ SpiceDouble bsight [3],
+ SpiceInt * n,
+ SpiceDouble bounds [][3] );
+
+
+ void getmsg_c ( ConstSpiceChar * option,
+ SpiceInt lenout,
+ SpiceChar * msg );
+
+
+ SpiceBoolean gfbail_c ( void );
+
+
+ void gfclrh_c ( void );
+
+
+ void gfdist_c ( ConstSpiceChar * target,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+
+ void gfevnt_c ( void ( * udstep ) ( SpiceDouble et,
+ SpiceDouble * step ),
+
+ void ( * udrefn ) ( SpiceDouble t1,
+ SpiceDouble t2,
+ SpiceBoolean s1,
+ SpiceBoolean s2,
+ SpiceDouble * t ),
+ ConstSpiceChar * gquant,
+ SpiceInt qnpars,
+ SpiceInt lenvals,
+ const void * qpnams,
+ const void * qcpars,
+ ConstSpiceDouble * qdpars,
+ ConstSpiceInt * qipars,
+ ConstSpiceBoolean * qlpars,
+ ConstSpiceChar * op,
+ SpiceDouble refval,
+ SpiceDouble tol,
+ SpiceDouble adjust,
+ SpiceBoolean rpt,
+
+ void ( * udrepi ) ( SpiceCell * cnfine,
+ ConstSpiceChar * srcpre,
+ ConstSpiceChar * srcsuf ),
+
+ void ( * udrepu ) ( SpiceDouble ivbeg,
+ SpiceDouble ivend,
+ SpiceDouble et ),
+
+ void ( * udrepf ) ( void ),
+ SpiceInt nintvls,
+ SpiceBoolean bail,
+ SpiceBoolean ( * udbail ) ( void ),
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+
+ void gffove_c ( ConstSpiceChar * inst,
+ ConstSpiceChar * tshape,
+ ConstSpiceDouble raydir [3],
+ ConstSpiceChar * target,
+ ConstSpiceChar * tframe,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble tol,
+ void ( * udstep ) ( SpiceDouble et,
+ SpiceDouble * step ),
+ void ( * udrefn ) ( SpiceDouble t1,
+ SpiceDouble t2,
+ SpiceBoolean s1,
+ SpiceBoolean s2,
+ SpiceDouble * t ),
+ SpiceBoolean rpt,
+ void ( * udrepi ) ( SpiceCell * cnfine,
+ ConstSpiceChar * srcpre,
+ ConstSpiceChar * srcsuf ),
+ void ( * udrepu ) ( SpiceDouble ivbeg,
+ SpiceDouble ivend,
+ SpiceDouble et ),
+ void ( * udrepf ) ( void ),
+ SpiceBoolean bail,
+ SpiceBoolean ( * udbail ) ( void ),
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfinth_c ( int sigcode );
+
+
+ void gfocce_c ( ConstSpiceChar * occtyp,
+ ConstSpiceChar * front,
+ ConstSpiceChar * fshape,
+ ConstSpiceChar * fframe,
+ ConstSpiceChar * back,
+ ConstSpiceChar * bshape,
+ ConstSpiceChar * bframe,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * abcorr,
+ SpiceDouble tol,
+ void ( * udstep ) ( SpiceDouble et,
+ SpiceDouble * step ),
+ void ( * udrefn ) ( SpiceDouble t1,
+ SpiceDouble t2,
+ SpiceBoolean s1,
+ SpiceBoolean s2,
+ SpiceDouble * t ),
+ SpiceBoolean rpt,
+ void ( * udrepi ) ( SpiceCell * cnfine,
+ ConstSpiceChar * srcpre,
+ ConstSpiceChar * srcsuf ),
+ void ( * udrepu ) ( SpiceDouble ivbeg,
+ SpiceDouble ivend,
+ SpiceDouble et ),
+ void ( * udrepf ) ( void ),
+ SpiceBoolean bail,
+ SpiceBoolean ( * udbail ) ( void ),
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+
+ void gfoclt_c ( ConstSpiceChar * occtyp,
+ ConstSpiceChar * front,
+ ConstSpiceChar * fshape,
+ ConstSpiceChar * fframe,
+ ConstSpiceChar * back,
+ ConstSpiceChar * bshape,
+ ConstSpiceChar * bframe,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * abcorr,
+ SpiceDouble step,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfposc_c ( ConstSpiceChar * target,
+ ConstSpiceChar * frame,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * crdsys,
+ ConstSpiceChar * coord,
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfrefn_c ( SpiceDouble t1,
+ SpiceDouble t2,
+ SpiceBoolean s1,
+ SpiceBoolean s2,
+ SpiceDouble * t );
+
+
+ void gfrepf_c ( void );
+
+
+ void gfrepi_c ( SpiceCell * window,
+ ConstSpiceChar * begmss,
+ ConstSpiceChar * endmss );
+
+
+ void gfrepu_c ( SpiceDouble ivbeg,
+ SpiceDouble ivend,
+ SpiceDouble time );
+
+
+ void gfrfov_c ( ConstSpiceChar * inst,
+ ConstSpiceDouble raydir [3],
+ ConstSpiceChar * rframe,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble step,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfrr_c ( ConstSpiceChar * target,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfsep_c ( ConstSpiceChar * targ1,
+ ConstSpiceChar * frame1,
+ ConstSpiceChar * shape1,
+ ConstSpiceChar * targ2,
+ ConstSpiceChar * frame2,
+ ConstSpiceChar * shape2,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfsntc_c ( ConstSpiceChar * target,
+ ConstSpiceChar * fixref,
+ ConstSpiceChar * method,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * dref,
+ ConstSpiceDouble dvec [3],
+ ConstSpiceChar * crdsys,
+ ConstSpiceChar * coord,
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfsstp_c ( SpiceDouble step );
+
+
+ void gfstep_c ( SpiceDouble time,
+ SpiceDouble * step );
+
+
+ void gfsubc_c ( ConstSpiceChar * target,
+ ConstSpiceChar * fixref,
+ ConstSpiceChar * method,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * crdsys,
+ ConstSpiceChar * coord,
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gftfov_c ( ConstSpiceChar * inst,
+ ConstSpiceChar * target,
+ ConstSpiceChar * tshape,
+ ConstSpiceChar * tframe,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble step,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gfuds_c ( void ( * udfunc ) ( SpiceDouble x,
+ SpiceDouble * value ),
+
+ void ( * udqdec ) ( void ( * udfunc )
+ ( SpiceDouble x,
+ SpiceDouble * value ),
+
+ SpiceDouble x,
+ SpiceBoolean * isdecr ),
+
+ ConstSpiceChar * relate,
+ SpiceDouble refval,
+ SpiceDouble adjust,
+ SpiceDouble step,
+ SpiceInt nintvls,
+ SpiceCell * cnfine,
+ SpiceCell * result );
+
+
+ void gipool_c ( ConstSpiceChar * name,
+ SpiceInt start,
+ SpiceInt room,
+ SpiceInt * n,
+ SpiceInt * ivals,
+ SpiceBoolean * found );
+
+
+ void gnpool_c ( ConstSpiceChar * name,
+ SpiceInt start,
+ SpiceInt room,
+ SpiceInt lenout,
+ SpiceInt * n,
+ void * kvars,
+ SpiceBoolean * found );
+
+
+ SpiceDouble halfpi_c ( void );
+
+ void hx2dp_c ( ConstSpiceChar * string,
+ SpiceInt lenout,
+ SpiceDouble * number,
+ SpiceBoolean * error,
+ SpiceChar * errmsg
+ );
+
+
+ void ident_c ( SpiceDouble matrix[3][3] );
+
+
+ void ilumin_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * fixref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceDouble spoint [3],
+ SpiceDouble * trgepc,
+ SpiceDouble srfvec [3],
+ SpiceDouble * phase,
+ SpiceDouble * solar,
+ SpiceDouble * emissn );
+
+
+ void illum_c ( ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceDouble spoint [3],
+ SpiceDouble * phase,
+ SpiceDouble * solar,
+ SpiceDouble * emissn );
+
+
+ void inedpl_c ( SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ ConstSpicePlane * plane,
+ SpiceEllipse * ellipse,
+ SpiceBoolean * found );
+
+
+ void inelpl_c ( ConstSpiceEllipse * ellips,
+ ConstSpicePlane * plane,
+ SpiceInt * nxpts,
+ SpiceDouble xpt1[3],
+ SpiceDouble xpt2[3] );
+
+
+ void insrtc_c ( ConstSpiceChar * item,
+ SpiceCell * set );
+
+
+ void insrtd_c ( SpiceDouble item,
+ SpiceCell * set );
+
+
+ void insrti_c ( SpiceInt item,
+ SpiceCell * set );
+
+
+ void inter_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ void inrypl_c ( ConstSpiceDouble vertex [3],
+ ConstSpiceDouble dir [3],
+ ConstSpicePlane * plane,
+ SpiceInt * nxpts,
+ SpiceDouble xpt [3] );
+
+
+ SpiceInt intmax_c ( void );
+
+
+ SpiceInt intmax_ ( void );
+
+
+ SpiceInt intmin_c ( void );
+
+
+ SpiceInt intmin_ ( void );
+
+
+ void invert_c ( ConstSpiceDouble m1[3][3],
+ SpiceDouble m2[3][3] );
+
+
+ void invort_c ( ConstSpiceDouble m [3][3],
+ SpiceDouble mit[3][3] );
+
+
+ SpiceBoolean isordv_c ( ConstSpiceInt * array,
+ SpiceInt n );
+
+
+ SpiceBoolean isrot_c ( ConstSpiceDouble m [3][3],
+ SpiceDouble ntol,
+ SpiceDouble dtol );
+
+
+
+ SpiceInt isrchc_c ( ConstSpiceChar * value,
+ SpiceInt ndim,
+ SpiceInt lenvals,
+ const void * array );
+
+
+ SpiceInt isrchd_c ( SpiceDouble value,
+ SpiceInt ndim,
+ ConstSpiceDouble * array );
+
+
+ SpiceInt isrchi_c ( SpiceInt value,
+ SpiceInt ndim,
+ ConstSpiceInt * array );
+
+
+ SpiceBoolean iswhsp_c ( ConstSpiceChar * string );
+
+
+ SpiceDouble j1900_c ( void );
+
+
+ SpiceDouble j1950_c ( void );
+
+
+ SpiceDouble j2000_c ( void );
+
+
+ SpiceDouble j2100_c ( void );
+
+
+ SpiceDouble jyear_c ( void );
+
+
+ void kclear_c ( void );
+
+
+ void kdata_c ( SpiceInt which,
+ ConstSpiceChar * kind,
+ SpiceInt fillen,
+ SpiceInt typlen,
+ SpiceInt srclen,
+ SpiceChar * file,
+ SpiceChar * filtyp,
+ SpiceChar * source,
+ SpiceInt * handle,
+ SpiceBoolean * found );
+
+
+ void kinfo_c ( ConstSpiceChar * file,
+ SpiceInt typlen,
+ SpiceInt srclen,
+ SpiceChar * filtyp,
+ SpiceChar * source,
+ SpiceInt * handle,
+ SpiceBoolean * found );
+
+
+ void ktotal_c ( ConstSpiceChar * kind,
+ SpiceInt * count );
+
+
+ void kxtrct_c ( ConstSpiceChar * keywd,
+ SpiceInt termlen,
+ const void * terms,
+ SpiceInt nterms,
+ SpiceInt stringlen,
+ SpiceInt substrlen,
+ SpiceChar * string,
+ SpiceBoolean * found,
+ SpiceChar * substr );
+
+
+ SpiceInt lastnb_c ( ConstSpiceChar * string );
+
+
+ void latcyl_c ( SpiceDouble radius,
+ SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble * r,
+ SpiceDouble * lonc,
+ SpiceDouble * z );
+
+
+ void latrec_c ( SpiceDouble radius,
+ SpiceDouble longitude,
+ SpiceDouble latitude,
+ SpiceDouble rectan [3] );
+
+
+ void latsph_c ( SpiceDouble radius,
+ SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble * rho,
+ SpiceDouble * colat,
+ SpiceDouble * lons );
+
+
+ void lcase_c ( SpiceChar * in,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void ldpool_c ( ConstSpiceChar * filename );
+
+
+ void lmpool_c ( const void * cvals,
+ SpiceInt lenvals,
+ SpiceInt n );
+
+
+ void lparse_c ( ConstSpiceChar * list,
+ ConstSpiceChar * delim,
+ SpiceInt nmax,
+ SpiceInt lenout,
+ SpiceInt * n,
+ void * items );
+
+
+ void lparsm_c ( ConstSpiceChar * list,
+ ConstSpiceChar * delims,
+ SpiceInt nmax,
+ SpiceInt lenout,
+ SpiceInt * n,
+ void * items );
+
+
+ void lparss_c ( ConstSpiceChar * list,
+ ConstSpiceChar * delims,
+ SpiceCell * set );
+
+
+ SpiceDouble lspcn_c ( ConstSpiceChar * body,
+ SpiceDouble et,
+ ConstSpiceChar * abcorr );
+
+
+ SpiceInt lstlec_c ( ConstSpiceChar * string,
+ SpiceInt n,
+ SpiceInt lenvals,
+ const void * array );
+
+
+ SpiceInt lstled_c ( SpiceDouble x,
+ SpiceInt n,
+ ConstSpiceDouble * array );
+
+
+ SpiceInt lstlei_c ( SpiceInt x,
+ SpiceInt n,
+ ConstSpiceInt * array );
+
+
+ SpiceInt lstltc_c ( ConstSpiceChar * string,
+ SpiceInt n,
+ SpiceInt lenvals,
+ const void * array );
+
+
+ SpiceInt lstltd_c ( SpiceDouble x,
+ SpiceInt n,
+ ConstSpiceDouble * array );
+
+
+ SpiceInt lstlti_c ( SpiceInt x,
+ SpiceInt n,
+ ConstSpiceInt * array );
+
+
+ void ltime_c ( SpiceDouble etobs,
+ SpiceInt obs,
+ ConstSpiceChar * dir,
+ SpiceInt targ,
+ SpiceDouble * ettarg,
+ SpiceDouble * elapsd );
+
+
+ void lx4dec_c ( ConstSpiceChar * string,
+ SpiceInt first,
+ SpiceInt * last,
+ SpiceInt * nchar );
+
+
+ void lx4num_c ( ConstSpiceChar * string,
+ SpiceInt first,
+ SpiceInt * last,
+ SpiceInt * nchar );
+
+
+ void lx4sgn_c ( ConstSpiceChar * string,
+ SpiceInt first,
+ SpiceInt * last,
+ SpiceInt * nchar );
+
+
+ void lx4uns_c ( ConstSpiceChar * string,
+ SpiceInt first,
+ SpiceInt * last,
+ SpiceInt * nchar );
+
+
+ void lxqstr_c ( ConstSpiceChar * string,
+ SpiceChar qchar,
+ SpiceInt first,
+ SpiceInt * last,
+ SpiceInt * nchar );
+
+
+ void m2eul_c ( ConstSpiceDouble r[3][3],
+ SpiceInt axis3,
+ SpiceInt axis2,
+ SpiceInt axis1,
+ SpiceDouble * angle3,
+ SpiceDouble * angle2,
+ SpiceDouble * angle1 );
+
+
+ void m2q_c ( ConstSpiceDouble r[3][3],
+ SpiceDouble q[4] );
+
+
+
+ SpiceBoolean matchi_c ( ConstSpiceChar * string,
+ ConstSpiceChar * templ,
+ SpiceChar wstr,
+ SpiceChar wchr );
+
+
+ SpiceBoolean matchw_c ( ConstSpiceChar * string,
+ ConstSpiceChar * templ,
+ SpiceChar wstr,
+ SpiceChar wchr );
+
+
+ SpiceDouble maxd_c ( SpiceInt n,
+ ... );
+
+
+ SpiceInt maxi_c ( SpiceInt n,
+ ... );
+
+
+ void mequ_c ( ConstSpiceDouble m1 [3][3],
+ SpiceDouble mout[3][3] );
+
+
+ void mequg_c ( const void * m1,
+ SpiceInt nr,
+ SpiceInt nc,
+ void * mout );
+
+
+ SpiceDouble mind_c ( SpiceInt n,
+ ... );
+
+
+ SpiceInt mini_c ( SpiceInt n,
+ ... );
+
+
+ int moved_ ( SpiceDouble * arrfrm,
+ SpiceInt * ndim,
+ SpiceDouble * arrto );
+
+
+ void mtxm_c ( ConstSpiceDouble m1 [3][3],
+ ConstSpiceDouble m2 [3][3],
+ SpiceDouble mout[3][3] );
+
+
+ void mtxmg_c ( const void * m1,
+ const void * m2,
+ SpiceInt row1,
+ SpiceInt col1,
+ SpiceInt col2,
+ void * mout );
+
+
+ void mtxv_c ( ConstSpiceDouble m1 [3][3],
+ ConstSpiceDouble vin [3],
+ SpiceDouble vout[3] );
+
+
+ void mtxvg_c ( const void * m1,
+ const void * v2,
+ SpiceInt ncol1,
+ SpiceInt nr1r2,
+ void * vout );
+
+
+ void mxm_c ( ConstSpiceDouble m1 [3][3],
+ ConstSpiceDouble m2 [3][3],
+ SpiceDouble mout[3][3] );
+
+
+ void mxmg_c ( const void * m1,
+ const void * m2,
+ SpiceInt row1,
+ SpiceInt col1,
+ SpiceInt col2,
+ void * mout );
+
+
+ void mxmt_c ( ConstSpiceDouble m1 [3][3],
+ ConstSpiceDouble m2 [3][3],
+ SpiceDouble mout[3][3] );
+
+
+ void mxmtg_c ( const void * m1,
+ const void * m2,
+ SpiceInt nrow1,
+ SpiceInt nc1c2,
+ SpiceInt nrow2,
+ void * mout );
+
+
+ void mxv_c ( ConstSpiceDouble m1[3][3],
+ ConstSpiceDouble vin[3],
+ SpiceDouble vout[3] );
+
+
+ void mxvg_c ( const void * m1,
+ const void * v2,
+ SpiceInt nrow1,
+ SpiceInt nc1r2,
+ void * vout );
+
+
+ void namfrm_c ( ConstSpiceChar * frname,
+ SpiceInt * frcode );
+
+
+ SpiceInt ncpos_c ( ConstSpiceChar * str,
+ ConstSpiceChar * chars,
+ SpiceInt start );
+
+
+ SpiceInt ncposr_c ( ConstSpiceChar * str,
+ ConstSpiceChar * chars,
+ SpiceInt start );
+
+
+ void nearpt_c ( ConstSpiceDouble positn[3],
+ SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ SpiceDouble npoint[3],
+ SpiceDouble * alt );
+
+
+ void npedln_c ( SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ ConstSpiceDouble linept[3],
+ ConstSpiceDouble linedr[3],
+ SpiceDouble pnear[3],
+ SpiceDouble * dist );
+
+
+ void npelpt_c ( ConstSpiceDouble point[3],
+ ConstSpiceEllipse * ellips,
+ SpiceDouble pnear[3],
+ SpiceDouble * dist );
+
+
+ void nplnpt_c ( ConstSpiceDouble linpt [3],
+ ConstSpiceDouble lindir [3],
+ ConstSpiceDouble point [3],
+ SpiceDouble pnear [3],
+ SpiceDouble * dist );
+
+
+ void nvc2pl_c ( ConstSpiceDouble normal[3],
+ SpiceDouble constant,
+ SpicePlane * plane );
+
+
+ void nvp2pl_c ( ConstSpiceDouble normal[3],
+ ConstSpiceDouble point[3],
+ SpicePlane * plane );
+
+
+ SpiceInt ordc_c ( ConstSpiceChar * item,
+ SpiceCell * set );
+
+
+ SpiceInt ordd_c ( SpiceDouble item,
+ SpiceCell * set );
+
+
+ SpiceInt ordi_c ( SpiceInt item,
+ SpiceCell * set );
+
+
+ void orderc_c ( SpiceInt lenvals,
+ const void * array,
+ SpiceInt ndim,
+ SpiceInt * iorder );
+
+
+ void orderd_c ( ConstSpiceDouble * array,
+ SpiceInt ndim,
+ SpiceInt * iorder );
+
+
+ void orderi_c ( ConstSpiceInt * array,
+ SpiceInt ndim,
+ SpiceInt * iorder );
+
+
+ void oscelt_c ( ConstSpiceDouble state[6],
+ SpiceDouble et ,
+ SpiceDouble mu ,
+ SpiceDouble elts[8] );
+
+
+ void pckcov_c ( ConstSpiceChar * pck,
+ SpiceInt idcode,
+ SpiceCell * cover );
+
+
+ void pckfrm_c ( ConstSpiceChar * pck,
+ SpiceCell * ids );
+
+
+ void pcklof_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+
+ void pckuof_c ( SpiceInt handle );
+
+
+ void pcpool_c ( ConstSpiceChar * name,
+ SpiceInt n,
+ SpiceInt lenvals,
+ const void * cvals );
+
+
+ void pdpool_c ( ConstSpiceChar * name,
+ SpiceInt n,
+ ConstSpiceDouble * dvals );
+
+
+ void pgrrec_c ( ConstSpiceChar * body,
+ SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble alt,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble rectan[3] );
+
+
+ SpiceDouble pi_c ( void );
+
+
+ void pipool_c ( ConstSpiceChar * name,
+ SpiceInt n,
+ ConstSpiceInt * ivals );
+
+
+ void pjelpl_c ( ConstSpiceEllipse * elin,
+ ConstSpicePlane * plane,
+ SpiceEllipse * elout );
+
+
+ void pl2nvc_c ( ConstSpicePlane * plane,
+ SpiceDouble normal[3],
+ SpiceDouble * constant );
+
+
+ void pl2nvp_c ( ConstSpicePlane * plane,
+ SpiceDouble normal[3],
+ SpiceDouble point[3] );
+
+
+ void pl2psv_c ( ConstSpicePlane * plane,
+ SpiceDouble point[3],
+ SpiceDouble span1[3],
+ SpiceDouble span2[3] );
+
+
+ SpiceInt pos_c ( ConstSpiceChar * str,
+ ConstSpiceChar * substr,
+ SpiceInt start );
+
+
+ SpiceInt posr_c ( ConstSpiceChar * str,
+ ConstSpiceChar * substr,
+ SpiceInt start );
+
+
+ void prefix_c ( ConstSpiceChar * pref,
+ SpiceInt spaces,
+ SpiceInt lenout,
+ SpiceChar * string );
+
+
+ SpiceChar * prompt_c ( ConstSpiceChar * prmptStr,
+ SpiceInt lenout,
+ SpiceChar * buffer );
+
+
+ void prop2b_c ( SpiceDouble gm,
+ ConstSpiceDouble pvinit[6],
+ SpiceDouble dt,
+ SpiceDouble pvprop[6] );
+
+
+ void prsdp_c ( ConstSpiceChar * string,
+ SpiceDouble * dpval );
+
+
+ void prsint_c ( ConstSpiceChar * string,
+ SpiceInt * intval );
+
+
+ void psv2pl_c ( ConstSpiceDouble point[3],
+ ConstSpiceDouble span1[3],
+ ConstSpiceDouble span2[3],
+ SpicePlane * plane );
+
+
+ void putcml_c ( SpiceInt argc ,
+ SpiceChar ** argv );
+
+
+ void pxform_c ( ConstSpiceChar * from,
+ ConstSpiceChar * to,
+ SpiceDouble et,
+ SpiceDouble rotate[3][3] );
+
+
+ void q2m_c ( ConstSpiceDouble q[4],
+ SpiceDouble r[3][3] );
+
+
+ void qdq2av_c ( ConstSpiceDouble q[4],
+ ConstSpiceDouble dq[4],
+ SpiceDouble av[3] );
+
+
+ void qxq_c ( ConstSpiceDouble q1[4],
+ ConstSpiceDouble q2[4],
+ SpiceDouble qout[4] );
+
+
+
+ void radrec_c ( SpiceDouble range,
+ SpiceDouble ra,
+ SpiceDouble dec,
+ SpiceDouble rectan[3] );
+
+
+ void rav2xf_c ( ConstSpiceDouble rot [3][3],
+ ConstSpiceDouble av [3],
+ SpiceDouble xform [6][6] );
+
+
+ void raxisa_c ( ConstSpiceDouble matrix[3][3],
+ SpiceDouble axis [3],
+ SpiceDouble * angle );
+
+
+ void rdtext_c ( ConstSpiceChar * file,
+ SpiceInt lenout,
+ SpiceChar * line,
+ SpiceBoolean * eof );
+
+
+ void reccyl_c ( ConstSpiceDouble rectan[3],
+ SpiceDouble * r,
+ SpiceDouble * lon,
+ SpiceDouble * z );
+
+
+ void recgeo_c ( ConstSpiceDouble rectan[3],
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble * lon,
+ SpiceDouble * lat,
+ SpiceDouble * alt );
+
+
+ void reclat_c ( ConstSpiceDouble rectan[3],
+ SpiceDouble * radius,
+ SpiceDouble * longitude,
+ SpiceDouble * latitude );
+
+
+ void recpgr_c ( ConstSpiceChar * body,
+ SpiceDouble rectan[3],
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble * lon,
+ SpiceDouble * lat,
+ SpiceDouble * alt );
+
+
+ void recrad_c ( ConstSpiceDouble rectan[3],
+ SpiceDouble * radius,
+ SpiceDouble * ra,
+ SpiceDouble * dec );
+
+
+
+ void reordc_c ( ConstSpiceInt * iorder,
+ SpiceInt ndim,
+ SpiceInt lenvals,
+ void * array );
+
+
+ void reordd_c ( ConstSpiceInt * iorder,
+ SpiceInt ndim,
+ SpiceDouble * array );
+
+
+ void reordi_c ( ConstSpiceInt * iorder,
+ SpiceInt ndim,
+ SpiceInt * array );
+
+
+ void reordl_c ( ConstSpiceInt * iorder,
+ SpiceInt ndim,
+ SpiceBoolean * array );
+
+
+ void removc_c ( ConstSpiceChar * item,
+ SpiceCell * set );
+
+
+ void removd_c ( SpiceDouble item,
+ SpiceCell * set );
+
+
+ void removi_c ( SpiceInt item,
+ SpiceCell * set );
+
+
+ void repmc_c ( ConstSpiceChar * in,
+ ConstSpiceChar * marker,
+ ConstSpiceChar * value,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void repmct_c ( ConstSpiceChar * in,
+ ConstSpiceChar * marker,
+ SpiceInt value,
+ SpiceChar strCase,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void repmd_c ( ConstSpiceChar * in,
+ ConstSpiceChar * marker,
+ SpiceDouble value,
+ SpiceInt sigdig,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void repmf_c ( ConstSpiceChar * in,
+ ConstSpiceChar * marker,
+ SpiceDouble value,
+ SpiceInt sigdig,
+ SpiceChar format,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void repmi_c ( ConstSpiceChar * in,
+ ConstSpiceChar * marker,
+ SpiceInt value,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void repmot_c ( ConstSpiceChar * in,
+ ConstSpiceChar * marker,
+ SpiceInt value,
+ SpiceChar strCase,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void reset_c ( void );
+
+
+ SpiceBoolean return_c ( void );
+
+
+ void recsph_c ( ConstSpiceDouble rectan[3],
+ SpiceDouble * r,
+ SpiceDouble * colat,
+ SpiceDouble * lon );
+
+
+ void rotate_c ( SpiceDouble angle,
+ SpiceInt iaxis,
+ SpiceDouble mout[3][3] );
+
+
+ void rotmat_c ( ConstSpiceDouble m1[3][3],
+ SpiceDouble angle,
+ SpiceInt iaxis,
+ SpiceDouble mout[3][3] );
+
+
+ void rotvec_c ( ConstSpiceDouble v1[3],
+ SpiceDouble angle,
+ SpiceInt iaxis,
+ SpiceDouble vout[3] );
+
+
+ SpiceDouble rpd_c ( void );
+
+
+ void rquad_c ( SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ SpiceDouble root1[2],
+ SpiceDouble root2[2] );
+
+
+ void saelgv_c ( ConstSpiceDouble vec1 [3],
+ ConstSpiceDouble vec2 [3],
+ SpiceDouble smajor[3],
+ SpiceDouble sminor[3] );
+
+
+ void scard_c ( SpiceInt card,
+ SpiceCell * cell );
+
+
+ void scdecd_c ( SpiceInt sc,
+ SpiceDouble sclkdp,
+ SpiceInt sclklen,
+ SpiceChar * sclkch );
+
+
+ void sce2s_c ( SpiceInt sc,
+ SpiceDouble et,
+ SpiceInt sclklen,
+ SpiceChar * sclkch );
+
+
+ void sce2c_c ( SpiceInt sc,
+ SpiceDouble et,
+ SpiceDouble * sclkdp );
+
+
+ void sce2t_c ( SpiceInt sc,
+ SpiceDouble et,
+ SpiceDouble * sclkdp );
+
+
+ void scencd_c ( SpiceInt sc,
+ ConstSpiceChar * sclkch,
+ SpiceDouble * sclkdp );
+
+
+ void scfmt_c ( SpiceInt sc,
+ SpiceDouble ticks,
+ SpiceInt clkstrlen,
+ SpiceChar * clkstr );
+
+
+ void scpart_c ( SpiceInt sc,
+ SpiceInt * nparts,
+ SpiceDouble * pstart,
+ SpiceDouble * pstop );
+
+
+ void scs2e_c ( SpiceInt sc,
+ ConstSpiceChar * sclkch,
+ SpiceDouble * et );
+
+
+ void sct2e_c ( SpiceInt sc,
+ SpiceDouble sclkdp,
+ SpiceDouble * et );
+
+
+ void sctiks_c ( SpiceInt sc,
+ ConstSpiceChar * clkstr,
+ SpiceDouble * ticks );
+
+
+ void sdiff_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ SpiceBoolean set_c ( SpiceCell * a,
+ ConstSpiceChar * op,
+ SpiceCell * b );
+
+
+ void setmsg_c ( ConstSpiceChar * msg );
+
+
+ void shellc_c ( SpiceInt ndim,
+ SpiceInt lenvals,
+ void * array );
+
+
+ void shelld_c ( SpiceInt ndim,
+ SpiceDouble * array );
+
+
+ void shelli_c ( SpiceInt ndim,
+ SpiceInt * array );
+
+
+ void sigerr_c ( ConstSpiceChar * message );
+
+
+ void sincpt_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * fixref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * dref,
+ ConstSpiceDouble dvec [3],
+ SpiceDouble spoint [3],
+ SpiceDouble * trgepc,
+ SpiceDouble srfvec [3],
+ SpiceBoolean * found );
+
+
+ SpiceInt size_c ( SpiceCell * size );
+
+
+ SpiceDouble spd_c ( void );
+
+
+ void sphcyl_c ( SpiceDouble radius,
+ SpiceDouble colat,
+ SpiceDouble slon,
+ SpiceDouble * r,
+ SpiceDouble * lon,
+ SpiceDouble * z );
+
+
+ void sphlat_c ( SpiceDouble r,
+ SpiceDouble colat,
+ SpiceDouble lons,
+ SpiceDouble * radius,
+ SpiceDouble * lon,
+ SpiceDouble * lat );
+
+
+ void sphrec_c ( SpiceDouble r,
+ SpiceDouble colat,
+ SpiceDouble lon,
+ SpiceDouble rectan[3] );
+
+
+ void spk14a_c ( SpiceInt handle,
+ SpiceInt ncsets,
+ ConstSpiceDouble coeffs [],
+ ConstSpiceDouble epochs [] );
+
+
+ void spk14b_c ( SpiceInt handle,
+ ConstSpiceChar * segid,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ SpiceInt chbdeg );
+
+
+ void spk14e_c ( SpiceInt handle );
+
+
+ void spkapo_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceDouble sobs[6],
+ ConstSpiceChar * abcorr,
+ SpiceDouble ptarg[3],
+ SpiceDouble * lt );
+
+
+ void spkapp_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceDouble sobs [6],
+ ConstSpiceChar * abcorr,
+ SpiceDouble starg [6],
+ SpiceDouble * lt );
+
+
+ void spkcls_c ( SpiceInt handle );
+
+
+ void spkcov_c ( ConstSpiceChar * spk,
+ SpiceInt idcode,
+ SpiceCell * cover );
+
+
+ void spkacs_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * abcorr,
+ SpiceInt obs,
+ SpiceDouble starg[6],
+ SpiceDouble * lt,
+ SpiceDouble * dlt );
+
+
+ void spkaps_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceDouble stobs[6],
+ ConstSpiceDouble accobs[6],
+ SpiceDouble starg[6],
+ SpiceDouble * lt,
+ SpiceDouble * dlt );
+
+
+ void spkez_c ( SpiceInt target,
+ SpiceDouble epoch,
+ ConstSpiceChar * frame,
+ ConstSpiceChar * abcorr,
+ SpiceInt observer,
+ SpiceDouble state[6],
+ SpiceDouble * lt );
+
+
+ void spkezp_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * abcorr,
+ SpiceInt obs,
+ SpiceDouble ptarg[3],
+ SpiceDouble * lt );
+
+
+ void spkezr_c ( ConstSpiceChar * target,
+ SpiceDouble epoch,
+ ConstSpiceChar * frame,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * observer,
+ SpiceDouble state[6],
+ SpiceDouble * lt );
+
+
+ void spkgeo_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ SpiceInt obs,
+ SpiceDouble state[6],
+ SpiceDouble * lt );
+
+
+ void spkgps_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ SpiceInt obs,
+ SpiceDouble pos[3],
+ SpiceDouble * lt );
+
+
+ void spklef_c ( ConstSpiceChar * filename,
+ SpiceInt * handle );
+
+
+ void spkltc_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceDouble stobs[6],
+ SpiceDouble starg[6],
+ SpiceDouble * lt,
+ SpiceDouble * dlt );
+
+
+ void spkobj_c ( ConstSpiceChar * spk,
+ SpiceCell * ids );
+
+
+ void spkopa_c ( ConstSpiceChar * file,
+ SpiceInt * handle );
+
+
+ void spkopn_c ( ConstSpiceChar * name,
+ ConstSpiceChar * ifname,
+ SpiceInt ncomch,
+ SpiceInt * handle );
+
+
+ void spkpds_c ( SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceInt type,
+ SpiceDouble first,
+ SpiceDouble last,
+ SpiceDouble descr[5] );
+
+
+ void spkpos_c ( ConstSpiceChar * targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obs,
+ SpiceDouble ptarg[3],
+ SpiceDouble * lt );
+
+
+ void spkssb_c ( SpiceInt targ,
+ SpiceDouble et,
+ ConstSpiceChar * ref,
+ SpiceDouble starg[6] );
+
+
+ void spksub_c ( SpiceInt handle,
+ SpiceDouble descr[5],
+ ConstSpiceChar * ident,
+ SpiceDouble begin,
+ SpiceDouble end,
+ SpiceInt newh );
+
+
+ void spkuds_c ( ConstSpiceDouble descr [5],
+ SpiceInt * body,
+ SpiceInt * center,
+ SpiceInt * frame,
+ SpiceInt * type,
+ SpiceDouble * first,
+ SpiceDouble * last,
+ SpiceInt * begin,
+ SpiceInt * end );
+
+
+ void spkuef_c ( SpiceInt handle );
+
+
+ void spkw02_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceDouble intlen,
+ SpiceInt n,
+ SpiceInt polydg,
+ ConstSpiceDouble cdata [],
+ SpiceDouble btime );
+
+
+ void spkw03_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceDouble intlen,
+ SpiceInt n,
+ SpiceInt polydg,
+ ConstSpiceDouble cdata [],
+ SpiceDouble btime );
+
+
+ void spkw05_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceDouble gm,
+ SpiceInt n,
+ ConstSpiceDouble states [][6],
+ ConstSpiceDouble epochs [] );
+
+
+ void spkw08_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceInt degree,
+ SpiceInt n,
+ ConstSpiceDouble states[][6],
+ SpiceDouble epoch1,
+ SpiceDouble step );
+
+
+ void spkw09_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceInt degree,
+ SpiceInt n,
+ ConstSpiceDouble states[][6],
+ ConstSpiceDouble epochs[] );
+
+
+ void spkw10_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ ConstSpiceDouble consts [8],
+ SpiceInt n,
+ ConstSpiceDouble elems [],
+ ConstSpiceDouble epochs [] );
+
+
+ void spkw12_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceInt degree,
+ SpiceInt n,
+ ConstSpiceDouble states[][6],
+ SpiceDouble epoch0,
+ SpiceDouble step );
+
+
+ void spkw13_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceInt degree,
+ SpiceInt n,
+ ConstSpiceDouble states[][6],
+ ConstSpiceDouble epochs[] );
+
+
+ void spkw15_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceDouble epoch,
+ ConstSpiceDouble tp [3],
+ ConstSpiceDouble pa [3],
+ SpiceDouble p,
+ SpiceDouble ecc,
+ SpiceDouble j2flg,
+ ConstSpiceDouble pv [3],
+ SpiceDouble gm,
+ SpiceDouble j2,
+ SpiceDouble radius );
+
+
+ void spkw17_c ( SpiceInt handle,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceDouble epoch,
+ ConstSpiceDouble eqel [9],
+ SpiceDouble rapol,
+ SpiceDouble decpol );
+
+
+ void spkw18_c ( SpiceInt handle,
+ SpiceSPK18Subtype subtyp,
+ SpiceInt body,
+ SpiceInt center,
+ ConstSpiceChar * frame,
+ SpiceDouble first,
+ SpiceDouble last,
+ ConstSpiceChar * segid,
+ SpiceInt degree,
+ SpiceInt n,
+ const void * packts,
+ ConstSpiceDouble epochs[] );
+
+
+ void srfrec_c ( SpiceInt body,
+ SpiceDouble lon,
+ SpiceDouble lat,
+ SpiceDouble rectan[3] );
+
+
+ void srfxpt_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ ConstSpiceChar * dref,
+ ConstSpiceDouble dvec [3],
+ SpiceDouble spoint [3],
+ SpiceDouble * dist,
+ SpiceDouble * trgepc,
+ SpiceDouble obspos [3],
+ SpiceBoolean * found );
+
+
+ void ssize_c ( SpiceInt size,
+ SpiceCell * cell );
+
+
+ void stelab_c ( ConstSpiceDouble pobj[3],
+ ConstSpiceDouble vobs[3],
+ SpiceDouble appobj[3] );
+
+
+ void stpool_c ( ConstSpiceChar * item,
+ SpiceInt nth,
+ ConstSpiceChar * contin,
+ SpiceInt lenout,
+ SpiceChar * string,
+ SpiceInt * size,
+ SpiceBoolean * found );
+
+
+ void str2et_c ( ConstSpiceChar * date,
+ SpiceDouble * et );
+
+
+ void subpnt_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * fixref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble spoint [3],
+ SpiceDouble * trgepc,
+ SpiceDouble srfvec [3] );
+
+
+ void subpt_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble spoint [3],
+ SpiceDouble * alt );
+
+
+ void subslr_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * fixref,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble spoint [3],
+ SpiceDouble * trgepc,
+ SpiceDouble srfvec [3] );
+
+
+ void subsol_c ( ConstSpiceChar * method,
+ ConstSpiceChar * target,
+ SpiceDouble et,
+ ConstSpiceChar * abcorr,
+ ConstSpiceChar * obsrvr,
+ SpiceDouble spoint[3] );
+
+
+ SpiceDouble sumad_c ( ConstSpiceDouble array[],
+ SpiceInt n );
+
+
+ SpiceInt sumai_c ( ConstSpiceInt array[],
+ SpiceInt n );
+
+
+ void surfnm_c ( SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ ConstSpiceDouble point[3],
+ SpiceDouble normal[3] );
+
+
+ void surfpt_c ( ConstSpiceDouble positn[3],
+ ConstSpiceDouble u[3],
+ SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ SpiceDouble point[3],
+ SpiceBoolean * found );
+
+
+ void surfpv_c ( ConstSpiceDouble stvrtx[6],
+ ConstSpiceDouble stdir [6],
+ SpiceDouble a,
+ SpiceDouble b,
+ SpiceDouble c,
+ SpiceDouble stx [6],
+ SpiceBoolean * found );
+
+
+ void swpool_c ( ConstSpiceChar * agent,
+ SpiceInt nnames,
+ SpiceInt lenvals,
+ const void * names );
+
+
+ void sxform_c ( ConstSpiceChar * from,
+ ConstSpiceChar * to,
+ SpiceDouble et,
+ SpiceDouble xform[6][6] );
+
+
+ void szpool_c ( ConstSpiceChar * name,
+ SpiceInt * n,
+ SpiceBoolean * found );
+
+
+ void timdef_c ( ConstSpiceChar * action,
+ ConstSpiceChar * item,
+ SpiceInt lenout,
+ SpiceChar * value );
+
+
+ void timout_c ( SpiceDouble et,
+ ConstSpiceChar * pictur,
+ SpiceInt lenout,
+ SpiceChar * output );
+
+
+ void tipbod_c ( ConstSpiceChar * ref,
+ SpiceInt body,
+ SpiceDouble et,
+ SpiceDouble tipm[3][3] );
+
+
+ void tisbod_c ( ConstSpiceChar * ref,
+ SpiceInt body,
+ SpiceDouble et,
+ SpiceDouble tsipm[6][6] );
+
+
+ ConstSpiceChar * tkvrsn_c ( ConstSpiceChar * item );
+
+
+ void tparse_c ( ConstSpiceChar * string,
+ SpiceInt lenout,
+ SpiceDouble * sp2000,
+ SpiceChar * errmsg );
+
+
+ void tpictr_c ( ConstSpiceChar * sample,
+ SpiceInt lenpictur,
+ SpiceInt lenerror,
+ SpiceChar * pictur,
+ SpiceBoolean * ok,
+ SpiceChar * error );
+
+
+ SpiceDouble trace_c ( ConstSpiceDouble matrix[3][3] );
+
+
+ void trcoff_c ( void );
+
+
+ void tsetyr_c ( SpiceInt year );
+
+
+ SpiceDouble twopi_c ( void );
+
+
+ void twovec_c ( ConstSpiceDouble axdef [3],
+ SpiceInt indexa,
+ ConstSpiceDouble plndef [3],
+ SpiceInt indexp,
+ SpiceDouble mout [3][3] );
+
+
+ SpiceDouble tyear_c ( void );
+
+
+ void ucase_c ( SpiceChar * in,
+ SpiceInt lenout,
+ SpiceChar * out );
+
+
+ void ucrss_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3],
+ SpiceDouble vout[3] );
+
+
+ void uddc_c ( void ( * udfunc ) ( SpiceDouble x,
+ SpiceDouble * value ),
+
+ SpiceDouble x,
+ SpiceDouble dx,
+ SpiceBoolean * isdecr );
+
+
+ void uddf_c ( void ( * udfunc ) ( SpiceDouble x,
+ SpiceDouble * value ),
+ SpiceDouble x,
+ SpiceDouble dx,
+ SpiceDouble * deriv );
+
+
+ void union_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ SpiceDouble unitim_c ( SpiceDouble epoch,
+ ConstSpiceChar * insys,
+ ConstSpiceChar * outsys );
+
+
+ void unload_c ( ConstSpiceChar * file );
+
+
+ void unorm_c ( ConstSpiceDouble v1[3],
+ SpiceDouble vout[3],
+ SpiceDouble * vmag );
+
+
+ void unormg_c ( ConstSpiceDouble * v1,
+ SpiceInt ndim,
+ SpiceDouble * vout,
+ SpiceDouble * vmag );
+
+
+ void utc2et_c ( ConstSpiceChar * utcstr,
+ SpiceDouble * et );
+
+
+ void vadd_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3],
+ SpiceDouble vout[3] ) ;
+
+
+ void vaddg_c ( ConstSpiceDouble * v1,
+ ConstSpiceDouble * v2,
+ SpiceInt ndim,
+ SpiceDouble * vout );
+
+
+ void valid_c ( SpiceInt size,
+ SpiceInt n,
+ SpiceCell * a );
+
+
+ void vcrss_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3],
+ SpiceDouble vout[3] );
+
+
+ SpiceDouble vdist_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3] );
+
+
+ SpiceDouble vdistg_c ( ConstSpiceDouble * v1,
+ ConstSpiceDouble * v2,
+ SpiceInt ndim );
+
+
+ SpiceDouble vdot_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3] );
+
+ SpiceDouble vdotg_c ( ConstSpiceDouble * v1,
+ ConstSpiceDouble * v2,
+ SpiceInt ndim );
+
+ void vequ_c ( ConstSpiceDouble vin[3],
+ SpiceDouble vout[3] );
+
+
+ void vequg_c ( ConstSpiceDouble * vin,
+ SpiceInt ndim,
+ SpiceDouble * vout );
+
+
+ void vhat_c ( ConstSpiceDouble v1 [3],
+ SpiceDouble vout[3] );
+
+
+ void vhatg_c ( ConstSpiceDouble * v1,
+ SpiceInt ndim,
+ SpiceDouble * vout );
+
+
+ void vlcom_c ( SpiceDouble a,
+ ConstSpiceDouble v1[3],
+ SpiceDouble b,
+ ConstSpiceDouble v2[3],
+ SpiceDouble sum[3] );
+
+
+ void vlcom3_c ( SpiceDouble a,
+ ConstSpiceDouble v1[3],
+ SpiceDouble b,
+ ConstSpiceDouble v2[3],
+ SpiceDouble c,
+ ConstSpiceDouble v3[3],
+ SpiceDouble sum[3] );
+
+
+ void vlcomg_c ( SpiceInt n,
+ SpiceDouble a,
+ ConstSpiceDouble * v1,
+ SpiceDouble b,
+ ConstSpiceDouble * v2,
+ SpiceDouble * sum );
+
+
+ void vminug_c ( ConstSpiceDouble * vin,
+ SpiceInt ndim,
+ SpiceDouble * vout );
+
+
+ void vminus_c ( ConstSpiceDouble v1[3],
+ SpiceDouble vout[3] );
+
+
+ SpiceDouble vnorm_c ( ConstSpiceDouble v1[3] );
+
+
+ SpiceDouble vnormg_c ( ConstSpiceDouble * v1,
+ SpiceInt ndim );
+
+
+ void vpack_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble v[3] );
+
+
+ void vperp_c ( ConstSpiceDouble a[3],
+ ConstSpiceDouble b[3],
+ SpiceDouble p[3] );
+
+
+ void vprjp_c ( ConstSpiceDouble vin [3],
+ ConstSpicePlane * plane,
+ SpiceDouble vout [3] );
+
+
+ void vprjpi_c ( ConstSpiceDouble vin [3],
+ ConstSpicePlane * projpl,
+ ConstSpicePlane * invpl,
+ SpiceDouble vout [3],
+ SpiceBoolean * found );
+
+
+ void vproj_c ( ConstSpiceDouble a[3],
+ ConstSpiceDouble b[3],
+ SpiceDouble p[3] );
+
+
+ SpiceDouble vrel_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3] );
+
+
+ SpiceDouble vrelg_c ( ConstSpiceDouble * v1,
+ ConstSpiceDouble * v2,
+ SpiceInt ndim );
+
+
+ void vrotv_c ( ConstSpiceDouble v[3],
+ ConstSpiceDouble axis[3],
+ SpiceDouble theta,
+ SpiceDouble r[3] );
+
+
+ void vscl_c ( SpiceDouble s,
+ ConstSpiceDouble v1[3],
+ SpiceDouble vout[3] );
+
+
+ void vsclg_c ( SpiceDouble s,
+ ConstSpiceDouble * v1,
+ SpiceInt ndim,
+ SpiceDouble * vout );
+
+
+ SpiceDouble vsep_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3] );
+
+
+ void vsub_c ( ConstSpiceDouble v1[3],
+ ConstSpiceDouble v2[3],
+ SpiceDouble vout[3] );
+
+
+ void vsubg_c ( ConstSpiceDouble * v1,
+ ConstSpiceDouble * v2,
+ SpiceInt ndim,
+ SpiceDouble * vout );
+
+
+ SpiceDouble vsepg_c ( ConstSpiceDouble * v1,
+ ConstSpiceDouble * v2,
+ SpiceInt ndim );
+
+
+ SpiceDouble vtmv_c ( ConstSpiceDouble v1 [3],
+ ConstSpiceDouble matrix [3][3],
+ ConstSpiceDouble v2 [3] );
+
+
+ SpiceDouble vtmvg_c ( const void * v1,
+ const void * matrix,
+ const void * v2,
+ SpiceInt nrow,
+ SpiceInt ncol );
+
+
+ void vupack_c ( ConstSpiceDouble v[3],
+ SpiceDouble * x,
+ SpiceDouble * y,
+ SpiceDouble * z );
+
+ SpiceBoolean vzero_c ( ConstSpiceDouble v[3] );
+
+
+ SpiceBoolean vzerog_c ( ConstSpiceDouble * v,
+ SpiceInt ndim );
+
+ SpiceInt wncard_c ( SpiceCell * window );
+
+ void wncomd_c ( SpiceDouble left,
+ SpiceDouble right,
+ SpiceCell * window,
+ SpiceCell * result );
+
+
+ void wncond_c ( SpiceDouble left,
+ SpiceDouble right,
+ SpiceCell * window );
+
+
+ void wndifd_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ SpiceBoolean wnelmd_c ( SpiceDouble point,
+ SpiceCell * window );
+
+
+ void wnexpd_c ( SpiceDouble left,
+ SpiceDouble right,
+ SpiceCell * window );
+
+
+ void wnextd_c ( SpiceChar side,
+ SpiceCell * window );
+
+
+ void wnfetd_c ( SpiceCell * window,
+ SpiceInt n,
+ SpiceDouble * left,
+ SpiceDouble * right );
+
+
+ void wnfild_c ( SpiceDouble sml,
+ SpiceCell * window );
+
+
+ void wnfltd_c ( SpiceDouble sml,
+ SpiceCell * window );
+
+
+ SpiceBoolean wnincd_c ( SpiceDouble left,
+ SpiceDouble right,
+ SpiceCell * window );
+
+
+ void wninsd_c ( SpiceDouble left,
+ SpiceDouble right,
+ SpiceCell * window );
+
+
+ void wnintd_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ SpiceBoolean wnreld_c ( SpiceCell * a,
+ ConstSpiceChar * op,
+ SpiceCell * b );
+
+
+ void wnsumd_c ( SpiceCell * window,
+ SpiceDouble * meas,
+ SpiceDouble * avg,
+ SpiceDouble * stddev,
+ SpiceInt * shortest,
+ SpiceInt * longest );
+
+
+ void wnunid_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c );
+
+
+ void wnvald_c ( SpiceInt size,
+ SpiceInt n,
+ SpiceCell * window );
+
+
+
+ void xf2eul_c ( ConstSpiceDouble xform [6][6],
+ SpiceInt axisa,
+ SpiceInt axisb,
+ SpiceInt axisc,
+ SpiceDouble eulang [6],
+ SpiceBoolean * unique );
+
+
+ void xf2rav_c ( ConstSpiceDouble xform [6][6],
+ SpiceDouble rot [3][3],
+ SpiceDouble av [3] );
+
+
+ void xpose_c ( ConstSpiceDouble m1 [3][3],
+ SpiceDouble mout[3][3] );
+
+
+ void xpose6_c ( ConstSpiceDouble m1 [6][6],
+ SpiceDouble mout[6][6] );
+
+
+ void xposeg_c ( const void * matrix,
+ SpiceInt nrow,
+ SpiceInt ncol,
+ void * xposem );
+
+
+ void zzgetcml_c( SpiceInt * argc,
+ SpiceChar *** argv,
+ SpiceBoolean init );
+
+
+ SpiceBoolean zzgfgeth_c ( void );
+
+
+ void zzgfsavh_c( SpiceBoolean status );
+
+
+ void zzsynccl_c( SpiceTransDir xdir,
+ SpiceCell * cell );
+
+
+#endif
diff --git a/ext/spice/src/cspice/SpiceZst.h b/ext/spice/src/cspice/SpiceZst.h
new file mode 100644
index 0000000000..ba48b16c1c
--- /dev/null
+++ b/ext/spice/src/cspice/SpiceZst.h
@@ -0,0 +1,199 @@
+/*
+
+-Header_File SpiceZst.h ( Fortran/C string conversion utilities )
+
+-Abstract
+
+ Define prototypes for CSPICE Fortran/C string conversion utilities.
+
+ Caution: these prototypes are subject to revision without notice.
+
+ These are private routines and are not part of the official CSPICE
+ user interface.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Particulars
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 6.0.0, 10-JUL-2002 (NJB)
+
+ Added prototype for new functions C2F_MapStrArr and
+ C2F_MapFixStrArr.
+
+ -CSPICE Version 5.0.0, 18-MAY-2001 (WLT)
+
+ Added #ifdef's to add namespace specification for C++ compilation.
+
+ -CSPICE Version 4.0.0, 14-FEB-2000 (NJB)
+
+ Added prototype for new function C2F_CreateStrArr_Sig.
+
+ -CSPICE Version 3.0.0, 12-JUL-1999 (NJB)
+
+ Added prototype for function C2F_CreateFixStrArr.
+ Added prototype for function F2C_ConvertTrStrArr.
+ Removed reference in comments to C2F_CreateStrArr_Sig, which
+ does not exist.
+
+ -CSPICE Version 2.0.1, 06-MAR-1998 (NJB)
+
+ Type SpiceVoid was changed to void.
+
+ -CSPICE Version 2.0.1, 09-FEB-1998 (EDW)
+
+ Added prototype for F2C_ConvertStrArr.
+
+ -CSPICE Version 2.0.0, 04-JAN-1998 (NJB)
+
+ Added prototype for F2C_ConvertStr.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB) (KRG) (EDW)
+
+-Index_Entries
+
+ protoypes of CSPICE Fortran/C string conversion utilities
+
+*/
+
+#include
+#include
+#include "SpiceZdf.h"
+
+#ifndef HAVE_FCSTRINGS_H
+#define HAVE_FCSTRINGS_H
+
+#ifdef __cplusplus
+namespace Jpl_NAIF_CSpice {
+#endif
+
+ SpiceStatus C2F_CreateStr ( ConstSpiceChar *,
+ SpiceInt *,
+ SpiceChar ** );
+
+ void C2F_CreateStr_Sig ( ConstSpiceChar *,
+ SpiceInt *,
+ SpiceChar ** );
+
+ void C2F_CreateFixStrArr ( SpiceInt nStr,
+ SpiceInt cStrDim,
+ ConstSpiceChar ** cStrArr,
+ SpiceInt * fStrLen,
+ SpiceChar ** fStrArr );
+
+ SpiceStatus C2F_CreateStrArr ( SpiceInt,
+ ConstSpiceChar **,
+ SpiceInt *,
+ SpiceChar ** );
+
+ void C2F_CreateStrArr_Sig ( SpiceInt nStr,
+ ConstSpiceChar ** cStrArr,
+ SpiceInt * fStrLen,
+ SpiceChar ** fStrArr );
+
+ void C2F_MapFixStrArr ( ConstSpiceChar * caller,
+ SpiceInt nStr,
+ SpiceInt cStrLen,
+ const void * cStrArr,
+ SpiceInt * fStrLen,
+ SpiceChar ** fStrArr );
+
+ void C2F_MapStrArr ( ConstSpiceChar * caller,
+ SpiceInt nStr,
+ SpiceInt cStrLen,
+ const void * cStrArr,
+ SpiceInt * fStrLen,
+ SpiceChar ** fStrArr );
+
+ SpiceStatus C2F_StrCpy ( ConstSpiceChar *,
+ SpiceInt,
+ SpiceChar * );
+
+ void F_Alloc ( SpiceInt,
+ SpiceChar** );
+
+ void F2C_ConvertStr ( SpiceInt,
+ SpiceChar * );
+
+ void F2C_ConvertStrArr ( SpiceInt n,
+ SpiceInt lenout,
+ SpiceChar * cvals );
+
+ void F2C_ConvertTrStrArr ( SpiceInt n,
+ SpiceInt lenout,
+ SpiceChar * cvals );
+
+ SpiceStatus F2C_CreateStr ( SpiceInt,
+ ConstSpiceChar *,
+ SpiceChar ** );
+
+ void F2C_CreateStr_Sig ( SpiceInt,
+ ConstSpiceChar *,
+ SpiceChar ** );
+
+ SpiceStatus F2C_CreateStrArr ( SpiceInt,
+ SpiceInt,
+ ConstSpiceChar *,
+ SpiceChar *** );
+
+ void F2C_CreateStrArr_Sig ( SpiceInt,
+ SpiceInt,
+ ConstSpiceChar *,
+ SpiceChar *** );
+
+ void F2C_FreeStrArr ( SpiceChar **cStrArr );
+
+
+ SpiceStatus F2C_StrCpy ( SpiceInt,
+ ConstSpiceChar *,
+ SpiceInt,
+ SpiceChar * );
+
+ SpiceInt F_StrLen ( SpiceInt,
+ ConstSpiceChar * );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/ext/spice/src/cspice/abort_.c b/ext/spice/src/cspice/abort_.c
new file mode 100644
index 0000000000..696af7681e
--- /dev/null
+++ b/ext/spice/src/cspice/abort_.c
@@ -0,0 +1,32 @@
+/*
+ 06-FEB-1999 (NJB)
+
+ The statement
+
+ return 0;
+
+ for the normal C case was added to suppress compilation warnings.
+
+*/
+
+#include "stdio.h"
+#include "f2c.h"
+
+#ifdef KR_headers
+extern VOID sig_die();
+
+int abort_()
+#else
+extern void sig_die(char*,int);
+
+int abort_(void)
+#endif
+{
+sig_die("Fortran abort routine called", 1);
+
+return 0;
+
+#ifdef __cplusplus
+return 0;
+#endif
+}
diff --git a/ext/spice/src/cspice/accept.c b/ext/spice/src/cspice/accept.c
new file mode 100644
index 0000000000..c4d5e213ec
--- /dev/null
+++ b/ext/spice/src/cspice/accept.c
@@ -0,0 +1,318 @@
+/* accept.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure ACCEPT ( Accept New Long Error Message ) */
+logical accept_0_(int n__, logical *ok)
+{
+ /* Initialized data */
+
+ static logical savok = TRUE_;
+
+ /* System generated locals */
+ logical ret_val;
+
+/* $ Abstract */
+
+/* Indicate to the SPICELIB error handling mechanism whether or not */
+/* a replacement or modification of the long error message can be */
+/* accepted. DO NOT CALL THIS ROUTINE. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* ERROR */
+
+/* $ Keywords */
+
+/* ERROR */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* OK I Indicates whether long error msg changes are ok. */
+
+/* The function takes an UNSPECIFIED value on exit. */
+
+/* $ Detailed_Input */
+
+/* OK Indicates to the error handling mechanism whether */
+/* replacement of or changes to the long error message */
+/* are to be allowed; for them to be allowed, */
+/* both of the following must be true: */
+
+/* 1. No error condition exists, or the error response */
+/* action is not 'RETURN'. */
+
+/* 2. The current error response mode is not 'IGNORE'. */
+
+
+/* $ Detailed_Output */
+
+/* The function is assigned a value on output, but the */
+/* value is not meaningful. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* This routine does not detect any errors. */
+
+/* However, this routine is part of the SPICELIB error */
+/* handling mechanism. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* DO NOT CALL THIS ROUTINE. */
+
+/* $ Examples */
+
+/* None. */
+
+/* $ Restrictions */
+
+/* DO NOT CALL THIS ROUTINE. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (NJB) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* None. */
+
+/* -& */
+/* $ Revisions */
+
+
+/* - Beta Version 1.1.0, 13-DEC-1989 (NJB) */
+
+/* ACCEPT must return a value, in order to comply with the */
+/* Fortran standard. So, now it does. The value has no */
+/* meaning, as far as the specification of ACCEPT is */
+/* concerned. */
+
+/* - Beta Version 1.0.1, 08-FEB-1989 (NJB) */
+
+/* Warnings added to discourage use of this routine in */
+/* non-error-handling code. */
+
+/* -& */
+
+/* SPICELIB functions: */
+
+
+/* Local Variables: */
+
+
+/* Initial Values: */
+
+ switch(n__) {
+ case 1: goto L_allowd;
+ }
+
+
+/* Executable Code: */
+
+ savok = *ok;
+ ret_val = FALSE_;
+ return ret_val;
+/* $Procedure ALLOWD (Are Changes of Long Error Message Allowed?) */
+
+L_allowd:
+/* $ Abstract */
+
+/* True if replacement or modification of the long error message */
+/* is allowed. DO NOT CALL THIS ROUTINE. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* ERROR */
+
+/* $ Keywords */
+
+/* ERROR */
+
+/* $ Declarations */
+
+/* None. */
+
+/* $ Brief_I/O */
+
+/* The function takes the value, .TRUE., if replacement or */
+/* modification of the long error message is currently allowed. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* The function takes the value, .TRUE., if replacement of or */
+/* changes to the long error message are to be allowed; for them */
+/* to be allowed, both of the following must be true: */
+
+/* 1. No error condition exists, or the error response */
+/* action is not 'RETURN'. */
+
+/* 2. The current error response mode is not 'IGNORE'. */
+
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* This routine does not detect any errors. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* DO NOT CALL THIS ROUTINE. */
+
+/* Non-error handling routines should not call this routine. Such */
+/* routines can set the long error message using SETMSG, which */
+/* itself calls this routine to test whether an update is allowed. */
+
+/* The initial value returned by ALLOWD is .FALSE. */
+
+/* $ Examples */
+
+/* None. */
+
+/* $ Restrictions */
+
+/* DO NOT CALL THIS ROUTINE. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* H.A. Neilan (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (NJB) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* allow changes of long error message */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.1.0, 18-DEC-1989 (HAN) */
+
+/* Empty parentheses added to the ENTRY statement in order to */
+/* comply with the ANSI Fortran 77 Standard. */
+
+/* - Beta Version 1.0.1, 08-FEB-1989 (NJB) */
+
+/* Warnings added to discourage use of this routine in */
+/* non-error-handling code. */
+
+/* -& */
+
+/* Executable Code: */
+
+ ret_val = savok;
+ return ret_val;
+} /* accept_ */
+
+logical accept_(logical *ok)
+{
+ return accept_0_(0, ok);
+ }
+
+logical allowd_(void)
+{
+ return accept_0_(1, (logical *)0);
+ }
+
diff --git a/ext/spice/src/cspice/alltru.c b/ext/spice/src/cspice/alltru.c
new file mode 100644
index 0000000000..3be7a41c82
--- /dev/null
+++ b/ext/spice/src/cspice/alltru.c
@@ -0,0 +1,154 @@
+/* alltru.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure ALLTRU ( All entries true? ) */
+logical alltru_(logical *logcls, integer *n)
+{
+ /* System generated locals */
+ integer i__1;
+ logical ret_val;
+
+ /* Local variables */
+ integer i__;
+
+/* $ Abstract */
+
+/* Determine if all the entries in an array of logicals are .TRUE. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* LOGCLS I An array of logicals. */
+/* N I Number of elements in the array LOGCLS. */
+
+/* The function returns .TRUE. if all of the values in the array */
+/* LOGCLS are true. */
+
+/* $ Detailed_Input */
+
+/* LOGCLS is an array of logicals. */
+
+/* N is the number of elements in the array LOGCLS */
+
+/* $ Detailed_Output */
+
+/* The function returns true if the value of every entry of LOGCLS */
+/* is .TRUE. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* If N is less than 1, the function returns a value of .TRUE. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This function examines each element of LOGCLS until */
+/* a .FALSE. value is found or until all values have been */
+/* examined. */
+
+/* $ Examples */
+
+/* Suppose you needed to confirm that each a character set */
+/* WORDS contained all of the words in the phrase */
+
+/* 'EVERY GOOD BOY DOES FINE' */
+
+/* You might execute the following block of code. */
+
+/* FOUND(1) = ELEMC ( 'EVERY', WORDS ) */
+/* FOUND(2) = ELEMC ( 'GOOD', WORDS ) */
+/* FOUND(3) = ELEMC ( 'BOY', WORDS ) */
+/* FOUND(4) = ELEMC ( 'DOES', WORDS ) */
+/* FOUND(5) = ELEMC ( 'FINE', WORDS ) */
+
+/* OK = ALLTRU ( FOUND, 5 ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 12-JUL-1991 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* test whether all logicals in an array are true */
+
+/* -& */
+
+/* Just do it. */
+
+ i__1 = *n;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ if (! logcls[i__ - 1]) {
+ ret_val = FALSE_;
+ return ret_val;
+ }
+ }
+ ret_val = TRUE_;
+ return ret_val;
+} /* alltru_ */
+
diff --git a/ext/spice/src/cspice/ana.c b/ext/spice/src/cspice/ana.c
new file mode 100644
index 0000000000..e0fc337d81
--- /dev/null
+++ b/ext/spice/src/cspice/ana.c
@@ -0,0 +1,281 @@
+/* ana.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__33 = 33;
+static integer c__22 = 22;
+
+/* $Procedure ANA ( AN or A ? ) */
+/* Character */ VOID ana_(char *ret_val, ftnlen ret_val_len, char *word, char
+ *case__, ftnlen word_len, ftnlen case_len)
+{
+ /* Initialized data */
+
+ static char a[2*3] = "A " "A " "a ";
+ static char an[2*3] = "AN" "An" "an";
+ static char anword[8*22] = "HEIR " "HONEST " "HONOR " "H "
+ "HOUR " "HORS " "HOMBRE " "F " "L " "M "
+ "N " "R " "S " "X " "UNIN " "UNIM "
+ "ONEI " "ONER " "SPK " "EK " "IK " "SCLK ";
+ static char aword[8*33] = "HORSE " "ONE " "ONE- " "ONCE "
+ "ONENESS " "UIG " "UIN " "UKA " "UKE " "UKO "
+ "UKI " "UKU " "ULOT " "UNANI " "UNI " "UNINU "
+ "UPA " "URA " "URE " "URO " "USA " "USE "
+ "USU " "UTE " "UTI " "UTO " "UVA " "UVE "
+ "UVU " "EU " "EWE " "UTRI " "U ";
+
+ /* System generated locals */
+ integer i__1;
+
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer i_indx(char *, char *, ftnlen, ftnlen), s_rnge(char *, integer,
+ char *, integer);
+
+ /* Local variables */
+ static integer caps, i__;
+ static char begin[1];
+ extern /* Subroutine */ int ucase_(char *, char *, ftnlen, ftnlen);
+ static char start[32*7];
+ extern /* Subroutine */ int ljust_(char *, char *, ftnlen, ftnlen);
+ extern integer isrchc_(char *, integer *, char *, ftnlen, ftnlen);
+ extern /* Subroutine */ int replch_(char *, char *, char *, char *,
+ ftnlen, ftnlen, ftnlen, ftnlen);
+ static char mycase[1], myword[32];
+
+/* $ Abstract */
+
+/* Return the correct article "a" or "an" used to modify a word */
+/* and return it capitalized, lower case, or upper case. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* WORD */
+
+/* $ Keywords */
+
+/* UTILITY */
+/* WORD */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* WORD I is a word that should be modified by "a" or "an" */
+/* CASE I 'U', 'L', or 'C' to specify capitalization of ANA. */
+/* ANA O 'A' or 'AN' appropriately capitalized. */
+
+/* $ Detailed_Input */
+
+/* WORD is any english word for which you want to write the */
+/* correct phrase "a(an) response(answer)". The case */
+/* of the letters of word do not matter. */
+
+/* Leading white space in word is ignored. The characters */
+/* " and ' are ignored. Thus ''' apple '' ' and */
+/* '"apple"' and ' apple' and 'apple' are all treated as */
+/* the same word. */
+
+/* CASE is a character that describes how the value returned */
+/* in ANA should be capitalized. The rules are: */
+
+/* 'U' --- ANA is returned in all caps ( A, AN ) */
+/* 'C' --- ANA is returned capitalized ( A, An ) */
+/* 'L' --- ANA is returned lower case ( a, an ) */
+
+/* The case of CASE does not matter. Any value other */
+/* than those specified result in ANA being returned */
+/* in all lower case. */
+
+/* $ Detailed_Output */
+
+/* ANA is a character function an will return the correct */
+/* indefinite article needed to modify the word contained */
+/* in WORD. ANA should be declared to be CHARACTER*(2) */
+/* (or CHARACTER*(N) where N > 1) in the calling */
+/* program. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error Free */
+
+/* 1) If the uppercase value of CASE is not 'U', 'C' or 'L', it shall */
+/* be treated as 'L'. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine allows you to construct grammatically correct phrases */
+/* when you need to modify a word by an indefinite article. Using */
+/* the pronunciations contained in the Webster's Ninth Collegiate */
+/* Dictionary, the phrase */
+
+/* ANA(WORD, CASE) // ' ' // WORD */
+
+/* will be grammatically correct. */
+
+/* $ Examples */
+
+/* Suppose you wished to construct one of the messages */
+
+/* 'a new file' */
+/* 'an existing file' */
+
+/* and that the NEW/EXISTING word was in the variable WORD. Then */
+/* you could write */
+
+/* MESSAGE = ANA( WORD, 'L' ) // ' ' // WORD // ' file ' */
+/* CALL CMPRSS ( ' ', 1, MESSAGE, MESSAGE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* Webster's Ninth Collegiate Dictionary. */
+
+/* $ Author_and_Institution */
+
+/* B.V. Semenov (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.2, 28-FEB-2008 (BVS) */
+
+/* Corrected the contents of the Required_Reading section. */
+
+/* - SPICELIB Version 1.1.1, 22-SEP-2004 (EDW) */
+
+/* Added Copyright section. */
+
+/* - SPICELIB Version 1.1.0, 18-JAN-2001 (WLT) */
+
+/* Made SCLK and "an" word. */
+
+/* - SPICELIB Version 1.0.0, 29-NOV-1995 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* GET THE CORRECT INDEFINITE ARTICLE */
+
+/* -& */
+ ucase_(word, myword, word_len, (ftnlen)32);
+ replch_(myword, "'", " ", myword, (ftnlen)32, (ftnlen)1, (ftnlen)1, (
+ ftnlen)32);
+ replch_(myword, "\"", " ", myword, (ftnlen)32, (ftnlen)1, (ftnlen)1, (
+ ftnlen)32);
+ ljust_(myword, myword, (ftnlen)32, (ftnlen)32);
+ ucase_(case__, mycase, case_len, (ftnlen)1);
+ s_copy(ret_val, " ", ret_val_len, (ftnlen)1);
+ if (*(unsigned char *)mycase == 'U') {
+ caps = 1;
+ } else if (*(unsigned char *)mycase == 'C') {
+ caps = 2;
+ } else {
+ caps = 3;
+ }
+
+/* Handle the obvious things first. */
+
+ *(unsigned char *)begin = *(unsigned char *)myword;
+ if (i_indx("AI", begin, (ftnlen)2, (ftnlen)1) > 0) {
+ s_copy(ret_val, an + (((i__1 = caps - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("an", i__1, "ana_", (ftnlen)235)) << 1), ret_val_len, (
+ ftnlen)2);
+ return ;
+ } else if (i_indx("BCDGJKPQTVWYZ", begin, (ftnlen)13, (ftnlen)1) > 0) {
+ s_copy(ret_val, a + (((i__1 = caps - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("a", i__1, "ana_", (ftnlen)240)) << 1), ret_val_len, (
+ ftnlen)2);
+ return ;
+ }
+
+/* If we are still here, we need to be a bit more careful */
+/* in our determination of ANA. */
+
+/* Get the beginnings of the input word. */
+
+ for (i__ = 1; i__ <= 7; ++i__) {
+ s_copy(start + (((i__1 = i__ - 1) < 7 && 0 <= i__1 ? i__1 : s_rnge(
+ "start", i__1, "ana_", (ftnlen)252)) << 5), myword, (ftnlen)
+ 32, i__);
+ }
+
+/* Now see if the start of the input word belongs to */
+/* one of the special collections. */
+
+ for (i__ = 7; i__ >= 2; --i__) {
+ if (isrchc_(start + (((i__1 = i__ - 1) < 7 && 0 <= i__1 ? i__1 :
+ s_rnge("start", i__1, "ana_", (ftnlen)261)) << 5), &c__33,
+ aword, (ftnlen)32, (ftnlen)8) != 0) {
+ s_copy(ret_val, a + (((i__1 = caps - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("a", i__1, "ana_", (ftnlen)263)) << 1),
+ ret_val_len, (ftnlen)2);
+ return ;
+ }
+ if (isrchc_(start + (((i__1 = i__ - 1) < 7 && 0 <= i__1 ? i__1 :
+ s_rnge("start", i__1, "ana_", (ftnlen)268)) << 5), &c__22,
+ anword, (ftnlen)32, (ftnlen)8) != 0) {
+ s_copy(ret_val, an + (((i__1 = caps - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("an", i__1, "ana_", (ftnlen)270)) << 1),
+ ret_val_len, (ftnlen)2);
+ return ;
+ }
+ }
+
+/* If we got this far we can determine the ANAe by */
+/* just looking at the beginning of the string. */
+
+ if (i_indx("AEIOU", myword, (ftnlen)5, (ftnlen)1) > 0) {
+ s_copy(ret_val, an + (((i__1 = caps - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("an", i__1, "ana_", (ftnlen)282)) << 1), ret_val_len, (
+ ftnlen)2);
+ } else {
+ s_copy(ret_val, a + (((i__1 = caps - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("a", i__1, "ana_", (ftnlen)286)) << 1), ret_val_len, (
+ ftnlen)2);
+ }
+ return ;
+} /* ana_ */
+
diff --git a/ext/spice/src/cspice/appndc.c b/ext/spice/src/cspice/appndc.c
new file mode 100644
index 0000000000..8189f275b7
--- /dev/null
+++ b/ext/spice/src/cspice/appndc.c
@@ -0,0 +1,188 @@
+/* appndc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure APPNDC ( Append an item to a character cell ) */
+/* Subroutine */ int appndc_(char *item, char *cell, ftnlen item_len, ftnlen
+ cell_len)
+{
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ extern integer cardc_(char *, ftnlen);
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen);
+ extern integer sizec_(char *, ftnlen);
+ extern /* Subroutine */ int scardc_(integer *, char *, ftnlen);
+ integer nwcard;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Append an item to a character cell. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CELLS */
+
+/* $ Keywords */
+
+/* CELLS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* ITEM I The item to append. */
+/* CELL I/O The cell to which ITEM will be appended. */
+
+/* $ Detailed_Input */
+
+/* ITEM is a character string which is to be appended to CELL. */
+
+/* CELL is a character cell to which ITEM will be appended. */
+
+/* $ Detailed_Output */
+
+/* CELL is a character cell in which the last element is ITEM. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the cell is not large enough to accommodate the addition */
+/* of a new element, the error SPICE(CELLTOOSMALL) is signalled. */
+
+/* 2) If the length of the item is longer than the length of the */
+/* cell, ITEM is truncated on the right. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* In the following example, the item 'PLUTO' is appended to */
+/* the character cell PLANETS. */
+
+/* Before appending 'PLUTO', the cell contains: */
+
+/* PLANETS (1) = 'MERCURY' */
+/* PLANETS (2) = 'VENUS' */
+/* PLANETS (3) = 'EARTH' */
+/* PLANTES (4) = 'MARS' */
+/* PLANETS (5) = 'JUPITER' */
+/* PLANETS (6) = 'SATURN' */
+/* PLANETS (7) = 'URANUS' */
+/* PLANETS (8) = 'NEPTUNE' */
+
+/* The call */
+
+/* CALL APPNDC ( 'PLUTO', PLANETS ) */
+
+/* appends the element 'PLUTO' at the location PLANETS (9), and the */
+/* cardinality is updated. */
+
+/* If the cell is not big enough to accomodate the addition of */
+/* the item, an error is signalled. In this case, the cell is not */
+/* altered. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* H.A. Neilan (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (HAN) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* append an item to a character cell */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("APPNDC", (ftnlen)6);
+ }
+
+/* Check to see if the cell can accomodate the addition of a */
+/* new item. If there is room, append the item to the cell and */
+/* reset the cardinality. If the cell cannot accomodate the */
+/* addition of a new item, signal an error. */
+
+ nwcard = cardc_(cell, cell_len) + 1;
+ if (nwcard <= sizec_(cell, cell_len)) {
+ s_copy(cell + (nwcard + 5) * cell_len, item, cell_len, item_len);
+ scardc_(&nwcard, cell, cell_len);
+ } else {
+ setmsg_("The cell cannot accomodate the addition of the item *.", (
+ ftnlen)54);
+ errch_("*", item, (ftnlen)1, item_len);
+ sigerr_("SPICE(CELLTOOSMALL)", (ftnlen)19);
+ }
+ chkout_("APPNDC", (ftnlen)6);
+ return 0;
+} /* appndc_ */
+
diff --git a/ext/spice/src/cspice/appndc_c.c b/ext/spice/src/cspice/appndc_c.c
new file mode 100644
index 0000000000..2391fbcbcd
--- /dev/null
+++ b/ext/spice/src/cspice/appndc_c.c
@@ -0,0 +1,286 @@
+/*
+
+-Procedure appndc_c ( Append an item to a character cell )
+
+-Abstract
+
+ Append an item to a character cell.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CELLS
+
+-Keywords
+
+ CELLS
+
+*/
+
+
+#include "SpiceUsr.h"
+#include "SpiceZfc.h"
+#include "SpiceZmc.h"
+#include "f2cMang.h"
+
+
+ void appndc_c ( ConstSpiceChar * item,
+ SpiceCell * cell )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ item I The item to append.
+ cell I/O The cell to which item will be appended.
+
+-Detailed_Input
+
+ item is a character string which is to be appended to cell.
+
+ cell is a character SpiceCell to which item will be appended.
+
+-Detailed_Output
+
+ cell is the input SpiceCell with item appended. item is the
+ last member of cell.
+
+ If cell is actually a CSPICE set on input and ceases to
+ qualify as a set as result of the append operation,
+ the isSet member of cell will be set to SPICEFALSE.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the input cell argument is a SpiceCell of type other than
+ character, the error SPICE(TYPEMISMATCH) is signaled.
+
+ 2) If the cell is not large enough to accommodate the addition
+ of a new element, the error SPICE(CELLTOOSMALL) is signaled.
+
+ 3) If the length of the item is longer than the length of the
+ cell, ITEM is truncated on the right.
+
+ 4) If on input cell is actually a CSPICE set, that is, it
+ contains sorted elements with no duplicates, and if item
+ is not strictly greater than the last element, on output the
+ isSet member of cell will be set to SPICEFALSE. This case
+ is not considered an error.
+
+ 5) If the input string pointer is null, the error SPICE(NULLPOINTER)
+ is signaled.
+
+-Files
+
+ None.
+
+-Particulars
+
+ None.
+
+-Examples
+
+ 1) In the following example, the item "PLUTO" is appended to
+ the character cell planets. planets is declared with
+ string length NAMLEN.
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Declare the cell with string length NAMLEN and with maximum
+ number of elements MAXSIZ.
+ ./
+ SPICECHAR_CELL ( planets, MAXSIZ, NAMLEN );
+ .
+ .
+ .
+ /.
+ Before appending "PLUTO", suppose the cell planets' data array
+ contains:
+
+ Element 0: == "MERCURY"
+ Element 1: == "VENUS"
+ Element 2: == "EARTH"
+ Element 3: == "MARS"
+ Element 4: == "JUPITER"
+ Element 5: == "SATURN"
+ Element 6: == "URANUS"
+ Element 7: == "NEPTUNE"
+
+ Append the string "PLUTO" at index 8, and update the
+ cell's cardinality.
+ ./
+
+ appndc_c ( "PLUTO", &planets );
+
+ /.
+ The cell's data array now has the contents
+
+ Element 0: == "MERCURY"
+ Element 1: == "VENUS"
+ Element 2: == "EARTH"
+ Element 3: == "MARS"
+ Element 4: == "JUPITER"
+ Element 5: == "SATURN"
+ Element 6: == "URANUS"
+ Element 7: == "NEPTUNE"
+ Element 8: == "PLUTO"
+ ./
+
+-Restrictions
+
+ 1) String comparisons performed by this routine are Fortran-style:
+ trailing blanks in the input array or key value are ignored.
+ This gives consistent behavior with CSPICE code generated by
+ the f2c translator, as well as with the Fortran SPICE Toolkit.
+
+ Note that this behavior is not identical to that of the ANSI
+ C library functions strcmp and strncmp.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ H.A. Neilan (JPL)
+
+-Version
+
+ -CSPICE Version 1.1.0, 07-MAR-2009 (NJB)
+
+ This file now includes the header file f2cMang.h.
+ This header supports name mangling of f2c library
+ functions.
+
+ Header sections were re-ordered.
+
+ -CSPICE Version 1.0.0, 21-AUG-2002 (NJB) (HAN)
+
+-Index_Entries
+
+ append an item to a character cell
+
+-&
+*/
+
+{ /* Begin appndc_c */
+
+
+ /*
+ f2c library utility prototypes
+ */
+ extern integer s_cmp (char *a, char *b, ftnlen la, ftnlen lb );
+
+
+ /*
+ Local variables
+ */
+ SpiceChar * sPtr;
+
+ SpiceInt card;
+ SpiceInt diff;
+
+
+ /*
+ Use discovery check-in.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+
+
+ /*
+ Check the input string pointer to make sure it's not null.
+ */
+ CHKPTR ( CHK_DISCOVER, "appndc_c", item );
+
+
+ /*
+ Make sure we're working with a character cell.
+ */
+ CELLTYPECHK ( CHK_DISCOVER, "appndc_c", SPICE_CHR, cell );
+
+
+ /*
+ Initialize the cell if necessary.
+ */
+ CELLINIT ( cell );
+
+
+ card = cell->card;
+
+ if ( card == cell->size )
+ {
+ chkin_c ( "appndc_c" );
+ setmsg_c ( "The cell cannot accommodate the addition of the "
+ "element *" );
+ errch_c ( "*", item );
+ sigerr_c ( "SPICE(CELLTOOSMALL)" );
+ chkout_c ( "appndc_c" );
+ return;
+ }
+
+
+ if ( ( cell->isSet ) && ( card > 0 ) )
+ {
+ /*
+ The item must be strictly greater than its predecessor, or
+ the input cell is no longer a set.
+ */
+ sPtr = SPICE_CELL_ELEM_C(cell, card-1 );
+
+ diff = s_cmp ( (char *) item,
+ (char *) sPtr,
+ (ftnlen ) strlen(item),
+ (ftnlen ) strlen(sPtr) );
+
+ if ( diff < 1 )
+ {
+ cell->isSet = SPICEFALSE;
+ }
+ }
+
+
+ /*
+ Append the item to the cell and increment the cell's cardinality.
+ */
+ SPICE_CELL_SET_C ( item, card, cell );
+
+ (cell->card) ++;
+
+
+} /* End appndc_c */
diff --git a/ext/spice/src/cspice/appndd.c b/ext/spice/src/cspice/appndd.c
new file mode 100644
index 0000000000..acfd1c24f5
--- /dev/null
+++ b/ext/spice/src/cspice/appndd.c
@@ -0,0 +1,188 @@
+/* appndd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure APPNDD ( Append an item to a double precision cell ) */
+/* Subroutine */ int appndd_(doublereal *item, doublereal *cell)
+{
+ extern integer cardd_(doublereal *);
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errdp_(char *,
+ doublereal *, ftnlen);
+ extern integer sized_(doublereal *);
+ extern /* Subroutine */ int scardd_(integer *, doublereal *);
+ integer nwcard;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Append an item to a double precision cell. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CELLS */
+
+/* $ Keywords */
+
+/* CELLS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* ITEM I The item to append. */
+/* CELL I/O The cell to which ITEM will be appended. */
+
+/* $ Detailed_Input */
+
+/* ITEM is a double precision value which is to be appended */
+/* to CELL. */
+
+/* CELL is a double precision cell to which ITEM will be */
+/* appended. */
+
+/* $ Detailed_Output */
+
+/* CELL is a double precision cell in which the last element */
+/* is ITEM. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the cell is not big enough to accommodate the addition */
+/* of a new element, the error SPICE(CELLTOOSMALL) is signalled. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* In the following example, the element 34.0D0 is appended to */
+/* the d.p. cell NUMBERS. */
+
+/* Before appending 34.0D0, the cell contains: */
+
+/* NUMBERS (1) = 1.0D0 */
+/* NUMBERS (2) = 1.D0D */
+/* NUMBERS (3) = 2.0D0 */
+/* NUMBERS (4) = 3.0D0 */
+/* NUMBERS (5) = 5.0D0 */
+/* NUMBERS (6) = 8.0D0 */
+/* NUMBERS (7) = 13.0D0 */
+/* NUMBERS (8) = 21.0D0 */
+
+/* The call */
+
+/* CALL APPNDD ( 34.0D0, NUMBERS ) */
+
+/* appends the element 34.0D0 at the location NUMBERS (9), and the */
+/* cardinality is updated. */
+
+/* If the cell is not big enough to accomodate the addition of */
+/* the item, an error is signalled. In this case, the cell is not */
+/* altered. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* H.A. Neilan (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 09-NOV-2006 (WLT) */
+
+/* Corrected typo in Examples section describing the cell as */
+/* character instead of d.p. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (HAN) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* append an item to a d.p. cell */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("APPNDD", (ftnlen)6);
+ }
+
+/* Check to see if the cell can accomodate the addition of a */
+/* new item. If there is room, append the item to the cell and */
+/* reset the cardinality. If the cell cannot accomodate the */
+/* addition of a new item, signal an error. */
+
+ nwcard = cardd_(cell) + 1;
+ if (nwcard <= sized_(cell)) {
+ cell[nwcard + 5] = *item;
+ scardd_(&nwcard, cell);
+ } else {
+ setmsg_("The cell cannot accomodate the addition of the element *. ",
+ (ftnlen)58);
+ errdp_("*", item, (ftnlen)1);
+ sigerr_("SPICE(CELLTOOSMALL)", (ftnlen)19);
+ }
+ chkout_("APPNDD", (ftnlen)6);
+ return 0;
+} /* appndd_ */
+
diff --git a/ext/spice/src/cspice/appndd_c.c b/ext/spice/src/cspice/appndd_c.c
new file mode 100644
index 0000000000..24406614ab
--- /dev/null
+++ b/ext/spice/src/cspice/appndd_c.c
@@ -0,0 +1,216 @@
+/*
+
+-Procedure appndd_c ( Append an item to a double precision cell )
+
+-Abstract
+
+ Append an item to a double precision cell.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CELLS
+
+-Keywords
+
+ CELLS
+
+*/
+
+#include "SpiceUsr.h"
+#include "SpiceZmc.h"
+
+
+ void appndd_c ( SpiceDouble item,
+ SpiceCell * cell )
+
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ item I The item to append.
+ cell I/O The cell to which item will be appended.
+
+-Detailed_Input
+
+ item is an double precision value which is to be appended to
+ cell.
+
+ cell is a double precision SpiceCell to which item will be
+ appended.
+
+-Detailed_Output
+
+ cell is the input SpiceCell with item appended. item is the
+ last member of cell.
+
+ If cell is actually a CSPICE set on input and ceases to
+ qualify as a set as result of the requested append
+ operation, the isSet member of cell will be set to
+ SPICEFALSE.
+-Parameters
+
+ None.
+
+-Files
+
+ None.
+
+-Exceptions
+
+ 1) If the input cell argument doesn't have double precision data type,
+ the error SPICE(TYPEMISMATCH) is signaled.
+
+ 2) If the cell is not big enough to accommodate the addition
+ of a new element, the error SPICE(CELLTOOSMALL) is signaled.
+
+-Particulars
+
+ None.
+
+-Examples
+
+ 1) In the following example, the element 34 is appended to
+ the double precision cell fibNums.
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Declare the cell with maximum number of elements MAXSIZ.
+ ./
+ SPICEINT_CELL ( fibNums, MAXSIZ );
+ .
+ .
+ .
+ /.
+ Before appending 34, the cell contains:
+
+ Element 0: == 1.0
+ Element 1: == 1.0
+ Element 2: == 2.0
+ Element 3: == 3.0
+ Element 4: == 5.0
+ Element 5: == 8.0
+ Element 6: == 13.0
+ Element 7: == 21.0
+
+ The following call appends the element 34 at index 8, and
+ updates the cardinality.
+ ./
+
+ appndd_c ( 34, &fibNums );
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ H.A. Neilan (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 01-AUG-2002 (NJB) (HAN)
+
+-Index_Entries
+
+ append an item to a d.p. cell
+
+-&
+*/
+
+{ /* Begin appndd_c */
+
+
+ /*
+ Use discovery check-in.
+ */
+
+ /*
+ Make sure we're working with a DP cell.
+ */
+ CELLTYPECHK ( CHK_DISCOVER, "appndd_c", SPICE_DP, cell );
+
+
+ if ( cell->card == cell->size )
+ {
+ chkin_c ( "appndd_c" );
+ setmsg_c ( "The cell cannot accommodate the addition of the "
+ "element *" );
+ errdp_c ( "*", item );
+ sigerr_c ( "SPICE(CELLTOOSMALL)" );
+ chkout_c ( "appndd_c" );
+ return;
+ }
+
+
+ /*
+ Initialize the cell if necessary.
+ */
+ CELLINIT ( cell );
+
+
+ /*
+ The item must be strictly greater than its predecessor, or
+ the input cell is no longer a set.
+ */
+ if ( ( cell->isSet ) && ( cell->card > 0 ) )
+ {
+ if ( item <= SPICE_CELL_ELEM_D(cell, cell->card-1) )
+ {
+ cell->isSet = SPICEFALSE;
+ }
+ }
+
+
+ /*
+ Append the item to the cell and increment the cell's cardinality.
+ */
+ SPICE_CELL_SET_D ( item, cell->card, cell );
+
+ (cell->card) ++;
+
+
+ /*
+ Sync the cell.
+ */
+ zzsynccl_c ( C2F, cell );
+
+
+} /* End appndd_c */
+
diff --git a/ext/spice/src/cspice/appndi.c b/ext/spice/src/cspice/appndi.c
new file mode 100644
index 0000000000..86a4de460d
--- /dev/null
+++ b/ext/spice/src/cspice/appndi.c
@@ -0,0 +1,186 @@
+/* appndi.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure APPNDI ( Append an item to an integer cell ) */
+/* Subroutine */ int appndi_(integer *item, integer *cell)
+{
+ extern integer cardi_(integer *);
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ extern integer sizei_(integer *);
+ extern /* Subroutine */ int scardi_(integer *, integer *);
+ integer nwcard;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Append an item to an integer cell. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CELLS */
+
+/* $ Keywords */
+
+/* CELLS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* ITEM I The item to append. */
+/* CELL I/O The cell to which ITEM will be appended. */
+
+/* $ Detailed_Input */
+
+/* ITEM is an integer value which is to be appended to CELL. */
+
+/* CELL is an integer cell to which ITEM will be appended. */
+
+/* $ Detailed_Output */
+
+/* CELL is an integer cell in which the last element is ITEM. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the cell is not big enough to accommodate the addition */
+/* of a new element, the error SPICE(CELLTOOSMALL) is signaled. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* In the following example, the element 34 is appended to */
+/* the integer cell NUMBERS. */
+
+/* Before appending 34, the cell contains: */
+
+/* NUMBERS (1) = 1 */
+/* NUMBERS (2) = 1 */
+/* NUMBERS (3) = 2 */
+/* NUMBERS (4) = 3 */
+/* NUMBERS (5) = 5 */
+/* NUMBERS (6) = 8 */
+/* NUMBERS (7) = 13 */
+/* NUMBERS (8) = 21 */
+
+/* The call */
+
+/* CALL APPNDI ( 34, NUMBERS ) */
+
+/* appends the element 34 at the location NUMBERS (9), and the */
+/* cardinality is updated. */
+
+/* If the cell is not big enough to accommodate the addition of */
+/* the item, an error is signaled. In this case, the cell is not */
+/* altered. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* H.A. Neilan (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 31-JUL-2002 (NJB) */
+
+/* Corrected miscellaneous typos in header and in the long */
+/* error message text. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (HAN) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* append an item to an integer cell */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("APPNDI", (ftnlen)6);
+ }
+
+/* Check to see if the cell can accommodate the addition of a */
+/* new item. If there is room, append the item to the cell and */
+/* reset the cardinality. If the cell cannot accommodate the */
+/* addition of a new item, signal an error. */
+
+ nwcard = cardi_(cell) + 1;
+ if (nwcard <= sizei_(cell)) {
+ cell[nwcard + 5] = *item;
+ scardi_(&nwcard, cell);
+ } else {
+ setmsg_("The cell cannot accommodate the addition of the element *. ",
+ (ftnlen)59);
+ errint_("*", item, (ftnlen)1);
+ sigerr_("SPICE(CELLTOOSMALL)", (ftnlen)19);
+ }
+ chkout_("APPNDI", (ftnlen)6);
+ return 0;
+} /* appndi_ */
+
diff --git a/ext/spice/src/cspice/appndi_c.c b/ext/spice/src/cspice/appndi_c.c
new file mode 100644
index 0000000000..c23b02869b
--- /dev/null
+++ b/ext/spice/src/cspice/appndi_c.c
@@ -0,0 +1,218 @@
+/*
+
+-Procedure appndi_c ( Append an item to an integer cell )
+
+-Abstract
+
+ Append an item to an integer cell.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CELLS
+
+-Keywords
+
+ CELLS
+
+*/
+
+
+#include "SpiceUsr.h"
+#include "SpiceZmc.h"
+
+
+ void appndi_c ( SpiceInt item,
+ SpiceCell * cell )
+
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ item I The item to append.
+ cell I/O The cell to which item will be appended.
+
+-Detailed_Input
+
+ item is an integer value which is to be appended to cell.
+
+ cell is an integer SpiceCell to which item will be appended.
+
+-Detailed_Output
+
+ cell is the input SpiceCell with item appended. item is the
+ last member of cell.
+
+ If cell is actually a CSPICE set on input and ceases to
+ qualify as a set as result of the requested append
+ operation, the isSet member of cell will be set to
+ SPICEFALSE.
+-Parameters
+
+ None.
+
+-Files
+
+ None.
+
+-Exceptions
+
+ 1) If the input cell argument doesn't have integer data type,
+ the error SPICE(TYPEMISMATCH) is signaled.
+
+ 2) If the cell is not big enough to accommodate the addition
+ of a new element, the error SPICE(CELLTOOSMALL) is signaled.
+
+-Particulars
+
+ None.
+
+-Examples
+
+ 1) In the following example, the element 34 is appended to
+ the integer cell fibNums.
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Declare the cell with maximum number of elements MAXSIZ.
+ ./
+ SPICEINT_CELL ( fibNums, MAXSIZ );
+ .
+ .
+ .
+ /.
+ Before appending 34, the cell contains:
+
+ Element 0: == 1
+ Element 1: == 1
+ Element 2: == 2
+ Element 3: == 3
+ Element 4: == 5
+ Element 5: == 8
+ Element 6: == 13
+ Element 7: == 21
+
+ The following call appends the element 34 at index 8, and
+ updates the cardinality.
+ ./
+
+ appndi_c ( 34, &fibNums );
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ H.A. Neilan (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 01-AUG-2002 (NJB) (HAN)
+
+-Index_Entries
+
+ append an item to an integer cell
+
+-&
+*/
+
+{ /* Begin appndi_c */
+
+
+ /*
+ Use discovery check-in.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+
+ /*
+ Make sure we're working with an integer cell.
+ */
+ CELLTYPECHK ( CHK_DISCOVER, "appndi_c", SPICE_INT, cell );
+
+
+ if ( cell->card == cell->size )
+ {
+ chkin_c ( "appndi_c" );
+ setmsg_c ( "The cell cannot accomodate the addition of the "
+ "element *" );
+ errint_c ( "*", item );
+ sigerr_c ( "SPICE(CELLTOOSMALL)" );
+ chkout_c ( "appndi_c" );
+ return;
+ }
+
+
+ /*
+ Initialize the cell if necessary.
+ */
+ CELLINIT ( cell );
+
+
+ /*
+ The item must be strictly greater than its predecessor, or
+ the input cell is no longer a set.
+ */
+ if ( ( cell->isSet ) && ( cell->card > 0 ) )
+ {
+ if ( item <= SPICE_CELL_ELEM_I(cell, cell->card-1) )
+ {
+ cell->isSet = SPICEFALSE;
+ }
+ }
+
+
+ /*
+ Append the item to the cell and increment the cell's cardinality.
+ */
+ SPICE_CELL_SET_I ( item, cell->card, cell );
+
+ (cell->card) ++;
+
+
+ /*
+ Sync the cell.
+ */
+ zzsynccl_c ( C2F, cell );
+
+
+} /* End appndi_c */
diff --git a/ext/spice/src/cspice/approx.c b/ext/spice/src/cspice/approx.c
new file mode 100644
index 0000000000..d7d8835f53
--- /dev/null
+++ b/ext/spice/src/cspice/approx.c
@@ -0,0 +1,144 @@
+/* approx.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure APPROX ( Approximate equality ) */
+logical approx_(doublereal *x, doublereal *y, doublereal *tol)
+{
+ /* System generated locals */
+ doublereal d__1;
+ logical ret_val;
+
+/* $ Abstract */
+
+/* True if two double precision numbers are equal to within some */
+/* tolerance. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* COMPARE */
+/* NUMBERS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* X, */
+/* Y I Double precision numbers. */
+/* TOL I Tolerance. */
+
+/* The function is true whenever |X - Y| < TOL. */
+/* - */
+
+/* $ Detailed_Input */
+
+/* X, */
+/* Y are arbitrary double precision numbers. */
+
+/* TOL is a tolerance. X and Y are considered to be equal */
+/* if they differ by no more than this amount. If TOL */
+/* is negative, X and Y are never considered equal. */
+
+/* $ Detailed_Output */
+
+/* The function is true whenever |X - Y| < TOL, and is false */
+/* otherwise. - */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* C */
+/* C If the eccentricity is near one, this a parabola. */
+/* C */
+/* IF ( APPROX ( ECC, 1.D0, 10.D-12 ) ) THEN */
+/* TYPE = 'PARABOLA' */
+
+/* ELSE IF ( ECC .LT. 1 ) THEN */
+/* TYPE = 'ELLIPSE' */
+
+/* ELSE */
+/* TYPE = 'HYPERBOLA' */
+/* END IF */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* approximate equality */
+
+/* -& */
+
+/* Just shorthand, really. */
+
+ ret_val = (d__1 = *x - *y, abs(d__1)) <= *tol;
+ return ret_val;
+} /* approx_ */
+
diff --git a/ext/spice/src/cspice/astrip.c b/ext/spice/src/cspice/astrip.c
new file mode 100644
index 0000000000..44f9f010c8
--- /dev/null
+++ b/ext/spice/src/cspice/astrip.c
@@ -0,0 +1,239 @@
+/* astrip.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure ASTRIP ( STRIP Ascii characters from a string ) */
+/* Subroutine */ int astrip_(char *instr, char *asciib, char *asciie, char *
+ outstr, ftnlen instr_len, ftnlen asciib_len, ftnlen asciie_len,
+ ftnlen outstr_len)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer last, i__, j, k;
+ extern integer lastnb_(char *, ftnlen);
+ integer lwrbnd, uprbnd, outlen;
+
+/* $ Abstract */
+
+/* Remove from a character string all characters which fall */
+/* between specified starting and ending characters, inclusive. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ASCII, CHARACTER */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* INSTR I Input string. */
+/* ASCIIB I First ASCII character in range to be stripped. */
+/* ASCIIE I Last ASCII character in range to be stripped. */
+/* OUTSTR O Output (stripped) string. */
+
+/* $ Detailed_Input */
+
+/* INSTR Is a character string from which all characters */
+/* between ASCIIB and ASCIIE, inclusive, are to be */
+/* removed. */
+
+/* ASCIIB Is the first ASCII character in the range of */
+/* characters to be removed from the input string. */
+/* ASCIIB is itself removed from the string, if */
+/* it occurs. */
+
+/* ASCIIE Is the last ASCII character in the range of */
+/* characters to be removed from the input string. */
+/* ASCIIE is itself removed from the string, if */
+/* it occurs. */
+
+/* $ Detailed_Output */
+
+/* OUTSTR Is the input string after all the character */
+/* between ASCIIB and ASCIIE, inclusive, have */
+/* been removed. */
+
+/* If OUTSTR is not large enough to hold the output */
+/* string, it is truncated on the right. */
+
+/* OUTSTR may overwrite INSTR. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* ASTRIP checks each character */
+/* in INSTR to determine if it falls between the characters ASCIIB */
+/* and ASCIIE. If so this character is removed from the string */
+/* (and the string is shortened). Remaining characters are copied */
+/* to the output string. */
+
+/* $ Examples */
+
+/* The following examples illustrate the use of ASTRIP. */
+
+/* ASCIIB = 'b' */
+/* ASCIIE = 'k' */
+/* INSTR = 'Now is the time for all good men to come quick.' */
+/* OUTSTR = 'Now s t tm or all oo mn to om qu.' */
+
+/* ASCIIB = 'a' */
+/* ASCIIE = 'z' */
+/* INSTR = 'SELECT column TIME FROM table TEST' */
+/* OUTSTR = 'SELECT TIME FROM TEST' */
+
+/* ASCIIB = 'a' */
+/* ASCIIE = 'z' */
+/* INSTR = 'this is going to be an empty string' */
+/* OUTSTR = ' ' */
+
+/* ASCIIB = '!' */
+/* ASCIIE = '!' */
+/* INSTR = 'Only 32 more shopping days until Christmas!' */
+/* OUTSTR = 'Only 32 more shopping days until Christmas' */
+
+/* ASTRIP may also be used to strip ASCII control characters */
+/* (line feeds, tab stops, and so on), as shown in the example */
+/* below. */
+
+/* ASCIIB = CHAR ( 0 ) */
+/* ASCIIE = CHAR ( 31 ) */
+/* CALL ASTRIP ( STRING, ASCIIB, ASCIIE, STRING ) */
+
+/* $ Restrictions */
+
+/* If ASCIIB and ASCIIE are not properly ordered (that is, */
+/* if ICHAR(ASCIIB) is not less than or equal to ICHAR(ASCIIE)) */
+/* then ASTRIP will not function as described. (In fact, it will */
+/* copy the input string to the output string without change.) */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* strip ascii characters from a string */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local Variables */
+
+
+/* Find the length of the output string. We don't want to */
+/* exceed it. */
+
+ outlen = i_len(outstr, outstr_len);
+
+/* Find the last non-blank character of the input string. */
+
+ last = lastnb_(instr, instr_len);
+
+/* Get the numeric representation of ASCIIB and ASCIIE. */
+
+ lwrbnd = *(unsigned char *)asciib;
+ uprbnd = *(unsigned char *)asciie;
+
+/* Step through INSTR (I) a character at a time, transferring */
+/* characters to OUTSTR (J) whenever they fall outside the range */
+/* [ASCIIB, ASCIIE]. */
+
+/* If the end of OUTSTR is reached, stop transferring characters */
+/* and return. */
+
+ j = 0;
+ i__1 = last;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ k = *(unsigned char *)&instr[i__ - 1];
+ if (k < lwrbnd || k > uprbnd) {
+
+/* The character is kept. Note that if the user inputs */
+/* ASCIIB and ASCIIE in the wrong order this test will */
+/* always succeed so that the output string will be */
+/* the same as the input string. */
+
+ ++j;
+ *(unsigned char *)&outstr[j - 1] = *(unsigned char *)&instr[i__ -
+ 1];
+ if (j == outlen) {
+ return 0;
+ }
+ }
+ }
+
+/* Pad the output string with blanks. */
+
+ if (j < outlen) {
+ i__1 = j;
+ s_copy(outstr + i__1, " ", outstr_len - i__1, (ftnlen)1);
+ }
+ return 0;
+} /* astrip_ */
+
diff --git a/ext/spice/src/cspice/axisar.c b/ext/spice/src/cspice/axisar.c
new file mode 100644
index 0000000000..6debcf2310
--- /dev/null
+++ b/ext/spice/src/cspice/axisar.c
@@ -0,0 +1,255 @@
+/* axisar.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure AXISAR ( Axis and angle to rotation ) */
+/* Subroutine */ int axisar_(doublereal *axis, doublereal *angle, doublereal *
+ r__)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ extern /* Subroutine */ int vequ_(doublereal *, doublereal *);
+ integer i__;
+ extern /* Subroutine */ int ident_(doublereal *);
+ doublereal vtemp[3];
+ extern /* Subroutine */ int vrotv_(doublereal *, doublereal *, doublereal
+ *, doublereal *);
+
+/* $ Abstract */
+
+/* Construct a rotation matrix that rotates vectors by a specified */
+/* angle about a specified axis. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* ROTATION */
+
+/* $ Keywords */
+
+/* MATRIX */
+/* ROTATION */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* AXIS I Rotation axis. */
+/* ANGLE I Rotation angle, in radians. */
+/* R O Rotation matrix corresponding to AXIS and ANGLE. */
+
+/* $ Detailed_Input */
+
+/* AXIS, */
+/* ANGLE are, respectively, a rotation axis and a rotation */
+/* angle. AXIS and ANGLE determine a coordinate */
+/* transformation whose effect on any vector V is to */
+/* rotate V by ANGLE radians about the vector AXIS. */
+
+/* $ Detailed_Output */
+
+/* R is a rotation matrix representing the coordinate */
+/* transformation determined by AXIS and ANGLE: for */
+/* each vector V, R*V is the vector resulting from */
+/* rotating V by ANGLE radians about AXIS. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* 1) If AXIS is the zero vector, the rotation generated is the */
+/* identity. This is consistent with the specification of VROTV. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* AXISAR can be thought of as a partial inverse of RAXISA. AXISAR */
+/* really is a `left inverse': the code fragment */
+
+/* CALL RAXISA ( R, AXIS, ANGLE ) */
+/* CALL AXISAR ( AXIS, ANGLE, R ) */
+
+/* preserves R, except for round-off error, as long as R is a */
+/* rotation matrix. */
+
+/* On the other hand, the code fragment */
+
+/* CALL AXISAR ( AXIS, ANGLE, R ) */
+/* CALL RAXISA ( R, AXIS, ANGLE ) */
+
+/* preserves AXIS and ANGLE, except for round-off error, only if */
+/* ANGLE is in the range (0, pi). So AXISAR is a right inverse */
+/* of RAXISA only over a limited domain. */
+
+/* $ Examples */
+
+/* 1) A matrix that rotates vectors by pi/2 radians about the z-axis */
+/* can be found using the code fragment */
+
+/* AXIS(1) = 0.D0 */
+/* AXIS(2) = 0.D0 */
+/* AXIS(3) = 1.D0 */
+
+/* CALL AXISAR ( AXIS, HALFPI(), R ) */
+
+/* The returned matrix R will equal */
+
+/* +- -+ */
+/* | 0 -1 0 | */
+/* | | */
+/* | 1 0 0 |. */
+/* | | */
+/* | 0 0 1 | */
+/* +- -+ */
+
+
+/* 2) Linear interpolation between two rotation matrices: */
+
+/* Let R(t) be a time-varying rotation matrix; R could be */
+/* a C-matrix describing the orientation of a spacecraft */
+/* structure. Given two points in time t1 and t2 at which */
+/* R(t) is known, and given a third time t3, where */
+
+/* t1 < t3 < t2, */
+
+/* we can estimate R(t3) by linear interpolation. In other */
+/* words, we approximate the motion of R by pretending that */
+/* R rotates about a fixed axis at a uniform angular rate */
+/* during the time interval [t1, t2]. More specifically, we */
+/* assume that each column vector of R rotates in this */
+/* fashion. This procedure will not work if R rotates through */
+/* an angle of pi radians or more during the time interval */
+/* [t1, t2]; an aliasing effect would occur in that case. */
+
+/* If we let */
+
+/* R1 = R(t1) */
+/* R2 = R(t2), and */
+
+/* -1 */
+/* Q = R2 * R1 , */
+
+/* then the rotation axis and angle of Q define the rotation */
+/* that each column of R(t) undergoes from time t1 to time */
+/* t2. Since R(t) is orthogonal, we can find Q using the */
+/* transpose of R1. We find the rotation axis and angle via */
+/* RAXISA. */
+
+/* CALL MXMT ( R2, R1, Q ) */
+/* CALL RAXISA ( Q, AXIS, ANGLE ) */
+
+/* Find the fraction of the total rotation angle that R */
+/* rotates through in the time interval [t1, t3]. */
+
+/* FRAC = ( T3 - T1 ) / ( T2 - T1 ) */
+
+/* Finally, find the rotation DELTA that R(t) undergoes */
+/* during the time interval [t1, t3], and apply that rotation */
+/* to R1, yielding R(t3), which we'll call R3. */
+
+/* CALL AXISAR ( AXIS, FRAC * ANGLE, DELTA ) */
+/* CALL MXM ( DELTA, R1, R3 ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 25-AUG-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in VROTV call. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 30-AUG-1990 (NJB) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* axis and angle to rotation */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 25-AUG-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in VROTV call. */
+
+/* Identity matrix is now obtained from IDENT. */
+
+/* -& */
+
+/* Local variables */
+
+
+/* First, set R equal to the identity. */
+
+ ident_(r__);
+
+/* The matrix we want rotates EVERY vector by ANGLE about AXIS. */
+/* In particular, it does so to our basis vectors. The columns */
+/* of R are the images of the basis vectors under this rotation. */
+
+ for (i__ = 1; i__ <= 3; ++i__) {
+ vrotv_(&r__[(i__1 = i__ * 3 - 3) < 9 && 0 <= i__1 ? i__1 : s_rnge(
+ "r", i__1, "axisar_", (ftnlen)240)], axis, angle, vtemp);
+ vequ_(vtemp, &r__[(i__1 = i__ * 3 - 3) < 9 && 0 <= i__1 ? i__1 :
+ s_rnge("r", i__1, "axisar_", (ftnlen)241)]);
+ }
+ return 0;
+} /* axisar_ */
+
diff --git a/ext/spice/src/cspice/axisar_c.c b/ext/spice/src/cspice/axisar_c.c
new file mode 100644
index 0000000000..11d5ced651
--- /dev/null
+++ b/ext/spice/src/cspice/axisar_c.c
@@ -0,0 +1,226 @@
+/*
+
+-Procedure axisar_c ( Axis and angle to rotation )
+
+-Abstract
+
+ Construct a rotation matrix that rotates vectors by a specified
+ angle about a specified axis.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ ROTATION
+
+-Keywords
+
+ MATRIX
+ ROTATION
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #undef axisar_c
+
+
+ void axisar_c ( ConstSpiceDouble axis [3],
+ SpiceDouble angle,
+ SpiceDouble r [3][3] )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ axis I Rotation axis.
+ angle I Rotation angle, in radians.
+ r O Rotation matrix corresponding to axis and angle.
+
+-Detailed_Input
+
+ axis,
+ angle are, respectively, a rotation axis and a rotation
+ angle. axis and angle determine a coordinate
+ transformation whose effect on any vector v is to
+ rotate v by angle radians about the vector axis.
+
+-Detailed_Output
+
+ r is a rotation matrix representing the coordinate
+ transformation determined by axis and angle: for
+ each vector v, r*v is the vector resulting from
+ rotating v by angle radians about axis.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+ 1) If axis is the zero vector, the rotation generated is the
+ identity. This is consistent with the specification of vrotv.
+
+-Files
+
+ None.
+
+-Particulars
+
+ axisar_c can be thought of as a partial inverse of raxisa_c.
+ axisar_c is really is a `left inverse': the code fragment
+
+ raxisa_c ( r, axis, &angle );
+ axisar_c ( axis, angle, r );
+
+ preserves r, except for round-off error, as long as r is a
+ rotation matrix.
+
+ On the other hand, the code fragment
+
+ axisar_c ( axis, angle, r );
+ raxisa_c ( r, axis, &angle );
+
+ preserves axis and angle, except for round-off error, only if
+ angle is in the range (0, pi). So axisar_c is a right inverse
+ of raxisa_c only over a limited domain.
+
+-Examples
+
+ 1) A matrix that rotates vectors by pi/2 radians about the z-axis
+ can be found using the code fragment
+
+ axis[0] = 0.
+ axis[1] = 0.
+ axis[2] = 1.
+
+ axisar_c ( axis, halfpi_c(), r );
+
+ The returned matrix r will equal
+
+ +- -+
+ | 0 -1 0 |
+ | |
+ | 1 0 0 |.
+ | |
+ | 0 0 1 |
+ +- -+
+
+
+ 2) Linear interpolation between two rotation matrices:
+
+ Let r(t) be a time-varying rotation matrix; r could be
+ a C-matrix describing the orientation of a spacecraft
+ structure. Given two points in time t1 and t2 at which
+ r(t) is known, and given a third time t3, where
+
+ t1 < t3 < t2,
+
+ we can estimate r(t3) by linear interpolation. In other
+ words, we approximate the motion of r by pretending that
+ r rotates about a fixed axis at a uniform angular rate
+ during the time interval [t1, t2]. More specifically, we
+ assume that each column vector of r rotates in this
+ fashion. This procedure will not work if r rotates through
+ an angle of pi radians or more during the time interval
+ [t1, t2]; an aliasing effect would occur in that case.
+
+ If we let
+
+ r1 = r(t1)
+ r2 = r(t2), and
+
+ -1
+ q = r2 * r1 ,
+
+ then the rotation axis and angle of q define the rotation
+ that each column of r(t) undergoes from time t1 to time
+ t2. Since r(t) is orthogonal, we can find q using the
+ transpose of r1. We find the rotation axis and angle via
+ raxisa_c.
+
+ mxmt_c ( r2, r1, q );
+ raxisa_c ( q, axis, &angle );
+
+ Find the fraction of the total rotation angle that r
+ rotates through in the time interval [t1, t3].
+
+ frac = ( t3 - t1 ) / ( t2 - t1 )
+
+ Finally, find the rotation delta that r(t) undergoes
+ during the time interval [t1, t3], and apply that rotation
+ to r1, yielding r(t3), which we'll call r3.
+
+ axisar_c ( axis, frac * angle, delta );
+ mxm_c ( delta, r1, r3 );
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 18-JUN-1999 (NJB)
+
+-Index_Entries
+
+ axis and angle to rotation
+
+-&
+*/
+
+{ /* Begin axisar_c */
+
+
+
+ /*
+ Error free: no error tracing required.
+ */
+
+ axisar_ ( ( doublereal * ) axis,
+ ( doublereal * ) &angle,
+ ( doublereal * ) r );
+
+ /*
+ Transpose the output matrix to put it in row-major order.
+ */
+
+ xpose_c ( r, r );
+
+
+} /* End axisar_c */
diff --git a/ext/spice/src/cspice/b1900.c b/ext/spice/src/cspice/b1900.c
new file mode 100644
index 0000000000..b216222b19
--- /dev/null
+++ b/ext/spice/src/cspice/b1900.c
@@ -0,0 +1,126 @@
+/* b1900.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure B1900 ( Besselian Date 1900.0 ) */
+doublereal b1900_(void)
+{
+ /* System generated locals */
+ doublereal ret_val;
+
+/* $ Abstract */
+
+/* Return the Julian Date corresponding to Besselian Date 1900.0. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CONSTANTS */
+
+/* $ Declarations */
+
+/* None. */
+
+/* $ Brief_I/O */
+
+/* The function returns the Julian Date corresponding to Besselian */
+/* date 1900.0. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* The function returns 2415020.31352, the Julian Date corresponding */
+/* to Besselian Date 1900.0. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The function always returns the constant value shown above. */
+
+/* $ Examples */
+
+/* The following code fragment illustrates the use of B1900. */
+
+/* C */
+/* C Convert Julian Date to UTC seconds past the reference */
+/* C epoch (B1900). */
+/* C */
+/* SPREF = ( JD - B1900() ) * SPD() */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* besselian date 1900.0 */
+
+/* -& */
+ ret_val = 2415020.31352;
+ return ret_val;
+} /* b1900_ */
+
diff --git a/ext/spice/src/cspice/b1900_c.c b/ext/spice/src/cspice/b1900_c.c
new file mode 100644
index 0000000000..b2d07a6799
--- /dev/null
+++ b/ext/spice/src/cspice/b1900_c.c
@@ -0,0 +1,136 @@
+/*
+
+-Procedure b1900_c ( Besselian Date 1900.0 )
+
+-Abstract
+
+ Return the Julian Date corresponding to Besselian Date 1900.0.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ CONSTANTS
+
+*/
+
+ #include "SpiceUsr.h"
+
+ SpiceDouble b1900_c ( void )
+
+/*
+
+-Brief_I/O
+
+ The function returns the Julian Date corresponding to Besselian
+ date 1900.0.
+
+-Detailed_Input
+
+ None.
+
+-Detailed_Output
+
+ The function returns 2415020.31352, the Julian Date corresponding
+ to Besselian Date 1900.0 as reported by Lieske [1].
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+-Files
+
+ None.
+
+-Particulars
+
+ Lieske [1] defines a mapping from Julian Ephemeris Date
+ to Besselian:
+
+ BE = 1900. + (JED - 2415020.31352)/365.242198781
+
+ The inverse mapping being:
+
+ JED = (BE - 1900.)*365.242198781 + 2415020.31352
+
+-Examples
+
+ The following code fragment illustrates the use of b1900_c.
+
+ /.
+ Convert Julian Date to UTC seconds past the reference
+ epoch (B1900).
+ ./
+
+ spref = ( jd - b1900_c() ) * spd_c();
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ [1] Jay Lieske, ``Precession Matrix Based on IAU (1976)
+ System of Astronomical Constants,'' Astron. Astrophys.
+ 73, 282-284 (1979).
+
+-Author_and_Institution
+
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.1.0, 01-SEP-2005 (EDW)
+
+ Added journal reference and associated citations.
+
+ -CSPICE Version 1.0.1, 08-FEB-1998 (EDW)
+
+ Corrected and clarified header entries.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (EDW)
+
+-Index_Entries
+
+ besselian date 1900.0
+
+-&
+*/
+
+{ /* Begin b1900_c */
+
+ return 2415020.31352;
+
+} /* End b1900_c */
diff --git a/ext/spice/src/cspice/b1950.c b/ext/spice/src/cspice/b1950.c
new file mode 100644
index 0000000000..5799defd51
--- /dev/null
+++ b/ext/spice/src/cspice/b1950.c
@@ -0,0 +1,144 @@
+/* b1950.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure B1950 ( Besselian Date 1950.0 ) */
+doublereal b1950_(void)
+{
+ /* System generated locals */
+ doublereal ret_val;
+
+/* $ Abstract */
+
+/* Return the Julian Date corresponding to Besselian Date 1950.0. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CONSTANTS */
+
+/* $ Declarations */
+
+/* None. */
+
+/* $ Brief_I/O */
+
+/* The function returns the Julian Date corresponding to Besselian */
+/* date 1950.0. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* The function returns 2433282.42345905, the Julian Date */
+/* corresponding to Besselian Date 1950.0. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The function always returns the constant value shown above. */
+
+/* $ Examples */
+
+/* The following code fragment illustrates the use of B1950. */
+
+/* C */
+/* C Convert Julian Date to UTC seconds past the reference */
+/* C epoch (B1950). */
+/* C */
+/* SPREF = ( JD - B1950() ) * SPD() */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* [1] Jay Lieske, ``Precession Matrix Based on IAU (1976) */
+/* System of Astronomical Constants,'' Astron. Astrophys. */
+/* 73, 282-284 (1979). */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1, 18-AUG-2008 (EDW) */
+
+/* Edited the value stated in Detailed_Output to match the */
+/* current return value. The edit changed: */
+
+/* 2433282.423 */
+
+/* to */
+
+/* 2433282.42345905 */
+
+/* - SPICELIB Version 2.0.0, 30-JUL-1993 (WLT) */
+
+/* The value of B1950 was updated to reflect the value given */
+/* by Lieske in [1] */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* besselian date 1950.0 */
+
+/* -& */
+ ret_val = 2433282.42345905;
+ return ret_val;
+} /* b1950_ */
+
diff --git a/ext/spice/src/cspice/b1950_c.c b/ext/spice/src/cspice/b1950_c.c
new file mode 100644
index 0000000000..18bbdee79f
--- /dev/null
+++ b/ext/spice/src/cspice/b1950_c.c
@@ -0,0 +1,154 @@
+/*
+
+-Procedure b1950_c ( Besselian Date 1950.0 )
+
+-Abstract
+
+ Return the Julian Date corresponding to Besselian Date 1950.0.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ CONSTANTS
+
+*/
+
+ #include "SpiceUsr.h"
+
+ SpiceDouble b1950_c ( void )
+
+/*
+
+-Brief_I/O
+
+ The function returns the Julian Date corresponding to Besselian
+ date 1950.0.
+
+-Detailed_Input
+
+ None.
+
+-Detailed_Output
+
+ The function returns 2433282.42345905, the Julian Date corresponding
+ to Besselian Date 1950.0 as reported by Lieske [1].
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+-Files
+
+ None.
+
+-Particulars
+
+ Lieske [1] defines a mapping from Julian Ephemeris Date
+ to Besselian:
+
+ BE = 1900. + (JED - 2415020.31352)/365.242198781
+
+ The inverse mapping being:
+
+ JED = (BE - 1900.)*365.242198781 + 2415020.31352
+
+-Examples
+
+ The following code fragment illustrates the use of b1950_c.
+
+ /.
+ Convert Julian Date to UTC seconds past the reference
+ epoch (b1950_c).
+ ./
+
+ spref = ( jd - b1950_c() ) * spd_c();
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ [1] Jay Lieske, ``Precession Matrix Based on IAU (1976)
+ System of Astronomical Constants,'' Astron. Astrophys.
+ 73, 282-284 (1979).
+
+-Author_and_Institution
+
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 2.0.0, 01-SEP-2005 (EDW)
+
+ This routine now returns the value reported in the Lieske
+ paper:
+
+ 2433282.42345905
+
+ The same value returned by the FORTRAN SPICELIB routine
+ B1950.
+
+ This routine previously returned the value reported in the
+ "Explanatory Supplement to the Astronomical Almanac", 1992,
+ page 699:
+
+ 2433282.423
+
+ The ESAA value describing a truncation of the Lieske value.
+ The difference between the two values expressed as seconds
+ yields approximately 39.662 seconds.
+
+ -CSPICE Version 1.0.1, 08-FEB-1998 (EDW)
+
+ Corrected and clarified header entries.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (EDW)
+
+-Index_Entries
+
+ besselian date 1950.0
+
+-&
+*/
+
+{ /* Begin b1950_c */
+
+
+ return 2433282.42345905;
+
+
+} /* End b1950_c */
diff --git a/ext/spice/src/cspice/backspace.c b/ext/spice/src/cspice/backspace.c
new file mode 100644
index 0000000000..c3fa545df2
--- /dev/null
+++ b/ext/spice/src/cspice/backspace.c
@@ -0,0 +1,69 @@
+#include "f2c.h"
+#include "fio.h"
+#ifdef KR_headers
+integer f_back(a) alist *a;
+#else
+integer f_back(alist *a)
+#endif
+{ unit *b;
+ long v, w, x, y, z;
+ uiolen n;
+ FILE *f;
+
+ f__curunit = b = &f__units[a->aunit]; /* curunit for error messages */
+ if(a->aunit >= MXUNIT || a->aunit < 0)
+ err(a->aerr,101,"backspace")
+ if(b->useek==0) err(a->aerr,106,"backspace")
+ if((f = b->ufd) == NULL) {
+ fk_open(1, 1, a->aunit);
+ return(0);
+ }
+ if(b->uend==1)
+ { b->uend=0;
+ return(0);
+ }
+ if(b->uwrt) {
+ (void) t_runc(a);
+ if (f__nowreading(b))
+ err(a->aerr,errno,"backspace")
+ }
+ if(b->url>0)
+ {
+ x=ftell(f);
+ y = x % b->url;
+ if(y == 0) x--;
+ x /= b->url;
+ x *= b->url;
+ (void) fseek(f,x,SEEK_SET);
+ return(0);
+ }
+
+ if(b->ufmt==0)
+ { fseek(f,-(long)sizeof(uiolen),SEEK_CUR);
+ fread((char *)&n,sizeof(uiolen),1,f);
+ fseek(f,-(long)n-2*sizeof(uiolen),SEEK_CUR);
+ return(0);
+ }
+ w = x = ftell(f);
+ z = 0;
+ loop:
+ while(x) {
+ x -= x < 64 ? x : 64;
+ fseek(f,x,SEEK_SET);
+ for(y = x; y < w; y++) {
+ if (getc(f) != '\n')
+ continue;
+ v = ftell(f);
+ if (v == w) {
+ if (z)
+ goto break2;
+ goto loop;
+ }
+ z = v;
+ }
+ err(a->aerr,(EOF),"backspace")
+ }
+ break2:
+ fseek(f, z, SEEK_SET);
+ return 0;
+}
diff --git a/ext/spice/src/cspice/badkpv.c b/ext/spice/src/cspice/badkpv.c
new file mode 100644
index 0000000000..59b0ce5c99
--- /dev/null
+++ b/ext/spice/src/cspice/badkpv.c
@@ -0,0 +1,393 @@
+/* badkpv.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BADKPV ( Bad Kernel Pool Variable ) */
+logical badkpv_(char *caller, char *name__, char *comp, integer *size,
+ integer *divby, char *type__, ftnlen caller_len, ftnlen name_len,
+ ftnlen comp_len, ftnlen type_len)
+{
+ /* System generated locals */
+ logical ret_val;
+
+ /* Builtin functions */
+ integer s_cmp(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ extern logical eqchr_(char *, char *, ftnlen, ftnlen);
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
+ char class__[1];
+ logical found;
+ integer ratio;
+ logical ok;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), dtpool_(char *, logical *, integer *, char *, ftnlen,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern logical return_(void);
+ integer dim;
+
+/* $ Abstract */
+
+/* Determine if a kernel pool variable is present and if so */
+/* that it has the correct size and type. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ERROR */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* CALLER I Name of the routine calling this routine. */
+/* NAME I Name of a kernel pool variable */
+/* COMP I Comparison operator. */
+/* SIZE I Expected size of the kernel pool variable */
+/* DIVBY I A divisor of the size of the kernel pool variable. */
+/* TYPE I Expected type of the kernel pool variable */
+
+/* The function returns FALSE if the kernel pool variable is OK */
+
+/* $ Detailed_Input */
+
+/* CALLER is the name of the routine calling this routine */
+/* to check correctness of kernel pool variables. */
+
+/* NAME is the name of a kernel pool variable that the */
+/* calling program expects to be present in the */
+/* kernel pool. */
+
+/* COMP is the comparison operator to use when comparing */
+/* the number of components of the kernel pool variable */
+/* specified by NAME with the integer SIZE. If DIM is */
+/* is the actual size of the kernel pool variable then */
+/* BADKPV will check that the sentence */
+
+/* DIM COMP SIZE */
+
+/* is a true statement. If it is not a true statement */
+/* an error will be signalled. */
+
+/* Allowed values for COMP and their meanings are: */
+
+/* '=' DIM .EQ. SIZE */
+/* '<' DIM .LT. SIZE */
+/* '>' DIM .GT. SIZE */
+/* '=>' DIM .GE. SIZE */
+/* '<=' DIM .LE. SIZE */
+
+
+/* SIZE is an integer to compare with the actual */
+/* number of components of the kernel pool variable */
+/* specified by NAME. */
+
+/* DIVBY is an integer that is one of the factors of the */
+/* actual dimension of the specified kernel pool variable. */
+/* In other words, it is expected that DIVBY evenly */
+/* divides the actual dimension of NAME. In those */
+/* cases in which the factors of the dimension of NAME */
+/* are not important, set DIVBY to 1 in the calling */
+/* program. */
+
+/* TYPE is the expected type of the kernel pool variable. */
+/* Recognize values are */
+
+/* 'C' for character type */
+/* 'N' for numeric type (integer and double precision) */
+
+/* The case of type is insignificant. If the value */
+/* of TYPE is not one of the 2 values given above */
+/* no check for the type of the variable will be */
+/* performed. */
+
+
+/* $ Detailed_Output */
+
+/* The function returns the value FALSE if the kernel pool variable */
+/* has the expected properties. Otherwise the routine signals */
+/* an error and returns the value .TRUE. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the kernel pool variable specified by NAME is not */
+/* present in the kernels pool, the error */
+/* 'SPICE(VARIABLENOTFOUND)' will be signalled and the */
+/* routine will return the value .TRUE. */
+
+/* 2) If the comparison operator specified by COMP is unrecognized */
+/* the error 'SPICE(UNKNOWNCOMPARE)' will be signalled and the */
+/* routine will return the value .TRUE. */
+
+/* 3) If the comparison of the actual size of the kernel pool */
+/* variable with SIZE is not satisfied, the error */
+/* 'SPICE(BADVARIABLESIZE)' will be signalled and the */
+/* routine will return the value .TRUE. */
+
+/* 4) If the variable does not have the expected type, the error */
+/* 'SPICE(BADVARIABLETYPE)' will be signalled and the routine */
+/* will return the value .TRUE. */
+
+/* $ Particulars */
+
+/* This routine takes care of routine checking that often needs */
+/* to be done by programs and routines that rely upon kernel */
+/* pool variables being present and having the correct attributes. */
+
+/* It checks for the presence of the kernel pool variable and */
+/* examines the type and dimension of the variable to make sure */
+/* they conform to the requirements of the calling routine. */
+
+/* $ Examples */
+
+/* Suppose that you need to fetch a number of variables */
+/* from the kernel pool and want to check that the requested */
+/* items are in fact available prior to performing further */
+/* computations. The following shows how you might use */
+/* this routine to handle the details of checking of */
+/* the various items. */
+
+/* CALLER = 'MYROUTINE' */
+
+/* We need some data for body 399 and we expect there to be an */
+/* even number of items available and at least 4 such items. */
+/* Moreover we expect these items to be numeric. Note that */
+/* The variable assignments below are comments and are present */
+/* only to assist in understanding the calls to BADKPV. */
+
+/* C NAME = 'BODY_399_DATA' */
+/* C COMP = '=>' */
+/* C SIZE = 4 */
+/* C DIVBY = 2 */
+/* C TYPE = 'N' */
+
+/* In addition we need the units associated with this data. */
+/* We expect the units to be character and that the number */
+/* of components is 1. Since we expect only one item, the */
+/* number of items should be divisible by 1. */
+
+/* C NAME = 'BODY_399_DATAUNIT' */
+/* C COMP = '=' */
+/* C SIZE = 1 */
+/* C DIVBY = 1 */
+/* C TYPE = 'C' */
+
+/* IF ( BADKPV( CALLER, 'BODY_399_DATA', '=>', 4, 2, 'N') */
+/* . .OR. BADKPV( CALLER, 'BODY_399_DATAUNITS', '=', 1, 1, 'C')) */
+/* . THEN */
+
+/* CALL CHKOUT ( 'MYROUTINE' ) */
+/* RETURN */
+
+/* END IF */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.2, 22-AUG-2006 (EDW) */
+
+/* Replaced references to LDPOOL with references */
+/* to FURNSH. */
+
+/* - SPICELIB Version 1.1.1, 10-MAY-2000 (WLT) */
+
+/* Modified the example section so that it is consistent with */
+/* calling sequence for BADKPV. */
+
+/* - SPICELIB Version 1.1.0, 26-AUG-1997 (WLT) */
+
+/* Moved the initial assignment of BADKPV to the lines */
+/* prior to the check of RETURN(). This avoids returning */
+/* without having assigned value to BADKPV. */
+
+/* - SPICELIB Version 1.0.0, 09-APR-1997 (WLT) */
+
+
+/* -& */
+/* $ Index_Entries */
+
+/* Check the properties of a kernel pool variable */
+
+/* -& */
+
+/* SPICELIB Functions */
+
+
+/* Local Variables */
+
+
+/* Until we know otherwise, we shall assume that we have */
+/* a bad kernel pool variable. */
+
+ ret_val = TRUE_;
+ if (return_()) {
+ return ret_val;
+ }
+ chkin_("BADKPV", (ftnlen)6);
+
+/* Look up the attributes of this variable in the kernel pool. */
+
+ dtpool_(name__, &found, &dim, class__, name_len, (ftnlen)1);
+ if (! found) {
+ setmsg_("#: The kernel pool variable '#' is not currently present in"
+ " the kernel pool. Possible reasons are that the appropriate "
+ "text kernel file has not been loaded via a call to FURNSH or"
+ " that the routine CLPOOL has been called after loading the a"
+ "ppropriate file. ", (ftnlen)256);
+ errch_("#", caller, (ftnlen)1, caller_len);
+ errch_("#", name__, (ftnlen)1, name_len);
+ sigerr_("SPICE(VARIABLENOTFOUND)", (ftnlen)23);
+ chkout_("BADKPV", (ftnlen)6);
+ return ret_val;
+ }
+
+/* Compare the dimension of the specified variable with the */
+/* input SIZE. */
+
+ if (s_cmp(comp, "=", comp_len, (ftnlen)1) == 0) {
+ ok = dim == *size;
+ } else if (s_cmp(comp, "<", comp_len, (ftnlen)1) == 0) {
+ ok = dim < *size;
+ } else if (s_cmp(comp, ">", comp_len, (ftnlen)1) == 0) {
+ ok = dim > *size;
+ } else if (s_cmp(comp, "<=", comp_len, (ftnlen)2) == 0) {
+ ok = dim <= *size;
+ } else if (s_cmp(comp, "=>", comp_len, (ftnlen)2) == 0) {
+ ok = dim >= *size;
+ } else {
+ setmsg_("#: The comparison operator '#' is not a recognized value. "
+ "The recognized values are '<', '<=', '=', '=>', '>'. ", (
+ ftnlen)112);
+ errch_("#", caller, (ftnlen)1, caller_len);
+ errch_("#", comp, (ftnlen)1, comp_len);
+ sigerr_("SPICE(UNKNOWNCOMPARE)", (ftnlen)21);
+ chkout_("BADKPV", (ftnlen)6);
+ return ret_val;
+ }
+
+/* If the comparison was not favorable, signal an error */
+/* and return. */
+
+ if (! ok) {
+ setmsg_("#: The kernel pool variable '#' is expected to have a numbe"
+ "r of components DIM such that the comparison DIM # # is TRUE"
+ ". However, the current number of components for '#' is #. ",
+ (ftnlen)178);
+ errch_("#", caller, (ftnlen)1, caller_len);
+ errch_("#", name__, (ftnlen)1, name_len);
+ errch_("#", comp, (ftnlen)1, comp_len);
+ errint_("#", size, (ftnlen)1);
+ errch_("#", name__, (ftnlen)1, name_len);
+ errint_("#", &dim, (ftnlen)1);
+ sigerr_("SPICE(BADVARIABLESIZE)", (ftnlen)22);
+ chkout_("BADKPV", (ftnlen)6);
+ return ret_val;
+ }
+
+/* Check to see that DIVBY evenly divides the dimension of */
+/* the variable. */
+
+ if (*divby != 0) {
+ ratio = dim / *divby;
+ } else {
+ ratio = 1;
+ }
+ if (*divby * ratio != dim) {
+ setmsg_("#: The number of components of the kernel pool variable '#'"
+ " is required to be divisible by #. However, the actual numb"
+ "er of components is # which is not evenly divisible by #. ", (
+ ftnlen)177);
+ errch_("#", caller, (ftnlen)1, caller_len);
+ errch_("#", name__, (ftnlen)1, name_len);
+ errint_("#", divby, (ftnlen)1);
+ errint_("#", &dim, (ftnlen)1);
+ errint_("#", divby, (ftnlen)1);
+ sigerr_("SPICE(BADVARIABLESIZE)", (ftnlen)22);
+ chkout_("BADKPV", (ftnlen)6);
+ return ret_val;
+ }
+
+/* Finally check the type of the variable. */
+
+ if (eqchr_(type__, "C", type_len, (ftnlen)1)) {
+ if (*(unsigned char *)class__ != 'C') {
+ setmsg_("#: The kernel pool variable '#' must be of type \"CHARA"
+ "CTER\". However, the current type is numeric. ", (ftnlen)
+ 99);
+ errch_("#", caller, (ftnlen)1, caller_len);
+ errch_("#", name__, (ftnlen)1, name_len);
+ sigerr_("SPICE(BADVARIABLETYPE)", (ftnlen)22);
+ chkout_("BADKPV", (ftnlen)6);
+ return ret_val;
+ }
+ } else if (eqchr_(type__, "N", type_len, (ftnlen)1)) {
+ if (*(unsigned char *)class__ != 'N') {
+ setmsg_("#: The kernel pool variable '#' must be of type \"NUMER"
+ "IC\". However, the current type is character. ", (ftnlen)
+ 100);
+ errch_("#", caller, (ftnlen)1, caller_len);
+ errch_("#", name__, (ftnlen)1, name_len);
+ sigerr_("SPICE(BADVARIABLETYPE)", (ftnlen)22);
+ chkout_("BADKPV", (ftnlen)6);
+ return ret_val;
+ }
+ }
+ ret_val = FALSE_;
+ chkout_("BADKPV", (ftnlen)6);
+ return ret_val;
+} /* badkpv_ */
+
diff --git a/ext/spice/src/cspice/badkpv_c.c b/ext/spice/src/cspice/badkpv_c.c
new file mode 100644
index 0000000000..3e79d0061c
--- /dev/null
+++ b/ext/spice/src/cspice/badkpv_c.c
@@ -0,0 +1,281 @@
+/*
+
+-Procedure badkpv_c ( Bad Kernel Pool Variable )
+
+-Abstract
+
+ Determine if a kernel pool variable is present and if so
+ that it has the correct size and type.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ ERROR
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ SpiceBoolean badkpv_c ( ConstSpiceChar *caller,
+ ConstSpiceChar *name,
+ ConstSpiceChar *comp,
+ SpiceInt size,
+ SpiceInt divby,
+ SpiceChar type )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ caller I Name of the routine calling this routine.
+ name I Name of a kernel pool variable
+ comp I Comparison operator.
+ size I Expected size of the kernel pool variable
+ divby I A divisor of the size of the kernel pool variable.
+ type I Expected type of the kernel pool variable
+
+ The function returns SPICEFALSE if the kernel pool variable is OK.
+
+-Detailed_Input
+
+ caller is the name of the routine calling this routine
+ to check correctness of kernel pool variables.
+
+ name is the name of a kernel pool variable that the
+ calling program expects to be present in the
+ kernel pool.
+
+ comp is the comparison operator to use when comparing
+ the number of components of the kernel pool variable
+ specified by name with the integer size. If dim is
+ is the actual size of the kernel pool variable then
+ badkpv_c will check that the sentence
+
+ dim comp size
+
+ is a true statement. If it is not a true statement
+ an error will be signaled.
+
+ Allowed values for comp and their meanings are:
+
+ "=" dim == size
+ "<" dim < size
+ ">" dim > size
+ "=>" dim >= size
+ "<=" dim <= size
+
+
+ size is an integer to compare with the actual
+ number of components of the kernel pool variable
+ specified by name.
+
+ divby is an integer that is one of the factors of the
+ actual dimension of the specified kernel pool variable.
+ In other words, it is expected that divby evenly
+ divides the actual dimension of name. In those
+ cases in which the factors of the dimension of name
+ are not important, set divby to 1 in the calling
+ program.
+
+ type is the expected type of the kernel pool variable.
+ Recognized values are
+
+ 'C' for character type
+ 'N' for numeric type (integer and double precision)
+
+ The case of type is insignificant. If the value
+ of TYPE is not one of the 2 values given above
+ no check for the type of the variable will be
+ performed.
+
+
+-Detailed_Output
+
+ The function returns the value SPICEFALSE if the kernel pool variable
+ has the expected properties. Otherwise the routine signals
+ an error and returns the value SPICETRUE.
+
+-Parameters
+
+ None.
+
+-Files
+
+ None.
+
+-Exceptions
+
+ 1) If the kernel pool variable specified by name is not
+ present in the kernel pool, the error
+ SPICE(VARIABLENOTFOUND) will be signaled and the
+ routine will return the value SPICETRUE.
+
+ 2) If the comparison operator specified by comp is unrecognized
+ the error SPICE(UNKNOWNCOMPARE) will be signaled and the
+ routine will return the value SPICETRUE.
+
+ 3) If the comparison of the actual size of the kernel pool
+ variable with size is not satisfied, the error
+ SPICE(BADVARIABLESIZE) will be signaled and the
+ routine will return the value SPICETRUE.
+
+ 4) If the variable does not have the expected type, the error
+ SPICE(BADVARIABLETYPE) will be signaled and the routine
+ will return the value SPICETRUE.
+
+ 5) If any input string pointers are null, the error
+ SPICE(NULLPOINTER) will be signaled.
+
+ 6) If any input strings have length zero, the error
+ SPICE(EMPTYSTRING) will be signaled.
+
+-Particulars
+
+ This routine takes care of routine checking that often needs
+ to be done by programs and routines that rely upon kernel
+ pool variables being present and having the correct attributes.
+
+ It checks for the presence of the kernel pool variable and
+ examines the type and dimension of the variable to make sure
+ they conform to the requirements of the calling routine.
+
+-Examples
+
+ Suppose that you need to fetch a number of variables
+ from the kernel pool and want to check that the requested
+ items are in fact available prior to performing further
+ computations. The following shows how you might use
+ this routine to handle the details of checking of
+ the various items.
+
+ caller == "MYROUTINE"
+
+ We need some data for body 399 and we expect there to
+ be an even number of items available. Moreover we
+ expect these items to be numeric.
+
+ name == "BODY_399_DATA"
+ comp == ">"
+ size == 1
+ divby == 2
+ type == 'N'
+
+ In addition we need the units associated with this data.
+ We expect the units to be character and that the number
+ of components is 1.
+
+ name == "BODY_399_DATAUNIT";
+ comp == "="
+ size == 1
+ divby == 1
+ type == 'C'
+
+
+ if ( badkpv_c( caller, "BODY_399_DATA", ">", 1, 2, 'N' )
+ || badkpv_c( caller, "BODY_399_DATAUNITS", "=", 1, 1, 'C' ) )
+ {
+ chkout_c ( "MYROUTINE" );
+ return;
+ }
+
+
+-Restrictions
+
+ None.
+
+-Author_and_Institution
+
+ W.L. Taber (JPL)
+ N.J. Bachman (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 07-JUL-2000 (WLT) (NJB)
+
+-Index_Entries
+
+ Check the properties of a kernel pool variable
+
+-&
+*/
+
+{ /* Begin badkpv_c */
+
+
+ /*
+ Local variables
+ */
+ logical isbad;
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "badkpv_c" );
+
+
+ /*
+ Check the input strings to make sure the pointers are non-null
+ and the string lengths are non-zero.
+ */
+ CHKFSTR_VAL ( CHK_STANDARD, "badkpv_c", caller, SPICETRUE );
+ CHKFSTR_VAL ( CHK_STANDARD, "badkpv_c", name, SPICETRUE );
+ CHKFSTR_VAL ( CHK_STANDARD, "badkpv_c", comp, SPICETRUE );
+
+ /*
+ Let the f2c'd routine do all the work.
+ */
+ isbad = badkpv_ ( (char *) caller,
+ (char *) name,
+ (char *) comp,
+ (integer *) &size,
+ (integer *) &divby,
+ (char *) &type,
+ (ftnlen ) strlen(caller),
+ (ftnlen ) strlen(name),
+ (ftnlen ) strlen(comp),
+ (ftnlen ) 1 );
+
+
+ chkout_c ( "badkpv_c" );
+
+ return ( (SpiceBoolean) isbad );
+
+} /* End badkpv_c */
diff --git a/ext/spice/src/cspice/bedec.c b/ext/spice/src/cspice/bedec.c
new file mode 100644
index 0000000000..9f265757a4
--- /dev/null
+++ b/ext/spice/src/cspice/bedec.c
@@ -0,0 +1,278 @@
+/* bedec.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+
+/* $Procedure BEDEC ( Be a decimal number? ) */
+logical bedec_(char *string, ftnlen string_len)
+{
+ /* System generated locals */
+ logical ret_val;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen), s_cmp(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer c__, d__, e, l;
+ extern logical beint_(char *, ftnlen), beuns_(char *, ftnlen);
+ extern integer pos_(char *, char *, integer *, ftnlen, ftnlen);
+
+/* $ Abstract */
+
+/* Determine whether a string represents a decimal number. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* WORDS */
+
+/* $ Keywords */
+
+/* ALPHANUMERIC */
+/* NUMBERS */
+/* SCANNING */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* STRING I Character string. */
+
+/* The function returns TRUE if the string represents a decimal */
+/* number. Otherwise, it returns FALSE. */
+
+/* $ Detailed_Input */
+
+/* STRING is any string. */
+
+/* $ Detailed_Output */
+
+/* If the input string contains a decimal number (as defined */
+/* in $Particulars below), the function returns TRUE. Otherwise, */
+/* the functions returns FALSE. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* A decimal number may be constructed by concatenating */
+/* the following components in the order shown. */
+
+/* 1) A sign ('+' or '-'), or the null string. */
+
+/* 2) An unsigned integer (as defined by function BEUNS), */
+/* or the null string. */
+
+/* 3) A decimal point, or the null string. */
+
+/* 4) An unsigned integer, or the null string. */
+
+/* $ Examples */
+
+/* Four classes of numbers recognized by the various BE functions. */
+
+/* UNS unsigned integer */
+/* INT integer (includes INT) */
+/* DEC decimal number (includes UNS, INT) */
+/* NUM number (includes UNS, INT, NUM) */
+
+/* The following table illustrates the differences between */
+/* the classes. (Any number of leading and trailing blanks */
+/* are acceptable.) */
+
+/* String Accepted by */
+/* ------------------ ------------------ */
+/* 0 UNS, INT, DEC, NUM */
+/* 21 */
+/* 21994217453648 */
+
+/* +0 INT, DEC, NUM */
+/* -13 */
+/* +21946 */
+
+/* 1.23 DEC, NUM */
+/* 12. */
+/* .17 */
+/* +4.1 */
+/* -.25 */
+
+/* 2.3e17 NUM */
+/* 17.D-13275849 */
+/* -.194265E+0004 */
+
+/* Note that the functions don't take the magnitudes of the numbers */
+/* into account. They may accept numbers that cannot be represented */
+/* in Fortran variables. (For example, '2.19E999999999999' probably */
+/* exceeds the maximum floating point number on any machine, but */
+/* is perfectly acceptable to BENUM.) */
+
+/* The following strings are not accepted by any of the functions. */
+
+/* String Reason */
+/* --------------- ---------------------------------------- */
+/* 3/4 No implied operations (rational numbers) */
+/* 37+14 No explicit operations */
+/* E12 Must have mantissa */
+/* 217,346.91 No commas */
+/* 3.14 159 264 No embedded spaces */
+/* PI No special numbers */
+/* FIVE No textual numbers */
+/* CXIV No roman numerals */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 01-DEC-1995 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* determine if a string is a decimal number */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local Variables */
+
+
+/* First determine whether or not a decimal point is present. */
+
+ d__ = pos_(string, ".", &c__1, string_len, (ftnlen)1);
+ c__ = d__ - 1;
+ e = d__ + 1;
+ if (d__ == 0) {
+
+/* If there is no decimal point just apply the integer test. */
+
+ ret_val = beint_(string, string_len);
+ } else {
+
+/* A decimal point is present, get the length of the string */
+/* and see where the decimal point is relative to the last */
+/* character. */
+
+ l = i_len(string, string_len);
+ if (l == 1) {
+
+/* The string is one character long and a decimal point. */
+/* Sorry, this is not a decimal number. */
+
+ ret_val = FALSE_;
+ } else if (d__ == 1) {
+
+/* The decimal point occurs as the first character of the */
+/* string. The string following it must begin with */
+/* a non-blank character and be an unsigned integer. */
+
+ ret_val = *(unsigned char *)&string[e - 1] != ' ' && beuns_(
+ string + (e - 1), string_len - (e - 1));
+ } else if (d__ == l) {
+
+/* The decimal point is the last character of the string. */
+/* The character that precedes it must be non-blank and */
+/* the substring to the left must be an integer. */
+
+ ret_val = *(unsigned char *)&string[c__ - 1] != ' ' && beint_(
+ string, c__);
+ } else if (*(unsigned char *)&string[c__ - 1] == ' ') {
+
+/* The decimal point occurs somewhere in the middle of the */
+/* string and the character preceding it is blank. */
+
+ ret_val = *(unsigned char *)&string[e - 1] != ' ' && s_cmp(string,
+ " ", c__, (ftnlen)1) == 0 && beuns_(string + (e - 1),
+ string_len - (e - 1));
+ } else if (*(unsigned char *)&string[e - 1] == ' ') {
+
+/* Again the decimal point occurs somewhere in the middle of */
+/* the string and the character following it is blank. */
+
+ ret_val = s_cmp(string + (e - 1), " ", l - (e - 1), (ftnlen)1) ==
+ 0 && *(unsigned char *)&string[c__ - 1] != ' ' && beint_(
+ string, c__);
+ } else if (*(unsigned char *)&string[c__ - 1] == '-' || *(unsigned
+ char *)&string[c__ - 1] == '+') {
+
+/* The decimal point is in the middle of the string and */
+/* is preceded by a '+' or '-'. There should be nothing */
+/* preceeding the sign and what follows the decimal point */
+/* should be an unsigned integer. (we already know that the */
+/* character following the decimal point is not a blank) */
+
+ if (c__ == 1) {
+ ret_val = beuns_(string + (e - 1), l - (e - 1));
+ } else {
+ ret_val = beuns_(string + (e - 1), l - (e - 1)) && s_cmp(
+ string, " ", c__ - 1, (ftnlen)1) == 0;
+ }
+ } else {
+
+/* Last chance, the decimal point is in the middle of the */
+/* string. The characters to the right and left of the */
+/* point are non-blank and we know the character to the */
+/* left of the point is not a sign. The string left must */
+/* be an integer, the string to the right must be an */
+/* unsigned integer. */
+
+ ret_val = beint_(string, c__) && beuns_(string + (e - 1), l - (e
+ - 1));
+ }
+ }
+ return ret_val;
+} /* bedec_ */
+
diff --git a/ext/spice/src/cspice/beint.c b/ext/spice/src/cspice/beint.c
new file mode 100644
index 0000000000..716ccbf05d
--- /dev/null
+++ b/ext/spice/src/cspice/beint.c
@@ -0,0 +1,227 @@
+/* beint.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BEINT ( Be an Integer? ) */
+logical beint_(char *string, ftnlen string_len)
+{
+ /* System generated locals */
+ logical ret_val;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen);
+
+ /* Local variables */
+ integer i__, l;
+ extern logical beuns_(char *, ftnlen);
+ extern integer frstnb_(char *, ftnlen);
+ char letter[1];
+
+/* $ Abstract */
+
+/* Determine whether a string represents an integer. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* WORDS */
+
+/* $ Keywords */
+
+/* ALPHANUMERIC */
+/* NUMBERS */
+/* SCANNING */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* STRING I Character string. */
+
+/* The function returns TRUE if the string represents an integer. */
+/* Otherwise, it returns FALSE. */
+
+/* $ Detailed_Input */
+
+/* STRING is any string. */
+
+/* $ Detailed_Output */
+
+/* If the input string contains an integer (as defined in */
+/* $Particulars below), the function returns TRUE. Otherwise, */
+/* the function returns FALSE. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* An integer may be either of the following: */
+
+/* 1) An unsigned integer (as defined by function BEUNS). */
+
+/* 2) A sign ('+' or '-') followed by an unsigned */
+/* integer. */
+
+/* $ Examples */
+
+/* Four classes of numbers recognized by the various BE functions. */
+
+/* UNS unsigned integer */
+/* INT integer (includes INT) */
+/* DEC decimal number (includes UNS, INT) */
+/* NUM number (includes UNS, INT, NUM) */
+
+/* The following table illustrates the differences between */
+/* the classes. (Any number of leading and trailing blanks */
+/* are acceptable.) */
+
+/* String Accepted by */
+/* ------------------ ------------------ */
+/* 0 UNS, INT, DEC, NUM */
+/* 21 */
+/* 21994217453648 */
+
+/* +0 INT, DEC, NUM */
+/* -13 */
+/* +21946 */
+
+/* 1.23 DEC, NUM */
+/* 12. */
+/* .17 */
+/* +4.1 */
+/* -.25 */
+
+/* 2.3e17 NUM */
+/* 17.D-13275849 */
+/* -.194265E+0004 */
+
+/* Note that the functions don't take the magnitudes of the numbers */
+/* into account. They may accept numbers that cannot be represented */
+/* in Fortran variables. (For example, '2.19E999999999999' probably */
+/* exceeds the maximum floating point number on any machine, but */
+/* is perfectly acceptable to BENUM.) */
+
+/* The following strings are not accepted by any of the functions. */
+
+/* String Reason */
+/* --------------- ---------------------------------------- */
+/* 3/4 No implied operations (rational numbers) */
+/* 37+14 No explicit operations */
+/* E12 Must have mantissa */
+/* 217,346.91 No commas */
+/* 3.14 159 264 No embedded spaces */
+/* PI No special numbers */
+/* FIVE No textual numbers */
+/* CXIV No roman numerals */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 01-DEC-1995 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* determine if a string is an integer */
+
+/* -& */
+
+/* Find the first non-blank character and the length of the */
+/* string. */
+
+ l = i_len(string, string_len);
+ i__ = frstnb_(string, string_len);
+
+/* If there isn't a non-blank character, this isn't an */
+/* integer. */
+
+ if (i__ == 0) {
+ ret_val = FALSE_;
+ return ret_val;
+ }
+
+/* Copy the first non-blank letter in the string. */
+
+ *(unsigned char *)letter = *(unsigned char *)&string[i__ - 1];
+ if (i__ < l) {
+
+/* The first character is not the last, so we might start with */
+/* a plus or minus. If so the rest must be an unsigned integer. */
+
+ if (*(unsigned char *)letter == '+' || *(unsigned char *)letter ==
+ '-') {
+ ++i__;
+ if (*(unsigned char *)&string[i__ - 1] != ' ') {
+ ret_val = beuns_(string + (i__ - 1), string_len - (i__ - 1));
+ } else {
+ ret_val = FALSE_;
+ }
+ } else {
+
+/* If the first character isn't plus (+) or minus (-) */
+/* the string must be an unsigned integer if its going */
+/* to be an integer. */
+
+ ret_val = beuns_(string + (i__ - 1), string_len - (i__ - 1));
+ }
+ } else {
+
+/* If the first (non-blank) character is the last one, then */
+/* it must be an unsigned integer, for the string to */
+/* represent an integer. */
+
+ ret_val = beuns_(letter, (ftnlen)1);
+ }
+ return ret_val;
+} /* beint_ */
+
diff --git a/ext/spice/src/cspice/benum.c b/ext/spice/src/cspice/benum.c
new file mode 100644
index 0000000000..fb84a2edc8
--- /dev/null
+++ b/ext/spice/src/cspice/benum.c
@@ -0,0 +1,214 @@
+/* benum.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+
+/* $Procedure BENUM ( Be a number? ) */
+logical benum_(char *string, ftnlen string_len)
+{
+ /* System generated locals */
+ logical ret_val;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen);
+
+ /* Local variables */
+ extern integer cpos_(char *, char *, integer *, ftnlen, ftnlen);
+ extern logical bedec_(char *, ftnlen);
+ integer d__, e, f, l;
+ extern logical beint_(char *, ftnlen);
+
+/* $ Abstract */
+
+/* Determine whether a string represents a number. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* WORDS */
+
+/* $ Keywords */
+
+/* ALPHANUMERIC */
+/* NUMBERS */
+/* SCANNING */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* STRING I Character string. */
+
+/* The function returns TRUE if the string is a number. */
+/* Otherwise, it returns FALSE. */
+
+/* $ Detailed_Input */
+
+/* STRING is any string. */
+
+/* $ Detailed_Output */
+
+/* If the input string contains a number (as defined in */
+/* $Particulars below) the function returns TRUE. Otherwise, */
+/* the function returns FALSE. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* A number may be either of the following: */
+
+/* 1) A decimal number (as defined by function BEDEC). */
+
+/* 2) A decimal number followed by an exponent character */
+/* ('E', 'e', 'D', or 'd') and an integer (as defined */
+/* by function BEINT). */
+
+/* $ Examples */
+
+/* Four classes of numbers recognized by the various BE functions. */
+
+/* UNS unsigned integer */
+/* INT integer (includes INT) */
+/* DEC decimal number (includes UNS, INT) */
+/* NUM number (includes UNS, INT, NUM) */
+
+/* The following table illustrates the differences between */
+/* the classes. (Any number of leading and trailing blanks */
+/* are acceptable.) */
+
+/* String Accepted by */
+/* ------------------ ------------------ */
+/* 0 UNS, INT, DEC, NUM */
+/* 21 */
+/* 21994217453648 */
+
+/* +0 INT, DEC, NUM */
+/* -13 */
+/* +21946 */
+
+/* 1.23 DEC, NUM */
+/* 12. */
+/* .17 */
+/* +4.1 */
+/* -.25 */
+
+/* 2.3e17 NUM */
+/* 17.D-13275849 */
+/* -.194265E+0004 */
+
+/* Note that the functions don't take the magnitudes of the numbers */
+/* into account. They may accept numbers that cannot be represented */
+/* in Fortran variables. (For example, '2.19E999999999999' probably */
+/* exceeds the maximum floating point number on any machine, but */
+/* is perfectly acceptable to BENUM.) */
+
+/* The following strings are not accepted by any of the functions. */
+
+/* String Reason */
+/* --------------- ---------------------------------------- */
+/* 3/4 No implied operations (rational numbers) */
+/* 37+14 No explicit operations */
+/* E12 Must have mantissa */
+/* 217,346.91 No commas */
+/* 3.14 159 264 No embedded spaces */
+/* PI No special numbers */
+/* FIVE No textual numbers */
+/* CXIV No roman numerals */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 01-DEC-1995 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* determine if a string is a number */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local Variables */
+
+
+/* Determine whether or not there is an exponent character in the */
+/* string. */
+
+ l = i_len(string, string_len);
+ e = cpos_(string, "EeDd", &c__1, string_len, (ftnlen)4);
+ d__ = e - 1;
+ f = e + 1;
+ if (e == 0) {
+
+/* There is no exponent character, this is a number if it */
+/* is a decimal number. */
+
+ ret_val = bedec_(string, string_len);
+ } else if (e == 1 || e == l) {
+ ret_val = FALSE_;
+ } else if (*(unsigned char *)&string[d__ - 1] == ' ' || *(unsigned char *)
+ &string[f - 1] == ' ') {
+ ret_val = FALSE_;
+ } else {
+ ret_val = bedec_(string, d__) && beint_(string + (f - 1), l - (f - 1))
+ ;
+ }
+ return ret_val;
+} /* benum_ */
+
diff --git a/ext/spice/src/cspice/beuns.c b/ext/spice/src/cspice/beuns.c
new file mode 100644
index 0000000000..7becf11e7d
--- /dev/null
+++ b/ext/spice/src/cspice/beuns.c
@@ -0,0 +1,225 @@
+/* beuns.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BEUNS ( Be an unsigned integer? ) */
+logical beuns_(char *string, ftnlen string_len)
+{
+ /* System generated locals */
+ logical ret_val;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen), i_indx(char *, char *, ftnlen, ftnlen),
+ s_cmp(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer i__, l;
+ logical ok;
+ extern integer frstnb_(char *, ftnlen);
+
+/* $ Abstract */
+
+/* Determine whether a string represents an unsigned integer. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* WORDS */
+
+/* $ Keywords */
+
+/* ALPHANUMERIC */
+/* NUMBERS */
+/* SCANNING */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* STRING I Character string. */
+
+/* The function returns TRUE if the string represents an unsigned */
+/* integer. Otherwise, it returns FALSE. */
+
+/* $ Detailed_Input */
+
+/* STRING is any string. */
+
+/* $ Detailed_Output */
+
+/* If STRING contains a single word made entirely from the */
+/* characters '0' through '9', then the function returns TRUE. */
+/* Otherwise, it returns FALSE. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* By definition an unsigned integer is a word made exclusively */
+/* from the characters '0', '1', '2', '3', '4', '5', '6', '7', '8', */
+/* and '9'. */
+
+/* $ Examples */
+
+
+/* Four classes of numbers recognized by the various BE functions. */
+
+/* UNS unsigned integer */
+/* INT integer (includes INT) */
+/* DEC decimal number (includes UNS, INT) */
+/* NUM number (includes UNS, INT, NUM) */
+
+/* The following table illustrates the differences between */
+/* the classes. (Any number of leading and trailing blanks */
+/* are acceptable.) */
+
+/* String Accepted by */
+/* ------------------ ------------------ */
+/* 0 UNS, INT, DEC, NUM */
+/* 21 */
+/* 21994217453648 */
+
+/* +0 INT, DEC, NUM */
+/* -13 */
+/* +21946 */
+
+/* 1.23 DEC, NUM */
+/* 12. */
+/* .17 */
+/* +4.1 */
+/* -.25 */
+
+/* 2.3e17 NUM */
+/* 17.D-13275849 */
+/* -.194265E+0004 */
+
+/* Note that the functions don't take the magnitudes of the numbers */
+/* into account. They may accept numbers that cannot be represented */
+/* in Fortran variables. (For example, '2.19E999999999999' probably */
+/* exceeds the maximum floating point number on any machine, but */
+/* is perfectly acceptable to BENUM.) */
+
+/* The following strings are not accepted by any of the functions. */
+
+/* String Reason */
+/* --------------- ---------------------------------------- */
+/* 3/4 No implied operations (rational numbers) */
+/* 37+14 No explicit operations */
+/* E12 Must have mantissa */
+/* 217,346.91 No commas */
+/* 3.14 159 264 No embedded spaces */
+/* PI No special numbers */
+/* FIVE No textual numbers */
+/* CXIV No roman numerals */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 01-DEC-1995 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* determine if a string is an unsigned integer */
+
+/* -& */
+
+/* SPICE functions */
+
+
+/* Local variables */
+
+
+/* Get the length of the string and the position of its */
+/* first non-blank character. */
+
+ l = i_len(string, string_len);
+ i__ = frstnb_(string, string_len);
+
+/* If there isn't a non-blank character, this isn't an */
+/* unsigned integer. */
+
+ if (i__ == 0) {
+ ret_val = FALSE_;
+ return ret_val;
+ }
+
+/* As far as we know right now, everything is ok. Examine */
+/* characters until we run out of string or until we */
+/* hit a non-digit character. */
+
+ ok = TRUE_;
+ while(ok && i__ <= l) {
+ if (i_indx("0123456789", string + (i__ - 1), (ftnlen)10, (ftnlen)1) >
+ 0) {
+ ++i__;
+ } else {
+ ok = FALSE_;
+ }
+ }
+
+/* If the string still is ok as an unsigned integer, it must be */
+/* one... */
+
+ if (ok) {
+ ret_val = TRUE_;
+ } else {
+
+/* ... otherwise, it's an unsigned integer if the remainder is blank. */
+
+ ret_val = s_cmp(string + (i__ - 1), " ", string_len - (i__ - 1), (
+ ftnlen)1) == 0;
+ }
+ return ret_val;
+} /* beuns_ */
+
diff --git a/ext/spice/src/cspice/bodc2n.c b/ext/spice/src/cspice/bodc2n.c
new file mode 100644
index 0000000000..adedb99a7f
--- /dev/null
+++ b/ext/spice/src/cspice/bodc2n.c
@@ -0,0 +1,265 @@
+/* bodc2n.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BODC2N ( Body ID code to name translation ) */
+/* Subroutine */ int bodc2n_(integer *code, char *name__, logical *found,
+ ftnlen name_len)
+{
+ extern /* Subroutine */ int zzbodc2n_(integer *, char *, logical *,
+ ftnlen), chkin_(char *, ftnlen), chkout_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Translate the SPICE integer code of a body into a common name */
+/* for that body. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* NAIF_IDS */
+
+/* $ Keywords */
+
+/* BODY */
+/* CONVERSION */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* CODE I Integer ID code to be translated into a name. */
+/* NAME O A common name for the body identified by CODE. */
+/* FOUND O True if translated, otherwise false. */
+/* MAXL P Maximum length of NAME string. */
+
+/* $ Detailed_Input */
+
+/* CODE is an integer code for a body --- */
+/* a planet, satellite, barycenter, spacecraft, */
+/* asteroid, comet, or other ephemeris object. */
+
+/* $ Detailed_Output */
+
+/* NAME is a common name of the body identified by CODE. */
+/* If CODE has more than one translation, then the */
+/* most recently defined NAME corresponding to CODE */
+/* is returned. NAME will have the exact format (case */
+/* and blanks) as when the name/code pair was defined. */
+/* If the input value of CODE is not recognized, NAME */
+/* will remain unchanged from its input value. */
+
+/* FOUND is true if CODE has a translation. Otherwise, FOUND */
+/* is false. */
+
+/* $ Parameters */
+
+/* MAXL is the maximum allowable length of a body name. */
+/* This amount of storage space should be declared */
+/* to receive NAME, otherwise truncation may occur. */
+/* The value of this parameter may be found in the */
+/* include file 'zzbodtrn.inc'. */
+
+/* $ Exceptions */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* BODS2N is one of five related subroutines, */
+
+/* BODS2C Body string to code */
+/* BODC2S Body code to string */
+/* BODN2C Body name to code */
+/* BODC2N Body code to name */
+/* BODDEF Body name/code definition */
+
+/* BODS2C, BODC2S, BODN2C, and BODC2N perform translations between */
+/* body names and their corresponding integer ID codes which are */
+/* used in SPICE files and routines. */
+
+/* BODS2C is a slightly more general version of BODN2C: support */
+/* for strings containing ID codes in string format enables a caller */
+/* to identify a body using a string, even when no name is */
+/* associated with that body. */
+
+/* BODC2S is a general version of BODC2N; the routine returns either */
+/* the name assigned in the body ID to name mapping or a string */
+/* representation of the CODE value if no mapping exists. */
+
+/* BODDEF assigns a body name to ID mapping. The mapping has */
+/* priority in name-to-ID and ID-to-name translations. */
+
+/* Refer to NAIF_IDs for the list of name/code associations built */
+/* into SPICE, and for details concerning adding new name/code */
+/* associations at run time by loading text kernels. */
+
+/* $ Examples */
+
+/* 1. Suppose you ran the utility program SPACIT to summarize */
+/* an SPK ephemeris file and the following data was output */
+/* to the terminal screen. */
+
+/* ---------------------------------------------------------- */
+/* Segment identifier: JPL archive 21354 */
+/* Body : -77 Center : 399 */
+/* From : 1990 DEC 08 18:00:00.000 */
+/* To : 1990 DEC 10 21:10:00.000 */
+/* Reference : DE-200 SPK Type :1 */
+/* ---------------------------------------------------------- */
+
+/* You could write a program to translate the body codes */
+/* shown in the SPACIT output: */
+
+/* CALL BODC2N ( -77, BODY, FOUND ) */
+/* CALL BODC2N ( 399, CENTER, FOUND ) */
+
+/* IF ( FOUND ) THEN */
+
+/* WRITE ( *,* ) 'BODY: -77 = ', BODY */
+/* WRITE ( *,* ) 'CENTER: 399 = ', CENTER */
+
+/* END IF */
+
+/* You could also read the body and center codes directly from */
+/* the SPK files, using the appropriate DAF routines, and then */
+/* translate them, as above. */
+
+
+/* 2. In this example, we assume that BODDEF has not been called, */
+/* so only the set of default name/code pairs has */
+/* been defined. */
+
+/* Given these names, BODN2C will return the following codes: */
+
+/* Name Code Found? */
+/* ------------------------ ------ ------ */
+/* 'EARTH' 399 Yes */
+/* ' Earth ' 399 Yes */
+/* 'EMB' 3 Yes */
+/* 'Solar System Barycenter' 0 Yes */
+/* 'SolarSystemBarycenter' - No */
+/* 'SSB' 0 Yes */
+/* 'Voyager 2' -32 Yes */
+/* 'U.S.S. Enterprise' - No */
+/* ' ' - No */
+/* 'Halley's Comet' - No */
+
+
+/* Given these codes, BODC2N will return the following names: */
+
+/* Code Name Found? */
+/* ------- ------------------- ------ */
+/* 399 'EARTH' Yes */
+/* 0 'SOLAR SYSTEM BARYCENTER' Yes */
+/* 3 'EARTH BARYCENTER' Yes */
+/* -77 'GALILEO ORBITER' Yes */
+/* 11 - No */
+/* -1 - No */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* B.V. Semenov (JPL) */
+/* F.S. Turner (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.4, 16-MAY-2009 (EDW) */
+
+/* Edit to Particulars section to document the BODC2S routine. */
+
+/* - SPICELIB Version 1.0.3, 28-FEB-2008 (BVS) */
+
+/* Corrected the contents of the Required_Reading section. */
+
+/* - SPICELIB Version 1.0.2, 26-AUG-2002 (FST) */
+
+/* Added documentation discussing the parameter MAXL. */
+
+/* - SPICELIB Version 1.0.1, 01-DEC-1998 (WLT) */
+
+/* Added documentation that describes the output NAME if CODE */
+/* is not a recognized body ID. */
+
+/* - SPICELIB Version 1.0.0, 23-JAN-1996 (KRG) */
+
+/* This was the BODC2N entry point from the original BODTRN */
+/* subroutine that was in the NAIF toolkit SUPPORT library. */
+/* When the private subroutine ZZBODTRN was added to SPICELIB, */
+/* superceding the BODTRN from SUPPORT, the body ID code/name */
+/* translation interface from the original BODTRN was moved to */
+/* SPICELIB so that ID codes did not have to be hard coded by */
+/* users of the toolkit. */
+
+/* This subroutine simply calls the private subroutine ZZBODC2N */
+/* to perform its job. */
+
+/* -& */
+/* $ Index_Entries */
+
+/* body id code to name */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Standard SPICELIB error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("BODC2N", (ftnlen)6);
+ }
+ zzbodc2n_(code, name__, found, name_len);
+
+/* No need for any error checking, since all we do is check out */
+/* and return anyway. We leave the error checking to the caller. */
+
+ chkout_("BODC2N", (ftnlen)6);
+ return 0;
+} /* bodc2n_ */
+
diff --git a/ext/spice/src/cspice/bodc2n_c.c b/ext/spice/src/cspice/bodc2n_c.c
new file mode 100644
index 0000000000..2df87d7954
--- /dev/null
+++ b/ext/spice/src/cspice/bodc2n_c.c
@@ -0,0 +1,313 @@
+/*
+
+-Procedure bodc2n_c ( Body ID code to name translation )
+
+-Abstract
+
+ Translate the SPICE integer code of a body into a common name
+ for that body.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ NAIF_IDS
+
+-Keywords
+
+ BODY
+ CONVERSION
+
+*/
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+ #undef bodc2n_c
+
+ void bodc2n_c ( SpiceInt code,
+ SpiceInt lenout,
+ SpiceChar * name,
+ SpiceBoolean * found )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ code I Integer ID code to be translated into a name.
+ lenout I Maximum length of output name.
+ name O A common name for the body identified by code.
+ found O True if translated, otherwise false.
+
+-Detailed_Input
+
+ code is an integer code for a body ---
+ a planet, satellite, barycenter, spacecraft,
+ asteroid, comet, or other ephemeris object.
+
+ lenout is the maximum allowed length of the output name,
+ including the terminating null character. For example,
+ if the caller wishes to be able to accept a 32-character
+ name, lenout must be set to (at least) 33. The current
+ maximum name length is 32 characters, so a value of 33
+ for lenout will suffice.
+
+-Detailed_Output
+
+ name is a common name of the body identified by code.
+ If code has more than one translation, then the
+ most recently defined name corresponding to code
+ is returned. 'name' will have the exact format (case
+ and blanks) as when the name/code pair was defined.
+
+ No more than lenout characters, including the
+ terminating null, will be written to name. A terminating
+ null will always be written.
+
+ found is SPICETRUE if code has a translation. Otherwise, found
+ is SPICEFALSE.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the output string pointer is null, the error SPICE(NULLPOINTER)
+ is signaled.
+
+ 2) If the output string has length less than two characters, it
+ is too short to contain one character of output data plus a null
+ terminator, so it cannot be passed to the underlying Fortran
+ routine. In this event, the error SPICE(STRINGTOOSHORT) is
+ signaled.
+
+-Files
+
+ None.
+
+-Particulars
+
+ bodc2n_c is one of five related subroutines,
+
+ bods2c_c Body string to code
+ bodc2s_c Body code to string
+ bodn2c_c Body name to code
+ bodc2n_c Body code to name
+ boddef_c Body name/code definition
+
+ bods2c_c, bodc2s_c, bodn2c_c, and bodc2n_c perform translations between
+ body names and their corresponding integer ID codes which are
+ used in SPICE files and routines.
+
+ bods2c_c is a slightly more general version of bodn2c_c: support
+ for strings containing ID codes in string format enables a caller
+ to identify a body using a string, even when no name is
+ associated with that body.
+
+ bodc2s_c is a general version of bodc2n_c; the routine returns either
+ the name assigned in the body ID to name mapping or a string
+ representation of the CODE value if no mapping exists.
+
+ boddef_c assigns a body name to ID mapping. The mapping has priority
+ in name-to-ID and ID-to-name translations.
+
+ Refer to NAIF_ID.REQ for the list of name/code associations built into
+ SPICE, and for details concerning adding new name/code
+ associations at run time by loading text kernels.
+
+-Examples
+
+ 1. Suppose you ran the utility program SPACIT to summarize
+ an SPK ephemeris file and the following data was output
+ to the terminal screen.
+
+ ----------------------------------------------------------
+ Segment identifier: JPL archive 21354
+ Body : -77 Center : 399
+ From : 1990 DEC 08 18:00:00.000
+ To : 1990 DEC 10 21:10:00.000
+ Reference : DE-200 SPK Type :1
+ ----------------------------------------------------------
+
+ You could write a program to translate the body codes
+ shown in the SPACIT output:
+
+ #define MAXLEN 32
+ .
+ .
+ .
+ bodc2n_c ( -77, MAXLEN, body, found );
+ bodc2n_c ( 399, MAXLEN, center, found );
+
+ if ( found )
+ {
+ printf ( "body: -77 = %s\n", body );
+ printf ( "center: 399 = %s\n", center );
+ }
+
+ You could also read the body and center codes directly from
+ the SPK files, using the appropriate DAF routines, and then
+ translate them, as above.
+
+
+ 2. In this example, we assume that boddef_c has not been called,
+ so only the set of default name/code pairs has
+ been defined.
+
+ Given these names, bodn2c_c will return the following codes:
+
+ Name Code Found?
+ ------------------------ ------ ------
+ "EARTH" 399 Yes
+ " Earth " 399 Yes
+ "EMB" 3 Yes
+ "Solar System Barycenter" 0 Yes
+ "SolarSystemBarycenter" - No
+ "SSB" 0 Yes
+ "Voyager 2" -32 Yes
+ "U.S.S. Enterprise" - No
+ " " - No
+ "Halley's Comet" - No
+
+
+ Given these codes, bodc2n_c will return the following names:
+
+ Code Name Found?
+ ------- ------------------- ------
+ 399 "EARTH" Yes
+ 0 "SOLAR SYSTEM BARYCENTER" Yes
+ 3 "EARTH BARYCENTER" Yes
+ -77 "GALILEO ORBITER" Yes
+ 11 - No
+ -1 - No
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ B.V. Semenov (JPL)
+
+-Version
+
+ -CSPICE Version 2.2.2, 24-APR-2010 (EDW)
+
+ Edit to Particulars section to document the bodc2s_c routine.
+ Minor edit to code comments eliminating typo.
+
+ -CSPICE Version 2.2.1, 27-FEB-2008 (BVS)
+
+ Corrected the contents of the Required_Reading section of
+ the header.
+
+ -CSPICE Version 2.2.0, 02-SEP-1999 (NJB)
+
+ Local type logical variable now used for found flag used in
+ interface of bodc2n_.
+
+ -CSPICE Version 2.1.1, 25-MAR-1998 (EDW)
+
+ Minor corrections to header.
+
+ -CSPICE Version 2.1.0, 09-FEB-1998 (NJB)
+
+ Re-implemented routine without dynamically allocated, temporary
+ strings. Updated the Exceptions header section.
+
+ -CSPICE Version 2.0.1, 16-JAN-1998 (EDW)
+
+ Corrected and clarified header entries.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB)
+
+ Based on SPICELIB Version 1.0.0, 23-JAN-1996 (KRG)
+
+-Index_Entries
+
+ body id code to name
+
+-&
+*/
+
+{ /* Begin bodc2n_c */
+
+
+ /*
+ Local variables
+ */
+ logical fnd;
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "bodc2n_c");
+
+
+ /*
+ Make sure the output name has at least enough room for one output
+ character and a null terminator. Also check for a null pointer.
+ */
+ CHKOSTR ( CHK_STANDARD, "bodc2n_c", name, lenout );
+
+
+ /*
+ Call the f2c'd routine.
+ */
+ bodc2n_( ( integer * ) &code,
+ ( char * ) name,
+ ( logical * ) &fnd,
+ ( ftnlen ) lenout-1 );
+
+
+ /*
+ Assign the SpiceBoolean found flag.
+ */
+
+ *found = fnd;
+
+
+ /*
+ Convert the Fortran string to a C string by placing a null
+ after the last non-blank character. This operation is valid
+ whether or not the CSPICE routine signaled an error.
+ */
+ F2C_ConvertStr ( lenout, name );
+
+
+ chkout_c ( "bodc2n_c");
+
+} /* End bodc2n_c */
diff --git a/ext/spice/src/cspice/bodc2s.c b/ext/spice/src/cspice/bodc2s.c
new file mode 100644
index 0000000000..0a0fbef4fe
--- /dev/null
+++ b/ext/spice/src/cspice/bodc2s.c
@@ -0,0 +1,249 @@
+/* bodc2s.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BODC2S ( Body ID code to string translation ) */
+/* Subroutine */ int bodc2s_(integer *code, char *name__, ftnlen name_len)
+{
+ extern /* Subroutine */ int zzbodc2n_(integer *, char *, logical *,
+ ftnlen), chkin_(char *, ftnlen);
+ logical found;
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int intstr_(integer *, char *, ftnlen);
+
+/* $ Abstract */
+
+/* Translate a body ID code to either the corresponding name */
+/* or if no name to ID code mapping exists, the string */
+/* representation of the body ID value. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* NAIF_IDS */
+
+/* $ Keywords */
+
+/* BODY */
+/* CONVERSION */
+/* ID */
+/* NAME */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* CODE I Integer ID code to translate to a string. */
+/* NAME O String corresponding to CODE. */
+
+/* $ Detailed_Input */
+
+/* CODE the integer code for a body: planet, satellite, */
+/* barycenter, spacecraft, asteroid, comet, or */
+/* other ephemeris object. */
+
+/* $ Detailed_Output */
+
+/* NAME the string name of the body identified by CODE */
+/* if a mapping between CODE and a body name exists */
+/* within SPICE. */
+
+/* If CODE has more than one translation, then the */
+/* most recently defined NAME corresponding to CODE */
+/* is returned. NAME will have the exact format (case */
+/* and blanks) as when the name/code pair was defined. */
+
+/* If the input value of CODE does not map to a body */
+/* name, NAME returns the string representation */
+/* of CODE. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* None. */
+
+/* $ Files */
+
+/* Body-name mappings may be defined at run time by loading text */
+/* kernels containing kernel variable assignments of the form */
+
+/* NAIF_BODY_NAME += ( , ... ) */
+/* NAIF_BODY_CODE += ( , ... ) */
+
+/* See NAIF_ID.REQ for details. */
+
+/* $ Particulars */
+
+/* BODS2N is one of five related subroutines, */
+
+/* BODS2C Body string to code */
+/* BODC2S Body code to string */
+/* BODN2C Body name to code */
+/* BODC2N Body code to name */
+/* BODDEF Body name/code definition */
+
+/* BODS2C, BODC2S, BODN2C, and BODC2N perform translations between */
+/* body names and their corresponding integer ID codes which are */
+/* used in SPICE files and routines. */
+
+/* BODS2C is a slightly more general version of BODN2C: support */
+/* for strings containing ID codes in string format enables a caller */
+/* to identify a body using a string, even when no name is */
+/* associated with that body. */
+
+/* BODC2S is a general version of BODC2N; the routine returns either */
+/* the name assigned in the body ID to name mapping or a string */
+/* representation of the CODE value if no mapping exists. */
+
+/* BODDEF assigns a body name to ID mapping. The mapping has */
+/* priority in name-to-ID and ID-to-name translations. */
+
+/* Refer to NAIF_ID.REQ for the list of name/code associations built */
+/* into SPICE, and for details concerning adding new name/code */
+/* associations at run time by loading text kernels. */
+
+/* $ Examples */
+
+/* Apply the BODC2S call to several IDs representing codes */
+/* included in the default SPICE ID-name lists and codes not */
+/* included in the list. */
+
+/* PROGRAM BODC2S_T */
+
+/* INTEGER CODE (7) */
+/* CHARACTER*(32) NAME */
+
+/* C */
+/* C Assign an array of body IDs. Not all the listed IDS */
+/* C map to a body name. */
+/* C */
+/* CODE(1) = 399 */
+/* CODE(2) = 0 */
+/* CODE(3) = 3 */
+/* CODE(4) = -77 */
+/* CODE(5) = 11 */
+/* CODE(6) = -1 */
+/* CODE(7) = 6000001 */
+
+/* C */
+/* C Loop over the CODE array, call BODC2S for each */
+/* C element of CODE. */
+/* C */
+/* DO I= 1, 7 */
+
+/* CALL BODC2S( CODE(I), NAME ) */
+
+/* WRITE(*, '(I8,3x,A)' ) CODE(I), NAME */
+
+/* END DO */
+
+/* END */
+
+/* Given these codes, BODC2S returns the following NAME strings: */
+
+/* Code Name */
+/* ------- ------------------- */
+/* 399 'EARTH' */
+/* 0 'SOLAR SYSTEM BARYCENTER' */
+/* 3 'EARTH BARYCENTER' */
+/* -77 'GALILEO ORBITER' */
+/* 11 '11' */
+/* -1 'GEOTAIL' */
+/* 6000001 '6000001' */
+
+/* The codes 11 and 6000001 did not map to a name so the call */
+/* returns as NAME the string expression of the codes. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* E.D. Wright (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 10-APR-2010 (EDW) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* body ID code to string */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICELIB error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("BODC2S", (ftnlen)6);
+
+/* Fortran. No type check available for CODE. Bother. */
+
+
+/* Attempt to translate the input CODE to a name. Use */
+/* the private routine ZZBODC2N. */
+
+ zzbodc2n_(code, name__, &found, name_len);
+ if (found) {
+
+/* Success. CODE maps to NAME. Return. */
+
+ chkout_("BODC2S", (ftnlen)6);
+ return 0;
+ }
+
+/* If execution reaches this level, the SPICE body ID */
+/* to name mapping lacks an assignment for CODE. Convert */
+/* CODE to a string representation of the integer value. */
+
+ intstr_(code, name__, name_len);
+ chkout_("BODC2S", (ftnlen)6);
+ return 0;
+} /* bodc2s_ */
+
diff --git a/ext/spice/src/cspice/bodc2s_c.c b/ext/spice/src/cspice/bodc2s_c.c
new file mode 100644
index 0000000000..009e5b45cf
--- /dev/null
+++ b/ext/spice/src/cspice/bodc2s_c.c
@@ -0,0 +1,262 @@
+/*
+
+-Procedure bodc2s_c ( Body ID code to string translation )
+
+-Abstract
+
+ Translate a body ID code to either the corresponding name or if no
+ name to ID code mapping exists, the string representation of the
+ body ID value.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ NAIF_IDS
+
+-Keywords
+
+ BODY
+ CONVERSION
+
+*/
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+ #undef bodc2s_c
+
+ void bodc2s_c ( SpiceInt code,
+ SpiceInt lenout,
+ SpiceChar * name )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ code I Integer ID code to translate to a string.
+ lenout I Maximum length of output name.
+ name O String corresponding to 'code'.
+
+-Detailed_Input
+
+ code the integer code for a body: planet, satellite,
+ barycenter, spacecraft, asteroid, comet, or
+ other ephemeris object.
+
+ lenout is the maximum allowed length of the output name,
+ including the terminating null character. For example,
+ if the caller wishes to be able to accept a 32-character
+ name, lenout must be set to (at least) 33. The current
+ maximum name length is 32 characters, so a value of 33
+ for lenout will suffice.
+
+-Detailed_Output
+
+ name the string name of the body identified by 'code'
+ if a mapping between 'code' and a body name exists
+ within SPICE.
+
+ If 'code' has more than one translation, then the
+ most recently defined 'name' corresponding to 'code'
+ is returned. 'name' will have the exact format (case
+ and blanks) as when the name/code pair was defined.
+
+ If the input value of 'code' does not map to a body
+ name, 'name' returns with the string representation
+ of 'code'.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the output string pointer is null, the error SPICE(NULLPOINTER)
+ is signaled.
+
+ 2) If the output string has length less than two characters, it
+ is too short to contain one character of output data plus a null
+ terminator, so it cannot be passed to the underlying Fortran
+ routine. In this event, the error SPICE(STRINGTOOSHORT) is
+ signaled.
+
+-Files
+
+ Body-name mappings may be defined at run time by loading text
+ kernels containing kernel variable assignments of the form
+
+ NAIF_BODY_NAME += ( , ... )
+ NAIF_BODY_CODE += ( , ... )
+
+ See NAIF_ID.REQ for details.
+
+-Particulars
+
+ bodc2s_c is one of five related subroutines,
+
+ bods2c_c Body string to code
+ bodc2s_c Body code to string
+ bodn2c_c Body name to code
+ bodc2n_c Body code to name
+ boddef_c Body name/code definition
+
+ bods2c_c, bodc2s_c, bodn2c_c, and bodc2n_c perform translations between
+ body names and their corresponding integer ID codes which are
+ used in SPICE files and routines.
+
+ bods2c_c is a slightly more general version of bodn2c_c: support
+ for strings containing ID codes in string format enables a caller
+ to identify a body using a string, even when no name is
+ associated with that body.
+
+ bodc2s_c is a general version of bodc2n_c; the routine returns either
+ the name assigned in the body ID to name mapping or a string
+ representation of the CODE value if no mapping exists.
+
+ boddef_c assigns a body name to ID mapping. The mapping has priority
+ in name-to-ID and ID-to-name translations.
+
+ Refer to NAIF_ID.REQ for the list of name/code associations built into
+ SPICE, and for details concerning adding new name/code
+ associations at run time by loading text kernels.
+
+-Examples
+
+ Apply the BODC2S call to several IDs representing codes
+ included in the default SPICE ID-name lists and codes not
+ included in the list.
+
+ #include
+ #include "SpiceUsr.h"
+ #define LEN 32
+
+ int main()
+ {
+
+ /.
+ Assign an array of body ID codes. Not all the listed codes
+ map to a body name.
+ ./
+
+ SpiceInt code[] = { 399, 0, 3, -77,
+ 11, -1, 6000001 };
+
+ SpiceInt lenout = LEN;
+ SpiceChar name [LEN];
+ SpiceInt i;
+
+ /.
+ Loop over the 'code' array, call bodc2s_c for each
+ element of 'code'.
+ ./
+
+ for (i=0; i<7; i++ )
+ {
+ (void) bodc2s_c ( code[i], lenout, name );
+ printf("%ld %s\n", code[i], name);
+ }
+
+ return ( 0 );
+ }
+
+ Given these codes, bodc2s_c returns the following 'name' strings:
+
+ Code Name
+ ------- -------------------
+ 399 'EARTH'
+ 0 'SOLAR SYSTEM BARYCENTER'
+ 3 'EARTH BARYCENTER'
+ -77 'GALILEO ORBITER'
+ 11 '11'
+ -1 'GEOTAIL'
+ 6000001 '6000001'
+
+ The codes 11 and 6000001 did not map to a name so the call
+ returns as 'name' the string expression of the codes.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 24-APR-2010 (EDW)
+
+-Index_Entries
+
+ body id code to string
+
+-&
+*/
+
+{ /* Begin bodc2s_c */
+
+
+ /*
+ Local variables
+ */
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "bodc2s_c");
+
+
+ /*
+ Make sure the output name has at least enough room for one output
+ character and a null terminator. Also check for a null pointer.
+ */
+ CHKOSTR ( CHK_STANDARD, "bodc2s_c", name, lenout );
+
+
+ /*
+ Call the f2c'd routine.
+ */
+ (void) bodc2s_( ( integer * ) &code,
+ ( char * ) name,
+ ( ftnlen ) lenout-1 );
+
+ /*
+ Convert the Fortran string to a C string by placing a null
+ after the last non-blank character. This operation is valid
+ whether or not the CSPICE routine signaled an error.
+ */
+ F2C_ConvertStr ( lenout, name );
+
+ chkout_c ( "bodc2s_c");
+
+} /* End bodc2s_c */
diff --git a/ext/spice/src/cspice/boddef.c b/ext/spice/src/cspice/boddef.c
new file mode 100644
index 0000000000..1c9e23d26e
--- /dev/null
+++ b/ext/spice/src/cspice/boddef.c
@@ -0,0 +1,301 @@
+/* boddef.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BODDEF ( Body name/ID code definition ) */
+/* Subroutine */ int boddef_(char *name__, integer *code, ftnlen name_len)
+{
+ extern /* Subroutine */ int zzboddef_(char *, integer *, ftnlen), chkin_(
+ char *, ftnlen), chkout_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Define a body name/ID code pair for later translation via */
+/* BODN2C or BODC2N. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* NAIF_IDS */
+
+/* $ Keywords */
+
+/* BODY */
+/* CONVERSION */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* NAME I Common name of some body. */
+/* CODE I Integer code for that body. */
+/* MAXL P Maximum length of NAME string. */
+
+/* $ Detailed_Input */
+
+/* NAME is an arbitrary name of a body which could be */
+/* a planet, satellite, barycenter, spacecraft, */
+/* asteroid, comet, or other ephemeris object. */
+
+/* The case and positions of blanks in a name are */
+/* significant. BODC2N returns the same string */
+/* (case and space) most recently mapped to a code. */
+/* When NAME consists of more than one word, the */
+/* words require separation by at least one blank. */
+
+/* The kernel sub-system stores NAME as described in */
+/* the BODDEF call, but creates an equivalence class */
+/* based on NAME for comparisons in BODN2C. This class */
+/* ignores leading/trailing whitespace, compresses */
+/* interior whitespace to a single space, and ignores */
+/* character case. */
+
+/* The following strings belong to the same equivalence */
+/* class: */
+
+/* 'JUPITER BARYCENTER' */
+/* 'Jupiter Barycenter' */
+/* 'JUPITER BARYCENTER ' */
+/* 'JUPITER BARYCENTER' */
+/* ' JUPITER BARYCENTER' */
+
+/* However, 'JUPITERBARYCENTER' is distinct from */
+/* the names above. */
+
+/* When ignoring trailing blanks, NAME must be short */
+/* enough to fit into the space defined by parameter */
+/* MAXL. */
+
+/* CODE is the integer ID code for assignment to body NAME. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* MAXL is the maximum allowed length of a body NAME. */
+/* Names exceeding this length will be truncated */
+/* on assignment to a code with BODDEF. The value */
+/* of this parameter may be found in the include */
+/* file 'zzbodtrn.inc'. */
+
+/* $ Exceptions */
+
+/* 1) Routines in the call tree of this routine may signal errors */
+/* if improper inputs are supplied, or if there is insufficient */
+/* room to store the requested addition. */
+
+/* 2) If a name-code definition inserted into this routine seems to */
+/* have no effect, it is possible that the contents of the */
+/* definition are masked by the higher precedence kernel pool */
+/* assignments. See the "Particulars" section of this document */
+/* for more information. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* BODDEF is one of five related subroutines, */
+
+/* BODS2C Body string to code */
+/* BODC2S Body code to string */
+/* BODN2C Body name to code */
+/* BODC2N Body code to name */
+/* BODDEF Body name/code definition */
+
+/* BODS2C, BODC2S, BODN2C, and BODC2N perform translations between */
+/* body names and their corresponding integer ID codes which are */
+/* used in SPICE files and routines. */
+
+/* BODS2C is a slightly more general version of BODN2C: support */
+/* for strings containing ID codes in string format enables a caller */
+/* to identify a body using a string, even when no name is */
+/* associated with that body. */
+
+/* BODC2S is a general version of BODC2N; the routine returns either */
+/* the name assigned in the body ID to name mapping or a string */
+/* representation of the CODE value if no mapping exists. */
+
+/* BODDEF assigns a body name to ID mapping. The mapping has */
+/* priority in name-to-ID and ID-to-name translations. */
+
+/* Refer to NAIF_IDs for the list of name/code associations built */
+/* into SPICE, and for details concerning adding new name/code */
+/* associations at run time by loading text kernels. */
+
+/* Modifying the SPICE name-ID mapping set */
+/* ======================================= */
+
+/* Each body has a unique integer CODE, but may have several */
+/* names. Thus you may associate more than one name with */
+/* a particular integer code. */
+
+/* CODE may already have a name as defined by a previous */
+/* call to BODDEF or as part of the set of default */
+/* definitions. That previous definition will remain, */
+/* and a translation of that name will still give the */
+/* same CODE. However, future translations of CODE will */
+/* give the new NAME instead of the previous one. This */
+/* feature is useful for assigning a more familiar or */
+/* abbreviated name to a body. For example, in addition */
+/* to the default name for body 5, 'JUPITER BARYCENTER', */
+/* you could define the abbreviation 'JB' to mean 5. */
+
+/* Note: In the case where BODDEF performs a name-to-ID mapping */
+/* assignment for an unused body name and unused ID value, */
+/* any subsequent assignment to NAME destroys the previous */
+/* mapping. */
+
+/* BODDEF( 'spud', 22) */
+
+/* then */
+
+/* BODDEF( 'spud', 23) */
+
+/* results in the state 'spud' maps to 23, 23 maps to 'spud', */
+/* and 22 maps to nothing (FOUND in BODC2N returns FALSE). */
+
+/* $ Examples */
+
+/* You may associate a new name for a previously defined code: */
+
+/* CALL BODDEF ( 'JB', 5 ) */
+
+/* You may also define the name and integer code for a new body: */
+
+/* CALL BODDEF ( 'Asteroid Frank', 20103456 ) */
+
+/* After these calls to BODDEF, BODN2C would return the following */
+/* translations: */
+
+/* Name Code Found? */
+/* ------------------------ ------ ------ */
+/* 'JB' 5 Yes */
+/* 'Jupiter Barycenter' 5 Yes */
+/* 'ASTEROID FRANK' 20103456 Yes */
+/* 'ASTEROIDFRANK' - No */
+/* 'Frank' - No */
+
+/* and BODC2N will return these translations: */
+
+/* Code Name Found? */
+/* ------- ------------------- ------ */
+/* 5 'JB' Yes */
+/* 20103456 'Asteroid Frank' Yes */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* B.V. Semenov (JPL) */
+/* F.S. Turner (JPL) */
+/* E.D. Wright (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.2, 16-MAY-2009 (EDW) */
+
+/* Edit to Particulars section to document the BODC2S routine. */
+
+/* - SPICELIB Version 1.1.1, 28-FEB-2008 (BVS) */
+
+/* Corrected the contents of the Required_Reading section. */
+
+/* - SPICELIB Version 1.1.0, 23-JAN-2004 (EDW) */
+
+/* Rewrote header for clarity with regards to the */
+/* current capabilities of the kernel subsystem. */
+
+/* - SPICELIB Version 1.0.2, 26-AUG-2002 (FST) */
+
+/* Updated header to describe the parameter MAXL and */
+/* its effect on this module. The exceptions section */
+/* was updated to include a more general discussion */
+/* of errors that routines in the call tree of this */
+/* routine may signal. */
+
+/* - SPICELIB Version 1.0.1, 12-AUG-2001 (EDW) */
+
+/* Updated header with information on new functionality. */
+/* The code-to-name retrieval routines now return the exact */
+/* string as defined in the last code/name mapping (case */
+/* and space). */
+
+/* - SPICELIB Version 1.0.0, 23-JAN-1996 (KRG) */
+
+/* This was the BODDEF entry point from the original BODTRN */
+/* subroutine that was in the NAIF toolkit SUPPORT library. */
+/* When the private subroutine ZZBODTRN was added to SPICELIB, */
+/* superceding the BODTRN from SUPPORT, the body ID code/name */
+/* translation interface from the original BODTRN was moved to */
+/* SPICELIB so that ID codes did not have to be hard coded by */
+/* users of the toolkit. */
+
+/* This subroutine simply calls the private subroutine ZZBODDEF */
+/* to perform its job. */
+
+/* -& */
+/* $ Index_Entries */
+
+/* body name/id code definition */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Standard SPICELIB error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("BODDEF", (ftnlen)6);
+ }
+ zzboddef_(name__, code, name_len);
+
+/* No need for any error checking, since all we do is check out */
+/* and return anyway. We leave the error checking to the caller. */
+
+ chkout_("BODDEF", (ftnlen)6);
+ return 0;
+} /* boddef_ */
+
diff --git a/ext/spice/src/cspice/boddef_c.c b/ext/spice/src/cspice/boddef_c.c
new file mode 100644
index 0000000000..6f0f7f2592
--- /dev/null
+++ b/ext/spice/src/cspice/boddef_c.c
@@ -0,0 +1,319 @@
+/*
+
+-Procedure boddef_c ( Body name/ID code definition )
+
+-Abstract
+
+ Define a body name/ID code pair for later translation via
+ bodn2c_c or bodc2n_c.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ NAIF_IDS
+
+-Keywords
+
+ BODY
+ CONVERSION
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+ void boddef_c ( ConstSpiceChar * name,
+ SpiceInt code )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ name I Common name of some body.
+ code I Integer code for that body.
+
+-Detailed_Input
+
+ name is an arbitrary name of a body which could be
+ a planet, satellite, barycenter, spacecraft,
+ asteroid, comet, or other ephemeris object.
+
+ The case and positions of blanks in a name are
+ significant. bodc2n_c returns the same string
+ (case and space) most recently mapped to a code.
+ When 'name' consists of more than one word, the
+ words require separation by at least one blank.
+
+ The kernel sub-system stores 'name' as described in
+ the boddef_c call, but creates an equivalence class
+ based on 'name for comparisons in bodn2c_c. This class
+ ignores leading/trailing whitespace, compresses
+ interior whitespace to a single space, and ignores
+ character case.
+
+ The following strings belong to the same equivalence
+ class:
+
+ "JUPITER BARYCENTER"
+ "Jupiter Barycenter"
+ "JUPITER BARYCENTER "
+ "JUPITER BARYCENTER"
+ " JUPITER BARYCENTER"
+
+ However, "JUPITERBARYCENTER" is distinct from
+ the names above.
+
+ When ignoring trailing blanks, NAME must be short
+ enough to fit into the space defined by parameter
+ MAXL.The value may be found in the C file
+ zzbodtrn.c. Due to the way in which f2c converts
+ FORTRAN code to C, you must examine the dimensions
+ assigned to the variables:
+
+ defnam
+ defnor
+ kernam
+ kernor
+
+ to obtain the MAXL value. These variables have a
+ declaration of the form:
+
+ static char variable_name[MAXL*array_length]
+
+ (note MAXL is this first value).
+
+ The maximum allowed length of a name is in any case
+ at least 32 characters.
+
+ code is the integer ID code for assignment to body 'name'.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) An attempt to associate more than one code with a given name
+ will cause an error to be signaled by a routine called by this
+ routine.
+
+ 2) Names too long to be stored will be truncated on the right.
+ Names of length not exceeding 32 characters will not be
+ truncated.
+
+-Files
+
+ None.
+
+-Particulars
+
+ boddef_c is one of five related subroutines,
+
+ bods2c_c Body string to code
+ bodc2s_c Body code to string
+ bodn2c_c Body name to code
+ bodc2n_c Body code to name
+ boddef_c Body name/code definition
+
+ bods2c_c, bodc2s_c, bodn2c_c, and bodc2n_c perform translations between
+ body names and their corresponding integer ID codes which are
+ used in SPICE files and routines.
+
+ bods2c_c is a slightly more general version of bodn2c_c: support
+ for strings containing ID codes in string format enables a caller
+ to identify a body using a string, even when no name is
+ associated with that body.
+
+ bodc2s_c is a general version of bodc2n_c; the routine returns either
+ the name assigned in the body ID to name mapping or a string
+ representation of the CODE value if no mapping exists.
+
+ boddef_c assigns a body name to ID mapping. The mapping has priority
+ in name-to-ID and ID-to-name translations.
+
+ Refer to NAIF_IDs for the list of name/code associations built into
+ SPICE, and for details concerning adding new name/code
+ associations at run time by loading text kernels.
+
+ Modifying the SPICE name-ID mapping set
+ =======================================
+
+ Each body has a unique integer 'code', but may have several
+ names. Thus you may associate more than one name with
+ a particular integer code.
+
+ 'code' may already have a name as defined by a previous
+ call to boddef_c or as part of the set of default
+ definitions. That previous definition will remain,
+ and a translation of that name will still give the
+ same 'code'. However, future translations of 'code' will
+ give the new 'name' instead of the previous one. This
+ feature is useful for assigning a more familiar or
+ abbreviated name to a body. For example, in addition
+ to the default name for body 5, "JUPITER BARYCENTER",
+ you could define the abbreviation "JB" to mean 5.
+
+ Note: In the case where boddef_c performs a name-to-ID mapping
+ assignment for an unused body name and unused ID value,
+ any subsequent assignment to NAME destroys the previous
+ mapping.
+
+ boddef_c ( "spud", 22)
+
+ then
+
+ boddef_c ( "spud", 23)
+
+ results in the state "spud" maps to 23, 23 maps to "spud",
+ and 22 maps to nothing ('found' in bodc2n_c returns SPICEFALSE).
+
+-Examples
+
+ You may associate a new name with a particular code that
+ has already been defined:
+
+ boddef_c ( "JB", 5 );
+
+ You may also define the name and integer code for a new body:
+
+ boddef_c ( "Asteroid Frank", 20103456 );
+
+ After these calls to boddef_c, bodn2c_c would return the following
+ translations:
+
+ Name Code Found?
+ ------------------------ ------ ------
+ "JB" 5 Yes
+ "Jupiter Barycenter" 5 Yes
+ "ASTEROID FRANK" 20103456 Yes
+ "ASTEROIDFRANK" - No
+ "Frank" - No
+
+ and BODC2N will return these translations:
+
+ Code Name Found?
+ ------- ------------------- ------
+ 5 "JB" Yes
+ 20103456 "Asteroid Frank" Yes
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ B.V. Semenov (JPL)
+
+-Version
+
+ -CSPICE Version 2.2.2, 16-MAY-2009 (EDW)
+
+ Edit to Particulars section to document the bodc2s_c routine.
+
+ -CSPICE Version 2.2.1, 27-FEB-2008 (BVS)
+
+ Corrected the contents of the Required_Reading section of
+ the header.
+
+ -CSPICE Version 2.2.0, 23-JAN-2004 (EDW)
+
+ Rewrote header for clarity with regards to the
+ current capabilities of the kernel subsystem.
+
+ -CSPICE Version 2.1.0, 17-NOV-2003 (EDW)
+
+ Updated header to describe the maximum allowed length
+ for 'name' and its effect on this module.
+
+ Updated header with information on new functionality.
+ The code-to-name retrieval routines now return the exact
+ string as defined in the last code/name mapping (case
+ and space).
+
+ -CSPICE Version 2.0.1, 08-FEB-1998 (EDW)
+
+ Corrected and clarified header entries.
+
+ -CSPICE Version 2.0.0, 06-JAN-1998 (NJB)
+
+ The type of the input argument name was changed to
+ ConstSpiceChar *.
+
+ References to C2F_CreateStr_Sig were removed; code was
+ cleaned up accordingly. String checks are now done using
+ the macro CHKFSTR.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB)
+
+ Based on SPICELIB Version 1.0.0, 23-JAN-1996 (KRG)
+
+-Index_Entries
+
+ body name/id code definition
+
+-&
+*/
+
+{ /* Begin boddef_c */
+
+ /*
+ Participate in error handling
+ */
+ chkin_c ( "boddef_c");
+
+
+ /*
+ Check the input string name to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "boddef_c", name );
+
+
+ /*
+ Effect the new name/code mapping.
+ */
+ boddef_ ( ( char * ) name,
+ ( integer * ) &code,
+ ( ftnlen ) strlen(name) );
+
+
+ chkout_c ( "boddef_c");
+
+} /* End boddef_c */
diff --git a/ext/spice/src/cspice/bodeul.c b/ext/spice/src/cspice/bodeul.c
new file mode 100644
index 0000000000..c19acbc2c9
--- /dev/null
+++ b/ext/spice/src/cspice/bodeul.c
@@ -0,0 +1,622 @@
+/* bodeul.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static integer c__3 = 3;
+static integer c__100 = 100;
+
+/* $Procedure BODEUL ( Return Euler angles for a body ) */
+/* Subroutine */ int bodeul_(integer *body, doublereal *et, doublereal *ra,
+ doublereal *dec, doublereal *w, doublereal *lambda)
+{
+ /* Initialized data */
+
+ static logical first = TRUE_;
+ static logical found = FALSE_;
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+ doublereal d__1;
+
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ double d_mod(doublereal *, doublereal *);
+ integer i_dnnt(doublereal *), s_rnge(char *, integer, char *, integer);
+ double sin(doublereal), cos(doublereal);
+
+ /* Local variables */
+ char bref[32], item[32];
+ doublereal j2ref[9] /* was [3][3] */, j2bfx[9] /* was [3][3] */;
+ extern integer zzbodbry_(integer *);
+ extern /* Subroutine */ int eul2m_(doublereal *, doublereal *, doublereal
+ *, integer *, integer *, integer *, doublereal *), m2eul_(
+ doublereal *, integer *, integer *, integer *, doublereal *,
+ doublereal *, doublereal *);
+ doublereal d__;
+ integer i__;
+ doublereal dcoef[3], t;
+ integer refid;
+ doublereal delta;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ doublereal epoch, rcoef[3], tcoef[200] /* was [2][100] */, wcoef[3],
+ theta;
+ extern /* Subroutine */ int repmi_(char *, char *, integer *, char *,
+ ftnlen, ftnlen, ftnlen), errdp_(char *, doublereal *, ftnlen);
+ doublereal costh[100];
+ extern doublereal vdotg_(doublereal *, doublereal *, integer *);
+ doublereal sinth[100];
+ extern doublereal twopi_(void);
+ static integer j2code;
+ doublereal rf2bfx[9] /* was [3][3] */, ac[100], dc[100];
+ integer na, nd, nl;
+ doublereal wc[100];
+ extern logical bodfnd_(integer *, char *, ftnlen);
+ extern /* Subroutine */ int cleard_(integer *, doublereal *), bodvcd_(
+ integer *, char *, integer *, integer *, doublereal *, ftnlen);
+ extern doublereal halfpi_(void);
+ integer nw;
+ doublereal conepc, conref, eulang[6];
+ integer ntheta;
+ extern /* Subroutine */ int pckeul_(integer *, doublereal *, logical *,
+ char *, doublereal *, ftnlen), gdpool_(char *, integer *, integer
+ *, integer *, doublereal *, logical *, ftnlen), sigerr_(char *,
+ ftnlen), chkout_(char *, ftnlen), irfnum_(char *, integer *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen), irfrot_(integer *, integer *, doublereal *);
+ extern logical return_(void);
+ extern doublereal j2000_(void);
+ integer dim, ref;
+ doublereal phi;
+ extern doublereal rpd_(void), spd_(void);
+ extern /* Subroutine */ int mxm_(doublereal *, doublereal *, doublereal *)
+ ;
+
+/* $ Abstract */
+
+/* Return the Euler angles needed to compute the transformation */
+/* from inertial to body-fixed coordinates for any body in the */
+/* kernel pool. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* PCK */
+/* NAIF_IDS */
+/* TIME */
+
+/* $ Keywords */
+
+/* CONSTANTS */
+/* ROTATION */
+/* TRANSFORMATION */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* BODY I ID code of body. */
+/* ET I Epoch of transformation. */
+/* RA O Right ascension of the (IAU) north pole. */
+/* DEC O Declination of the (IAU) north pole of the body. */
+/* W O Angle between the x-axis and the prime meridian. */
+/* LAMBDA O Angle between the prime meridian and longitude of */
+/* longest axis. */
+
+/* $ Detailed_Input */
+
+/* BODY is the integer ID code of the body for which the */
+/* transformation is requested. Bodies are numbered */
+/* according to the standard NAIF numbering scheme. */
+
+/* ET is the epoch at which the transformation is */
+/* requested. (This is typically the epoch of */
+/* observation minus the one-way light time from */
+/* the observer to the body at the epoch of */
+/* observation.) */
+
+/* $ Detailed_Output */
+
+/* RA, */
+/* DEC are the right ascension and declination of the */
+/* (IAU) north pole of the body at the epoch of */
+/* transformation. RA and DEC are given in radians. */
+
+/* W is the angle between the x-axis (inertial) and the */
+/* prime meridian of the body. W is given in radians. */
+
+/* LAMBDA is the angle between the prime meridian and the */
+/* longest axis of the tri-axial ellipsoid which */
+/* models the body. LAMBDA is given in radians. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the number of phase terms is insufficient, the error */
+/* SPICE(KERNELVARNOTFOUND) is signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* If there exists high-precision binary PCK kernel information */
+/* for the body at the requested time, the angles, W, DELTA */
+/* and PHI are computed directly from that file. These angles */
+/* are then used to compute RA, DEC and W. The most recently */
+/* loaded binary PCK file has first priority followed by previously */
+/* loaded binary PCK files in backward time order. If no binary */
+/* PCK file has been loaded, the text P_constants kernel file */
+/* is used. */
+
+/* If there is only text PCK kernel information, it is */
+/* expressed in terms of RA, DEC and W (same W as above), where */
+
+/* RA = PHI - HALFPI() */
+/* DEC = HALFPI() - DELTA */
+
+/* RA, DEC, and W are defined as follows in the text PCK file: */
+
+/* RA = RA0 + RA1*T + RA2*T*T + a sin theta */
+/* i i */
+
+/* DEC = DEC0 + DEC1*T + DEC2*T*T + d cos theta */
+/* i i */
+
+/* W = W0 + W1*d + W2*d*d + w sin theta */
+/* i i */
+
+/* where: */
+
+/* d = days past J2000. */
+
+/* T = Julian centuries past J2000. */
+
+/* a , d , and w arrays apply to satellites only. */
+/* i i i */
+
+/* theta = THETA0 * THETA1*T are specific to each planet. */
+/* i */
+
+/* These angles -- typically nodal rates -- vary in number and */
+/* definition from one planetary system to the next. */
+
+/* The offset LAMBDA is a constant for a given body. LAMBDA is */
+/* needed to distinguish between the latitude and longitude */
+/* system and the geometric system (where Prime Meridian always */
+/* intersects the longest axis). */
+
+/* $ Examples */
+
+/* In the following code fragment, BODEUL is used to get the unit */
+/* vector (POLE) parallel to the north pole of a target body (BODY) */
+/* at a specific epoch (ET). */
+
+/* CALL BODEUL ( BODY, ET, RA, DEC, W, LAMBDA ) */
+/* CALL RADREC ( 1.D0, RA, DEC, POLE ) */
+
+/* Note that the items necessary to compute the Euler angles */
+/* must have been loaded into the kernel pool (by one or more */
+/* previous calls to LDPOOL). */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* 1) Refer to the NAIF_IDS required reading file for a complete */
+/* list of the NAIF integer ID codes for bodies. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+/* K.S. Zukor (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.1.0, 24-OCT-2005 (NJB) */
+
+/* Calls to ZZBODVCD have been replaced with calls to */
+/* BODVCD. */
+
+/* - SPICELIB Version 4.0.0, 13-FEB-2004 (NJB) */
+
+/* Code has been updated to support satellite ID codes in the */
+/* range 10000 to 99999 and to allow nutation precession angles */
+/* to be associated with any object. */
+
+/* Implementation changes were made to improve robustness */
+/* of the code. */
+
+/* - SPICELIB Version 3.1.0, 21-MAR-1995 (KSZ) */
+
+/* REF frame is now passed correctly as a character string. */
+
+/* - SPICELIB Version 3.0.0, 10-MAR-1994 (KSZ) */
+
+/* Ability to get Euler angles from binary PCK file added. */
+/* This uses the new routine PCKEUL. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) */
+
+/* Updated to handle P_constants referenced to different epochs */
+/* and inertial reference frames. */
+
+/* - SPICELIB Version 1.1.0, 02-NOV-1990 (NJB) */
+
+/* Allowed number of nutation precession angles increased to */
+/* 100. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* euler angles for orientation of a body */
+/* fetch euler angles for a body */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 4.1.0, 24-OCT-2005 (NJB) */
+
+/* Calls to ZZBODVCD have been replaced with calls to */
+/* BODVCD. */
+
+/* - SPICELIB Version 4.0.0, 13-FEB-2004 (NJB) */
+
+/* Code has been updated to support satellite ID codes in the */
+/* range 10000 to 99999 and to allow nutation precession angles */
+/* to be associated with any object. */
+
+/* Calls to deprecated kernel pool access routine RTPOOL */
+/* were replaced by calls to GDPOOL. */
+
+/* Calls to BODVAR have been replaced with calls to */
+/* ZZBODVCD. */
+
+/* - SPICELIB Version 3.1.0, 21-MAR-1995 (KSZ) */
+
+/* REF frame is now passed correctly as a character string. */
+
+/* - SPICELIB Version 3.0.0, 10-MAR-1994 (KSZ) */
+
+/* BODEUL now uses new software to check for the */
+/* existence of binary PCK files, search the for */
+/* data corresponding to the requested body and time, */
+/* and return the appropriate Euler angles, using the */
+/* new routine PCKEUL. Otherwise the code calculates */
+/* the Euler angles from the P_constants kernel file. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) */
+
+/* Updated to handle P_constants referenced to different epochs */
+/* and inertial reference frames. */
+
+/* Updated to handle P_constants referenced to different epochs */
+/* and inertial reference frames. */
+
+/* BODEUL now checks the kernel pool for presence of the */
+/* variables */
+
+/* BODY#_CONSTANTS_REF_FRAME */
+
+/* and */
+
+/* BODY#_CONSTANTS_JED_EPOCH */
+
+/* where # is the NAIF integer code of the barycenter of a */
+/* planetary system or of a body other than a planet or */
+/* satellite. If either or both of these variables are */
+/* present, the P_constants for BODY are presumed to be */
+/* referenced to the specified inertial frame or epoch. */
+/* If the epoch of the constants is not J2000, the input */
+/* time ET is converted to seconds past the reference epoch. */
+/* If the frame of the constants is not J2000, the Euler angles */
+/* defining the rotation from the P_constants' frame to */
+/* body-fixed coordinates are transformed so that they define */
+/* the rotation from J2000 coordinates to body-fixed */
+/* coordinates. */
+
+
+/* - SPICELIB Version 1.1.0, 02-NOV-1990 (NJB) */
+
+/* Allowed number of nutation precession angles increased to */
+/* 100. */
+
+/* - Beta Version 2.0.0, 23-JUN-1989 (HAN) */
+
+/* Mod angles by two pi. Check to see that right ascension and */
+/* prime meridian angles are within the range 0 to two pi. */
+
+/* LAMBDA used to be returned in degrees. It has been corrected */
+/* to return LAMBDA in radians. */
+
+/* - Beta Version 1.1.0, 16-FEB-1989 (IMU) (NJB) */
+
+/* Examples section completed. Declarations of unused variables */
+/* HALFPI and N removed. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("BODEUL", (ftnlen)6);
+ }
+
+/* Get the code for the J2000 frame, if we don't have it yet. */
+
+ if (first) {
+ irfnum_("J2000", &j2code, (ftnlen)5);
+ first = FALSE_;
+ }
+
+/* Get Euler angles from high precision data file. */
+
+ pckeul_(body, et, &found, bref, eulang, (ftnlen)32);
+ if (found) {
+ phi = eulang[0];
+ delta = eulang[1];
+ *w = eulang[2];
+ irfnum_(bref, &ref, (ftnlen)32);
+
+/* The offset of the prime meridian is optional. */
+
+ s_copy(item, "LONG_AXIS", (ftnlen)32, (ftnlen)9);
+ if (bodfnd_(body, item, (ftnlen)32)) {
+ bodvcd_(body, item, &c__1, &nl, lambda, (ftnlen)32);
+ *lambda *= rpd_();
+ d__1 = twopi_();
+ *lambda = d_mod(lambda, &d__1);
+ } else {
+ *lambda = 0.;
+ }
+ } else {
+
+/* Find the body code used to label the reference frame and epoch */
+/* specifiers for the orientation constants for BODY. */
+
+/* For planetary systems, the reference frame and epoch for the */
+/* orientation constants is associated with the system */
+/* barycenter, not with individual bodies in the system. For any */
+/* other bodies, (the Sun or asteroids, for example) the body's */
+/* own code is used as the label. */
+
+ refid = zzbodbry_(body);
+
+/* Look up the epoch of the constants. The epoch is specified */
+/* as a Julian ephemeris date. The epoch defaults to J2000. */
+
+ s_copy(item, "BODY#_CONSTANTS_JED_EPOCH", (ftnlen)32, (ftnlen)25);
+ repmi_(item, "#", &refid, item, (ftnlen)32, (ftnlen)1, (ftnlen)32);
+ gdpool_(item, &c__1, &c__1, &dim, &conepc, &found, (ftnlen)32);
+ if (found) {
+
+/* The reference epoch is returned as a JED. Convert to */
+/* ephemeris seconds past J2000. Then convert the input ET to */
+/* seconds past the reference epoch. */
+
+ conepc = spd_() * (conepc - j2000_());
+ epoch = *et - conepc;
+ } else {
+ epoch = *et;
+ }
+
+/* Look up the reference frame of the constants. The reference */
+/* frame is specified by a code recognized by CHGIRF. The */
+/* default frame is J2000, symbolized by the code J2CODE. */
+
+ irfnum_("J2000", &j2code, (ftnlen)5);
+ s_copy(item, "BODY#_CONSTANTS_REF_FRAME", (ftnlen)32, (ftnlen)25);
+ repmi_(item, "#", &refid, item, (ftnlen)32, (ftnlen)1, (ftnlen)32);
+ gdpool_(item, &c__1, &c__1, &dim, &conref, &found, (ftnlen)32);
+ if (found) {
+ ref = i_dnnt(&conref);
+ } else {
+ ref = j2code;
+ }
+
+/* Whatever the body, it has quadratic time polynomials for */
+/* the RA and Dec of the pole, and for the rotation of the */
+/* Prime Meridian. */
+
+ s_copy(item, "POLE_RA", (ftnlen)32, (ftnlen)7);
+ cleard_(&c__3, rcoef);
+ bodvcd_(body, item, &c__3, &na, rcoef, (ftnlen)32);
+ s_copy(item, "POLE_DEC", (ftnlen)32, (ftnlen)8);
+ cleard_(&c__3, dcoef);
+ bodvcd_(body, item, &c__3, &nd, dcoef, (ftnlen)32);
+ s_copy(item, "PM", (ftnlen)32, (ftnlen)2);
+ cleard_(&c__3, wcoef);
+ bodvcd_(body, item, &c__3, &nw, wcoef, (ftnlen)32);
+
+/* The offset of the prime meridian is optional. */
+
+ s_copy(item, "LONG_AXIS", (ftnlen)32, (ftnlen)9);
+ if (bodfnd_(body, item, (ftnlen)32)) {
+ bodvcd_(body, item, &c__1, &nl, lambda, (ftnlen)32);
+ } else {
+ *lambda = 0.;
+ }
+
+/* There may be additional nutation and libration (THETA) terms. */
+
+ ntheta = 0;
+ na = 0;
+ nd = 0;
+ nw = 0;
+ s_copy(item, "NUT_PREC_ANGLES", (ftnlen)32, (ftnlen)15);
+ if (bodfnd_(&refid, item, (ftnlen)32)) {
+ bodvcd_(&refid, item, &c__100, &ntheta, tcoef, (ftnlen)32);
+ ntheta /= 2;
+ }
+ s_copy(item, "NUT_PREC_RA", (ftnlen)32, (ftnlen)11);
+ if (bodfnd_(body, item, (ftnlen)32)) {
+ bodvcd_(body, item, &c__100, &na, ac, (ftnlen)32);
+ }
+ s_copy(item, "NUT_PREC_DEC", (ftnlen)32, (ftnlen)12);
+ if (bodfnd_(body, item, (ftnlen)32)) {
+ bodvcd_(body, item, &c__100, &nd, dc, (ftnlen)32);
+ }
+ s_copy(item, "NUT_PREC_PM", (ftnlen)32, (ftnlen)11);
+ if (bodfnd_(body, item, (ftnlen)32)) {
+ bodvcd_(body, item, &c__100, &nw, wc, (ftnlen)32);
+ }
+/* Computing MAX */
+ i__1 = max(na,nd);
+ if (max(i__1,nw) > ntheta) {
+ setmsg_("BODEUL: Insufficient number of nutation/precession angl"
+ "es for body * at time #.", (ftnlen)79);
+ errint_("*", body, (ftnlen)1);
+ errdp_("#", et, (ftnlen)1);
+ sigerr_("SPICE(KERNELVARNOTFOUND)", (ftnlen)24);
+ chkout_("BODEUL", (ftnlen)6);
+ return 0;
+ }
+
+/* Evaluate the time polynomials at EPOCH. */
+
+ d__ = epoch / spd_();
+ t = d__ / 36525.;
+ *ra = rcoef[0] + t * (rcoef[1] + t * rcoef[2]);
+ *dec = dcoef[0] + t * (dcoef[1] + t * dcoef[2]);
+ *w = wcoef[0] + d__ * (wcoef[1] + d__ * wcoef[2]);
+
+/* Add nutation and libration as appropriate. */
+
+ i__1 = ntheta;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ theta = (tcoef[(i__2 = (i__ << 1) - 2) < 200 && 0 <= i__2 ? i__2 :
+ s_rnge("tcoef", i__2, "bodeul_", (ftnlen)590)] + t *
+ tcoef[(i__3 = (i__ << 1) - 1) < 200 && 0 <= i__3 ? i__3 :
+ s_rnge("tcoef", i__3, "bodeul_", (ftnlen)590)]) * rpd_();
+ sinth[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("sinth",
+ i__2, "bodeul_", (ftnlen)592)] = sin(theta);
+ costh[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("costh",
+ i__2, "bodeul_", (ftnlen)593)] = cos(theta);
+ }
+ *ra += vdotg_(ac, sinth, &na);
+ *dec += vdotg_(dc, costh, &nd);
+ *w += vdotg_(wc, sinth, &nw);
+
+/* Convert from degrees to radians and mod by two pi. */
+
+ *ra *= rpd_();
+ *dec *= rpd_();
+ *w *= rpd_();
+ *lambda *= rpd_();
+ d__1 = twopi_();
+ *ra = d_mod(ra, &d__1);
+ d__1 = twopi_();
+ *dec = d_mod(dec, &d__1);
+ d__1 = twopi_();
+ *w = d_mod(w, &d__1);
+ d__1 = twopi_();
+ *lambda = d_mod(lambda, &d__1);
+
+/* Convert to Euler angles. */
+
+ phi = *ra + halfpi_();
+ delta = halfpi_() - *dec;
+ }
+
+/* Convert the angles to the J2000 frame if they are not already */
+/* referenced to J2000. */
+
+ if (ref != j2code) {
+
+/* Find the transformation from the J2000 frame to the frame */
+/* designated by REF. Form the transformation from `REF' */
+/* coordinates to body-fixed coordinates, using our Euler angles. */
+/* Compose the transformations to obtain the J2000-to-body-fixed */
+/* transformation. Decompose this transformation into Euler */
+/* angles. */
+
+ irfrot_(&j2code, &ref, j2ref);
+ eul2m_(w, &delta, &phi, &c__3, &c__1, &c__3, rf2bfx);
+ mxm_(rf2bfx, j2ref, j2bfx);
+ m2eul_(j2bfx, &c__3, &c__1, &c__3, w, &delta, &phi);
+ }
+
+/* The Euler angles now give the transformation from J2000 to */
+/* body-fixed coordinates at epoch ET seconds past J2000, */
+/* regardless of the epoch and frame of the orientation constants */
+/* for the specified body. */
+
+ *ra = phi - halfpi_();
+ *dec = halfpi_() - delta;
+
+/* Make sure that the prime meridian and right ascension are in */
+/* the correct range. */
+
+ if (*w < 0.) {
+ *w += twopi_();
+ }
+ if (*ra < 0.) {
+ *ra += twopi_();
+ }
+ chkout_("BODEUL", (ftnlen)6);
+ return 0;
+} /* bodeul_ */
+
diff --git a/ext/spice/src/cspice/bodfnd.c b/ext/spice/src/cspice/bodfnd.c
new file mode 100644
index 0000000000..44eb790734
--- /dev/null
+++ b/ext/spice/src/cspice/bodfnd.c
@@ -0,0 +1,214 @@
+/* bodfnd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__0 = 0;
+
+/* $Procedure BODFND ( Find values from the kernel pool ) */
+logical bodfnd_(integer *body, char *item, ftnlen item_len)
+{
+ /* System generated locals */
+ logical ret_val;
+
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ char code[16];
+ integer n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ logical found;
+ char dtype[1], varnam[32];
+ extern /* Subroutine */ int chkout_(char *, ftnlen), dtpool_(char *,
+ logical *, integer *, char *, ftnlen, ftnlen), suffix_(char *,
+ integer *, char *, ftnlen, ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int intstr_(integer *, char *, ftnlen);
+
+/* $ Abstract */
+
+/* Determine whether values exist for some item for any body */
+/* in the kernel pool. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* KERNEL */
+
+/* $ Keywords */
+
+/* CONSTANTS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* BODY I ID code of body. */
+/* ITEM I Item to find ('RADII', 'NUT_AMP_RA', etc.). */
+
+/* $ Detailed_Input */
+
+/* BODY is the ID code of the body for which the item is */
+/* requested. Bodies are numbered according to the */
+/* standard NAIF numbering scheme. */
+
+/* ITEM is the item to be returned. Together, the body and */
+/* item name combine to form a variable name, e.g., */
+
+/* 'BODY599_RADII' */
+/* 'BODY4_POLE_RA' */
+
+/* $ Detailed_Output */
+
+/* The result is TRUE if the item is in the kernel pool, */
+/* and is FALSE if it is not. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* None. */
+
+/* $ Particulars */
+
+/* BODVCD, which returns values from the kernel pool, causes an */
+/* error to be signalled whenever the specified item is not found. */
+/* In many cases, this is appropriate. However, sometimes the */
+/* program may attempt to recover, by providing default values, */
+/* prompting for replacements, and so on. */
+
+/* $ Examples */
+
+/* In the following example, default values are substituted for */
+/* bodies for which axes are not found. */
+
+/* IF ( BODFND ( TARGET, 'RADII' ) ) THEN */
+/* CALL BODVCD ( TARGET, 'RADII', 3, N, RADII ) */
+/* ELSE */
+/* CALL VPACK ( 100.D0, 100.D0, 100.D0, RADII ) */
+/* END IF */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* 1) Refer to the SPK required reading file for a complete list of */
+/* the NAIF integer ID codes for bodies. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.2.1, 24-OCT-2005 (NJB) */
+
+/* Header update: calls to BODVAR in example code were replaced */
+/* with calls to BODVCD. The string 'AXES' and variable AXES */
+/* were replaced with the string 'RADII' and variable 'RADII' */
+/* throughout the header. */
+
+/* - SPICELIB Version 1.2.0, 15-MAR-2002 (NJB) */
+
+/* Bug fix: routine was updated to work with string-valued */
+/* kernel variables. */
+
+/* - SPICELIB Version 1.1.0, 17-MAY-1994 (HAN) */
+
+/* If the value of the function RETURN is TRUE upon execution of */
+/* this module, this function is assigned a default value of */
+/* either 0, 0.0D0, .FALSE., or blank depending on the type of */
+/* the function. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* find constants for a body in the kernel pool */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ ret_val = FALSE_;
+ return ret_val;
+ } else {
+ chkin_("BODFND", (ftnlen)6);
+ }
+
+/* Construct the variable name from BODY and ITEM. */
+
+ s_copy(varnam, "BODY", (ftnlen)32, (ftnlen)4);
+ intstr_(body, code, (ftnlen)16);
+ suffix_(code, &c__0, varnam, (ftnlen)16, (ftnlen)32);
+ suffix_("_", &c__0, varnam, (ftnlen)1, (ftnlen)32);
+ suffix_(item, &c__0, varnam, item_len, (ftnlen)32);
+
+/* Search the kernel pool for the item. */
+
+ dtpool_(varnam, &found, &n, dtype, (ftnlen)32, (ftnlen)1);
+
+/* Was anything there? */
+
+ ret_val = found;
+ chkout_("BODFND", (ftnlen)6);
+ return ret_val;
+} /* bodfnd_ */
+
diff --git a/ext/spice/src/cspice/bodfnd_c.c b/ext/spice/src/cspice/bodfnd_c.c
new file mode 100644
index 0000000000..821b821b2f
--- /dev/null
+++ b/ext/spice/src/cspice/bodfnd_c.c
@@ -0,0 +1,210 @@
+/*
+
+-Procedure bodfnd_c ( Find values from the kernel pool )
+
+-Abstract
+
+ Determine whether values exist for some item for any body
+ in the kernel pool.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ KERNEL
+ NAIF_IDS
+ PCK
+
+-Keywords
+
+ CONSTANTS
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+ SpiceBoolean bodfnd_c ( SpiceInt body,
+ ConstSpiceChar * item )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ body I ID code of body.
+ item I Item to find ("RADII", "NUT_AMP_RA", etc.).
+
+ The function returns the value SPICETRUE if the item is in the
+ kernel pool, and is SPICEFALSE if it is not.
+
+-Detailed_Input
+
+ body is the ID code of the body for which the item is
+ requested. Bodies are numbered according to the
+ standard NAIF numbering scheme.
+
+ item is the item to be returned. Together, the body and
+ item name combine to form a variable name, e.g.,
+
+ "BODY599_RADII"
+ "BODY4_POLE_RA"
+
+-Detailed_Output
+
+ The function returns the value SPICETRUE if the item is in the
+ kernel pool, and is SPICEFALSE if it is not.
+
+-Parameters
+
+ None.
+
+-Particulars
+
+ The CSPICE routines bodvcd_c and bodvrd_c, which return values from
+ the kernel pool, signal an error if the specified item is not found.
+ In many cases, this is appropriate. However, sometimes the program
+ may attempt to recover, by providing default values, prompting for
+ replacements, and so on.
+
+-Examples
+
+ In the following example, default values are substituted for
+ bodies for which radii are not found.
+
+ #include "SpiceUsr.h"
+ ...
+ SpiceDouble radii[3];
+ SpiceInt n;
+ SpiceInt target;
+ ...
+
+ if ( bodfnd_c ( target, "RADII" ) )
+ {
+ bodvcd_c ( target, "AXES", 3, &n, radii );
+ }
+ else
+ {
+ vpack_c ( 100.0, 100.0, 100.0, radii );
+ }
+
+-Restrictions
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+-Files
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ H.A. Neilan (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+ E.D. Wright (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 2.0.2, 24-OCT-2005 (NJB)
+
+ Header updates: reference to bodvar_c was replaced with
+ reference to bodvcd_c. The string "AXES" and variable `axes'
+ were replaced with the string "RADII" and variable `radii'
+ throughout the header. A few other minor header edits were
+ made.
+
+ -CSPICE Version 2.0.1, 08-FEB-1998 (EDW)
+
+ Corrected and clarified header entries.
+
+ -CSPICE Version 2.0.0, 06-JAN-1998 (NJB)
+
+ Input argument item was changed to type ConstSpiceChar *.
+
+ References to C2F_CreateStr_Sig were removed; code was
+ cleaned up accordingly. String checks are now done using
+ the macro CHKFSTR_VAL.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (EDW)
+
+-Index_Entries
+
+ find constants for a body in the kernel pool
+
+-&
+*/
+
+
+{ /* Begin bodfnd_c */
+
+ /*
+ Local variables.
+ */
+ SpiceBoolean result;
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "bodfnd_c" );
+
+
+ /*
+ Check the input string to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR_VAL ( CHK_STANDARD, "bodfnd_c", item, SPICEFALSE );
+
+
+ /*
+ Execute the f2c'd routine.
+ */
+ result = (SpiceBoolean) bodfnd_( ( integer * ) &body,
+ ( char * ) item,
+ ( ftnlen ) strlen(item) );
+
+
+ /*
+ We now have a true or false. Tell the caller the value. It may need
+ to know.
+ */
+ chkout_c ( "bodfnd_c" );
+
+ return ( result );
+
+} /* End bodfnd_c */
+
diff --git a/ext/spice/src/cspice/bodmat.c b/ext/spice/src/cspice/bodmat.c
new file mode 100644
index 0000000000..f7f8283975
--- /dev/null
+++ b/ext/spice/src/cspice/bodmat.c
@@ -0,0 +1,842 @@
+/* bodmat.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__1 = 1;
+static integer c__3 = 3;
+static integer c__100 = 100;
+static integer c__9 = 9;
+
+/* $Procedure BODMAT ( Return transformation matrix for a body ) */
+/* Subroutine */ int bodmat_(integer *body, doublereal *et, doublereal *tipm)
+{
+ /* Initialized data */
+
+ static logical first = TRUE_;
+ static logical found = FALSE_;
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+ doublereal d__1;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer i_dnnt(doublereal *);
+ double sin(doublereal), cos(doublereal), d_mod(doublereal *, doublereal *)
+ ;
+
+ /* Local variables */
+ integer cent;
+ char item[32];
+ doublereal j2ref[9] /* was [3][3] */;
+ extern integer zzbodbry_(integer *);
+ extern /* Subroutine */ int eul2m_(doublereal *, doublereal *, doublereal
+ *, integer *, integer *, integer *, doublereal *);
+ doublereal d__;
+ integer i__, j;
+ doublereal dcoef[3], t, w;
+ extern /* Subroutine */ int etcal_(doublereal *, char *, ftnlen);
+ integer refid;
+ doublereal delta;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ doublereal epoch, rcoef[3], tcoef[200] /* was [2][100] */, wcoef[3];
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
+ doublereal theta;
+ extern /* Subroutine */ int moved_(doublereal *, integer *, doublereal *),
+ repmi_(char *, char *, integer *, char *, ftnlen, ftnlen, ftnlen)
+ , errdp_(char *, doublereal *, ftnlen);
+ doublereal costh[100];
+ extern doublereal vdotg_(doublereal *, doublereal *, integer *);
+ char dtype[1];
+ doublereal sinth[100], tsipm[36] /* was [6][6] */;
+ extern doublereal twopi_(void);
+ static integer j2code;
+ doublereal ac[100], dc[100];
+ integer na, nd;
+ doublereal ra, wc[100];
+ extern /* Subroutine */ int cleard_(integer *, doublereal *);
+ extern logical bodfnd_(integer *, char *, ftnlen);
+ extern /* Subroutine */ int bodvcd_(integer *, char *, integer *, integer
+ *, doublereal *, ftnlen);
+ integer frcode;
+ extern doublereal halfpi_(void);
+ extern /* Subroutine */ int ccifrm_(integer *, integer *, integer *, char
+ *, integer *, logical *, ftnlen);
+ integer nw;
+ doublereal conepc, conref;
+ extern /* Subroutine */ int pckmat_(integer *, doublereal *, integer *,
+ doublereal *, logical *);
+ integer ntheta;
+ extern /* Subroutine */ int gdpool_(char *, integer *, integer *, integer
+ *, doublereal *, logical *, ftnlen);
+ char fixfrm[32], errmsg[1840];
+ extern /* Subroutine */ int irfnum_(char *, integer *, ftnlen), dtpool_(
+ char *, logical *, integer *, char *, ftnlen, ftnlen);
+ doublereal tmpmat[9] /* was [3][3] */;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), suffix_(char *,
+ integer *, char *, ftnlen, ftnlen), errint_(char *, integer *,
+ ftnlen), sigerr_(char *, ftnlen), chkout_(char *, ftnlen),
+ irfrot_(integer *, integer *, doublereal *);
+ extern logical return_(void);
+ char timstr[35];
+ extern doublereal j2000_(void);
+ doublereal dec;
+ integer dim, ref;
+ doublereal phi;
+ extern doublereal rpd_(void), spd_(void);
+ extern /* Subroutine */ int mxm_(doublereal *, doublereal *, doublereal *)
+ ;
+
+/* $ Abstract */
+
+/* Return the J2000 to body Equator and Prime Meridian coordinate */
+/* transformation matrix for a specified body. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* PCK */
+/* NAIF_IDS */
+/* TIME */
+
+/* $ Keywords */
+
+/* CONSTANTS */
+
+/* $ Declarations */
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+
+/* Include File: SPICELIB Error Handling Parameters */
+
+/* errhnd.inc Version 2 18-JUN-1997 (WLT) */
+
+/* The size of the long error message was */
+/* reduced from 25*80 to 23*80 so that it */
+/* will be accepted by the Microsoft Power Station */
+/* FORTRAN compiler which has an upper bound */
+/* of 1900 for the length of a character string. */
+
+/* errhnd.inc Version 1 29-JUL-1997 (NJB) */
+
+
+
+/* Maximum length of the long error message: */
+
+
+/* Maximum length of the short error message: */
+
+
+/* End Include File: SPICELIB Error Handling Parameters */
+
+/* $ Abstract */
+
+/* The parameters below form an enumerated list of the recognized */
+/* frame types. They are: INERTL, PCK, CK, TK, DYN. The meanings */
+/* are outlined below. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Parameters */
+
+/* INERTL an inertial frame that is listed in the routine */
+/* CHGIRF and that requires no external file to */
+/* compute the transformation from or to any other */
+/* inertial frame. */
+
+/* PCK is a frame that is specified relative to some */
+/* INERTL frame and that has an IAU model that */
+/* may be retrieved from the PCK system via a call */
+/* to the routine TISBOD. */
+
+/* CK is a frame defined by a C-kernel. */
+
+/* TK is a "text kernel" frame. These frames are offset */
+/* from their associated "relative" frames by a */
+/* constant rotation. */
+
+/* DYN is a "dynamic" frame. These currently are */
+/* parameterized, built-in frames where the full frame */
+/* definition depends on parameters supplied via a */
+/* frame kernel. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 28-MAY-2004 (NJB) */
+
+/* The parameter DYN was added to support the dynamic frame class. */
+
+/* - SPICELIB Version 2.0.0, 12-DEC-1996 (WLT) */
+
+/* Various unused frames types were removed and the */
+/* frame time TK was added. */
+
+/* - SPICELIB Version 1.0.0, 10-DEC-1995 (WLT) */
+
+/* -& */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* BODY I ID code of body. */
+/* ET I Epoch of transformation. */
+/* TIPM O Transformation from Inertial to PM for BODY at ET. */
+
+/* $ Detailed_Input */
+
+/* BODY is the integer ID code of the body for which the */
+/* transformation is requested. Bodies are numbered */
+/* according to the standard NAIF numbering scheme. */
+
+/* ET is the epoch at which the transformation is */
+/* requested. (This is typically the epoch of */
+/* observation minus the one-way light time from */
+/* the observer to the body at the epoch of */
+/* observation.) */
+
+/* $ Detailed_Output */
+
+/* TIPM is the transformation matrix from Inertial to body */
+/* Equator and Prime Meridian. The X axis of the PM */
+/* system is directed to the intersection of the */
+/* equator and prime meridian. The Z axis points north. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If data required to define the body-fixed frame associated */
+/* with BODY are not found in the binary PCK system or the kernel */
+/* pool, the error SPICE(FRAMEDATANOTFOUND) is signaled. In */
+/* the case of IAU style body-fixed frames, the absence of */
+/* prime meridian polynomial data (which are required) is used */
+/* as an indicator of missing data. */
+
+/* 2) If the test for exception (1) passes, but in fact requested */
+/* data are not available in the kernel pool, the error will be */
+/* signaled by routines in the call tree of this routine. */
+
+/* 3) If the kernel pool does not contain all of the data required */
+/* to define the number of nutation precession angles */
+/* corresponding to the available nutation precession */
+/* coefficients, the error SPICE(INSUFFICIENTANGLES) is */
+/* signaled. */
+
+/* 4) If the reference frame REF is not recognized, a routine */
+/* called by BODMAT will diagnose the condition and invoke the */
+/* SPICE error handling system. */
+
+/* 5) If the specified body code BODY is not recognized, the */
+/* error is diagnosed by a routine called by BODMAT. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine is related to the more general routine TIPBOD */
+/* which returns a matrix that transforms vectors from a */
+/* specified inertial reference frame to body equator and */
+/* prime meridian coordinates. TIPBOD accepts an input argument */
+/* REF that allows the caller to specify an inertial reference */
+/* frame. */
+
+/* The transformation represented by BODMAT's output argument TIPM */
+/* is defined as follows: */
+
+/* TIPM = [W] [DELTA] [PHI] */
+/* 3 1 3 */
+
+/* If there exists high-precision binary PCK kernel information */
+/* for the body at the requested time, these angles, W, DELTA */
+/* and PHI are computed directly from that file. The most */
+/* recently loaded binary PCK file has first priority followed */
+/* by previously loaded binary PCK files in backward time order. */
+/* If no binary PCK file has been loaded, the text P_constants */
+/* kernel file is used. */
+
+/* If there is only text PCK kernel information, it is */
+/* expressed in terms of RA, DEC and W (same W as above), where */
+
+/* RA = PHI - HALFPI() */
+/* DEC = HALFPI() - DELTA */
+
+/* RA, DEC, and W are defined as follows in the text PCK file: */
+
+/* RA = RA0 + RA1*T + RA2*T*T + a sin theta */
+/* i i */
+
+/* DEC = DEC0 + DEC1*T + DEC2*T*T + d cos theta */
+/* i i */
+
+/* W = W0 + W1*d + W2*d*d + w sin theta */
+/* i i */
+
+/* where: */
+
+/* d = days past J2000. */
+
+/* T = Julian centuries past J2000. */
+
+/* a , d , and w arrays apply to satellites only. */
+/* i i i */
+
+/* theta = THETA0 * THETA1*T are specific to each planet. */
+/* i */
+
+/* These angles -- typically nodal rates -- vary in number and */
+/* definition from one planetary system to the next. */
+
+/* $ Examples */
+
+/* In the following code fragment, BODMAT is used to rotate */
+/* the position vector (POS) from a target body (BODY) to a */
+/* spacecraft from inertial coordinates to body-fixed coordinates */
+/* at a specific epoch (ET), in order to compute the planetocentric */
+/* longitude (PCLONG) of the spacecraft. */
+
+/* CALL BODMAT ( BODY, ET, TIPM ) */
+/* CALL MXV ( TIPM, POS, POS ) */
+/* CALL RECLAT ( POS, RADIUS, PCLONG, LAT ) */
+
+/* To compute the equivalent planetographic longitude (PGLONG), */
+/* it is necessary to know the direction of rotation of the target */
+/* body, as shown below. */
+
+/* CALL BODVCD ( BODY, 'PM', 3, DIM, VALUES ) */
+
+/* IF ( VALUES(2) .GT. 0.D0 ) THEN */
+/* PGLONG = PCLONG */
+/* ELSE */
+/* PGLONG = TWOPI() - PCLONG */
+/* END IF */
+
+/* Note that the items necessary to compute the transformation */
+/* TIPM must have been loaded into the kernel pool (by one or more */
+/* previous calls to FURNSH). */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* 1) Refer to the NAIF_IDS required reading file for a complete */
+/* list of the NAIF integer ID codes for bodies. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+/* K.S. Zukor (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.1.1, 01-FEB-2008 (NJB) */
+
+/* The routine was updated to improve the error messages created */
+/* when required PCK data are not found. Now in most cases the */
+/* messages are created locally rather than by the kernel pool */
+/* access routines. In particular missing binary PCK data will */
+/* be indicated with a reasonable error message. */
+
+/* - SPICELIB Version 4.1.0, 25-AUG-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in MXM call. */
+
+/* Calls to ZZBODVCD have been replaced with calls to */
+/* BODVCD. */
+
+/* - SPICELIB Version 4.0.0, 12-FEB-2004 (NJB) */
+
+/* Code has been updated to support satellite ID codes in the */
+/* range 10000 to 99999 and to allow nutation precession angles */
+/* to be associated with any object. */
+
+/* Implementation changes were made to improve robustness */
+/* of the code. */
+
+/* - SPICELIB Version 3.2.0, 22-MAR-1995 (KSZ) */
+
+/* Gets TSIPM matrix from PCKMAT (instead of Euler angles */
+/* from PCKEUL.) */
+
+/* - SPICELIB Version 3.0.0, 10-MAR-1994 (KSZ) */
+
+/* Ability to get Euler angles from binary PCK file added. */
+/* This uses the new routine PCKEUL. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) */
+
+/* Updated to handle P_constants referenced to different epochs */
+/* and inertial reference frames. */
+
+/* The header was updated to specify that the inertial reference */
+/* frame used by BODMAT is restricted to be J2000. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* fetch transformation matrix for a body */
+/* transformation from j2000 position to bodyfixed */
+/* transformation from j2000 to bodyfixed coordinates */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 4.1.0, 25-AUG-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in MXM call. */
+
+/* Calls to ZZBODVCD have been replaced with calls to */
+/* BODVCD. */
+
+/* - SPICELIB Version 4.0.0, 12-FEB-2004 (NJB) */
+
+/* Code has been updated to support satellite ID codes in the */
+/* range 10000 to 99999 and to allow nutation precession angles */
+/* to be associated with any object. */
+
+/* Calls to deprecated kernel pool access routine RTPOOL */
+/* were replaced by calls to GDPOOL. */
+
+/* Calls to BODVAR have been replaced with calls to */
+/* ZZBODVCD. */
+
+/* - SPICELIB Version 3.2.0, 22-MAR-1995 (KSZ) */
+
+/* BODMAT now get the TSIPM matrix from PCKMAT, and */
+/* unpacks TIPM from it. Also the calculated but unused */
+/* variable LAMBDA was removed. */
+
+/* - SPICELIB Version 3.0.0, 10-MAR-1994 (KSZ) */
+
+/* BODMAT now uses new software to check for the */
+/* existence of binary PCK files, search the for */
+/* data corresponding to the requested body and time, */
+/* and return the appropriate Euler angles, using the */
+/* new routine PCKEUL. Otherwise the code calculates */
+/* the Euler angles from the P_constants kernel file. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) */
+
+/* Updated to handle P_constants referenced to different epochs */
+/* and inertial reference frames. */
+
+/* The header was updated to specify that the inertial reference */
+/* frame used by BODMAT is restricted to be J2000. */
+
+/* BODMAT now checks the kernel pool for presence of the */
+/* variables */
+
+/* BODY#_CONSTANTS_REF_FRAME */
+
+/* and */
+
+/* BODY#_CONSTANTS_JED_EPOCH */
+
+/* where # is the NAIF integer code of the barycenter of a */
+/* planetary system or of a body other than a planet or */
+/* satellite. If either or both of these variables are */
+/* present, the P_constants for BODY are presumed to be */
+/* referenced to the specified inertial frame or epoch. */
+/* If the epoch of the constants is not J2000, the input */
+/* time ET is converted to seconds past the reference epoch. */
+/* If the frame of the constants is not J2000, the rotation from */
+/* the P_constants' frame to body-fixed coordinates is */
+/* transformed to the rotation from J2000 coordinates to */
+/* body-fixed coordinates. */
+
+/* For efficiency reasons, this routine now duplicates much */
+/* of the code of BODEUL so that it doesn't have to call BODEUL. */
+/* In some cases, BODEUL must covert Euler angles to a matrix, */
+/* rotate the matrix, and convert the result back to Euler */
+/* angles. If this routine called BODEUL, then in such cases */
+/* this routine would convert the transformed angles back to */
+/* a matrix. That would be a bit much.... */
+
+
+/* - Beta Version 1.1.0, 16-FEB-1989 (IMU) (NJB) */
+
+/* Examples section completed. Declaration of unused variable */
+/* FOUND removed. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+
+/* Standard SPICE Error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("BODMAT", (ftnlen)6);
+ }
+
+/* Get the code for the J2000 frame, if we don't have it yet. */
+
+ if (first) {
+ irfnum_("J2000", &j2code, (ftnlen)5);
+ first = FALSE_;
+ }
+
+/* Get Euler angles from high precision data file. */
+
+ pckmat_(body, et, &ref, tsipm, &found);
+ if (found) {
+ for (i__ = 1; i__ <= 3; ++i__) {
+ for (j = 1; j <= 3; ++j) {
+ tipm[(i__1 = i__ + j * 3 - 4) < 9 && 0 <= i__1 ? i__1 :
+ s_rnge("tipm", i__1, "bodmat_", (ftnlen)485)] = tsipm[
+ (i__2 = i__ + j * 6 - 7) < 36 && 0 <= i__2 ? i__2 :
+ s_rnge("tsipm", i__2, "bodmat_", (ftnlen)485)];
+ }
+ }
+ } else {
+
+/* The data for the frame of interest are not available in a */
+/* loaded binary PCK file. This is not an error: the data may be */
+/* present in the kernel pool. */
+
+/* Conduct a non-error-signaling check for the presence of a */
+/* kernel variable that is required to implement an IAU style */
+/* body-fixed reference frame. If the data aren't available, we */
+/* don't want BODVCD to signal a SPICE(KERNELVARNOTFOUND) error; */
+/* we want to issue the error signal locally, with a better error */
+/* message. */
+
+ s_copy(item, "BODY#_PM", (ftnlen)32, (ftnlen)8);
+ repmi_(item, "#", body, item, (ftnlen)32, (ftnlen)1, (ftnlen)32);
+ dtpool_(item, &found, &nw, dtype, (ftnlen)32, (ftnlen)1);
+ if (! found) {
+
+/* Now we do have an error. */
+
+/* We don't have the data we'll need to produced the requested */
+/* state transformation matrix. In order to create an error */
+/* message understandable to the user, find, if possible, the */
+/* name of the reference frame associated with the input body. */
+/* Note that the body is really identified by a PCK frame class */
+/* ID code, though most of the documentation just calls it a */
+/* body ID code. */
+
+ ccifrm_(&c__2, body, &frcode, fixfrm, ¢, &found, (ftnlen)32);
+ etcal_(et, timstr, (ftnlen)35);
+ s_copy(errmsg, "PCK data required to compute the orientation of "
+ "the # # for epoch # TDB were not found. If these data we"
+ "re to be provided by a binary PCK file, then it is possi"
+ "ble that the PCK file does not have coverage for the spe"
+ "cified body-fixed frame at the time of interest. If the "
+ "data were to be provided by a text PCK file, then possib"
+ "ly the file does not contain data for the specified body"
+ "-fixed frame. In either case it is possible that a requi"
+ "red PCK file was not loaded at all.", (ftnlen)1840, (
+ ftnlen)475);
+
+/* Fill in the variable data in the error message. */
+
+ if (found) {
+
+/* The frame system knows the name of the body-fixed frame. */
+
+ setmsg_(errmsg, (ftnlen)1840);
+ errch_("#", "body-fixed frame", (ftnlen)1, (ftnlen)16);
+ errch_("#", fixfrm, (ftnlen)1, (ftnlen)32);
+ errch_("#", timstr, (ftnlen)1, (ftnlen)35);
+ } else {
+
+/* The frame system doesn't know the name of the */
+/* body-fixed frame, most likely due to a missing */
+/* frame kernel. */
+
+ suffix_("#", &c__1, errmsg, (ftnlen)1, (ftnlen)1840);
+ setmsg_(errmsg, (ftnlen)1840);
+ errch_("#", "body-fixed frame associated with the ID code", (
+ ftnlen)1, (ftnlen)44);
+ errint_("#", body, (ftnlen)1);
+ errch_("#", timstr, (ftnlen)1, (ftnlen)35);
+ errch_("#", "Also, a frame kernel defining the body-fixed fr"
+ "ame associated with body # may need to be loaded.", (
+ ftnlen)1, (ftnlen)96);
+ errint_("#", body, (ftnlen)1);
+ }
+ sigerr_("SPICE(FRAMEDATANOTFOUND)", (ftnlen)24);
+ chkout_("BODMAT", (ftnlen)6);
+ return 0;
+ }
+
+/* Find the body code used to label the reference frame and epoch */
+/* specifiers for the orientation constants for BODY. */
+
+/* For planetary systems, the reference frame and epoch for the */
+/* orientation constants is associated with the system */
+/* barycenter, not with individual bodies in the system. For any */
+/* other bodies, (the Sun or asteroids, for example) the body's */
+/* own code is used as the label. */
+
+ refid = zzbodbry_(body);
+
+/* Look up the epoch of the constants. The epoch is specified */
+/* as a Julian ephemeris date. The epoch defaults to J2000. */
+
+ s_copy(item, "BODY#_CONSTANTS_JED_EPOCH", (ftnlen)32, (ftnlen)25);
+ repmi_(item, "#", &refid, item, (ftnlen)32, (ftnlen)1, (ftnlen)32);
+ gdpool_(item, &c__1, &c__1, &dim, &conepc, &found, (ftnlen)32);
+ if (found) {
+
+/* The reference epoch is returned as a JED. Convert to */
+/* ephemeris seconds past J2000. Then convert the input ET to */
+/* seconds past the reference epoch. */
+
+ conepc = spd_() * (conepc - j2000_());
+ epoch = *et - conepc;
+ } else {
+ epoch = *et;
+ }
+
+/* Look up the reference frame of the constants. The reference */
+/* frame is specified by a code recognized by CHGIRF. The */
+/* default frame is J2000, symbolized by the code J2CODE. */
+
+ s_copy(item, "BODY#_CONSTANTS_REF_FRAME", (ftnlen)32, (ftnlen)25);
+ repmi_(item, "#", &refid, item, (ftnlen)32, (ftnlen)1, (ftnlen)32);
+ gdpool_(item, &c__1, &c__1, &dim, &conref, &found, (ftnlen)32);
+ if (found) {
+ ref = i_dnnt(&conref);
+ } else {
+ ref = j2code;
+ }
+
+/* Whatever the body, it has quadratic time polynomials for */
+/* the RA and Dec of the pole, and for the rotation of the */
+/* Prime Meridian. */
+
+ s_copy(item, "POLE_RA", (ftnlen)32, (ftnlen)7);
+ cleard_(&c__3, rcoef);
+ bodvcd_(body, item, &c__3, &na, rcoef, (ftnlen)32);
+ s_copy(item, "POLE_DEC", (ftnlen)32, (ftnlen)8);
+ cleard_(&c__3, dcoef);
+ bodvcd_(body, item, &c__3, &nd, dcoef, (ftnlen)32);
+ s_copy(item, "PM", (ftnlen)32, (ftnlen)2);
+ cleard_(&c__3, wcoef);
+ bodvcd_(body, item, &c__3, &nw, wcoef, (ftnlen)32);
+
+/* There may be additional nutation and libration (THETA) terms. */
+
+ ntheta = 0;
+ na = 0;
+ nd = 0;
+ nw = 0;
+ s_copy(item, "NUT_PREC_ANGLES", (ftnlen)32, (ftnlen)15);
+ if (bodfnd_(&refid, item, (ftnlen)32)) {
+ bodvcd_(&refid, item, &c__100, &ntheta, tcoef, (ftnlen)32);
+ ntheta /= 2;
+ }
+ s_copy(item, "NUT_PREC_RA", (ftnlen)32, (ftnlen)11);
+ if (bodfnd_(body, item, (ftnlen)32)) {
+ bodvcd_(body, item, &c__100, &na, ac, (ftnlen)32);
+ }
+ s_copy(item, "NUT_PREC_DEC", (ftnlen)32, (ftnlen)12);
+ if (bodfnd_(body, item, (ftnlen)32)) {
+ bodvcd_(body, item, &c__100, &nd, dc, (ftnlen)32);
+ }
+ s_copy(item, "NUT_PREC_PM", (ftnlen)32, (ftnlen)11);
+ if (bodfnd_(body, item, (ftnlen)32)) {
+ bodvcd_(body, item, &c__100, &nw, wc, (ftnlen)32);
+ }
+/* Computing MAX */
+ i__1 = max(na,nd);
+ if (max(i__1,nw) > ntheta) {
+ setmsg_("Insufficient number of nutation/precession angles for b"
+ "ody * at time #.", (ftnlen)71);
+ errint_("*", body, (ftnlen)1);
+ errdp_("#", et, (ftnlen)1);
+ sigerr_("SPICE(KERNELVARNOTFOUND)", (ftnlen)24);
+ chkout_("BODMAT", (ftnlen)6);
+ return 0;
+ }
+
+/* Evaluate the time polynomials at EPOCH. */
+
+ d__ = epoch / spd_();
+ t = d__ / 36525.;
+ ra = rcoef[0] + t * (rcoef[1] + t * rcoef[2]);
+ dec = dcoef[0] + t * (dcoef[1] + t * dcoef[2]);
+ w = wcoef[0] + d__ * (wcoef[1] + d__ * wcoef[2]);
+
+/* Add nutation and libration as appropriate. */
+
+ i__1 = ntheta;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ theta = (tcoef[(i__2 = (i__ << 1) - 2) < 200 && 0 <= i__2 ? i__2 :
+ s_rnge("tcoef", i__2, "bodmat_", (ftnlen)700)] + t *
+ tcoef[(i__3 = (i__ << 1) - 1) < 200 && 0 <= i__3 ? i__3 :
+ s_rnge("tcoef", i__3, "bodmat_", (ftnlen)700)]) * rpd_();
+ sinth[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("sinth",
+ i__2, "bodmat_", (ftnlen)702)] = sin(theta);
+ costh[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("costh",
+ i__2, "bodmat_", (ftnlen)703)] = cos(theta);
+ }
+ ra += vdotg_(ac, sinth, &na);
+ dec += vdotg_(dc, costh, &nd);
+ w += vdotg_(wc, sinth, &nw);
+
+/* Convert from degrees to radians and mod by two pi. */
+
+ ra *= rpd_();
+ dec *= rpd_();
+ w *= rpd_();
+ d__1 = twopi_();
+ ra = d_mod(&ra, &d__1);
+ d__1 = twopi_();
+ dec = d_mod(&dec, &d__1);
+ d__1 = twopi_();
+ w = d_mod(&w, &d__1);
+
+/* Convert to Euler angles. */
+
+ phi = ra + halfpi_();
+ delta = halfpi_() - dec;
+
+/* Produce the rotation matrix defined by the Euler angles. */
+
+ eul2m_(&w, &delta, &phi, &c__3, &c__1, &c__3, tipm);
+ }
+
+/* Convert TIPM to the J2000-to-bodyfixed rotation, if is is not */
+/* already referenced to J2000. */
+
+ if (ref != j2code) {
+
+/* Find the transformation from the J2000 frame to the frame */
+/* designated by REF. Form the transformation from `REF' */
+/* coordinates to body-fixed coordinates. Compose the */
+/* transformations to obtain the J2000-to-body-fixed */
+/* transformation. */
+
+ irfrot_(&j2code, &ref, j2ref);
+ mxm_(tipm, j2ref, tmpmat);
+ moved_(tmpmat, &c__9, tipm);
+ }
+
+/* TIPM now gives the transformation from J2000 to */
+/* body-fixed coordinates at epoch ET seconds past J2000, */
+/* regardless of the epoch and frame of the orientation constants */
+/* for the specified body. */
+
+ chkout_("BODMAT", (ftnlen)6);
+ return 0;
+} /* bodmat_ */
+
diff --git a/ext/spice/src/cspice/bodn2c.c b/ext/spice/src/cspice/bodn2c.c
new file mode 100644
index 0000000000..feddd7b949
--- /dev/null
+++ b/ext/spice/src/cspice/bodn2c.c
@@ -0,0 +1,286 @@
+/* bodn2c.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BODN2C ( Body name to ID code translation ) */
+/* Subroutine */ int bodn2c_(char *name__, integer *code, logical *found,
+ ftnlen name_len)
+{
+ extern /* Subroutine */ int zzbodn2c_(char *, integer *, logical *,
+ ftnlen), chkin_(char *, ftnlen), chkout_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Translate the name of a body or object to the corresponding SPICE */
+/* integer ID code. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* NAIF_IDS */
+
+/* $ Keywords */
+
+/* BODY */
+/* CONVERSION */
+/* ID */
+/* NAME */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* NAME I Body name to be translated into a SPICE ID code. */
+/* CODE O SPICE integer ID code for the named body. */
+/* FOUND O True if translated, otherwise false. */
+/* MAXL P Maximum length of NAME string. */
+
+/* $ Detailed_Input */
+
+/* NAME is the name of a body or object, such as a planet, */
+/* satellite, comet, asteroid, barycenter, DSN station, */
+/* spacecraft, or instrument, that is "known" to the */
+/* SPICE system, whether through hard-coded */
+/* registration or run-time registration in the SPICE */
+/* kernel pool. */
+
+/* Case and leading and trailing blanks in a name */
+/* are not significant. However when a name is made */
+/* up of more than one word, they must be separated by */
+/* at least one blank. That is, all of the following */
+/* strings are equivalent names: */
+
+/* 'JUPITER BARYCENTER' */
+/* 'Jupiter Barycenter' */
+/* 'JUPITER BARYCENTER ' */
+/* 'JUPITER BARYCENTER' */
+/* ' JUPITER BARYCENTER' */
+
+/* However, 'JUPITERBARYCENTER' is not equivalent to */
+/* the names above. */
+
+/* $ Detailed_Output */
+
+/* CODE is the SPICE or user-defined integer ID code for the */
+/* named body. */
+
+/* FOUND is true if NAME has a translation. Otherwise, FOUND */
+/* is false. */
+
+/* $ Parameters */
+
+/* MAXL is the maximum allowable length of a body name. */
+/* The value of this parameter may be found in the */
+/* include file 'zzbodtrn.inc'. */
+
+/* $ Exceptions */
+
+/* None. */
+
+/* $ Files */
+
+/* Body-name mappings may be defined at run time by loading text */
+/* kernels containing kernel variable assignments of the form */
+
+/* NAIF_BODY_NAME += ( , ... ) */
+/* NAIF_BODY_CODE += ( , ... ) */
+
+/* See NAIF_IDs for details. */
+
+/* $ Particulars */
+
+/* BODN2C is one of five related subroutines, */
+
+/* BODS2C Body string to code */
+/* BODC2S Body code to string */
+/* BODN2C Body name to code */
+/* BODC2N Body code to name */
+/* BODDEF Body name/code definition */
+
+/* BODS2C, BODC2S, BODN2C, and BODC2N perform translations between */
+/* body names and their corresponding integer ID codes which are */
+/* used in SPICE files and routines. */
+
+/* BODS2C is a slightly more general version of BODN2C: support */
+/* for strings containing ID codes in string format enables a caller */
+/* to identify a body using a string, even when no name is */
+/* associated with that body. */
+
+/* BODC2S is a general version of BODC2N; the routine returns either */
+/* the name assigned in the body ID to name mapping or a string */
+/* representation of the CODE value if no mapping exists. */
+
+/* BODDEF assigns a body name to ID mapping. The mapping has */
+/* priority in name-to-ID and ID-to-name translations. */
+
+/* Programmers writing user interface code should consider using the */
+/* SPICELIB routine BODS2C. BODS2C provides more flexibility in */
+/* handling input strings, since it accepts both body names and */
+/* strings representing integer ID codes, for example '399'. */
+
+/* Refer to NAIF_IDs for the list of name/code associations built */
+/* into SPICE, and for details concerning adding new name/code */
+/* associations at run time by loading text kernels. */
+
+/* $ Examples */
+
+/* 1. In the following code fragment, BODVCD returns the radii */
+/* of Jupiter. BODVCD requires the SPICE integer ID code for */
+/* Jupiter, so we use BODN2C to convert the name to */
+/* its corresponding integer ID code. */
+
+/* CALL BODN2C ( 'JUPITER', JUPID, FOUND ) */
+
+/* CALL BODVCD ( JUPID, 'RADII', 3, N, RADII ) */
+
+
+/* 2. In this example, we assume that only the set of default */
+/* name/code pairs has been defined. */
+
+/* Given these names, BODN2C will return the following codes: */
+
+/* Name Code Found? */
+/* ------------------------ ------ ------ */
+/* 'EARTH' 399 Yes */
+/* ' Earth ' 399 Yes */
+/* 'EMB' 3 Yes */
+/* 'Solar System Barycenter' 0 Yes */
+/* 'SolarSystemBarycenter' - No */
+/* 'SSB' 0 Yes */
+/* 'Voyager 2' -32 Yes */
+/* 'U.S.S. Enterprise' - No */
+/* ' ' - No */
+/* 'Halley's Comet' - No */
+
+
+/* Given these codes, BODC2N will return the following names: */
+
+/* Code Name Found? */
+/* ------- ------------------- ------ */
+/* 399 'EARTH' Yes */
+/* 0 'SOLAR SYSTEM BARYCENTER' Yes */
+/* 3 'EARTH BARYCENTER' Yes */
+/* -77 'GALILEO ORBITER' Yes */
+/* 11 - No */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* C.H. Acton (JPL) */
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* B.V. Semenov (JPL) */
+/* F.S. Turner (JPL) */
+/* E.D. Wright (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.8, 16-MAY-2009 (EDW) */
+
+/* Edit to Particulars section to document the BODC2S routine. */
+
+/* - SPICELIB Version 1.0.7, 28-FEB-2008 (BVS) */
+
+/* Corrected the contents of the Required_Reading section. */
+
+/* - SPICELIB Version 1.0.6, 31-JAN-2008 (NJB) */
+
+/* References to the routine BODS2C were added to the header. */
+
+/* - SPICELIB Version 1.0.5, 24-OCT-2005 (NJB) */
+
+/* Header update: changed references to BODVAR to references */
+/* to BODVCD. */
+
+/* - SPICELIB Version 1.0.4, 20-JUL-2004 (EDW) */
+
+/* Removed unneeded assignment of FOUND = .FALSE. */
+
+/* - SPICELIB Version 1.0.3, 29-JUL-2003 (NJB) (CHA) */
+
+/* Various header changes were made to improve clarity. Some */
+/* minor header corrections were made. */
+
+/* - SPICELIB Version 1.0.2, 26-AUG-2002 (FST) */
+
+/* Added discussion of MAXL to the parameters section. */
+
+/* - SPICELIB Version 1.0.1, 22-AUG-2001 (EDW) */
+
+/* Corrected ENDIF to END IF. */
+
+/* - SPICELIB Version 1.0.0, 23-JAN-1996 (KRG) */
+
+/* This was the BODN2C entry point from the original BODTRN */
+/* subroutine that was in the NAIF toolkit SUPPORT library. */
+/* When the private subroutine ZZBODTRN was added to SPICELIB, */
+/* superceding the BODTRN from SUPPORT, the body ID code/name */
+/* translation interface from the original BODTRN was moved to */
+/* SPICELIB so that ID codes did not have to be hard coded by */
+/* users of the Toolkit. */
+
+/* This subroutine simply calls the private subroutine ZZBODN2C */
+/* to perform its job. */
+
+/* -& */
+/* $ Index_Entries */
+
+/* body name to code */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Standard SPICELIB error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("BODN2C", (ftnlen)6);
+ }
+ zzbodn2c_(name__, code, found, name_len);
+
+/* No need for any error checking, since all we do is check out */
+/* and return anyway. We leave the error checking to the caller. */
+
+ chkout_("BODN2C", (ftnlen)6);
+ return 0;
+} /* bodn2c_ */
+
diff --git a/ext/spice/src/cspice/bodn2c_c.c b/ext/spice/src/cspice/bodn2c_c.c
new file mode 100644
index 0000000000..97b98de4f2
--- /dev/null
+++ b/ext/spice/src/cspice/bodn2c_c.c
@@ -0,0 +1,317 @@
+/*
+
+-Procedure bodn2c_c ( Body name to ID code translation )
+
+-Abstract
+
+ Translate the name of a body or object to the corresponding SPICE
+ integer ID code.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ NAIF_IDS
+
+-Keywords
+
+ BODY
+ CONVERSION
+ ID
+ NAME
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ void bodn2c_c ( ConstSpiceChar * name,
+ SpiceInt * code,
+ SpiceBoolean * found )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ name I Body name to be translated into a SPICE ID code.
+ code O SPICE integer ID code for the named body.
+ found O SPICETRUE if translated, otherwise SPICEFALSE.
+
+-Detailed_Input
+
+ name is the name of a body or object, such as a planet,
+ satellite, comet, asteroid, barycenter, DSN station,
+ spacecraft, or instrument, that is "known" to the SPICE
+ system, whether through hard-coded registration or
+ run-time registration in the SPICE kernel pool.
+
+ Case and leading and trailing blanks in `name'
+ are not significant. However when a name is made
+ up of more than one word, they must be separated by
+ at least one blank. That is, all of the following
+ strings are equivalent names:
+
+ "JUPITER BARYCENTER"
+ "Jupiter Barycenter"
+ "JUPITER BARYCENTER "
+ "JUPITER BARYCENTER"
+ " JUPITER BARYCENTER"
+
+ However, "JUPITERBARYCENTER" is not equivalent to
+ the names above.
+
+-Detailed_Output
+
+ code is the SPICE or user-defined integer ID code for the
+ named body.
+
+ found is SPICETRUE if `name' has a translation. Otherwise,
+ `found' is SPICEFALSE.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) The error SPICE(EMPTYSTRING) is signaled if the input string
+ `name' does not contain at least one character, since the input
+ string cannot be converted to a Fortran-style string in this
+ case.
+
+ 2) The error SPICE(NULLPOINTER) is signaled if the input string
+ pointer `name' is null.
+
+-Files
+
+ Body-name mappings may be defined at run time by loading text
+ kernels containing kernel variable assignments of the form
+
+ NAIF_BODY_NAME += ( , ... )
+ NAIF_BODY_CODE += ( , ... )
+
+ See NAIF_IDs for details.
+
+-Particulars
+
+ bodn2c_c is one of five related subroutines,
+
+ bods2c_c Body string to code
+ bodc2s_c Body code to string
+ bodn2c_c Body name to code
+ bodc2n_c Body code to name
+ boddef_c Body name/code definition
+
+ bods2c_c, bodc2s_c, bodn2c_c, and bodc2n_c perform translations between
+ body names and their corresponding integer ID codes which are
+ used in SPICE files and routines.
+
+ bods2c_c is a slightly more general version of bodn2c_c: support
+ for strings containing ID codes in string format enables a caller
+ to identify a body using a string, even when no name is
+ associated with that body.
+
+ bodc2s_c is a general version of bodc2n_c; the routine returns either
+ the name assigned in the body ID to name mapping or a string
+ representation of the CODE value if no mapping exists.
+
+ boddef_c assigns a body name to ID mapping. The mapping has priority
+ in name-to-ID and ID-to-name translations.
+
+ Programmers writing user interface code should consider using the
+ CSPICE routine bods2c_c. bods2c_c provides more flexibility in
+ handling input strings, since it accepts both body names and
+ strings representing integer ID codes, for example "399".
+
+ Refer to NAIF_IDs for the list of name/code associations built into
+ SPICE, and for details concerning adding new name/code
+ associations at run time by loading text kernels.
+
+-Examples
+
+ 1) In the following code fragment, bodvcd_c returns the radii
+ of Jupiter. bodvcd_c requires the SPICE integer ID code
+ for Jupiter, so we use bodn2c_c to convert the name to its
+ corresponding integer ID code.
+
+
+ bodn2c_c ( "JUPITER", &jupid, &found );
+
+ bodvcd_c ( jupid, "RADII", 3, &n, radii );
+
+
+ 2) In this example, we assume that only the set of default
+ name/code pairs has been defined.
+
+ Given these names, bodn2c_c will return the following codes:
+
+ Name Code Found?
+ ------------------------ ------ ------
+ "EARTH" 399 Yes
+ " Earth " 399 Yes
+ "EMB" 3 Yes
+ "Solar System Barycenter" 0 Yes
+ "SolarSystemBarycenter" - No
+ "SSB" 0 Yes
+ "Voyager 2" -32 Yes
+ "U.S.S. Enterprise" - No
+ " " - No
+ "Halley's Comet" - No
+
+
+ Given these codes, bodc2n_c will return the following names:
+
+ Code Name Found?
+ ------- ------------------- ------
+ 399 "EARTH" Yes
+ 0 "SOLAR SYSTEM BARYCENTER" Yes
+ 3 "EARTH BARYCENTER" Yes
+ -77 "GALILEO ORBITER" Yes
+ 11 - No
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ C.H. Acton (JPL)
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ B.V. Semenov (JPL)
+
+-Version
+
+ -CSPICE Version 2.1.6, 16-MAY-2009 (EDW)
+
+ Edit to Particulars section to document the bodc2s_c routine.
+
+ -CSPICE Version 2.1.5, 27-FEB-2008 (BVS)
+
+ Corrected the contents of the Required_Reading section of
+ the header.
+
+ -CSPICE Version 2.1.4, 31-JAN-2008 (NJB)
+
+ References to the routine bods2c_c were added to the header.
+
+ -CSPICE Version 2.1.3, 27-OCT-2005 (NJB)
+
+ Header update: replaced references to bodvar_c with
+ references to bodvcd_c.
+
+ -CSPICE Version 2.1.2, 23-JUL-2004 (NJB)
+
+ Header correction: Exceptions section was updated to document
+ input string error handling.
+
+ -CSPICE Version 2.1.1, 28-JUL-2003 (NJB)
+
+ Various header changes were made to improve clarity. Some
+ minor header corrections were made.
+
+ -CSPICE Version 2.1.0, 02-SEP-1999 (NJB)
+
+ Local type logical variable now used for found flag used in
+ interface of bodn2c_.
+
+ -CSPICE Version 2.0.2, 25-MAR-1998 (EDW)
+
+ Minor corrections to header.
+
+ -CSPICE Version 2.0.1, 08-FEB-1998 (EDW)
+
+ Corrected and clarified header entries.
+
+ -CSPICE Version 2.0.0, 06-JAN-1998 (NJB)
+
+ The type of the input argument name was changed to
+ ConstSpiceChar *.
+
+ References to C2F_CreateStr_Sig were removed; code was
+ cleaned up accordingly. String checks are now done using
+ the macro CHKFSTR.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB)
+
+ Based on SPICELIB Version 1.0.0, 23-JAN-1996 (KRG)
+
+-Index_Entries
+
+ body name to code
+
+-&
+*/
+
+{ /* Begin bodn2c_c */
+
+ /*
+ Local variables
+ */
+ logical fnd;
+
+
+ /*
+ Participate in error handling
+ */
+ chkin_c ( "bodn2c_c");
+
+
+ /*
+ Check the input string name to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "bodn2c_c", name );
+
+
+ /*
+ Translate the name to the corresponding code.
+ */
+ bodn2c_( ( char * ) name,
+ ( integer * ) code,
+ ( logical * ) &fnd,
+ ( ftnlen ) strlen(name) );
+
+
+ /*
+ Assign the SpiceBoolean found flag.
+ */
+
+ *found = fnd;
+
+
+
+ chkout_c ( "bodn2c_c");
+
+} /* End bodn2c_c */
diff --git a/ext/spice/src/cspice/bods2c.c b/ext/spice/src/cspice/bods2c.c
new file mode 100644
index 0000000000..f92e91a0e7
--- /dev/null
+++ b/ext/spice/src/cspice/bods2c.c
@@ -0,0 +1,311 @@
+/* bods2c.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BODS2C ( Body string to ID code translation ) */
+/* Subroutine */ int bods2c_(char *name__, integer *code, logical *found,
+ ftnlen name_len)
+{
+ extern /* Subroutine */ int zzbodn2c_(char *, integer *, logical *,
+ ftnlen), chkin_(char *, ftnlen);
+ extern logical beint_(char *, ftnlen);
+ extern /* Subroutine */ int nparsi_(char *, integer *, char *, integer *,
+ ftnlen, ftnlen), chkout_(char *, ftnlen);
+ char errmsg[1];
+ extern logical return_(void);
+ integer ptr;
+
+/* $ Abstract */
+
+/* Translate a string containing a body name or ID code to an */
+/* integer code. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* NAIF_IDS */
+
+/* $ Keywords */
+
+/* BODY */
+/* CONVERSION */
+/* ID */
+/* NAME */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* NAME I String to be translated to an ID code. */
+/* CODE O Integer ID code corresponding to NAME. */
+/* FOUND O Flag indicating whether translation succeeded. */
+
+/* $ Detailed_Input */
+
+/* NAME is a string containing the name or ID code of a */
+/* body or object, such as a planet, satellite, comet, */
+/* asteroid, barycenter, DSN station, spacecraft, or */
+/* instrument. */
+
+/* If NAME contains the name of a body or object, that */
+/* name must be "known" to the SPICE system, whether */
+/* through hard-coded registration or run-time */
+/* registration in the SPICE kernel pool. */
+
+/* Case and leading and trailing blanks in a name are */
+/* not significant. However when a name is made up of */
+/* more than one word, adjacent words must be separated */
+/* by at least one blank. That is, all of the following */
+/* strings are equivalent names: */
+
+/* 'JUPITER BARYCENTER' */
+/* 'Jupiter Barycenter' */
+/* 'JUPITER BARYCENTER ' */
+/* 'JUPITER BARYCENTER' */
+/* ' JUPITER BARYCENTER' */
+
+/* However, 'JUPITERBARYCENTER' is not equivalent to */
+/* the names above. */
+
+/* If NAME is a string representation of an integer, */
+/* for example */
+
+/* '399' */
+
+/* the string will be translated to the equivalent */
+/* INTEGER datum. The input integer need not be one */
+/* recognized by the SPICE system: the integer need not */
+/* be a built-in NAIF ID code, nor need it be associated */
+/* with a name via run-time registration. */
+
+/* $ Detailed_Output */
+
+/* CODE is, if NAME contains the name of a body or object, */
+/* the corresponding NAIF or user-defined integer ID */
+/* code, as determined by the SPICE name-code mapping */
+/* subsystem. If NAME represents an integer, the same */
+/* integer is returned in CODE. */
+
+/* CODE is assigned a value only if FOUND is returned */
+/* as .TRUE.; otherwise it is returned unchanged. */
+
+
+/* FOUND is .TRUE. if NAME has a translation or represents an */
+/* integer. Otherwise, FOUND is .FALSE. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* None. */
+
+/* $ Files */
+
+/* Body-name mappings may be defined at run time by loading text */
+/* kernels containing kernel variable assignments of the form */
+
+/* NAIF_BODY_NAME += ( , ... ) */
+/* NAIF_BODY_CODE += ( , ... ) */
+
+/* See NAIF_IDs for details. */
+
+/* $ Particulars */
+
+/* BODS2C is one of five related subroutines, */
+
+/* BODS2C Body string to code */
+/* BODC2S Body code to string */
+/* BODN2C Body name to code */
+/* BODC2N Body code to name */
+/* BODDEF Body name/code definition */
+
+/* BODS2C, BODC2S, BODN2C, and BODC2N perform translations between */
+/* body names and their corresponding integer ID codes which are */
+/* used in SPICE files and routines. */
+
+/* BODS2C is a slightly more general version of BODN2C: support */
+/* for strings containing ID codes in string format enables a caller */
+/* to identify a body using a string, even when no name is */
+/* associated with that body. */
+
+/* BODC2S is a general version of BODC2N; the routine returns either */
+/* the name assigned in the body ID to name mapping or a string */
+/* representation of the CODE value if no mapping exists. */
+
+/* BODDEF assigns a body name to ID mapping. The mapping has */
+/* priority in name-to-ID and ID-to-name translations. */
+
+/* Refer to NAIF_IDs for the list of name/code associations built */
+/* into SPICE, and for details concerning adding new name/code */
+/* associations at run time by loading text kernels. */
+
+/* $ Examples */
+
+/* 1. In the following code fragment, BODEUL returns the Euler */
+/* angles representing the orientation of Jupiter relative to */
+/* the J2000 reference frame. BODEUL requires the NAIF integer */
+/* ID code for Jupiter, so we use BODS2C to convert the name to */
+/* its corresponding integer ID code. */
+
+/* We know Jupiter has a built-in name-code mapping, so we */
+/* needn't check the FOUND flag. */
+
+/* CALL BODS2C ( 'JUPITER', JUPID, FOUND ) */
+
+/* CALL BODEUL ( JUPID, ET, RA, DEC, W, LAMBDA ) */
+
+
+/* 2. In this example, we assume that only the set of default */
+/* name/code pairs has been defined. */
+
+/* Given these names, BODS2C will return the following codes: */
+
+/* Name Code Found? */
+/* ------------------------ ------ ------ */
+/* 'EARTH' 399 Yes */
+/* ' Earth ' 399 Yes */
+/* '399' 399 Yes */
+/* ' 399 ' 399 Yes */
+/* 'EMB' 3 Yes */
+/* '3' 3 Yes */
+/* '1000000000' 1000000000 Yes */
+/* 'Solar System Barycenter' 0 Yes */
+/* 'SolarSystemBarycenter' - No */
+/* 'SSB' 0 Yes */
+/* 'Voyager 2' -32 Yes */
+/* 'U.S.S. Enterprise' - No */
+/* ' ' - No */
+/* 'Halley's Comet' - No */
+
+/* Given these codes, BODC2N will return the following names: */
+
+/* Code Name Found? */
+/* ------- ------------------- ------ */
+/* 399 'EARTH' Yes */
+/* 0 'SOLAR SYSTEM BARYCENTER' Yes */
+/* 3 'EARTH BARYCENTER' Yes */
+/* -77 'GALILEO ORBITER' Yes */
+/* 11 - No */
+/* 1000000000 - No */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* C.H. Acton (JPL) */
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* B.V. Semenov (JPL) */
+/* F.S. Turner (JPL) */
+/* E.D. Wright (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 16-MAY-2009 (EDW) */
+
+/* Edit to Particulars section to document the BODC2S routine. */
+
+/* - SPICELIB Version 1.0.1, 28-FEB-2008 (BVS) */
+
+/* Corrected the contents of the Required_Reading section. */
+
+/* - SPICELIB Version 1.0.0, 23-JUL-2003 (CHA) (NJB) (KRG) (FST) (EDW) */
+
+/* Based on SPICELIB Version 1.0.3, 29-JUL-2003 */
+/* (CHA) (NJB) (KEG) (FST) (EDW) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* body string to code */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICELIB error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("BODS2C", (ftnlen)6);
+
+/* Attempt to translate the input name to an integer code. Call */
+/* the private routine ZZBODN2C to avoid additional CHKIN and */
+/* CHKOUT calls. */
+
+ zzbodn2c_(name__, code, found, name_len);
+ if (! (*found)) {
+
+/* It's possible the name is a string representation */
+/* of an integer, for example, '999'. If so, find */
+/* the equivalent datum of INTEGER type. */
+
+ if (beint_(name__, name_len)) {
+
+/* The input conforms to the syntax of an integer, but it may */
+/* be outside of the range of the INTEGER data type. */
+/* Therefore we use the non-error-signaling routine NPARSI */
+/* rather than the cleaner PRSINT to attempt to convert the */
+/* string to an INTEGER. */
+
+ nparsi_(name__, code, errmsg, &ptr, name_len, (ftnlen)1);
+
+/* We have an ID code if and only if PTR is zero. */
+
+ *found = ptr == 0;
+ }
+ }
+
+/* FOUND is set. CODE is set if NAME was a recognized name */
+/* or a string representation of an integer. */
+
+ chkout_("BODS2C", (ftnlen)6);
+ return 0;
+} /* bods2c_ */
+
diff --git a/ext/spice/src/cspice/bods2c_c.c b/ext/spice/src/cspice/bods2c_c.c
new file mode 100644
index 0000000000..a49ee7eac2
--- /dev/null
+++ b/ext/spice/src/cspice/bods2c_c.c
@@ -0,0 +1,296 @@
+/*
+
+-Procedure bods2c_c ( Body string to ID code translation )
+
+-Abstract
+
+ Translate a string containing a body name or ID code to an integer
+ code.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ NAIF_IDS
+
+-Keywords
+
+ BODY
+ CONVERSION
+ ID
+ NAME
+ UTILITY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+ void bods2c_c ( ConstSpiceChar * name,
+ SpiceInt * code,
+ SpiceBoolean * found )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ name I String to be translated to an ID code.
+ code O Integer ID code corresponding to `name'.
+ found O Flag indicating whether translation succeeded.
+
+-Detailed_Input
+
+ name is a string containing the name or ID code of a body or
+ object, such as a planet, satellite, comet, asteroid,
+ barycenter, DSN station, spacecraft, or instrument.
+
+ If `name' contains the name of a body or object, that
+ name must be "known" to the SPICE system, whether
+ through hard-coded registration or run-time registration
+ in the SPICE kernel pool.
+
+ Case and leading and trailing blanks in `name'
+ are not significant. However when a name is made
+ up of more than one word, they must be separated by
+ at least one blank. That is, all of the following
+ strings are equivalent names:
+
+ "JUPITER BARYCENTER"
+ "Jupiter Barycenter"
+ "JUPITER BARYCENTER "
+ "JUPITER BARYCENTER"
+ " JUPITER BARYCENTER"
+
+ However, "JUPITERBARYCENTER" is not equivalent to
+ the names above.
+
+ If NAME is a string representation of an integer,
+ for example
+
+ "399"
+
+ the string will be translated to the equivalent SpiceInt
+ datum. The input integer need not be one recognized by
+ the SPICE system: the integer need not be a built-in
+ NAIF ID code, nor need it be associated with a name via
+ run-time registration.
+
+-Detailed_Output
+
+ code is, if `name' contains the name of a body or object,
+ the corresponding NAIF or user-defined integer ID code,
+ as determined by the SPICE name-code mapping subsystem.
+ If the input argument `name' represents an integer, the
+ same integer is returned in `code'.
+
+ `code' is assigned a value only if `found' is returned
+ as SPICETRUE; otherwise it is returned unchanged.
+
+
+ found is SPICETRUE if `name' has a translation. Otherwise,
+ `found' is SPICEFALSE.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) The error SPICE(EMPTYSTRING) is signaled if the input string
+ `name' does not contain at least one character, since the input
+ string cannot be converted to a Fortran-style string in this
+ case.
+
+ 2) The error SPICE(NULLPOINTER) is signaled if the input string
+ pointer `name' is null.
+
+-Files
+
+ Body-name mappings may be defined at run time by loading text
+ kernels containing kernel variable assignments of the form
+
+ NAIF_BODY_NAME += ( , ... )
+ NAIF_BODY_CODE += ( , ... )
+
+ See NAIF_IDs for details.
+
+-Particulars
+
+ bods2c_c is one of five related subroutines,
+
+ bods2c_c Body string to code
+ bodc2s_c Body code to string
+ bodn2c_c Body name to code
+ bodc2n_c Body code to name
+ boddef_c Body name/code definition
+
+ bods2c_c, bodc2s_c, bodn2c_c, and bodc2n_c perform translations between
+ body names and their corresponding integer ID codes which are
+ used in SPICE files and routines.
+
+ bods2c_c is a slightly more general version of bodn2c_c: support
+ for strings containing ID codes in string format enables a caller
+ to identify a body using a string, even when no name is
+ associated with that body.
+
+ bodc2s_c is a general version of bodc2n_c; the routine returns either
+ the name assigned in the body ID to name mapping or a string
+ representation of the CODE value if no mapping exists.
+
+ boddef_c assigns a body name to ID mapping. The mapping has priority
+ in name-to-ID and ID-to-name translations.
+
+ Refer to NAIF_IDs for the list of name/code associations built into
+ SPICE, and for details concerning adding new name/code
+ associations at run time by loading text kernels.
+
+-Examples
+
+ 1. In the following code fragment, bodeul_ returns the Euler
+ angles representing the orientation of Jupiter relative to
+ the J2000 reference frame. bodeul_ requires the NAIF integer
+ ID code for Jupiter, so we use bods2c_c to convert the name to
+ its corresponding integer ID code.
+
+ bods2c_c ( "JUPITER", &jupid, &found );
+
+ bodeul_ ( &jupid, &et, &ra, &dec, &w, &lambda );
+
+ 2. In this example, we assume that only the set of default
+ name/code pairs has been defined.
+
+ Given these names, bods2c_c will return the following codes:
+
+ Name Code Found?
+ ------------------------ ---------- ------
+ "EARTH" 399 Yes
+ " Earth " 399 Yes
+ "399" 399 Yes
+ " 399 " 399 Yes
+ "EMB" 3 Yes
+ "3" 3 Yes
+ "1000000000" 1000000000 Yes
+ "Solar System Barycenter" 0 Yes
+ "SolarSystemBarycenter" - No
+ "SSB" 0 Yes
+ "Voyager 2" -32 Yes
+ "U.S.S. Enterprise" - No
+ " " - No
+ "Halley's Comet" - No
+
+
+ Given these codes, bodc2n_c will return the following names:
+
+ Code Name Found?
+ ---------- ------------------------ ------
+ 399 "EARTH" Yes
+ 0 "SOLAR SYSTEM BARYCENTER" Yes
+ 3 "EARTH BARYCENTER" Yes
+ -77 "GALILEO ORBITER" Yes
+ 11 - No
+ 1000000000 - No
+
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ C.H. Acton (JPL)
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ B.V. Semenov (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.2, 16-MAY-2009 (EDW)
+
+ Edit to Particulars section to document the bodc2s_c routine.
+
+ -CSPICE Version 1.0.1, 27-FEB-2008 (BVS)
+
+ Corrected the contents of the Required_Reading section of
+ the header.
+
+ -CSPICE Version 1.0.0, 23-JUL-2004 (CHA) (NJB) (KRG)
+
+-Index_Entries
+
+ body name to code
+
+-&
+*/
+
+{ /* Begin bods2c_c */
+
+ /*
+ Local variables
+ */
+ logical fnd;
+
+
+ /*
+ Participate in error handling
+ */
+ chkin_c ( "bods2c_c");
+
+
+ /*
+ Check the input string name to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "bods2c_c", name );
+
+
+ /*
+ Translate the name to the corresponding code.
+ */
+ bods2c_( ( char * ) name,
+ ( integer * ) code,
+ ( logical * ) &fnd,
+ ( ftnlen ) strlen(name) );
+
+
+ /*
+ Assign the SpiceBoolean found flag.
+ */
+
+ *found = fnd;
+
+
+
+ chkout_c ( "bods2c_c");
+
+} /* End bods2c_c */
diff --git a/ext/spice/src/cspice/bodvar.c b/ext/spice/src/cspice/bodvar.c
new file mode 100644
index 0000000000..a6e73e9db3
--- /dev/null
+++ b/ext/spice/src/cspice/bodvar.c
@@ -0,0 +1,216 @@
+/* bodvar.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__0 = 0;
+
+/* $Procedure BODVAR ( Return values from the kernel pool ) */
+/* Subroutine */ int bodvar_(integer *body, char *item, integer *dim,
+ doublereal *values, ftnlen item_len)
+{
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ char code[16];
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen);
+ logical found;
+ char varnam[32];
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), suffix_(char *, integer *, char
+ *, ftnlen, ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int rtpool_(char *, integer *, doublereal *,
+ logical *, ftnlen), intstr_(integer *, char *, ftnlen);
+
+/* $ Abstract */
+
+/* Deprecated: This routine has been superseded by BODVCD and */
+/* BODVRD. This routine is supported for purposes of backward */
+/* compatibility only. */
+
+/* Return the values of some item for any body in the */
+/* kernel pool. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* KERNEL */
+
+/* $ Keywords */
+
+/* CONSTANTS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* BODY I ID code of body. */
+/* ITEM I Item for which values are desired. ('RADII', */
+/* 'NUT_PREC_ANGLES', etc. ) */
+/* DIM O Number of values returned. */
+/* VALUES O Values. */
+
+/* $ Detailed_Input */
+
+/* BODY is the ID code of the body for which ITEM is */
+/* requested. Bodies are numbered according to the */
+/* standard NAIF numbering scheme. */
+
+/* ITEM is the item to be returned. Together, the body and */
+/* item name combine to form a variable name, e.g., */
+
+/* 'BODY599_RADII' */
+/* 'BODY401_POLE_RA' */
+
+/* $ Detailed_Output */
+
+/* DIM is the number of values associated with the variable. */
+
+/* VALUES are the values associated with the variable. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* The call */
+
+/* CALL BODVAR ( 399, 'RADII', DIM, VALUE ) */
+
+/* returns the dimension and values associated with the variable */
+/* 'BODY399_RADII', for example, */
+
+/* DIM = 3 */
+/* VALUE(1) = 6378.140 */
+/* VALUE(2) = 6378.140 */
+/* VALUE(3) = 6356.755 */
+
+/* $ Restrictions */
+
+/* 1) If the requested item is not found, the error */
+/* SPICE(KERNELVARNOTFOUND) is signalled. */
+
+/* $ Literature_References */
+
+/* 1) Refer to the SPK required reading file for a complete list of */
+/* the NAIF integer ID codes for bodies. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.5, 18-MAY-2010 (BVS) */
+
+/* Index lines now state that this routine is deprecated. */
+
+/* - SPICELIB Version 1.0.4, 27-OCT-2005 (NJB) */
+
+/* Routine is now deprecated. */
+
+/* - SPICELIB Version 1.0.3, 08-JAN-2004 (EDW) */
+
+/* Trivial typo corrected. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 8-AUG-1990 (HAN) */
+
+/* Detailed Input section of the header was updated. The */
+/* description for the variable BODY was incorrect. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* DEPRECATED fetch constants for a body from the kernel pool */
+/* DEPRECATED physical constants for a body */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("BODVAR", (ftnlen)6);
+ }
+
+/* Construct the variable name from BODY and ITEM. */
+
+ s_copy(varnam, "BODY", (ftnlen)32, (ftnlen)4);
+ intstr_(body, code, (ftnlen)16);
+ suffix_(code, &c__0, varnam, (ftnlen)16, (ftnlen)32);
+ suffix_("_", &c__0, varnam, (ftnlen)1, (ftnlen)32);
+ suffix_(item, &c__0, varnam, item_len, (ftnlen)32);
+
+/* Grab the items. Complain if they aren't there. */
+
+ rtpool_(varnam, dim, values, &found, (ftnlen)32);
+ if (! found) {
+ setmsg_("The variable # could not be found in the kernel pool.", (
+ ftnlen)53);
+ errch_("#", varnam, (ftnlen)1, (ftnlen)32);
+ sigerr_("SPICE(KERNELVARNOTFOUND)", (ftnlen)24);
+ }
+ chkout_("BODVAR", (ftnlen)6);
+ return 0;
+} /* bodvar_ */
+
diff --git a/ext/spice/src/cspice/bodvar_c.c b/ext/spice/src/cspice/bodvar_c.c
new file mode 100644
index 0000000000..7734840448
--- /dev/null
+++ b/ext/spice/src/cspice/bodvar_c.c
@@ -0,0 +1,209 @@
+/*
+
+-Procedure bodvar_c ( Return values from the kernel pool )
+
+-Abstract
+
+ Deprecated: This routine has been superseded by bodvcd_c and
+ bodvrd_c. This routine is supported for purposes of backward
+ compatibility only.
+
+ Return the values of some item for any body in the
+ kernel pool.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ KERNEL
+
+-Keywords
+
+ CONSTANTS
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+ void bodvar_c ( SpiceInt body,
+ ConstSpiceChar * item,
+ SpiceInt * dim,
+ SpiceDouble * values )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ body I ID code of body.
+ item I Item for which values are desired. ("RADII",
+ "NUT_PREC_ANGLES", etc. )
+ dim O Number of values returned.
+ values O Values.
+
+
+-Detailed_Input
+
+ body is the ID code of the body for which ITEM is
+ requested. Bodies are numbered according to the
+ standard NAIF numbering scheme.
+
+ item is the item to be returned. Together, the body and
+ item name combine to form a variable name, e.g.,
+
+ "BODY599_RADII"
+ "BODY401_POLE_RA"
+
+-Detailed_Output
+
+ dim is the number of values associated with the variable.
+
+ values are the values associated with the variable.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+-Files
+
+ None.
+
+-Particulars
+
+ None.
+
+-Examples
+
+ The call
+
+ SpiceInt body;
+ SpiceInt dim;
+ SpiceChar * item;
+ SpiceDouble value[10];
+
+ body = 399;
+ item = "RADII";
+
+ bodvar_c ( body, item, &dim, value );
+
+ returns the dimension and values associated with the variable
+ "BODY399_RADII", for example,
+
+ dim is 3
+ value[0] is 6378.140
+ value[1] is 6378.140
+ value[2] is 6356.755
+
+
+-Restrictions
+
+ 1) If the requested item is not found, the error
+ SPICE(KERNELVARNOTFOUND) is signalled.
+
+-Literature_References
+
+ 1) Refer to the SPK required reading file for a complete list of
+ the NAIF integer ID codes for bodies.
+
+-Author_and_Institution
+
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 2.0.4, 19-MAY-2010 (BVS)
+
+ Index lines now states that this routine is deprecated.
+
+ -CSPICE Version 2.0.3, 27-OCT-2005 (NJB)
+
+ Routine is now deprecated.
+
+ -CSPICE Version 2.0.2, 08-JAN-2004 (EDW)
+
+ Trivial typo corrected.
+
+ -CSPICE Version 2.0.1, 08-FEB-1998 (EDW)
+
+ Corrected and clarified header entries.
+
+ -CSPICE Version 2.0.0, 06-JAN-1998 (NJB)
+
+ Input argument item was changed to type ConstSpiceChar *.
+
+ References to C2F_CreateStr_Sig were removed; code was
+ cleaned up accordingly. String checks are now done using
+ the macro CHKFSTR.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (EDW)
+
+-Index_Entries
+
+ DEPRECATED fetch constants for a body from the kernel pool
+ DEPRECATED physical constants for a body
+
+-&
+*/
+
+
+{ /* Begin bodvar_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "bodvar_c" );
+
+
+ /*
+ Check the input string to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "bodfnd_c", item );
+
+
+ /*
+ Call the f2c'd routine.
+ */
+ bodvar_( ( integer * ) &body,
+ ( char * ) item,
+ ( integer * ) dim,
+ ( doublereal * ) values,
+ ( ftnlen ) strlen(item) );
+
+
+ chkout_c ( "bodvar_c" );
+
+} /* End bodvar_c*/
diff --git a/ext/spice/src/cspice/bodvcd.c b/ext/spice/src/cspice/bodvcd.c
new file mode 100644
index 0000000000..340388c766
--- /dev/null
+++ b/ext/spice/src/cspice/bodvcd.c
@@ -0,0 +1,314 @@
+/* bodvcd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__0 = 0;
+static integer c__1 = 1;
+
+/* $Procedure BODVCD ( Return d.p. values from the kernel pool ) */
+/* Subroutine */ int bodvcd_(integer *bodyid, char *item, integer *maxn,
+ integer *dim, doublereal *values, ftnlen item_len)
+{
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ char code[16], type__[1];
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen);
+ logical found;
+ char varnam[32];
+ extern /* Subroutine */ int gdpool_(char *, integer *, integer *, integer
+ *, doublereal *, logical *, ftnlen), sigerr_(char *, ftnlen),
+ chkout_(char *, ftnlen), dtpool_(char *, logical *, integer *,
+ char *, ftnlen, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen), suffix_(char *, integer *, char *, ftnlen,
+ ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int intstr_(integer *, char *, ftnlen);
+
+/* $ Abstract */
+
+/* Fetch from the kernel pool the double precision values */
+/* of an item associated with a body, where the body is */
+/* specified by an integer ID code. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* KERNEL */
+/* NAIF_IDS */
+
+/* $ Keywords */
+
+/* CONSTANTS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* BODYID I Body ID code. */
+/* ITEM I Item for which values are desired. ('RADII', */
+/* 'NUT_PREC_ANGLES', etc. ) */
+/* MAXN I Maximum number of values that may be returned. */
+/* DIM O Number of values returned. */
+/* VALUES O Values. */
+
+/* $ Detailed_Input */
+
+/* BODYID is the NAIF integer ID code for a body of interest. */
+/* For example, if the body is the earth, the code is */
+/* 399. */
+
+/* ITEM is the item to be returned. Together, the NAIF ID */
+/* code of the body and the item name combine to form a */
+/* kernel variable name, e.g., */
+
+/* 'BODY599_RADII' */
+/* 'BODY401_POLE_RA' */
+
+/* The values associated with the kernel variable having */
+/* the name constructed as shown are sought. Below */
+/* we'll take the shortcut of calling this kernel variable */
+/* the "requested kernel variable." */
+
+/* Note that ITEM *is* case-sensitive. This attribute */
+/* is inherited from the case-sensitivity of kernel */
+/* variable names. */
+
+/* MAXN is the maximum number of values that may be returned. */
+/* The output array VALUES must be declared with size at */
+/* least MAXN. It's an error to supply an output array */
+/* that is too small to hold all of the values associated */
+/* with the requested kernel variable. */
+
+/* $ Detailed_Output */
+
+/* DIM is the number of values returned; this is always the */
+/* number of values associated with the requested kernel */
+/* variable unless an error has been signaled. */
+
+/* VALUES is the array of values associated with the requested */
+/* kernel variable. If VALUES is too small to hold all */
+/* of the values associated with the kernel variable, the */
+/* returned values of DIM and VALUES are undefined. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the requested kernel variable is not found in the kernel */
+/* pool, the error SPICE(KERNELVARNOTFOUND) is signaled. */
+
+/* 2) If the requested kernel variable is found but the associated */
+/* values aren't numeric, the error SPICE(TYPEMISMATCH) is */
+/* signaled. */
+
+/* 3) The output array VALUES must be declared with sufficient size */
+/* to contain all of the values associated with the requested */
+/* kernel variable. If the dimension of */
+/* VALUES indicated by MAXN is too small to contain the */
+/* requested values, the error SPICE(ARRAYTOOSMALL) is signaled. */
+
+/* 4) If the input dimension MAXN indicates there is more room */
+/* in VALUES than there really is---for example, if MAXN is */
+/* 10 but values is declared with dimension 5---and the dimension */
+/* of the requested kernel variable is larger than the actual */
+/* dimension of VALUES, then this routine may overwrite */
+/* memory. The results are unpredictable. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine simplifies looking up PCK kernel variables by */
+/* constructing names of requested kernel variables and by */
+/* performing error checking. */
+
+/* This routine is intended for use in cases where the maximum */
+/* number of values that may be returned is known at compile */
+/* time. The caller fetches all of the values associated with */
+/* the specified kernel variable via a single call to this */
+/* routine. If the number of values to be fetched cannot be */
+/* known until run time, the lower-level routine GDPOOL (an */
+/* entry point of POOL) should be used instead. GDPOOL supports */
+/* fetching arbitrary amounts of data in multiple "chunks." */
+
+/* This routine is intended for use in cases where the requested */
+/* kernel variable is expected to be present in the kernel pool. If */
+/* the variable is not found or has the wrong data type, this */
+/* routine signals an error. In cases where it is appropriate to */
+/* indicate absence of an expected kernel variable by returning a */
+/* boolean "found flag" with the value .FALSE., again the routine */
+/* GDPOOL should be used. */
+
+/* $ Examples */
+
+/* 1) When the kernel variable */
+
+/* BODY399_RADII */
+
+/* is present in the kernel pool---normally because a PCK */
+/* defining this variable has been loaded---the call */
+
+/* CALL BODVCD ( 399, 'RADII', 3, DIM, VALUES ) */
+
+/* returns the dimension and values associated with the variable */
+/* 'BODY399_RADII', for example, */
+
+/* DIM = 3 */
+/* VALUES(1) = 6378.140 */
+/* VALUES(2) = 6378.140 */
+/* VALUES(3) = 6356.755 */
+
+/* 2) The call */
+
+/* CALL BODVCD ( 399, 'radii', 3, DIM, VALUES ) */
+
+/* usually will cause a SPICE(KERNELVARNOTFOUND) error to be */
+/* signaled, because this call will attempt to look up the */
+/* values associated with a kernel variable of the name */
+
+/* 'BODY399_radii' */
+
+/* Since kernel variable names are case sensitive, this */
+/* name is not considered to match the name */
+
+/* 'BODY399_RADII' */
+
+/* which normally would be present after a text PCK */
+/* containing data for all planets and satellites has */
+/* been loaded. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* B.V. Semenov (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 24-OCT-2004 (NJB) (BVS) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* fetch constants for a body from the kernel pool */
+/* physical constants for a body */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("BODVCD", (ftnlen)6);
+ }
+
+/* Construct the variable name from BODY and ITEM. */
+
+ s_copy(varnam, "BODY", (ftnlen)32, (ftnlen)4);
+ intstr_(bodyid, code, (ftnlen)16);
+ suffix_(code, &c__0, varnam, (ftnlen)16, (ftnlen)32);
+ suffix_("_", &c__0, varnam, (ftnlen)1, (ftnlen)32);
+ suffix_(item, &c__0, varnam, item_len, (ftnlen)32);
+
+/* Make sure the item is present in the kernel pool. */
+
+ dtpool_(varnam, &found, dim, type__, (ftnlen)32, (ftnlen)1);
+ if (! found) {
+ setmsg_("The variable # could not be found in the kernel pool.", (
+ ftnlen)53);
+ errch_("#", varnam, (ftnlen)1, (ftnlen)32);
+ sigerr_("SPICE(KERNELVARNOTFOUND)", (ftnlen)24);
+ chkout_("BODVCD", (ftnlen)6);
+ return 0;
+ }
+
+/* Make sure the item's data type is numeric. */
+
+ if (*(unsigned char *)type__ != 'N') {
+ setmsg_("The data associated with variable # are not of numeric type."
+ , (ftnlen)60);
+ errch_("#", varnam, (ftnlen)1, (ftnlen)32);
+ sigerr_("SPICE(TYPEMISMATCH)", (ftnlen)19);
+ chkout_("BODVCD", (ftnlen)6);
+ return 0;
+ }
+
+/* Make sure there's enough room in the array VALUES to hold */
+/* the requested data. */
+
+ if (*maxn < *dim) {
+ setmsg_("The data array associated with variable # has dimension #, "
+ "which is larger than the available space # in the output arr"
+ "ay.", (ftnlen)122);
+ errch_("#", varnam, (ftnlen)1, (ftnlen)32);
+ errint_("#", dim, (ftnlen)1);
+ errint_("#", maxn, (ftnlen)1);
+ sigerr_("SPICE(ARRAYTOOSMALL)", (ftnlen)20);
+ chkout_("BODVCD", (ftnlen)6);
+ return 0;
+ }
+
+/* Grab the values. We know at this point they're present in */
+/* the kernel pool, so we don't check the FOUND flag. */
+
+ gdpool_(varnam, &c__1, maxn, dim, values, &found, (ftnlen)32);
+ chkout_("BODVCD", (ftnlen)6);
+ return 0;
+} /* bodvcd_ */
+
diff --git a/ext/spice/src/cspice/bodvcd_c.c b/ext/spice/src/cspice/bodvcd_c.c
new file mode 100644
index 0000000000..7b0ed7fd2d
--- /dev/null
+++ b/ext/spice/src/cspice/bodvcd_c.c
@@ -0,0 +1,270 @@
+/*
+
+-Procedure bodvcd_c ( Return d.p. values from the kernel pool )
+
+-Abstract
+
+ Fetch from the kernel pool the double precision values of an item
+ associated with a body, where the body is specified by an integer ID
+ code.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ KERNEL
+ NAIF_IDS
+
+-Keywords
+
+ CONSTANTS
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ void bodvcd_c ( SpiceInt bodyid,
+ ConstSpiceChar * item,
+ SpiceInt maxn,
+ SpiceInt * dim,
+ SpiceDouble * values )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ bodyid I Body ID code.
+ item I Item for which values are desired. ("RADII",
+ "NUT_PREC_ANGLES", etc. )
+ maxn I Maximum number of values that may be returned.
+ dim O Number of values returned.
+ values O Values.
+
+-Detailed_Input
+
+ bodyid is the NAIF integer ID code for a body of interest.
+ For example, if the body is the earth, the code is
+ 399.
+
+ item is the item to be returned. Together, the NAIF ID
+ code of the body and the item name combine to form a
+ kernel variable name, e.g.,
+
+ "BODY599_RADII"
+ "BODY401_POLE_RA"
+
+ The values associated with the kernel variable having
+ the name constructed as shown are sought. Below
+ we'll take the shortcut of calling this kernel variable
+ the "requested kernel variable."
+
+ Note that `item' *is* case-sensitive. This attribute
+ is inherited from the case-sensitivity of kernel
+ variable names.
+
+ maxn is the maximum number of values that may be returned.
+ The output array `values' must be declared with size at
+ least `maxn'. It's an error to supply an output array
+ that is too small to hold all of the values associated
+ with the requested kernel variable.
+
+-Detailed_Output
+
+ dim is the number of values returned; this is always the
+ number of values associated with the requested kernel
+ variable unless an error has been signaled.
+
+ values is the array of values associated with the requested
+ kernel variable. If `values' is too small to hold all
+ of the values associated with the kernel variable, the
+ returned values of `dim' and `values' are undefined.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the requested kernel variable is not found in the kernel
+ pool, the error SPICE(KERNELVARNOTFOUND) is signaled.
+
+ 2) If the requested kernel variable is found but the associated
+ values aren't numeric, the error SPICE(TYPEMISMATCH) is
+ signaled.
+
+ 3) The output array `values' must be declared with sufficient size
+ to contain all of the values associated with the requested kernel
+ variable. If the dimension of `values' indicated by `maxn' is
+ too small to contain the requested values, the error
+ SPICE(ARRAYTOOSMALL) is signaled.
+
+ 4) If the input dimension `maxn' indicates there is more room
+ in `values' than there really is---for example, if `maxn' is
+ 10 but `values' is declared with dimension 5---and the dimension
+ of the requested kernel variable is larger than the actual
+ dimension of `values', then this routine may overwrite
+ memory. The results are unpredictable.
+
+ 5) If the input string pointer `item' is null, the error
+ SPICE(NULLPOINTER) will be signaled.
+
+ 6) If either of the input strings referred to by `item' contains
+ no data characters, the error SPICE(EMPTYSTRING) will
+ be signaled.
+
+-Files
+
+ None.
+
+-Particulars
+
+ This routine simplifies looking up PCK kernel variables by
+ constructing names of requested kernel variables and by performing
+ error checking.
+
+ This routine is intended for use in cases where the maximum number
+ of values that may be returned is known at compile time. The caller
+ fetches all of the values associated with the specified kernel
+ variable via a single call to this routine. If the number of values
+ to be fetched cannot be known until run time, the lower-level
+ routine gdpool_c should be used instead. gdpool_c supports fetching
+ arbitrary amounts of data in multiple "chunks."
+
+ This routine is intended for use in cases where the requested kernel
+ variable is expected to be present in the kernel pool. If the
+ variable is not found or has the wrong data type, this routine
+ signals an error. In cases where it is appropriate to indicate
+ absence of an expected kernel variable by returning a boolean "found
+ flag" with the value SPICEFALSE, again the routine gdpool_c should
+ be used.
+
+-Examples
+
+ 1) When the kernel variable
+
+ BODY399_RADII
+
+ is present in the kernel pool---normally because a PCK defining
+ this variable has been loaded---the call
+
+ bodvcd_c ( 399, "RADII", 3, &dim, values );
+
+ returns the dimension and values associated with the variable
+ "BODY399_RADII", for example,
+
+ dim == 3
+ value[0] == 6378.140
+ value[1] == 6378.140
+ value[2] == 6356.755
+
+
+ 2) The call
+
+ bodvcd_c ( 399, "radii", 3, &dim, values );
+
+ usually will cause a SPICE(KERNELVARNOTFOUND) error to be
+ signaled, because this call will attempt to look up the values
+ associated with a kernel variable of the name
+
+ "BODY399_radii"
+
+ Since kernel variable names are case sensitive, this name is not
+ considered to match the name
+
+ "BODY399_RADII"
+
+ which normally would be present after a text PCK containing data
+ for all planets and satellites has been loaded.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ B.V. Semenov (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.1, 12-APR-2006 (NJB)
+
+ Header fix: output argument `dim' is now preceded by
+ an ampersand in example calls to bodvcd_c.c.
+
+ -CSPICE Version 1.0.0, 24-OCT-2005 (NJB) (BVS) (WLT) (IMU)
+
+-Index_Entries
+
+ fetch constants for a body from the kernel pool
+ physical constants for a body
+
+-&
+*/
+
+{ /* Begin bodvcd_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+ chkin_c ( "bodvcd_c" );
+
+
+ /*
+ Check the input string.
+ */
+ CHKFSTR ( CHK_STANDARD, "bodvcd_c", item );
+
+
+ /*
+ Call the f2c'd SPICELIB function.
+ */
+ bodvcd_ ( (integer *) &bodyid,
+ (char *) item,
+ (integer *) &maxn,
+ (integer *) dim,
+ (doublereal *) values,
+ (ftnlen ) strlen(item) );
+
+ chkout_c ( "bodvcd_c" );
+
+} /* End bodvcd_c */
diff --git a/ext/spice/src/cspice/bodvrd.c b/ext/spice/src/cspice/bodvrd.c
new file mode 100644
index 0000000000..593b6c6853
--- /dev/null
+++ b/ext/spice/src/cspice/bodvrd.c
@@ -0,0 +1,368 @@
+/* bodvrd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__0 = 0;
+static integer c__1 = 1;
+
+/* $Procedure BODVRD ( Return d.p. values from the kernel pool ) */
+/* Subroutine */ int bodvrd_(char *bodynm, char *item, integer *maxn, integer
+ *dim, doublereal *values, ftnlen bodynm_len, ftnlen item_len)
+{
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ char code[16], type__[1];
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen);
+ logical found;
+ extern /* Subroutine */ int bods2c_(char *, integer *, logical *, ftnlen);
+ integer bodyid;
+ char varnam[32];
+ extern /* Subroutine */ int gdpool_(char *, integer *, integer *, integer
+ *, doublereal *, logical *, ftnlen), sigerr_(char *, ftnlen),
+ chkout_(char *, ftnlen), dtpool_(char *, logical *, integer *,
+ char *, ftnlen, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen), suffix_(char *, integer *, char *, ftnlen,
+ ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int intstr_(integer *, char *, ftnlen);
+
+/* $ Abstract */
+
+/* Fetch from the kernel pool the double precision values */
+/* of an item associated with a body. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* KERNEL */
+/* NAIF_IDS */
+
+/* $ Keywords */
+
+/* CONSTANTS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* BODYNM I Body name. */
+/* ITEM I Item for which values are desired. ('RADII', */
+/* 'NUT_PREC_ANGLES', etc. ) */
+/* MAXN I Maximum number of values that may be returned. */
+/* DIM O Number of values returned. */
+/* VALUES O Values. */
+
+/* $ Detailed_Input */
+
+/* BODYNM is the name of the body for which ITEM is requested. */
+/* BODYNM is case-insensitive, and leading and trailing */
+/* blanks in BODYNM are not significant. Optionally, you */
+/* may supply the integer ID code for the object as an */
+/* integer string. For example both 'MOON' and '301' are */
+/* legitimate strings that indicate the moon is the body */
+/* of interest. */
+
+/* ITEM is the item to be returned. Together, the NAIF ID */
+/* code of the body and the item name combine to form a */
+/* kernel variable name, e.g., */
+
+/* 'BODY599_RADII' */
+/* 'BODY401_POLE_RA' */
+
+/* The values associated with the kernel variable having */
+/* the name constructed as shown are sought. Below */
+/* we'll take the shortcut of calling this kernel variable */
+/* the "requested kernel variable." */
+
+/* Note that ITEM *is* case-sensitive. This attribute */
+/* is inherited from the case-sensitivity of kernel */
+/* variable names. */
+
+/* MAXN is the maximum number of values that may be returned. */
+/* The output array VALUES must be declared with size at */
+/* least MAXN. It's an error to supply an output array */
+/* that is too small to hold all of the values associated */
+/* with the requested kernel variable. */
+
+/* $ Detailed_Output */
+
+/* DIM is the number of values returned; this is always the */
+/* number of values associated with the requested kernel */
+/* variable unless an error has been signaled. */
+
+/* VALUES is the array of values associated with the requested */
+/* kernel variable. If VALUES is too small to hold all */
+/* of the values associated with the kernel variable, the */
+/* returned values of DIM and VALUES are undefined. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input body name cannot be translated to an ID code, */
+/* and if the name is not a string representation of an integer */
+/* (for example, '399'), the error SPICE(NOTRANSLATION) is */
+/* signaled. */
+
+/* 2) If the requested kernel variable is not found in the kernel */
+/* pool, the error SPICE(KERNELVARNOTFOUND) is signaled. */
+
+/* 3) If the requested kernel variable is found but the associated */
+/* values aren't numeric, the error SPICE(TYPEMISMATCH) is */
+/* signaled. */
+
+/* 4) The output array VALUES must be declared with sufficient size */
+/* to contain all of the values associated with the requested */
+/* kernel variable. If the dimension of */
+/* VALUES indicated by MAXN is too small to contain the */
+/* requested values, the error SPICE(ARRAYTOOSMALL) is signaled. */
+
+/* 5) If the input dimension MAXN indicates there is more room */
+/* in VALUES than there really is---for example, if MAXN is */
+/* 10 but values is declared with dimension 5---and the dimension */
+/* of the requested kernel variable is larger than the actual */
+/* dimension of VALUES, then this routine may overwrite */
+/* memory. The results are unpredictable. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine simplifies looking up PCK kernel variables by */
+/* constructing names of requested kernel variables and by */
+/* performing error checking. */
+
+/* This routine is intended for use in cases where the maximum */
+/* number of values that may be returned is known at compile */
+/* time. The caller fetches all of the values associated with */
+/* the specified kernel variable via a single call to this */
+/* routine. If the number of values to be fetched cannot be */
+/* known until run time, the lower-level routine GDPOOL (an */
+/* entry point of POOL) should be used instead. GDPOOL supports */
+/* fetching arbitrary amounts of data in multiple "chunks." */
+
+/* This routine is intended for use in cases where the requested */
+/* kernel variable is expected to be present in the kernel pool. If */
+/* the variable is not found or has the wrong data type, this */
+/* routine signals an error. In cases where it is appropriate to */
+/* indicate absence of an expected kernel variable by returning a */
+/* boolean "found flag" with the value .FALSE., again the routine */
+/* GDPOOL should be used. */
+
+/* $ Examples */
+
+/* 1) When the kernel variable */
+
+/* BODY399_RADII */
+
+/* is present in the kernel pool---normally because a PCK */
+/* defining this variable has been loaded---the call */
+
+/* CALL BODVRD ( 'EARTH', 'RADII', 3, DIM, VALUES ) */
+
+/* returns the dimension and values associated with the variable */
+/* 'BODY399_RADII', for example, */
+
+/* DIM = 3 */
+/* VALUES(1) = 6378.140 */
+/* VALUES(2) = 6378.140 */
+/* VALUES(3) = 6356.755 */
+
+
+/* 2) The call */
+
+/* CALL BODVRD ( 'earth', 'RADII', 3, DIM, VALUES ) */
+
+/* will produce the same results shown in example (1), */
+/* since the case of the input argument BODYNM is */
+/* not significant. */
+
+
+/* 3) The call */
+
+/* CALL BODVRD ( '399', 'RADII', 3, DIM, VALUES ) */
+
+/* will produce the same results shown in example (1), */
+/* since strings containing integer codes are accepted */
+/* by this routine. */
+
+
+/* 4) The call */
+
+/* CALL BODVRD ( 'EARTH', 'radii', 3, DIM, VALUES ) */
+
+/* usually will cause a SPICE(KERNELVARNOTFOUND) error to be */
+/* signaled, because this call will attempt to look up the */
+/* values associated with a kernel variable of the name */
+
+/* 'BODY399_radii' */
+
+/* Since kernel variable names are case sensitive, this */
+/* name is not considered to match the name */
+
+/* 'BODY399_RADII' */
+
+/* which normally would be present after a text PCK */
+/* containing data for all planets and satellites has */
+/* been loaded. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* B.V. Semenov (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 22-JUL-2004 (NJB) */
+
+/* Updated to use BODS2C. */
+
+/* - SPICELIB Version 1.0.0, 23-FEB-2004 (NJB) (BVS) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* fetch constants for a body from the kernel pool */
+/* physical constants for a body */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 22-JUL-2004 (NJB) */
+
+/* Updated to use BODS2C. This simplifies the name-to-ID */
+/* mapping code. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("BODVRD", (ftnlen)6);
+ }
+
+/* Translate the input name to an ID code. */
+
+ bods2c_(bodynm, &bodyid, &found, bodynm_len);
+ if (! found) {
+ setmsg_("The body name # could not be translated to a NAIF ID code. "
+ " The cause of this problem may be that you need an updated v"
+ "ersion of the SPICE Toolkit.", (ftnlen)147);
+ errch_("#", bodynm, (ftnlen)1, bodynm_len);
+ sigerr_("SPICE(NOTRANSLATION)", (ftnlen)20);
+ chkout_("BODVRD", (ftnlen)6);
+ return 0;
+ }
+
+/* Construct the variable name from BODY and ITEM. */
+
+ s_copy(varnam, "BODY", (ftnlen)32, (ftnlen)4);
+ intstr_(&bodyid, code, (ftnlen)16);
+ suffix_(code, &c__0, varnam, (ftnlen)16, (ftnlen)32);
+ suffix_("_", &c__0, varnam, (ftnlen)1, (ftnlen)32);
+ suffix_(item, &c__0, varnam, item_len, (ftnlen)32);
+
+/* Make sure the item is present in the kernel pool. */
+
+ dtpool_(varnam, &found, dim, type__, (ftnlen)32, (ftnlen)1);
+ if (! found) {
+ setmsg_("The variable # could not be found in the kernel pool.", (
+ ftnlen)53);
+ errch_("#", varnam, (ftnlen)1, (ftnlen)32);
+ sigerr_("SPICE(KERNELVARNOTFOUND)", (ftnlen)24);
+ chkout_("BODVRD", (ftnlen)6);
+ return 0;
+ }
+
+/* Make sure the item's data type is numeric. */
+
+ if (*(unsigned char *)type__ != 'N') {
+ setmsg_("The data associated with variable # are not of numeric type."
+ , (ftnlen)60);
+ errch_("#", varnam, (ftnlen)1, (ftnlen)32);
+ sigerr_("SPICE(TYPEMISMATCH)", (ftnlen)19);
+ chkout_("BODVRD", (ftnlen)6);
+ return 0;
+ }
+
+/* Make sure there's enough room in the array VALUES to hold */
+/* the requested data. */
+
+ if (*maxn < *dim) {
+ setmsg_("The data array associated with variable # has dimension #, "
+ "which is larger than the available space # in the output arr"
+ "ay.", (ftnlen)122);
+ errch_("#", varnam, (ftnlen)1, (ftnlen)32);
+ errint_("#", dim, (ftnlen)1);
+ errint_("#", maxn, (ftnlen)1);
+ sigerr_("SPICE(ARRAYTOOSMALL)", (ftnlen)20);
+ chkout_("BODVRD", (ftnlen)6);
+ return 0;
+ }
+
+/* Grab the values. We know at this point they're present in */
+/* the kernel pool, so we don't check the FOUND flag. */
+
+ gdpool_(varnam, &c__1, maxn, dim, values, &found, (ftnlen)32);
+ chkout_("BODVRD", (ftnlen)6);
+ return 0;
+} /* bodvrd_ */
+
diff --git a/ext/spice/src/cspice/bodvrd_c.c b/ext/spice/src/cspice/bodvrd_c.c
new file mode 100644
index 0000000000..4aa101c71c
--- /dev/null
+++ b/ext/spice/src/cspice/bodvrd_c.c
@@ -0,0 +1,299 @@
+/*
+
+-Procedure bodvrd_c ( Return d.p. values from the kernel pool )
+
+-Abstract
+
+ Fetch from the kernel pool the double precision values
+ of an item associated with a body.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ KERNEL
+ NAIF_IDS
+
+-Keywords
+
+ CONSTANTS
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ void bodvrd_c ( ConstSpiceChar * bodynm,
+ ConstSpiceChar * item,
+ SpiceInt maxn,
+ SpiceInt * dim,
+ SpiceDouble * values )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ bodynm I Body name.
+ item I Item for which values are desired. ("RADII",
+ "NUT_PREC_ANGLES", etc. )
+ maxn I Maximum number of values that may be returned.
+ dim O Number of values returned.
+ values O Values.
+
+-Detailed_Input
+
+ bodynm is the name of the body for which `item' is requested.
+ `bodynm' is case-insensitive, and leading and trailing
+ blanks in `bodynm' are not significant. Optionally, you
+ may supply the integer ID code for the object as an
+ integer string. For example both "MOON" and "301" are
+ legitimate strings that indicate the moon is the body
+ of interest.
+
+ item is the item to be returned. Together, the NAIF ID
+ code of the body and the item name combine to form a
+ kernel variable name, e.g.,
+
+ "BODY599_RADII"
+ "BODY401_POLE_RA"
+
+ The values associated with the kernel variable having
+ the name constructed as shown are sought. Below
+ we'll take the shortcut of calling this kernel variable
+ the "requested kernel variable."
+
+ Note that `item' *is* case-sensitive. This attribute
+ is inherited from the case-sensitivity of kernel
+ variable names.
+
+ maxn is the maximum number of values that may be returned.
+ The output array `values' must be declared with size at
+ least `maxn'. It's an error to supply an output array
+ that is too small to hold all of the values associated
+ with the requested kernel variable.
+
+-Detailed_Output
+
+ dim is the number of values returned; this is always the
+ number of values associated with the requested kernel
+ variable unless an error has been signaled.
+
+ values is the array of values associated with the requested
+ kernel variable. If `values' is too small to hold all
+ of the values associated with the kernel variable, the
+ returned values of `dim' and `values' are undefined.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the input body name cannot be translated to an ID code,
+ and if the name is not a string representation of an integer
+ (for example, "399"), the error SPICE(NOTRANSLATION) is
+ signaled.
+
+ 2) If the requested kernel variable is not found in the kernel
+ pool, the error SPICE(KERNELVARNOTFOUND) is signaled.
+
+ 3) If the requested kernel variable is found but the associated
+ values aren't numeric, the error SPICE(TYPEMISMATCH) is
+ signaled.
+
+ 4) The output array `values' must be declared with sufficient size
+ to contain all of the values associated with the requested kernel
+ variable. If the dimension of `values' indicated by `maxn' is
+ too small to contain the requested values, the error
+ SPICE(ARRAYTOOSMALL) is signaled.
+
+ 5) If the input dimension `maxn' indicates there is more room
+ in `values' than there really is---for example, if `maxn' is
+ 10 but `values' is declared with dimension 5---and the dimension
+ of the requested kernel variable is larger than the actual
+ dimension of `values', then this routine may overwrite
+ memory. The results are unpredictable.
+
+ 6) If either of the input string pointers `bodynm' or `item'
+ are null, the error SPICE(NULLPOINTER) will be signaled.
+
+ 7) If either of the input strings referred to by `bodynm' or `item'
+ contain no data characters, the error SPICE(EMPTYSTRING) will
+ be signaled.
+
+-Files
+
+ None.
+
+-Particulars
+
+ This routine simplifies looking up PCK kernel variables by
+ constructing names of requested kernel variables and by performing
+ error checking.
+
+ This routine is intended for use in cases where the maximum number
+ of values that may be returned is known at compile time. The caller
+ fetches all of the values associated with the specified kernel
+ variable via a single call to this routine. If the number of values
+ to be fetched cannot be known until run time, the lower-level
+ routine gdpool_c should be used instead. gdpool_c supports fetching
+ arbitrary amounts of data in multiple "chunks."
+
+ This routine is intended for use in cases where the requested kernel
+ variable is expected to be present in the kernel pool. If the
+ variable is not found or has the wrong data type, this routine
+ signals an error. In cases where it is appropriate to indicate
+ absence of an expected kernel variable by returning a boolean "found
+ flag" with the value SPICEFALSE, again the routine gdpool_c should
+ be used.
+
+-Examples
+
+ 1) When the kernel variable
+
+ BODY399_RADII
+
+ is present in the kernel pool---normally because a PCK
+ defining this variable has been loaded---the call
+
+ bodvrd_c ( "EARTH", "RADII", 3, &dim, values );
+
+ returns the dimension and values associated with the variable
+ "BODY399_RADII", for example,
+
+ dim == 3
+ value[0] == 6378.140
+ value[1] == 6378.140
+ value[2] == 6356.755
+
+
+ 2) The call
+
+ bodvrd_c ( "earth", "RADII", 3, &dim, values );
+
+ will produce the same results shown in example (1),
+ since the case of the input argument `bodynm' is
+ not significant.
+
+
+ 3) The call
+
+ bodvrd_c ( "399", "RADII", 3, &dim, values );
+
+ will produce the same results shown in example (1),
+ since strings containing integer codes are accepted
+ by this routine.
+
+
+ 4) The call
+
+ bodvrd_c ( "EARTH", "radii", 3, &dim, values );
+
+ usually will cause a SPICE(KERNELVARNOTFOUND) error to be
+ signaled, because this call will attempt to look up the
+ values associated with a kernel variable of the name
+
+ "BODY399_radii"
+
+ Since kernel variable names are case sensitive, this
+ name is not considered to match the name
+
+ "BODY399_RADII"
+
+ which normally would be present after a text PCK
+ containing data for all planets and satellites has
+ been loaded.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ B.V. Semenov (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.1, 12-APR-2006 (NJB)
+
+ Header fix: output argument `dim' is now preceded by
+ an ampersand in example calls to bodvrd_c.c.
+
+ -CSPICE Version 1.0.0, 22-FEB-2004 (NJB)
+
+-Index_Entries
+
+ fetch constants for a body from the kernel pool
+ physical constants for a body
+
+-&
+*/
+
+{ /* Begin bodvrd_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+ chkin_c ( "bodvrd_c" );
+
+
+ /*
+ Check the input strings.
+ */
+ CHKFSTR ( CHK_STANDARD, "bodvrd_c", bodynm );
+ CHKFSTR ( CHK_STANDARD, "bodvrd_c", item );
+
+
+ /*
+ Call the f2c'd SPICELIB function.
+ */
+ bodvrd_ ( (char *) bodynm,
+ (char *) item,
+ (integer *) &maxn,
+ (integer *) dim,
+ (doublereal *) values,
+ (ftnlen ) strlen(bodynm),
+ (ftnlen ) strlen(item) );
+
+ chkout_c ( "bodvrd_c" );
+
+} /* End bodvrd_c */
diff --git a/ext/spice/src/cspice/brcktd.c b/ext/spice/src/cspice/brcktd.c
new file mode 100644
index 0000000000..77fadb34a5
--- /dev/null
+++ b/ext/spice/src/cspice/brcktd.c
@@ -0,0 +1,174 @@
+/* brcktd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BRCKTD (Bracket a double precision value within an interval) */
+doublereal brcktd_(doublereal *number, doublereal *end1, doublereal *end2)
+{
+ /* System generated locals */
+ doublereal ret_val, d__1, d__2;
+
+/* $ Abstract */
+
+/* Bracket a number. That is, given a number and an acceptable */
+/* interval, make sure that the number is contained in the */
+/* interval. (If the number is already in the interval, leave it */
+/* alone. If not, set it to the nearest endpoint of the interval.) */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* INTERVALS, NUMBERS, UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* NUMBER I Number to be bracketed. */
+/* END1 I One of the bracketing endpoints for NUMBER. */
+/* END2 I The other bracketing endpoint for NUMBER. */
+/* BRCKTD O Bracketed number. */
+
+/* $ Detailed_Input */
+
+/* NUMBER is the number to be bracketed. That is, the */
+/* value of NUMBER is constrained to lie in the */
+/* interval bounded by END1 and END2. */
+
+/* END1, */
+/* END2 are the lower and upper bounds for NUMBER. The */
+/* order is not important. */
+
+/* $ Detailed_Output */
+
+/* BRCKTD is NUMBER, if it was already in the interval */
+/* provided. Otherwise it is the value of the nearest */
+/* bound of the interval. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine provides a shorthand notation for code fragments */
+/* like the following */
+
+/* IF ( NUMBER .LT. END1 ) THEN */
+/* NUMBER = END1 */
+/* ELSE IF ( NUMBER .GT. END2 ) THEN */
+/* NUMBER = END2 */
+/* END IF */
+
+/* which occur frequently during the processing of program inputs. */
+
+/* $ Examples */
+
+/* The following illustrate the operation of BRCKTD. */
+
+/* BRCKTD ( -1.D0, 1.D0, 10.D0 ) = 1.D0 */
+/* BRCKTD ( 29.D0, 1.D0, 10.D0 ) = 10.D0 */
+/* BRCKTD ( 3.D0, -10.D0, 10.D0 ) = 3.D0 */
+/* BRCKTD ( 3.D0, -10.D0, -1.D0 ) = -1.D0 */
+
+/* The following code fragment illustrates a typical use for BRCKTD. */
+
+/* C */
+/* C Star magnitude limit must be in the range 0-10. */
+/* C */
+/* READ (5,*) MAGLIM */
+/* MAGLIM = BRCKTD ( MAGLIM, 0.D0, 10.D0 ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* bracket a d.p. value within an interval */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.1.0, 30-DEC-1988 (WLT) */
+
+/* The routine was modified so that the order of the endpoints */
+/* of the bracketing interval is not needed. The routine now */
+/* determines which is the left endpoint and which is the */
+/* right and acts appropriately. */
+
+/* -& */
+
+/* What else is there to say? */
+
+ if (*end1 < *end2) {
+/* Computing MAX */
+ d__1 = *end1, d__2 = min(*end2,*number);
+ ret_val = max(d__1,d__2);
+ } else {
+/* Computing MAX */
+ d__1 = *end2, d__2 = min(*end1,*number);
+ ret_val = max(d__1,d__2);
+ }
+ return ret_val;
+} /* brcktd_ */
+
diff --git a/ext/spice/src/cspice/brcktd_c.c b/ext/spice/src/cspice/brcktd_c.c
new file mode 100644
index 0000000000..8fade57214
--- /dev/null
+++ b/ext/spice/src/cspice/brcktd_c.c
@@ -0,0 +1,183 @@
+/*
+
+-Procedure brcktd_c (Bracket a d.p. value within an interval)
+
+-Abstract
+
+ Bracket a number. That is, given a number and an acceptable
+ interval, make sure that the number is contained in the
+ interval. (If the number is already in the interval, leave it
+ alone. If not, set it to the nearest endpoint of the interval.)
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ None.
+
+*/
+
+ #include "SpiceUsr.h"
+
+
+ SpiceDouble brcktd_c ( SpiceDouble number,
+ SpiceDouble end1,
+ SpiceDouble end2 )
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ number I Number to be bracketed.
+ end1 I One of the bracketing endpoints for number.
+ end2 I The other bracketing endpoint for number.
+
+ The function returns the bracketed number.
+
+-Detailed_Input
+
+ number is the number to be bracketed. That is, the
+ value of number is constrained to lie in the
+ interval bounded by end1 and end2.
+
+ end1,
+ end2 are the lower and upper bounds for number. The
+ order is not important.
+
+-Detailed_Output
+
+ The function returnes the input number, if it was already in the
+ interval provided. Otherwise the returned value is the nearest
+ bound of the interval.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+-Files
+
+ None.
+
+-Particulars
+
+ This routine provides a shorthand notation for code fragments
+ like the following
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ if ( number < end 1 )
+ {
+ number = end1;
+ }
+ else if ( number > end2 )
+ {
+ number = end2;
+ }
+
+
+ which occur frequently during the processing of program inputs.
+
+-Examples
+
+ The following illustrates the operation of brcktd_c.
+
+ brcktd_c ( -1., 1., 10. ) = 1.
+ brcktd_c ( 29., 1., 10. ) = 10.
+ brcktd_c ( 3., -10., 10. ) = 3.
+ brcktd_c ( 3., -10., -1. ) = -1.
+
+ The following code fragment illustrates a typical use for brcktd_c.
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Star magnitude limit must be in the range 0-10.
+ ./
+
+ prompt_c ( "Enter magnitude limit > ", 25, magLimStr );
+
+ prsdp_c ( magLimStr, &maglim );
+
+ maglim = brcktd_c ( maglim, 0., 10. );
+
+
+-Restrictions
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.1, 11-NOV-2006 (EDW)
+
+ Added "None." text to Keywords section, required for
+ API doc script (cspicehtml.pl) integrity checks.
+
+ -CSPICE Version 1.0.0, 16-AUG-1999 (NJB) (WLT) (IMU)
+
+-Index_Entries
+
+ bracket a d.p. value within an interval
+
+-&
+*/
+
+{ /* Begin brcktd_c */
+
+ if ( number < end1 )
+ {
+ return ( end1 );
+ }
+ else if ( number > end2 )
+ {
+ return ( end2 );
+ }
+
+ return ( number );
+
+} /* End brcktd_c */
diff --git a/ext/spice/src/cspice/brckti.c b/ext/spice/src/cspice/brckti.c
new file mode 100644
index 0000000000..493577093c
--- /dev/null
+++ b/ext/spice/src/cspice/brckti.c
@@ -0,0 +1,174 @@
+/* brckti.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BRCKTI ( Bracket an integer value within an interval. ) */
+integer brckti_(integer *number, integer *end1, integer *end2)
+{
+ /* System generated locals */
+ integer ret_val, i__1, i__2;
+
+/* $ Abstract */
+
+/* Bracket a number. That is, given a number and an acceptable */
+/* interval, make sure that the number is contained in the */
+/* interval. (If the number is already in the interval, leave it */
+/* alone. If not, set it to the nearest endpoint of the interval.) */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* INTERVALS, NUMBERS, UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* NUMBER I Number to be bracketed. */
+/* END1 I One of the bracketing endpoints for NUMBER. */
+/* END2 I The other bracketing endpoint for NUMBER. */
+/* BRCKTI O Bracketed number. */
+
+/* $ Detailed_Input */
+
+/* NUMBER is the number to be bracketed. That is, the */
+/* value of NUMBER is constrained to lie in the */
+/* interval bounded bye END1 and END2. */
+
+/* END1, */
+/* END2 are the lower and upper bounds for NUMBER. The */
+/* order is not important. */
+
+/* $ Detailed_Output */
+
+/* BRCKTI is NUMBER, if it was already in the interval */
+/* provided. Otherwise it is the value of the nearest */
+/* bound of the interval. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine provides a shorthand notation for code fragments */
+/* like the following */
+
+/* IF ( NUMBER .LT. END1 ) THEN */
+/* NUMBER = END1 */
+/* ELSE IF ( NUMBER .GT. END2 ) THEN */
+/* NUMBER = END2 */
+/* END IF */
+
+/* which occur frequently during the processing of program inputs. */
+
+/* $ Examples */
+
+/* The following illustrate the operation of BRCKTI. */
+
+/* BRCKTI ( -1, 1, 10 ) = 1 */
+/* BRCKTI ( 29, 1, 10 ) = 10 */
+/* BRCKTI ( 3, -10, 10 ) = 3 */
+/* BRCKTI ( 3, -10, -1 ) = -1 */
+
+/* The following code fragment illustrates a typical use for BRCKTI. */
+
+/* C */
+/* C Object code must be in the range 701-705. */
+/* C */
+/* READ (5,*) CODE */
+/* CODE = BRCKTI ( CODE, 701, 705 ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* bracket an integer value within an interval */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.1.0, 30-DEC-1988 (WLT) */
+
+/* The routine was modified so that the order of the endpoints */
+/* of the bracketing interval is not needed. The routine now */
+/* determines which is the left endpoint and which is the */
+/* right and acts appropriately. */
+
+/* -& */
+
+/* What else is there to say? */
+
+ if (*end1 < *end2) {
+/* Computing MAX */
+ i__1 = *end1, i__2 = min(*end2,*number);
+ ret_val = max(i__1,i__2);
+ } else {
+/* Computing MAX */
+ i__1 = *end2, i__2 = min(*end1,*number);
+ ret_val = max(i__1,i__2);
+ }
+ return ret_val;
+} /* brckti_ */
+
diff --git a/ext/spice/src/cspice/brckti_c.c b/ext/spice/src/cspice/brckti_c.c
new file mode 100644
index 0000000000..1f8c49dca4
--- /dev/null
+++ b/ext/spice/src/cspice/brckti_c.c
@@ -0,0 +1,183 @@
+/*
+
+-Procedure brckti_c (Bracket an integer value within an interval)
+
+-Abstract
+
+ Bracket a number. That is, given a number and an acceptable
+ interval, make sure that the number is contained in the
+ interval. (If the number is already in the interval, leave it
+ alone. If not, set it to the nearest endpoint of the interval.)
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ None.
+
+*/
+
+ #include "SpiceUsr.h"
+
+
+ SpiceInt brckti_c ( SpiceInt number,
+ SpiceInt end1,
+ SpiceInt end2 )
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ number I Number to be bracketed.
+ end1 I One of the bracketing endpoints for number.
+ end2 I The other bracketing endpoint for number.
+
+ The function returns the bracketed number.
+
+-Detailed_Input
+
+ number is the number to be bracketed. That is, the
+ value of number is constrained to lie in the
+ interval bounded by end1 and end2.
+
+ end1,
+ end2 are the lower and upper bounds for number. The
+ order is not important.
+
+-Detailed_Output
+
+ The function returnes the input number, if it was already in the
+ interval provided. Otherwise the returned value is the nearest
+ bound of the interval.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+-Files
+
+ None.
+
+-Particulars
+
+ This routine provides a shorthand notation for code fragments
+ like the following
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ if ( number < end 1 )
+ {
+ number = end1;
+ }
+ else if ( number > end2 )
+ {
+ number = end2;
+ }
+
+
+ which occur frequently during the processing of program inputs.
+
+-Examples
+
+ The following illustrates the operation of brckti_c.
+
+ brckti_c ( -1, 1, 10 ) = 1.0;
+ brckti_c ( 29, 1, 10 ) = 10.0;
+ brckti_c ( 3, -10, 10 ) = 3.0;
+ brckti_c ( 3, -10, -1 ) = -1.0;
+
+ The following code fragment illustrates a typical use for brckti_c.
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Number of time steps must be in the range 1-10.
+ ./
+
+ prompt_c ( "Enter number of time steps > ", 80, nStr );
+
+ prsint_c ( nStr, &n );
+
+ nstep = brckti_c ( n, 1, 10 );
+
+
+-Restrictions
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.1, 11-NOV-2006 (EDW)
+
+ Added "None." text to Keywords section, required for
+ API doc script (cspicehtml.pl) integrity checks.
+
+ -CSPICE Version 1.0.0, 16-AUG-1999 (NJB) (WLT) (IMU)
+
+-Index_Entries
+
+ bracket an integer value within an interval
+
+-&
+*/
+
+{ /* Begin brckti_c */
+
+ if ( number < end1 )
+ {
+ return ( end1 );
+ }
+ else if ( number > end2 )
+ {
+ return ( end2 );
+ }
+
+ return ( number );
+
+} /* End brckti_c */
diff --git a/ext/spice/src/cspice/bschoc.c b/ext/spice/src/cspice/bschoc.c
new file mode 100644
index 0000000000..488814f9c3
--- /dev/null
+++ b/ext/spice/src/cspice/bschoc.c
@@ -0,0 +1,205 @@
+/* bschoc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BSCHOC ( Binary search with order vector, character ) */
+integer bschoc_(char *value, integer *ndim, char *array, integer *order,
+ ftnlen value_len, ftnlen array_len)
+{
+ /* System generated locals */
+ integer ret_val;
+
+ /* Builtin functions */
+ integer s_cmp(char *, char *, ftnlen, ftnlen);
+ logical l_lt(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer left, i__, right;
+
+/* $ Abstract */
+
+/* Do a binary search for a given value within a character array, */
+/* accompanied by an order vector. Return the index of the */
+/* matching array entry, or zero if the key value is not found. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY, SEARCH */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* VALUE I Value to find in ARRAY. */
+/* NDIM I Dimension of ARRAY. */
+/* ARRAY I Array to be searched. */
+/* ORDER I Order vector. */
+/* BSCHOC O Index of VALUE in ARRAY. (Zero if not found.) */
+
+/* $ Detailed_Input */
+
+/* VALUE is the value to be found in the input array. */
+
+/* NDIM is the number of elements in the input array. */
+
+/* ARRAY is the array to be searched. */
+
+
+/* ORDER is an order array that can be used to access */
+/* the elements of ARRAY in order (according to the */
+/* ASCII collating sequence). */
+
+/* $ Detailed_Output */
+
+/* BSCHOC is the index of the input value in the input array. */
+/* If ARRAY does not contain VALUE, BSCHOC is zero. */
+
+/* If ARRAY contains more than one occurrence of VALUE, */
+/* BSCHOC may point to any of the occurrences. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* If NDIM < 1 the value of the function is zero. */
+
+/* $ Particulars */
+
+/* A binary search is implemented on the input array, whose order */
+/* is given by an associated order vector. If an element of the */
+/* array is found to match the input value, the index of that */
+/* element is returned. If no matching element is found, zero is */
+/* returned. */
+
+/* $ Examples */
+
+/* Let ARRAY and ORDER contain the following elements: */
+
+/* ARRAY ORDER */
+/* ----------- ----- */
+/* 'FEYNMAN' 2 */
+/* 'BOHR' 3 */
+/* 'EINSTEIN' 1 */
+/* 'NEWTON' 5 */
+/* 'GALILEO' 4 */
+
+/* Then */
+
+/* BSCHOC ( 'NEWTON', 5, ARRAY, ORDER ) = 4 */
+/* BSCHOC ( 'EINSTEIN', 5, ARRAY, ORDER ) = 3 */
+/* BSCHOC ( 'GALILEO', 5, ARRAY, ORDER ) = 5 */
+/* BSCHOC ( 'Galileo', 5, ARRAY, ORDER ) = 0 */
+/* BSCHOC ( 'BETHE', 5, ARRAY, ORDER ) = 0 */
+
+/* That is */
+
+/* ARRAY(4) = 'NEWTON' */
+/* ARRAY(3) = 'EINSTEIN' */
+/* ARRAY(5) = 'GALILEO' */
+
+/* (Compare with BSCHOC_2.) */
+
+/* $ Restrictions */
+
+/* ORDER is assumed to give the order of the elements of ARRAY */
+/* in increasing order according to the ASCII collating sequence. */
+/* If this condition is not met, the results of BSCHOC are */
+/* unpredictable. */
+
+/* $ Author_and_Institution */
+
+/* I. M. Underwood */
+/* W. L. Taber */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 18-SEP-1995 (IMU) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* binary search for a string using an order vector */
+
+/* -& */
+
+/* Local variables */
+
+
+/* Set the initial bounds for the search area. */
+
+ left = 1;
+ right = *ndim;
+ while(left <= right) {
+
+/* Check the middle element. */
+
+ i__ = (left + right) / 2;
+
+/* If the middle element matches, return its location. */
+
+ if (s_cmp(value, array + (order[i__ - 1] - 1) * array_len, value_len,
+ array_len) == 0) {
+ ret_val = order[i__ - 1];
+ return ret_val;
+
+/* Otherwise narrow the search area. */
+
+ } else if (l_lt(value, array + (order[i__ - 1] - 1) * array_len,
+ value_len, array_len)) {
+ right = i__ - 1;
+ } else {
+ left = i__ + 1;
+ }
+ }
+
+/* If the search area is empty, return zero. */
+
+ ret_val = 0;
+ return ret_val;
+} /* bschoc_ */
+
diff --git a/ext/spice/src/cspice/bschoc_c.c b/ext/spice/src/cspice/bschoc_c.c
new file mode 100644
index 0000000000..11a97bd3a6
--- /dev/null
+++ b/ext/spice/src/cspice/bschoc_c.c
@@ -0,0 +1,317 @@
+/*
+
+-Procedure bschoc_c ( Binary search with order vector, character )
+
+-Abstract
+
+ Do a binary search for a given value within a character string array,
+ accompanied by an order vector. Return the index of the matching array
+ entry, or -1 if the key value is not found.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ ARRAY, SEARCH
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+ #include "SpiceZim.h"
+ #include "f2cMang.h"
+ #undef bschoc_c
+
+
+ SpiceInt bschoc_c ( ConstSpiceChar * value,
+ SpiceInt ndim,
+ SpiceInt lenvals,
+ const void * array,
+ ConstSpiceInt * order )
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ value I Key value to be found in array.
+ ndim I Dimension of array.
+ lenvals I String length.
+ array I Character string array to search.
+ order I Order vector.
+
+ The function returns the index of the first matching array
+ element or -1 if the value is not found.
+
+-Detailed_Input
+
+ value is the key value to be found in the array. Trailing
+ blanks space in this key are not significant: string
+ matches found by this routine do not require trailing
+ blanks in value to match those in the corresponding
+ element of array.
+
+ ndim is the dimension of the array.
+
+ lenvals is the declared length of the strings in the input
+ string array, including null terminators. The input
+ array should be declared with dimension
+
+ [ndim][lenvals]
+
+ array is the array of character srings to be searched. Trailing
+ blanks in the strings in this array are not significant.
+
+ order is an order vector which can be used to access the elements
+ of array in order. The contents of order are a permutation
+ of the sequence of integers ranging from zero to ndim-1.
+
+-Detailed_Output
+
+ The function returns the index of the specified value in the input array.
+ Indices range from zero to ndim-1.
+
+ If the input array does not contain the specified value, the function
+ returns -1.
+
+ If the input array contains more than one occurrence of the specified
+ value, the returned index may point to any of the occurrences.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If ndim < 1 the function value is -1. This is not considered
+ an error.
+
+ 2) If input key value pointer is null, the error SPICE(NULLPOINTER) will
+ be signaled. The function returns -1.
+
+ 3) The input key value may have length zero. This case is not
+ considered an error.
+
+ 4) If the input array pointer is null, the error SPICE(NULLPOINTER) will
+ be signaled. The function returns -1.
+
+ 5) If the input array string's length is less than 2, the error
+ SPICE(STRINGTOOSHORT) will be signaled. The function returns -1.
+
+ 6) If memory cannot be allocated to create a Fortran-style version of
+ the input order vector, the error SPICE(MALLOCFAILED) is signaled.
+ The function returns -1 in this case.
+
+-Files
+
+ None.
+
+-Particulars
+
+ A binary search is performed on the input array, whose order is given
+ by an associated order vector. If an element of the array is found to
+ match the input value, the index of that element is returned. If no
+ matching element is found, -1 is returned.
+
+-Examples
+
+ Let the input arguments array and order contain the following elements:
+
+ array order
+
+ "FEYNMAN" 1
+ "BOHR" 2
+ "EINSTEIN" 0
+ "NEWTON" 4
+ "GALILEO" 3
+
+ Then
+
+ bschoc_c ( "NEWTON", 5, lenvals, array, order ) == 3
+ bschoc_c ( "EINSTEIN", 5, lenvals, array, order ) == 2
+ bschoc_c ( "GALILEO", 5, lenvals, array, order ) == 4
+ bschoc_c ( "Galileo", 5, lenvals, array, order ) == -1
+ bschoc_c ( "BETHE", 5, lenvals, array, order ) == -1
+
+-Restrictions
+
+ 1) The input array is assumed to be sorted in increasing order. If
+ this condition is not met, the results of bschoc_c are unpredictable.
+
+ 2) String comparisons performed by this routine are Fortran-style:
+ trailing blanks in the input array or key value are ignored.
+ This gives consistent behavior with CSPICE code generated by
+ the f2c translator, as well as with the Fortran SPICE Toolkit.
+
+ Note that this behavior is not identical to that of the ANSI
+ C library functions strcmp and strncmp.
+
+-Literature_References
+
+ None
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.1.0, 07-MAR-2009 (NJB)
+
+ This file now includes the header file f2cMang.h.
+ This header supports name mangling of f2c library
+ functions.
+
+ Header sections were re-ordered.
+
+ -CSPICE Version 1.0.0, 26-AUG-2002 (NJB) (WLT) (IMU)
+
+-Index_Entries
+
+ search in a character array
+
+-&
+*/
+
+{ /* Begin bschoc_c */
+
+
+ /*
+ f2c library utility prototypes
+ */
+ logical l_lt (char *a, char *b, ftnlen la, ftnlen lb );
+ extern integer s_cmp (char *a, char *b, ftnlen la, ftnlen lb );
+
+ /*
+ Local macros
+ */
+ #define ARR_ORD( i ) ( ( (SpiceChar *)array ) + order[(i)]*lenvals )
+
+
+ /*
+ Local variables
+ */
+ SpiceInt i;
+ SpiceInt keylen;
+ SpiceInt left;
+ SpiceInt lexord;
+ SpiceInt right;
+
+
+ /*
+ Use discovery check-in.
+
+ Return immediately if the array dimension is non-positive.
+ */
+ if ( ndim < 1 )
+ {
+ return ( -1 );
+ }
+
+
+ /*
+ Make sure the pointer for the key value is non-null
+ and that the length is adequate.
+ */
+ CHKPTR_VAL ( CHK_DISCOVER, "bschoc_c", value, -1 );
+
+
+ /*
+ Make sure the pointer for the string array is non-null
+ and that the length lenvals is sufficient.
+ */
+ CHKOSTR_VAL ( CHK_DISCOVER, "bschoc_c", array, lenvals, -1 );
+
+
+ /*
+ Do a binary search for the specified key value.
+ */
+ keylen = strlen(value);
+
+ left = 0;
+ right = ndim - 1;
+
+ while ( left <= right )
+ {
+ /*
+ Check the middle element.
+ */
+ i = ( left + right ) / 2;
+
+ /*
+ The f2c library function s_cmp performs a Fortran-style
+ lexical order comparison. A negative return value indicates
+ the first argument is less than the second, a return value
+ of zero indicates equality, and a positive value indicates
+ the second argument is greater.
+ */
+ lexord = (SpiceInt) s_cmp ( (char * ) value,
+ (char * ) ARR_ORD(i),
+ (ftnlen ) keylen,
+ (ftnlen ) strlen(ARR_ORD(i)) );
+
+ /*
+ If the middle element matches, return its location.
+ */
+ if ( lexord == 0 )
+ {
+ return ( order[i] );
+ }
+
+ /*
+ Otherwise, narrow the search area.
+ */
+ else if ( lexord < 0 )
+ {
+ /*
+ value is less than the middle element.
+ */
+ right = i - 1;
+ }
+
+ else
+ {
+ left = i + 1;
+ }
+
+ }
+
+ /*
+ If the search area is empty, indicate the value was not found.
+ */
+ return ( -1 );
+
+
+
+} /* End bschoc_c */
diff --git a/ext/spice/src/cspice/bschoi.c b/ext/spice/src/cspice/bschoi.c
new file mode 100644
index 0000000000..343b5dd361
--- /dev/null
+++ b/ext/spice/src/cspice/bschoi.c
@@ -0,0 +1,196 @@
+/* bschoi.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BSCHOI ( Binary search with order vector, integer ) */
+integer bschoi_(integer *value, integer *ndim, integer *array, integer *order)
+{
+ /* System generated locals */
+ integer ret_val;
+
+ /* Local variables */
+ integer left, i__, right;
+
+/* $ Abstract */
+
+/* Do a binary search for a given value within an integer array, */
+/* accompanied by an order vector. Return the index of the */
+/* matching array entry, or zero if the key value is not found. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY, SEARCH */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* VALUE I Value to find in ARRAY. */
+/* NDIM I Dimension of ARRAY. */
+/* ARRAY I Array to be searched. */
+/* ORDER I Order vector. */
+/* BSCHOI O Index of VALUE in ARRAY. (Zero if not found.) */
+
+/* $ Detailed_Input */
+
+/* VALUE is the value to be found in the input array. */
+
+/* NDIM is the number of elements in the input array. */
+
+/* ARRAY is the array to be searched. */
+
+
+/* ORDER is an order array that can be used to access */
+/* the elements of ARRAY in order. */
+
+/* $ Detailed_Output */
+
+/* BSCHOI is the index of the input value in the input array. */
+/* If ARRAY does not contain VALUE, BSCHOI is zero. */
+
+/* If ARRAY contains more than one occurrence of VALUE, */
+/* BSCHOI may point to any of the occurrences. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* 1) If NDIM < 1 the value of the function is zero. */
+
+/* $ Particulars */
+
+/* A binary search is implemented on the input array, whose order */
+/* is given by an associated order vector. If an element of the */
+/* array is found to match the input value, the index of that */
+/* element is returned. If no matching element is found, zero is */
+/* returned. */
+
+/* $ Examples */
+
+/* Let ARRAY and ORDER contain the following elements: */
+
+/* ARRAY ORDER */
+/* ----------- ----- */
+/* 100 2 */
+/* 1 3 */
+/* 10 1 */
+/* 10000 5 */
+/* 1000 4 */
+
+/* Then */
+
+/* BSCHOI ( 1000, 5, ARRAY, ORDER ) = 5 */
+/* BSCHOI ( 1, 5, ARRAY, ORDER ) = 2 */
+/* BSCHOI ( 10000, 5, ARRAY, ORDER ) = 4 */
+/* BSCHOI ( -1, 5, ARRAY, ORDER ) = 0 */
+/* BSCHOI ( 17, 5, ARRAY, ORDER ) = 0 */
+
+/* That is, */
+
+/* ARRAY(5) = 1000 */
+/* ARRAY(2) = 1 */
+/* ARRAY(4) = 10000 */
+
+/* (Compare with BSCHOI_2.) */
+
+/* $ Restrictions */
+
+/* ORDER is assumed to give the order of the elements of ARRAY */
+/* in increasing order. If this condition is not met, the results */
+/* of BSCHOI are unpredictable. */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 18-SEP-1995 (IMU) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* binary search for an integer using an order vector */
+
+/* -& */
+
+/* Local variables */
+
+
+/* Set the initial bounds for the search area. */
+
+ left = 1;
+ right = *ndim;
+ while(left <= right) {
+
+/* Check the middle element. */
+
+ i__ = (left + right) / 2;
+
+/* If the middle element matches, return its location. */
+
+ if (*value == array[order[i__ - 1] - 1]) {
+ ret_val = order[i__ - 1];
+ return ret_val;
+
+/* Otherwise narrow the search area. */
+
+ } else if (*value < array[order[i__ - 1] - 1]) {
+ right = i__ - 1;
+ } else {
+ left = i__ + 1;
+ }
+ }
+
+/* If the search area is empty, return zero. */
+
+ ret_val = 0;
+ return ret_val;
+} /* bschoi_ */
+
diff --git a/ext/spice/src/cspice/bschoi_c.c b/ext/spice/src/cspice/bschoi_c.c
new file mode 100644
index 0000000000..f9b2a8e770
--- /dev/null
+++ b/ext/spice/src/cspice/bschoi_c.c
@@ -0,0 +1,231 @@
+/*
+
+-Procedure bschoi_c ( Binary search with order vector, integer )
+
+-Abstract
+
+ Do a binary search for a given value within an integer array,
+ accompanied by an order vector. Return the index of the
+ matching array entry, or -1 if the key value is not found.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ ARRAY, SEARCH
+
+*/
+
+ #include
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZim.h"
+ #undef bschoi_c
+
+
+ SpiceInt bschoi_c ( SpiceInt value,
+ SpiceInt ndim,
+ ConstSpiceInt * array,
+ ConstSpiceInt * order )
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ value I Value to find in array.
+ ndim I Dimension of array.
+ array I Array to be searched.
+ order I Order vector.
+
+ The function returns the index of value in array, or -1 if the value
+ is not found.
+
+-Detailed_Input
+
+ value is the value to be found in the input array.
+
+ ndim is the number of elements in the input array.
+
+ array is the array to be searched.
+
+ order is an order vector which can be used to access the elements
+ of array in order. The contents of order are a permutation
+ of the sequence of integers ranging from zero to ndim-1.
+
+-Detailed_Output
+
+ The function returns the index of the input value in the input array.
+ Indices range from zero to ndim-1.
+
+ If the input array does not contain the specified value, the function
+ returns -1.
+
+ If the input array contains more than one occurrence of the specified
+ value, the returned index may point to any of the occurrences.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+
+ 1) If memory cannot be allocated to create a Fortran-style version of
+ the input order vector, the error SPICE(MALLOCFAILED) is signaled.
+ The function returns -1 in this case.
+
+ 2) If ndim < 1 the value of the function is -1. This is not an error.
+
+-Files
+
+ None.
+
+-Particulars
+
+ A binary search is performed on the input array, whose order is given
+ by an associated order vector. If an element of the array is found to
+ match the input value, the index of that element is returned. If no
+ matching element is found, -1 is returned.
+
+-Examples
+
+ Let array and order contain the following elements:
+
+ array order
+ ----------- -----
+ 100 1
+ 1 2
+ 10 0
+ 10000 4
+ 1000 3
+
+ Then
+
+ bschoi_c ( 1000, 5, array, order ) == 4
+ bschoi_c ( 1, 5, array, order ) == 1
+ bschoi_c ( 10000, 5, array, order ) == 3
+ bschoi_c ( -1, 5, array, order ) == -1
+ bschoi_c ( 17, 5, array, order ) == -1
+
+ That is,
+
+ array[4] == 1000
+ array[1] == 1
+ array[3] == 10000
+
+-Restrictions
+
+ The input order vector is assumed give the order of the elements of the
+ input array in increasing order. If this condition is not met, the
+ results of bschoi_c are unpredictable.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 10-JUL-2002 (NJB) (WLT) (IMU)
+
+-Index_Entries
+
+ binary search for an integer value
+
+-&
+*/
+
+{ /* Begin bschoi_c */
+
+
+ /*
+ Local variables
+ */
+ SpiceInt i ;
+ SpiceInt loc ;
+ SpiceInt * ordvec;
+ SpiceInt vSize;
+
+
+
+ /*
+ Use discovery check-in.
+
+ Return immediately if the array dimension is non-positive.
+ */
+ if ( ndim < 1 )
+ {
+ return ( -1 );
+ }
+
+
+ /*
+ Get a local copy of the input order vector; map the vector's contents
+ to the range 1:ndim.
+ */
+ vSize = ndim * sizeof(SpiceInt);
+
+ ordvec = (SpiceInt *) malloc( vSize );
+
+ if ( ordvec == 0 )
+ {
+ chkin_c ( "bschoi_c" );
+ setmsg_c ( "Failure on malloc call to create array "
+ "for Fortran-style order vector. Tried "
+ "to allocate # bytes." );
+ errint_c ( "#", vSize );
+ sigerr_c ( "SPICE(MALLOCFAILED)" );
+ chkout_c ( "bschoi_c" );
+
+ return ( -1 );
+ }
+
+ for ( i = 0; i < ndim; i++ )
+ {
+ ordvec[i] = order[i] + 1;
+ }
+
+ loc = bschoi_ ( (integer *) &value,
+ (integer *) &ndim,
+ (integer *) array,
+ (integer *) ordvec ) - 1;
+
+ free ( ordvec );
+
+ return ( loc );
+
+
+} /* End bschoi_c */
diff --git a/ext/spice/src/cspice/bsrchc.c b/ext/spice/src/cspice/bsrchc.c
new file mode 100644
index 0000000000..52a2551ac6
--- /dev/null
+++ b/ext/spice/src/cspice/bsrchc.c
@@ -0,0 +1,201 @@
+/* bsrchc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BSRCHC ( Binary search for a character string ) */
+integer bsrchc_(char *value, integer *ndim, char *array, ftnlen value_len,
+ ftnlen array_len)
+{
+ /* System generated locals */
+ integer ret_val;
+
+ /* Builtin functions */
+ integer s_cmp(char *, char *, ftnlen, ftnlen);
+ logical l_lt(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer left, i__, right;
+
+/* $ Abstract */
+
+/* Do a binary search for a given value within a character array, */
+/* assumed to be in increasing order. Return the index of the */
+/* matching array entry, or zero if the key value is not found. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY, SEARCH */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* VALUE I Value to find in ARRAY. */
+/* NDIM I Dimension of ARRAY. */
+/* ARRAY I Array to be searched. */
+/* BSRCHC O Index of VALUE in ARRAY. (Zero if not found.) */
+
+/* $ Detailed_Input */
+
+/* VALUE is the value to be found in the input array. */
+
+/* NDIM is the number of elements in the input array. */
+
+/* ARRAY is the array to be searched. The elements in */
+/* ARRAY are assumed to sorted according to the */
+/* ASCII collating sequence. */
+
+/* $ Detailed_Output */
+
+/* BSRCHC is the index of the input value in the input array. */
+/* If ARRAY does not contain VALUE, BSRCHC is zero. */
+
+/* If ARRAY contains more than one occurrence of VALUE, */
+/* BSRCHC may point to any of the occurrences. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* A binary search is implemented on the input array. If an */
+/* element of the array is found to match the input value, the */
+/* index of that element is returned. If no matching element */
+/* is found, zero is returned. */
+
+
+/* $ Examples */
+
+/* Let ARRAY contain the following elements: */
+
+/* 'BOHR' */
+/* 'EINSTEIN' */
+/* 'FEYNMAN' */
+/* 'GALILEO' */
+/* 'NEWTON' */
+
+/* Then */
+
+/* BSRCHC ( 'NEWTON', 5, ARRAY ) = 5 */
+/* BSRCHC ( 'EINSTEIN', 5, ARRAY ) = 2 */
+/* BSRCHC ( 'GALILEO', 5, ARRAY ) = 4 */
+/* BSRCHC ( 'Galileo', 5, ARRAY ) = 0 */
+/* BSRCHC ( 'BETHE', 5, ARRAY ) = 0 */
+
+/* $ Restrictions */
+
+/* ARRAY is assumed to be sorted in increasing order according to */
+/* the ASCII collating sequence. If this condition is not met, */
+/* the results of BSRCHC are unpredictable. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* If NDIM < 1 the value of the function is zero. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* binary search for a character_string */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.1.0, 8-JAN-1989 (IMU) */
+
+/* Now works for all values of NDIM. */
+
+/* -& */
+
+/* Local variables */
+
+
+/* Set the initial bounds for the search area. */
+
+ left = 1;
+ right = *ndim;
+ while(left <= right) {
+
+/* Check the middle element. */
+
+ i__ = (left + right) / 2;
+
+/* If the middle element matches, return its location. */
+
+ if (s_cmp(value, array + (i__ - 1) * array_len, value_len, array_len)
+ == 0) {
+ ret_val = i__;
+ return ret_val;
+
+/* Otherwise narrow the search area. */
+
+ } else if (l_lt(value, array + (i__ - 1) * array_len, value_len,
+ array_len)) {
+ right = i__ - 1;
+ } else {
+ left = i__ + 1;
+ }
+ }
+
+/* If the search area is empty, return zero. */
+
+ ret_val = 0;
+ return ret_val;
+} /* bsrchc_ */
+
diff --git a/ext/spice/src/cspice/bsrchc_c.c b/ext/spice/src/cspice/bsrchc_c.c
new file mode 100644
index 0000000000..85c3190079
--- /dev/null
+++ b/ext/spice/src/cspice/bsrchc_c.c
@@ -0,0 +1,304 @@
+/*
+
+-Procedure bsrchc_c ( Binary search for a character string )
+
+-Abstract
+
+ Do a binary earch for a given value within a character string array.
+ Return the index of the first matching array entry, or -1 if the key
+ value was not found.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ ARRAY, SEARCH
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+ #include "f2cMang.h"
+ #undef bsrchc_c
+
+
+ SpiceInt bsrchc_c ( ConstSpiceChar * value,
+ SpiceInt ndim,
+ SpiceInt lenvals,
+ const void * array )
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ value I Key value to be found in array.
+ ndim I Dimension of array.
+ lenvals I String length.
+ array I Character string array to search.
+
+ The function returns the index of the first matching array
+ element or -1 if the value is not found.
+
+-Detailed_Input
+
+ value is the key value to be found in the array. Trailing blanks
+ in this key are not significant: string matches found
+ by this routine do not require trailing blanks in
+ value to match that in the corresponding element of array.
+
+ ndim is the dimension of the array.
+
+ lenvals is the declared length of the strings in the input
+ string array, including null terminators. The input
+ array should be declared with dimension
+
+ [ndim][lenvals]
+
+ array is the array of character srings to be searched. Trailing
+ blanks in the strings in this array are not significant.
+
+-Detailed_Output
+
+ The function returns the index of the specified value in the input array.
+ Array indices range from zero to ndim-1.
+
+ If the input array does not contain the specified value, the function
+ returns -1.
+
+ If the input array contains more than one occurrence of the specified
+ value, the returned index may point to any of the occurrences.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If ndim < 1 the function value is -1. This is not considered
+ an error.
+
+ 2) If input key value pointer is null, the error SPICE(NULLPOINTER) will
+ be signaled. The function returns -1.
+
+ 3) The input key value may have length zero. This case is not
+ considered an error.
+
+ 4) If the input array pointer is null, the error SPICE(NULLPOINTER) will
+ be signaled. The function returns -1.
+
+ 5) If the input array string's length is less than 2, the error
+ SPICE(STRINGTOOSHORT) will be signaled. The function returns -1.
+
+-Files
+
+ None
+
+-Particulars
+
+ A binary search is performed on the input array. If an
+ element of the array is found to match the input value, the
+ index of that element is returned. If no matching element
+ is found, -1 is returned.
+
+-Examples
+
+ Let array be a character array of dimension
+
+ [5][lenvals]
+
+ which contains the following elements:
+
+ "BOHR"
+ "EINSTEIN"
+ "FEYNMAN"
+ "GALILEO"
+ "NEWTON"
+
+ Then
+
+ bsrchc_c ( "NEWTON", 5, lenvals, array ) == 4
+ bsrchc_c ( "EINSTEIN", 5, lenvals, array ) == 1
+ bsrchc_c ( "GALILEO", 5, lenvals, array ) == 3
+ bsrchc_c ( "Galileo", 5, lenvals, array ) == -1
+ bsrchc_c ( "BETHE", 5, lenvals, array ) == -1
+
+-Restrictions
+
+ 1) The input array is assumed to be sorted in increasing order. If
+ this condition is not met, the results of bsrchc_c are unpredictable.
+
+ 2) String comparisons performed by this routine are Fortran-style:
+ trailing blanks in the input array or key value are ignored.
+ This gives consistent behavior with CSPICE code generated by
+ the f2c translator, as well as with the Fortran SPICE Toolkit.
+
+ Note that this behavior is not identical to that of the ANSI
+ C library functions strcmp and strncmp.
+
+-Literature_References
+
+ None
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.M. Owen (JPL)
+
+-Version
+
+ -CSPICE Version 1.1.0, 07-MAR-2009 (NJB)
+
+ This file now includes the header file f2cMang.h.
+ This header supports name mangling of f2c library
+ functions.
+
+ Header sections were re-ordered.
+
+ -CSPICE Version 1.0.0, 26-AUG-2002 (NJB) (WMO)
+
+-Index_Entries
+
+ search in a character array
+
+-&
+*/
+
+{ /* Begin bsrchc_c */
+
+ /*
+ f2c library utility prototypes
+ */
+ logical l_lt (char *a, char *b, ftnlen la, ftnlen lb );
+ extern integer s_cmp (char *a, char *b, ftnlen la, ftnlen lb );
+
+ /*
+ Local macros
+ */
+ #define ARRAY( i ) ( ( (SpiceChar *)array ) + (i)*lenvals )
+
+
+ /*
+ Local variables
+ */
+ SpiceInt i;
+ SpiceInt keylen;
+ SpiceInt left;
+ SpiceInt order;
+ SpiceInt right;
+
+
+ /*
+ Use discovery check-in.
+
+ Return immediately if the array dimension is non-positive.
+ */
+ if ( ndim < 1 )
+ {
+ return ( -1 );
+ }
+
+
+ /*
+ Make sure the pointer for the key value is non-null
+ and that the length is adequate.
+ */
+ CHKPTR_VAL ( CHK_DISCOVER, "bsrchc_c", value, -1 );
+
+
+ /*
+ Make sure the pointer for the string array is non-null
+ and that the length lenvals is sufficient.
+ */
+ CHKOSTR_VAL ( CHK_DISCOVER, "bsrchc_c", array, lenvals, -1 );
+
+
+ /*
+ Do a binary search for the specified key value.
+ */
+ keylen = strlen(value);
+
+ left = 0;
+ right = ndim - 1;
+
+ while ( left <= right )
+ {
+ /*
+ Check the middle element.
+ */
+ i = ( left + right ) / 2;
+
+ /*
+ The f2c library function s_cmp performs a Fortran-style
+ lexical order comparison. A negative return value indicates
+ the first argument is less than the second, a return value
+ of zero indicates equality, and a positive value indicates
+ the second argument is greater.
+ */
+ order = (SpiceInt) s_cmp ( (char * ) value,
+ (char * ) ARRAY(i),
+ (ftnlen ) keylen,
+ (ftnlen ) strlen(ARRAY(i)) );
+
+ /*
+ If the middle element matches, return its location.
+ */
+ if ( order == 0 )
+ {
+ return ( i );
+ }
+
+ /*
+ Otherwise, narrow the search area.
+ */
+ else if ( order < 0 )
+ {
+ /*
+ value is less than the middle element.
+ */
+ right = i - 1;
+ }
+
+ else
+ {
+ left = i + 1;
+ }
+
+ }
+
+ /*
+ If the search area is empty, indicate the value was not found.
+ */
+ return ( -1 );
+
+
+} /* End bsrchc_c */
+
diff --git a/ext/spice/src/cspice/bsrchd.c b/ext/spice/src/cspice/bsrchd.c
new file mode 100644
index 0000000000..ab49100def
--- /dev/null
+++ b/ext/spice/src/cspice/bsrchd.c
@@ -0,0 +1,189 @@
+/* bsrchd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BSRCHD ( Binary search for double precision value ) */
+integer bsrchd_(doublereal *value, integer *ndim, doublereal *array)
+{
+ /* System generated locals */
+ integer ret_val;
+
+ /* Local variables */
+ integer left, i__, right;
+
+/* $ Abstract */
+
+/* Do a binary search for a given value within a DOUBLE PRECISION */
+/* array, assumed to be in increasing order. Return the index of */
+/* the matching array entry, or zero if the key value is not found. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY, SEARCH */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* VALUE I Value to find in ARRAY. */
+/* NDIM I Dimension of ARRAY. */
+/* ARRAY I Array to be searched. */
+/* BSRCHD O Index of VALUE in ARRAY. (Zero if not found.) */
+
+/* $ Detailed_Input */
+
+/* VALUE is the value to be found in the input array. */
+
+/* NDIM is the number of elements in the input array. */
+
+/* ARRAY is the array to be searched. The elements in */
+/* ARRAY are assumed to sorted in increasing order. */
+
+/* $ Detailed_Output */
+
+/* BSRCHD is the index of the input value in the input array. */
+/* If ARRAY does not contain VALUE, BSRCHD is zero. */
+
+/* If ARRAY contains more than one occurrence of VALUE, */
+/* BSRCHD may point to any of the occurrences. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* A binary search is implemented on the input array. If an */
+/* element of the array is found to match the input value, the */
+/* index of that element is returned. If no matching element */
+/* is found, zero is returned. */
+
+
+/* $ Examples */
+
+/* Let ARRAY contain the following elements: */
+
+/* -11.D0 */
+/* 0.D0 */
+/* 22.491D0 */
+/* 750.0D0 */
+
+/* Then */
+
+/* BSRCHD ( -11.D0, 4, ARRAY ) = 1 */
+/* BSRCHD ( 22.491D0, 4, ARRAY ) = 3 */
+/* BSRCHD ( 751.D0, 4, ARRAY ) = 0 */
+
+/* $ Restrictions */
+
+/* ARRAY is assumed to be sorted in increasing order. If this */
+/* condition is not met, the results of BSRCHD are unpredictable. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* If NDIM < 1 the value of the function is zero. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* binary search for d.p. value */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.1.0, 8-JAN-1989 (IMU) */
+
+/* Now works for all values of NDIM. */
+
+/* -& */
+
+/* Local variables */
+
+
+/* Set the initial bounds for the search area. */
+
+ left = 1;
+ right = *ndim;
+ while(left <= right) {
+
+/* Check the middle element. */
+
+ i__ = (left + right) / 2;
+
+/* If the middle element matches, return its location. */
+
+ if (*value == array[i__ - 1]) {
+ ret_val = i__;
+ return ret_val;
+
+/* Otherwise narrow the search area. */
+
+ } else if (*value < array[i__ - 1]) {
+ right = i__ - 1;
+ } else {
+ left = i__ + 1;
+ }
+ }
+
+/* If the search area is empty, return zero. */
+
+ ret_val = 0;
+ return ret_val;
+} /* bsrchd_ */
+
diff --git a/ext/spice/src/cspice/bsrchd_c.c b/ext/spice/src/cspice/bsrchd_c.c
new file mode 100644
index 0000000000..9eae844349
--- /dev/null
+++ b/ext/spice/src/cspice/bsrchd_c.c
@@ -0,0 +1,161 @@
+/*
+
+-Procedure bsrchd_c ( Binary search for a double precision value )
+
+-Abstract
+
+ Do a binary search for a key value within a double precision array,
+ assumed to be in increasing order. Return the index of the matching
+ array entry, or -1 if the key value is not found.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ ARRAY
+ SEARCH
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZim.h"
+ #undef bsrchd_c
+
+ SpiceInt bsrchd_c ( SpiceDouble value,
+ SpiceInt ndim,
+ ConstSpiceDouble * array )
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ value I Value to find in array.
+ ndim I Dimension of array.
+ array I Array to be searched.
+
+ The function returns the index of the input key value in the
+ input array, or -1 if the value is not found.
+
+-Detailed_Input
+
+ value is the value to be found in the input array.
+
+ ndim is the number of elements in the input array.
+
+ array is the array to be searched. The elements in the
+ array are assumed to sorted in increasing order.
+
+-Detailed_Output
+
+ The function returns the index of the input value in the input array.
+ Indices range from zero to ndim-1.
+
+ If the input array does not contain the specified value, the function
+ returns -1.
+
+ If the input array contains more than one occurrence of the specified
+ value, the returned index may point to any of the occurrences.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+ If ndim < 1 the value of the function is -1.
+
+-Files
+
+ None.
+
+-Particulars
+
+ A binary search is performed on the input array. If an element of
+ the array is found to match the input value, the index of that
+ element is returned. If no matching element is found, -1 is
+ returned.
+
+-Examples
+
+ Let array contain the following elements:
+
+ -11.0
+ 0.0
+ 22.0
+ 750.0
+
+ Then
+
+ bsrchd_c ( -11.0, 4, array ) == 0
+ bsrchd_c ( 22.0, 4, array ) == 2
+ bsrchd_c ( 751.0, 4, array ) == -1
+
+-Restrictions
+
+ array is assumed to be sorted in increasing order. If this
+ condition is not met, the results of bsrchd_c are unpredictable.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ I.M. Underwood (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 22-AUG-2002 (NJB) (IMU)
+
+-Index_Entries
+
+ binary search for a double precision value
+
+-&
+*/
+
+{ /* Begin bsrchd_c */
+
+
+ /*
+ Note that we adjust the return value to make it a C-style index.
+ */
+
+ return ( bsrchd_ ( (doublereal *) &value,
+ (integer *) &ndim,
+ (doublereal *) array ) - 1 );
+
+} /* End bsrchd_c */
+
diff --git a/ext/spice/src/cspice/bsrchi.c b/ext/spice/src/cspice/bsrchi.c
new file mode 100644
index 0000000000..121aea0f9f
--- /dev/null
+++ b/ext/spice/src/cspice/bsrchi.c
@@ -0,0 +1,189 @@
+/* bsrchi.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure BSRCHI ( Binary search for an integer value ) */
+integer bsrchi_(integer *value, integer *ndim, integer *array)
+{
+ /* System generated locals */
+ integer ret_val;
+
+ /* Local variables */
+ integer left, i__, right;
+
+/* $ Abstract */
+
+/* Do a binary search for a given value within an INTEGER array, */
+/* assumed to be in increasing order. Return the index of the */
+/* matching array entry, or zero if the key value is not found. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY, SEARCH */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* VALUE I Value to find in ARRAY. */
+/* NDIM I Dimension of ARRAY. */
+/* ARRAY I Array to be searched. */
+/* BSRCHI O Index of VALUE in ARRAY. (Zero if not found.) */
+
+/* $ Detailed_Input */
+
+/* VALUE is the value to be found in the input array. */
+
+/* NDIM is the number of elements in the input array. */
+
+/* ARRAY is the array to be searched. The elements in */
+/* ARRAY are assumed to sorted in increasing order. */
+
+/* $ Detailed_Output */
+
+/* BSRCHI is the index of the input value in the input array. */
+/* If ARRAY does not contain VALUE, BSRCHI is zero. */
+
+/* If ARRAY contains more than one occurrence of VALUE, */
+/* BSRCHI may point to any of the occurrences. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* A binary search is implemented on the input array. If an */
+/* element of the array is found to match the input value, the */
+/* index of that element is returned. If no matching element */
+/* is found, zero is returned. */
+
+
+/* $ Examples */
+
+/* Let ARRAY contain the following elements: */
+
+/* -11 */
+/* 0 */
+/* 22 */
+/* 750 */
+
+/* Then */
+
+/* BSRCHI ( -11, 4, ARRAY ) = 1 */
+/* BSRCHI ( 22, 4, ARRAY ) = 3 */
+/* BSRCHI ( 751, 4, ARRAY ) = 0 */
+
+/* $ Restrictions */
+
+/* ARRAY is assumed to be sorted in increasing order. If this */
+/* condition is not met, the results of BSRCHI are unpredictable. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* If NDIM < 1 the value of the function is zero. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* binary search for an integer value */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.1.0, 8-JAN-1989 (IMU) */
+
+/* Now works for all values of NDIM. */
+
+/* -& */
+
+/* Local variables */
+
+
+/* Set the initial bounds for the search area. */
+
+ left = 1;
+ right = *ndim;
+ while(left <= right) {
+
+/* Check the middle element. */
+
+ i__ = (left + right) / 2;
+
+/* If the middle element matches, return its location. */
+
+ if (*value == array[i__ - 1]) {
+ ret_val = i__;
+ return ret_val;
+
+/* Otherwise narrow the search area. */
+
+ } else if (*value < array[i__ - 1]) {
+ right = i__ - 1;
+ } else {
+ left = i__ + 1;
+ }
+ }
+
+/* If the search area is empty, return zero. */
+
+ ret_val = 0;
+ return ret_val;
+} /* bsrchi_ */
+
diff --git a/ext/spice/src/cspice/bsrchi_c.c b/ext/spice/src/cspice/bsrchi_c.c
new file mode 100644
index 0000000000..d93eb44c38
--- /dev/null
+++ b/ext/spice/src/cspice/bsrchi_c.c
@@ -0,0 +1,160 @@
+/*
+
+-Procedure bsrchi_c ( Binary search for an integer value )
+
+-Abstract
+
+ Do a binary search for a key value within an integer array,
+ assumed to be in increasing order. Return the index of the
+ matching array entry, or -1 if the key value is not found.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ ARRAY
+ SEARCH
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZim.h"
+ #undef bsrchi_c
+
+ SpiceInt bsrchi_c ( SpiceInt value,
+ SpiceInt ndim,
+ ConstSpiceInt * array )
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ value I Value to find in array.
+ ndim I Dimension of array.
+ array I Array to be searched.
+
+ The function returns the index of the input key value in the
+ input array, or -1 if the value is not found.
+
+-Detailed_Input
+
+ value is the value to be found in the input array.
+
+ ndim is the number of elements in the input array.
+
+ array is the array to be searched. The elements in the
+ array are assumed to sorted in increasing order.
+
+-Detailed_Output
+
+ The function returns the index of the input value in the input array.
+ Indices range from zero to ndim-1.
+
+ If the input array does not contain the specified value, the function
+ returns -1.
+
+ If the input array contains more than one occurrence of the specified
+ value, the returned index may point to any of the occurrences.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+ If ndim < 1 the value of the function is -1.
+
+-Files
+
+ None.
+
+-Particulars
+
+ A binary search is performed on the input array. If an element of
+ the array is found to match the input value, the index of that
+ element is returned. If no matching element is found, -1 is
+ returned.
+
+-Examples
+
+ Let array contain the following elements:
+
+ -11
+ 0
+ 22
+ 750
+
+ Then
+
+ bsrchi_c ( -11, 4, array ) == 0
+ bsrchi_c ( 22, 4, array ) == 2
+ bsrchi_c ( 751, 4, array ) == -1
+
+-Restrictions
+
+ array is assumed to be sorted in increasing order. If this
+ condition is not met, the results of bsrchi_c are unpredictable.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ I.M. Underwood (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 30-AUG-2002 (NJB) (IMU)
+
+-Index_Entries
+
+ binary search for an integer value
+
+-&
+*/
+
+{ /* Begin bsrchi_c */
+
+
+ /*
+ Note that we adjust the return value to make it a C-style index.
+ */
+
+ return ( bsrchi_ ( (integer *) &value,
+ (integer *) &ndim,
+ (integer *) array ) - 1 );
+
+} /* End bsrchi_c */
diff --git a/ext/spice/src/cspice/byebye.c b/ext/spice/src/cspice/byebye.c
new file mode 100644
index 0000000000..43e1b90d6a
--- /dev/null
+++ b/ext/spice/src/cspice/byebye.c
@@ -0,0 +1,170 @@
+/*
+
+-Procedure byebye_ ( Exit a program indicating an error status )
+
+-Abstract
+
+ Exit an executing program returning a success or failure status
+ to the operating system. Supports f2c'd code whose Fortran
+ counterpart calls the SPICELIB routine byebye.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ UTILITY
+
+*/
+ #include
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+ int byebye_ ( char *status, ftnlen statusLen )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ status I A string indicating the exit status of a program.
+ statusLen I Length of status string.
+
+-Detailed_Input
+
+ status This is a character string which indicates the status
+ to use when exiting a program. The two status values
+ currently supported are "SUCCESS" and "FAILURE", which
+ have their obvious meanings. The case of the input is
+ not important, i.e., "Success" or "failure" are accepted.
+
+ If STATUS has a value of "SUCCESS", then the calling
+ program will be terminated with the ANSI stdlib.h status
+ code EXIT_SUCCESS.
+
+ If STATUS has a value of "FAILURE", then the calling
+ program will be terminated with the ANSI stdlib.h status
+ code EXIT_FAILURE.
+
+ If STATUS has a value that is not recognized, the calling
+ program will be terminated with the ANSI stdlib.h status
+ code EXIT_FAILURE.
+
+
+ statusLen is the length of the string passed in via the first
+ argument status. This argument is provided for
+ compatibility with the signature generated by running
+ f2c on the Fortran version of byebye.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+ If the input status value is not recognized, the effect is the same
+ as if the input status were "FAILURE".
+
+-Files
+
+ None.
+
+-Particulars
+
+ This routine should not be called by user applications. It exists
+ solely for the use of CSPICE functions produced by running f2c
+ on Fortran code.
+
+ This subroutine is called by sigerr_ to exit a program
+ returning a success or failure indication to the operating
+ system.
+
+-Examples
+
+ To exit a program indicating success:
+
+ byebye_ ( "SUCCESS", 7 );
+
+ To exit a program indicating failure:
+
+ byebye_ ( "FAILURE", 7 );
+
+-Restrictions
+
+ 1) This function should not be called directly by user's application
+ software.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.1, 14-FEB-2008 (BVS)
+
+ Removed TABs from the header.
+
+ -CSPICE Version 1.0.0, 04-NOV-1998 (NJB) (KRG)
+
+-Index_Entries
+
+ gracefully exit a program
+
+-&
+*/
+
+{ /* Begin byebye_ */
+
+
+
+ if ( eqstr_c ( status, "SUCCESS" ) )
+ {
+ exit ( EXIT_SUCCESS );
+ }
+ else
+ {
+ exit ( EXIT_FAILURE );
+ }
+
+ return ( 0 );
+
+} /* End byebye_ */
+
diff --git a/ext/spice/src/cspice/c_abs.c b/ext/spice/src/cspice/c_abs.c
new file mode 100644
index 0000000000..041fbd3d8b
--- /dev/null
+++ b/ext/spice/src/cspice/c_abs.c
@@ -0,0 +1,14 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+extern double f__cabs();
+
+double c_abs(z) complex *z;
+#else
+extern double f__cabs(double, double);
+
+double c_abs(complex *z)
+#endif
+{
+return( f__cabs( z->r, z->i ) );
+}
diff --git a/ext/spice/src/cspice/c_cos.c b/ext/spice/src/cspice/c_cos.c
new file mode 100644
index 0000000000..4aea0c3cf6
--- /dev/null
+++ b/ext/spice/src/cspice/c_cos.c
@@ -0,0 +1,17 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+extern double sin(), cos(), sinh(), cosh();
+
+VOID c_cos(r, z) complex *r, *z;
+#else
+#undef abs
+#include "math.h"
+
+void c_cos(complex *r, complex *z)
+#endif
+{
+ double zr = z->r;
+ r->r = cos(zr) * cosh(z->i);
+ r->i = - sin(zr) * sinh(z->i);
+ }
diff --git a/ext/spice/src/cspice/c_div.c b/ext/spice/src/cspice/c_div.c
new file mode 100644
index 0000000000..ac963079ba
--- /dev/null
+++ b/ext/spice/src/cspice/c_div.c
@@ -0,0 +1,37 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+extern VOID sig_die();
+VOID c_div(c, a, b)
+complex *a, *b, *c;
+#else
+extern void sig_die(char*,int);
+void c_div(complex *c, complex *a, complex *b)
+#endif
+{
+ double ratio, den;
+ double abr, abi, cr;
+
+ if( (abr = b->r) < 0.)
+ abr = - abr;
+ if( (abi = b->i) < 0.)
+ abi = - abi;
+ if( abr <= abi )
+ {
+ if(abi == 0)
+ sig_die("complex division by zero", 1);
+ ratio = (double)b->r / b->i ;
+ den = b->i * (1 + ratio*ratio);
+ cr = (a->r*ratio + a->i) / den;
+ c->i = (a->i*ratio - a->r) / den;
+ }
+
+ else
+ {
+ ratio = (double)b->i / b->r ;
+ den = b->r * (1 + ratio*ratio);
+ cr = (a->r + a->i*ratio) / den;
+ c->i = (a->i - a->r*ratio) / den;
+ }
+ c->r = cr;
+ }
diff --git a/ext/spice/src/cspice/c_exp.c b/ext/spice/src/cspice/c_exp.c
new file mode 100644
index 0000000000..8252c7f701
--- /dev/null
+++ b/ext/spice/src/cspice/c_exp.c
@@ -0,0 +1,19 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+extern double exp(), cos(), sin();
+
+ VOID c_exp(r, z) complex *r, *z;
+#else
+#undef abs
+#include "math.h"
+
+void c_exp(complex *r, complex *z)
+#endif
+{
+double expx;
+
+expx = exp(z->r);
+r->r = expx * cos(z->i);
+r->i = expx * sin(z->i);
+}
diff --git a/ext/spice/src/cspice/c_log.c b/ext/spice/src/cspice/c_log.c
new file mode 100644
index 0000000000..6ac990ca26
--- /dev/null
+++ b/ext/spice/src/cspice/c_log.c
@@ -0,0 +1,17 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+extern double log(), f__cabs(), atan2();
+VOID c_log(r, z) complex *r, *z;
+#else
+#undef abs
+#include "math.h"
+extern double f__cabs(double, double);
+
+void c_log(complex *r, complex *z)
+#endif
+{
+ double zi;
+ r->i = atan2(zi = z->i, z->r);
+ r->r = log( f__cabs(z->r, zi) );
+ }
diff --git a/ext/spice/src/cspice/c_sin.c b/ext/spice/src/cspice/c_sin.c
new file mode 100644
index 0000000000..15acccc59a
--- /dev/null
+++ b/ext/spice/src/cspice/c_sin.c
@@ -0,0 +1,17 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+extern double sin(), cos(), sinh(), cosh();
+
+VOID c_sin(r, z) complex *r, *z;
+#else
+#undef abs
+#include "math.h"
+
+void c_sin(complex *r, complex *z)
+#endif
+{
+ double zr = z->r;
+ r->r = sin(zr) * cosh(z->i);
+ r->i = cos(zr) * sinh(z->i);
+ }
diff --git a/ext/spice/src/cspice/c_sqrt.c b/ext/spice/src/cspice/c_sqrt.c
new file mode 100644
index 0000000000..8481ee4857
--- /dev/null
+++ b/ext/spice/src/cspice/c_sqrt.c
@@ -0,0 +1,35 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+extern double sqrt(), f__cabs();
+
+VOID c_sqrt(r, z) complex *r, *z;
+#else
+#undef abs
+#include "math.h"
+extern double f__cabs(double, double);
+
+void c_sqrt(complex *r, complex *z)
+#endif
+{
+ double mag, t;
+ double zi = z->i, zr = z->r;
+
+ if( (mag = f__cabs(zr, zi)) == 0.)
+ r->r = r->i = 0.;
+ else if(zr > 0)
+ {
+ r->r = t = sqrt(0.5 * (mag + zr) );
+ t = zi / t;
+ r->i = 0.5 * t;
+ }
+ else
+ {
+ t = sqrt(0.5 * (mag - zr) );
+ if(zi < 0)
+ t = -t;
+ r->i = t;
+ t = zi / t;
+ r->r = 0.5 * t;
+ }
+ }
diff --git a/ext/spice/src/cspice/cabs.c b/ext/spice/src/cspice/cabs.c
new file mode 100644
index 0000000000..0487277de7
--- /dev/null
+++ b/ext/spice/src/cspice/cabs.c
@@ -0,0 +1,103 @@
+/*
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+*/
+
+/*
+
+-Description
+
+ This is a slightly modified version of the f2c library
+ file cabs.c, which was included in the 1998-09-13 f2c
+ distribution.
+
+ This file has been modified as follows:
+
+ 1) This "header" text has been added.
+
+ 2) The file optionally invokes macros that mangle the
+ external symbols in f2c's F77 and I77 libraries. The
+ purpose of this is to allow programs to link to
+ CSPICE and also link to Fortran objects that do
+ Fortran I/O.
+
+ The mangling is invoked by defining the preprocessor
+ flag
+
+ MIX_C_AND_FORTRAN
+
+
+ The name mangling capability used by this routine should only be
+ used as a last resort.
+
+-Version
+
+ -CSPICE Version 1.0.0, 19-DEC-2001 (NJB)
+
+
+-&
+*/
+
+ /*
+ Mangle external symbols if we're mixing C and Fortran. This
+ code was not in the original version of cabs.c obtained with
+ the f2c distribution.
+ */
+ #ifdef MIX_C_AND_FORTRAN
+ #include "f2cMang.h"
+ #endif
+ /*
+ End of modification.
+ */
+
+#ifdef KR_headers
+extern double sqrt();
+double f__cabs(real, imag) double real, imag;
+#else
+#undef abs
+#include "math.h"
+double f__cabs(double real, double imag)
+#endif
+{
+double temp;
+
+if(real < 0)
+ real = -real;
+if(imag < 0)
+ imag = -imag;
+if(imag > real){
+ temp = real;
+ real = imag;
+ imag = temp;
+}
+if((real+imag) == real)
+ return(real);
+
+temp = imag/real;
+temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/
+return(temp);
+}
diff --git a/ext/spice/src/cspice/card_c.c b/ext/spice/src/cspice/card_c.c
new file mode 100644
index 0000000000..cc2a27c54d
--- /dev/null
+++ b/ext/spice/src/cspice/card_c.c
@@ -0,0 +1,228 @@
+/*
+
+-Procedure card_c ( Cardinality of a cell )
+
+-Abstract
+
+ Return the cardinality (current number of elements) in a
+ cell of any data type.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CELLS
+
+-Keywords
+
+ CELLS
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZmc.h"
+
+ SpiceInt card_c ( SpiceCell * cell )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ cell I Input cell.
+
+ The function returns the cardinality of the input cell.
+
+-Detailed_Input
+
+ cell is a cell of character, double precision, or
+ integer data type.
+
+-Detailed_Output
+
+ The function returns the cardinality of (current number of elements
+ in) the input cell.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the input cell has invalid cardinality, the error
+ SPICE(INVALIDCARDINALITY) is signaled. card_c returns
+ an unspecified value in this case.
+
+ 2) If the input array has invalid size, the error
+ SPICE(INVALIDSIZE) is signaled. card_c returns
+ an unspecified value in this case.
+
+-Files
+
+ None.
+
+-Particulars
+
+ This is a generic function which may be used on SpiceCells of
+ character, double precision, or integer data type.
+
+-Examples
+
+ The cardinality function card_c is typically used to process
+ each of the elements of a cell. In the following example, cardc_c
+ is used to step through the individual elements of the character
+ cell names.
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Declare the cell names with string length LNSIZE and maximum
+ number of strings SIZE.
+ ./
+ SPICECHAR_CELL ( names, SIZE, LNSIZE );
+ .
+ .
+ .
+ for ( i = 0; i < card_c(&names); i++ )
+ {
+ .
+ .
+ .
+ }
+
+ In conjunction with the size_c function, card_c may be used
+ to predict (and subsequently avoid) overflows when manipulating
+ cells. In the following example, size_c is used to determine
+ whether the integer cell original can be safely copied into
+ the integer cell save before actually attempting the operation.
+ If original contains more elements than save can hold, then
+ the operation would fail.
+
+ if ( card_c(&original) <= size_c(&save) )
+ {
+ copy_c ( &original, &save );
+ }
+ else
+ {
+ .
+ .
+ .
+ }
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ C.A. Curzon (JPL)
+ H.A. Neilan (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 06-AUG-2002 (NJB) (CAC) (HAN) (WLT) (IMU)
+
+-Index_Entries
+
+ cardinality of an integer cell
+
+-&
+*/
+
+{ /* Begin card_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ if ( return_c() )
+ {
+ return ( cell->card );
+ }
+ chkin_c ( "card_c" );
+
+
+ /*
+ Initialize the cell if necessary.
+ */
+ CELLINIT ( cell );
+
+
+ /*
+ Check the size and cardinality of the input cell.
+ */
+ if ( cell->size < 0 )
+ {
+ setmsg_c ( "Invalid cell size. The size was #." );
+ errint_c ( "#", cell->size );
+ sigerr_c ( "SPICE(INVALIDSIZE)" );
+ chkout_c ( "card_c" );
+
+ return ( cell->card );
+ }
+
+ else if ( cell->card < 0 )
+ {
+ setmsg_c ( "Invalid cell cardinality. The "
+ "cardinality was #." );
+ errint_c ( "#", cell->card );
+ sigerr_c ( "SPICE(INVALIDCARDINALITY)" );
+ chkout_c ( "card_c" );
+
+ return ( cell->card );
+ }
+
+ else if ( cell->card > cell->size )
+ {
+ setmsg_c ( "Invalid cell cardinality; cardinality exceeds "
+ " cell size. The cardinality was #. The size "
+ " was #." );
+ errint_c ( "#", cell->card );
+ errint_c ( "#", cell->size );
+ sigerr_c ( "SPICE(INVALIDCARDINALITY)" );
+ chkout_c ( "card_c" );
+
+ return ( cell->card );
+ }
+
+
+ chkout_c ( "card_c" );
+
+ return ( cell->card );
+
+
+} /* End card_c */
+
diff --git a/ext/spice/src/cspice/cardc.c b/ext/spice/src/cspice/cardc.c
new file mode 100644
index 0000000000..5b73712b5c
--- /dev/null
+++ b/ext/spice/src/cspice/cardc.c
@@ -0,0 +1,225 @@
+/* cardc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CARDC ( Cardinality of a character cell ) */
+integer cardc_(char *cell, ftnlen cell_len)
+{
+ /* System generated locals */
+ integer ret_val;
+
+ /* Local variables */
+ integer card, size;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dechar_(char *,
+ integer *, ftnlen), sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Return the cardinality (number of elements) of a character cell. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CELLS */
+
+/* $ Keywords */
+
+/* CELLS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* CELL I Input cell. */
+
+/* The function returns the cardinality of the input cell. */
+
+/* $ Detailed_Input */
+
+
+/* CELL is a cell. */
+
+
+/* $ Detailed_Output */
+
+/* The function returns the cardinality of (number of elements in) */
+/* the input cell. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* The cardinality (CARD) functions are typically used to process */
+/* each of the elements of a cell. In the following example, CARDC */
+/* is used to step through the individual elements of the character */
+/* cell NAMES. */
+
+/* DO I = 1, CARDC ( NAMES ) */
+/* . */
+/* . */
+/* END DO */
+
+/* In conjunction with the size (SIZE) functions, they may be used */
+/* to predict (and subsequently avoid) overflows when manipulating */
+/* cells. In the following example, SIZEC is used to determine */
+/* whether the character cell ORIGINAL can be safely copied into */
+/* the character cell SAVE before actually attempting the operation. */
+/* If ORIGINAL contains more elements than SAVE can hold, then */
+/* the operation would fail. */
+
+/* IF ( CARDC ( ORIGINAL ) .LE. SIZEC ( SAVE ) ) THEN */
+/* CALL COPYC ( ORIGINAL, SAVE ) */
+
+/* ELSE */
+/* . */
+/* . */
+/* END IF */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input array has invalid cardinality, the error */
+/* SPICE(INVALIDCARDINALITY) is signaled. CARDC returns */
+/* an unspecified value in this case. */
+
+/* 2) If the input array has invalid size, the error */
+/* SPICE(INVALIDSIZE) is signaled. CARDC returns */
+/* an unspecified value in this case. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* C.A. Curzon (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1, 29-JUL-2002 (NJB) */
+
+/* Errors in code fragments in the Examples section of */
+/* the header were corrected. */
+
+/* - SPICELIB Version 1.1.0, 17-MAY-1994 (HAN) */
+
+/* If the value of the function RETURN is TRUE upon execution of */
+/* this module, this function is assigned a default value of */
+/* either 0, 0.0D0, .FALSE., or blank depending on the type of the */
+/* function. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (CAC) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cardinality of a character cell */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 2.0.0, 13-MAR-1989 (NJB) */
+
+/* Check for valid input cell added. The input cell must */
+/* have valid size and cardinality values. */
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+ if (return_()) {
+ ret_val = 0;
+ return ret_val;
+ } else {
+ chkin_("CARDC", (ftnlen)5);
+ }
+
+/* Set return value, regardless of validity. */
+
+ dechar_(cell + cell_len * 5, &card, cell_len);
+ ret_val = card;
+
+/* Squeal if something is awry. */
+
+ dechar_(cell + (cell_len << 2), &size, cell_len);
+ if (size < 0) {
+ setmsg_("Invalid cell size. The size was #.", (ftnlen)35);
+ errint_("#", &size, (ftnlen)1);
+ sigerr_("SPICE(INVALIDSIZE)", (ftnlen)18);
+ chkout_("CARDC", (ftnlen)5);
+ return ret_val;
+ } else if (card < 0) {
+ setmsg_("Invalid cell cardinality. The cardinality was #.", (ftnlen)
+ 49);
+ errint_("#", &card, (ftnlen)1);
+ sigerr_("SPICE(INVALIDCARDINALITY)", (ftnlen)25);
+ chkout_("CARDC", (ftnlen)5);
+ return ret_val;
+ } else if (card > size) {
+ setmsg_("Invalid cell cardinality; cardinality exceeds cell size. T"
+ "he cardinality was #. The size was #.", (ftnlen)97);
+ errint_("#", &card, (ftnlen)1);
+ errint_("#", &size, (ftnlen)1);
+ sigerr_("SPICE(INVALIDCARDINALITY)", (ftnlen)25);
+ chkout_("CARDC", (ftnlen)5);
+ return ret_val;
+ }
+ chkout_("CARDC", (ftnlen)5);
+ return ret_val;
+} /* cardc_ */
+
diff --git a/ext/spice/src/cspice/cardd.c b/ext/spice/src/cspice/cardd.c
new file mode 100644
index 0000000000..5e276ba0b5
--- /dev/null
+++ b/ext/spice/src/cspice/cardd.c
@@ -0,0 +1,223 @@
+/* cardd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CARDD ( Cardinality of a double precision cell ) */
+integer cardd_(doublereal *cell)
+{
+ /* System generated locals */
+ integer ret_val, i__1;
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), sigerr_(char *,
+ ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen),
+ errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Return the cardinality (number of elements) of a double */
+/* precision cell. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CELLS */
+
+/* $ Keywords */
+
+/* CELLS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* CELL I Input cell. */
+
+/* The function returns the cardinality of the input cell. */
+
+/* $ Detailed_Input */
+
+
+/* CELL is a cell. */
+
+
+/* $ Detailed_Output */
+
+/* The function returns the cardinality of (number of elements in) */
+/* the input cell. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* The cardinality (CARD) functions are typically used to process */
+/* each of the elements of a cell. In the following example, CARDC */
+/* is used to step through the individual elements of the character */
+/* cell NAMES. */
+
+/* DO I = 1, CARDC ( NAMES ) */
+/* . */
+/* . */
+/* END DO */
+
+/* In conjunction with the size (SIZE) functions, they may be used */
+/* to predict (and subsequently avoid) overflows when manipulating */
+/* cells. In the following example, SIZED is used to determine */
+/* whether the d.p. cell ORIGINAL can be safely copied into */
+/* the d.p. cell SAVE before actually attempting the operation. */
+/* If ORIGINAL contains more elements than SAVE can hold, then */
+/* the operation would fail. */
+
+/* IF ( CARDD ( ORIGINAL ) .LE. SIZED ( SAVE ) ) THEN */
+/* CALL COPYD ( ORIGINAL, SAVE ) */
+
+/* ELSE */
+/* . */
+/* . */
+/* END IF */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input array has invalid cardinality, the error */
+/* SPICE(INVALIDCARDINALITY) is signaled. CARDD returns */
+/* an unspecified value in this case. */
+
+/* 2) If the input array has invalid size, the error */
+/* SPICE(INVALIDSIZE) is signaled. CARDD returns */
+/* an unspecified value in this case. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* C.A. Curzon (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1, 29-JUL-2002 (NJB) */
+
+/* Errors in code fragments in the Examples section of */
+/* the header were corrected. */
+
+/* - SPICELIB Version 1.1.0, 17-MAY-1994 (HAN) */
+
+/* If the value of the function RETURN is TRUE upon execution of */
+/* this module, this function is assigned a default value of */
+/* either 0, 0.0D0, .FALSE., or blank depending on the type of the */
+/* function. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (CAC) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cardinality of a d.p. cell */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 2.0.0, 13-MAR-1989 (NJB) */
+
+/* Check for valid input cell added. The input cell must */
+/* have valid size and cardinality values. */
+/* -& */
+
+/* SPICELIB functions */
+
+ if (return_()) {
+ ret_val = 0;
+ return ret_val;
+ } else {
+ chkin_("CARDD", (ftnlen)5);
+ }
+
+/* Set return value, regardless of validity. */
+
+ ret_val = (integer) cell[5];
+
+/* Squeal if something is awry. */
+
+ if ((integer) cell[4] < 0) {
+ setmsg_("Invalid cell size. The size was #.", (ftnlen)35);
+ i__1 = (integer) cell[4];
+ errint_("#", &i__1, (ftnlen)1);
+ sigerr_("SPICE(INVALIDSIZE)", (ftnlen)18);
+ chkout_("CARDD", (ftnlen)5);
+ return ret_val;
+ } else if ((integer) cell[5] < 0) {
+ setmsg_("Invalid cell cardinality. The cardinality was #.", (ftnlen)
+ 49);
+ i__1 = (integer) cell[5];
+ errint_("#", &i__1, (ftnlen)1);
+ sigerr_("SPICE(INVALIDCARDINALITY)", (ftnlen)25);
+ chkout_("CARDD", (ftnlen)5);
+ return ret_val;
+ } else if ((integer) cell[5] > (integer) cell[4]) {
+ setmsg_("Invalid cell cardinality; cardinality exceeds cell size. T"
+ "he cardinality was #. The size was #.", (ftnlen)97);
+ i__1 = (integer) cell[5];
+ errint_("#", &i__1, (ftnlen)1);
+ i__1 = (integer) cell[4];
+ errint_("#", &i__1, (ftnlen)1);
+ sigerr_("SPICE(INVALIDCARDINALITY)", (ftnlen)25);
+ chkout_("CARDD", (ftnlen)5);
+ return ret_val;
+ }
+ chkout_("CARDD", (ftnlen)5);
+ return ret_val;
+} /* cardd_ */
+
diff --git a/ext/spice/src/cspice/cardi.c b/ext/spice/src/cspice/cardi.c
new file mode 100644
index 0000000000..15bc9a8b77
--- /dev/null
+++ b/ext/spice/src/cspice/cardi.c
@@ -0,0 +1,218 @@
+/* cardi.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CARDI ( Cardinality of an integer cell ) */
+integer cardi_(integer *cell)
+{
+ /* System generated locals */
+ integer ret_val;
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), sigerr_(char *,
+ ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen),
+ errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Return the cardinality (number of elements) of an integer cell. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CELLS */
+
+/* $ Keywords */
+
+/* CELLS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* CELL I Input cell. */
+
+/* The function returns the cardinality of the input cell. */
+
+/* $ Detailed_Input */
+
+
+/* CELL is a cell. */
+
+
+/* $ Detailed_Output */
+
+/* The function returns the cardinality of (number of elements in) */
+/* the input cell. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* The cardinality (CARD) functions are typically used to process */
+/* each of the elements of a cell. In the following example, CARDC */
+/* is used to step through the individual elements of the character */
+/* cell NAMES. */
+
+/* DO I = 1, CARDC ( NAMES ) */
+/* . */
+/* . */
+/* END DO */
+
+/* In conjunction with the size (SIZE) functions, they may be used */
+/* to predict (and subsequently avoid) overflows when manipulating */
+/* cells. In the following example, SIZEI is used to determine */
+/* whether the integer cell ORIGINAL can be safely copied into */
+/* the integer cell SAVE before actually attempting the operation. */
+/* If ORIGINAL contains more elements than SAVE can hold, then */
+/* the operation would fail. */
+
+/* IF ( CARDI ( ORIGINAL ) .LE. SIZEI ( SAVE ) ) THEN */
+/* CALL COPYI ( ORIGINAL, SAVE ) */
+
+/* ELSE */
+/* . */
+/* . */
+/* END IF */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input array has invalid cardinality, the error */
+/* SPICE(INVALIDCARDINALITY) is signaled. CARDI returns */
+/* an unspecified value in this case. */
+
+/* 2) If the input array has invalid size, the error */
+/* SPICE(INVALIDSIZE) is signaled. CARDI returns */
+/* an unspecified value in this case. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* C.A. Curzon (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1, 29-JUL-2002 (NJB) */
+
+/* Errors in code fragments in the Examples section of */
+/* the header were corrected. */
+
+/* - SPICELIB Version 1.1.0, 17-MAY-1994 (HAN) */
+
+/* If the value of the function RETURN is TRUE upon execution of */
+/* this module, this function is assigned a default value of */
+/* either 0, 0.0D0, .FALSE., or blank depending on the type of the */
+/* function. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (CAC) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cardinality of an integer cell */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 2.0.0, 13-MAR-1989 (NJB) */
+
+/* Check for valid input cell added. The input cell must */
+/* have valid size and cardinality values. */
+/* -& */
+
+/* SPICELIB functions */
+
+ if (return_()) {
+ ret_val = 0;
+ return ret_val;
+ } else {
+ chkin_("CARDI", (ftnlen)5);
+ }
+
+/* Set return value, regardless of validity. */
+
+ ret_val = cell[5];
+
+/* Squeal if something is awry. */
+
+ if (cell[4] < 0) {
+ setmsg_("Invalid cell size. The size was #.", (ftnlen)35);
+ errint_("#", &cell[4], (ftnlen)1);
+ sigerr_("SPICE(INVALIDSIZE)", (ftnlen)18);
+ chkout_("CARDI", (ftnlen)5);
+ return ret_val;
+ } else if (cell[5] < 0) {
+ setmsg_("Invalid cell cardinality. The cardinality was #.", (ftnlen)
+ 49);
+ errint_("#", &cell[5], (ftnlen)1);
+ sigerr_("SPICE(INVALIDCARDINALITY)", (ftnlen)25);
+ chkout_("CARDI", (ftnlen)5);
+ return ret_val;
+ } else if (cell[5] > cell[4]) {
+ setmsg_("Invalid cell cardinality; cardinality exceeds cell size. T"
+ "he cardinality was #. The size was #.", (ftnlen)97);
+ errint_("#", &cell[5], (ftnlen)1);
+ errint_("#", &cell[4], (ftnlen)1);
+ sigerr_("SPICE(INVALIDCARDINALITY)", (ftnlen)25);
+ chkout_("CARDI", (ftnlen)5);
+ return ret_val;
+ }
+ chkout_("CARDI", (ftnlen)5);
+ return ret_val;
+} /* cardi_ */
+
diff --git a/ext/spice/src/cspice/cgv2el.c b/ext/spice/src/cspice/cgv2el.c
new file mode 100644
index 0000000000..b0dec4481b
--- /dev/null
+++ b/ext/spice/src/cspice/cgv2el.c
@@ -0,0 +1,194 @@
+/* cgv2el.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CGV2EL ( Center and generating vectors to ellipse ) */
+/* Subroutine */ int cgv2el_(doublereal *center, doublereal *vec1, doublereal
+ *vec2, doublereal *ellips)
+{
+ extern /* Subroutine */ int vequ_(doublereal *, doublereal *), chkin_(
+ char *, ftnlen), saelgv_(doublereal *, doublereal *, doublereal *,
+ doublereal *), chkout_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Form a SPICELIB ellipse from a center vector and two generating */
+/* vectors. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* ELLIPSES */
+
+/* $ Keywords */
+
+/* ELLIPSE */
+/* GEOMETRY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* CENTER, */
+/* VEC1, */
+/* VEC2 I Center and two generating vectors for an ellipse. */
+/* ELLIPS O The SPICELIB ellipse defined by the input vectors. */
+
+/* $ Detailed_Input */
+
+/* CENTER, */
+/* VEC1, */
+/* VEC2 are a center and two generating vectors defining */
+/* an ellipse in three-dimensional space. The */
+/* ellipse is the set of points */
+
+/* CENTER + cos(theta) VEC1 + sin(theta) VEC2 */
+
+/* where theta ranges over the interval (-pi, pi]. */
+/* VEC1 and VEC2 need not be linearly independent. */
+
+/* $ Detailed_Output */
+
+/* ELLIPS is the SPICELIB ellipse defined by the input */
+/* vectors. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If VEC1 and VEC2 are linearly dependent, ELLIPS will be */
+/* degenerate. SPICELIB ellipses are allowed to represent */
+/* degenerate geometric ellipses. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* SPICELIB ellipses serve to simplify calling sequences and reduce */
+/* the chance for error in declaring and describing argument lists */
+/* involving ellipses. */
+
+/* The set of ellipse conversion routines is */
+
+/* CGV2EL ( Center and generating vectors to ellipse ) */
+/* EL2CGV ( Ellipse to center and generating vectors ) */
+
+/* $ Examples */
+
+/* 1) Find the intersecton of an ellipse with a plane. The ellipse */
+/* is defined by the vectors CENTER, VEC1, and VEC2. The plane */
+/* is defined by the normal vector N and the constant C. */
+
+/* C */
+/* C Make a SPICELIB ellipse. Make a plane while */
+/* C we're at it. */
+/* C */
+/* CALL CGV2EL ( CENTER, VEC1, VEC2, ELLIPS ) */
+/* CALL NVC2PL ( N, C, PLANE ) */
+
+/* C */
+/* C Find the intersection of the ellipse and plane. */
+/* C NXPTS is the number of intersection points; XPT1 */
+/* C and XPT2 are the points themselves. */
+/* C */
+/* CALL INELPL ( ELLIPS, PLANE, NXPTS, XPT1, XPT2 ) */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 02-NOV-1990 (NJB) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* center and generating vectors to ellipse */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* SPICELIB ellipses contain a center vector, a semi-major */
+/* axis vector, and a semi-minor axis vector. These are */
+/* located, respectively, in elements */
+
+/* CTRPOS through CTRPOS + 1 */
+
+/* MAJPOS through MAJPOS + 1 */
+
+/* MINPOS through MINPOS + 1 */
+
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CGV2EL", (ftnlen)6);
+ }
+
+/* The center of the ellipse is held in the first three elements. */
+
+ vequ_(center, ellips);
+
+/* Find the semi-axes of the ellipse. These may be degenerate. */
+
+ saelgv_(vec1, vec2, &ellips[3], &ellips[6]);
+ chkout_("CGV2EL", (ftnlen)6);
+ return 0;
+} /* cgv2el_ */
+
diff --git a/ext/spice/src/cspice/cgv2el_c.c b/ext/spice/src/cspice/cgv2el_c.c
new file mode 100644
index 0000000000..c92869f149
--- /dev/null
+++ b/ext/spice/src/cspice/cgv2el_c.c
@@ -0,0 +1,179 @@
+/*
+
+-Procedure cgv2el_c ( Center and generating vectors to ellipse )
+
+-Abstract
+
+ Form a CSPICE ellipse from a center vector and two generating
+ vectors.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ ELLIPSES
+
+-Keywords
+
+ ELLIPSE
+ GEOMETRY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZmc.h"
+ #undef cgv2el_c
+
+
+ void cgv2el_c ( ConstSpiceDouble center[3],
+ ConstSpiceDouble vec1 [3],
+ ConstSpiceDouble vec2 [3],
+ SpiceEllipse * ellipse )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ center,
+ vec1,
+ vec2 I Center and two generating vectors for an ellipse.
+ ellipse O The CSPICE ellipse defined by the input vectors.
+
+-Detailed_Input
+
+ center,
+ vec1,
+ vec2 are a center and two generating vectors defining
+ an ellipse in three-dimensional space. The
+ ellipse is the set of points
+
+ center + cos(theta) vec1 + sin(theta) vec2
+
+ where theta ranges over the interval (-pi, pi].
+ vec1 and vec2 need not be linearly independent.
+
+-Detailed_Output
+
+ ellipse is the CSPICE ellipse defined by the input
+ vectors.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If vec1 and vec2 are linearly dependent, ellips will be
+ degenerate. CSPICE ellipses are allowed to represent
+ degenerate geometric ellipses.
+
+-Files
+
+ None.
+
+-Particulars
+
+ CSPICE ellipses serve to simplify calling sequences and reduce
+ the chance for error in declaring and describing argument lists
+ involving ellipses.
+
+ The set of ellipse conversion routines is
+
+ cgv2el_c ( Center and generating vectors to ellipse )
+ el2cgv_c ( Ellipse to center and generating vectors )
+
+-Examples
+
+ 1) Find the intersecton of an ellipse with a plane. The ellipse
+ is defined by the vectors center, vec1, and vec2. The plane
+ is defined by the normal vector n and the constant c.
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Make a CSPICE ellipse. Make a plane while we're at it.
+ ./
+ cgv2el_c ( center, vec1, vec2, &ellipse );
+ nvc2pl_c ( n, c, &plane );
+
+ /.
+ Find the intersection of the ellipse and plane.
+ nxpts is the number of intersection points; xpt1
+ and xpt2 are the points themselves.
+ ./
+ inelpl_c ( &ellipse, &plane, &nxpts, xpt1, xpt2 );
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 05-MAR-1999 (NJB)
+
+-Index_Entries
+
+ center and generating vectors to ellipse
+
+-&
+*/
+
+{ /* Begin cgv2el_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "cgv2el_c" );
+
+ /*
+ The center of the ellipse is held in the first three elements.
+ */
+ MOVED ( center, 3, ellipse->center );
+
+ /*
+ Find the semi-axes of the ellipse. These may be degenerate.
+ */
+ saelgv_c ( vec1, vec2, ellipse->semiMajor, ellipse->semiMinor );
+
+
+ chkout_c ( "cgv2el_c" );
+
+} /* End cgv2el_c */
+
diff --git a/ext/spice/src/cspice/chbase.c b/ext/spice/src/cspice/chbase.c
new file mode 100644
index 0000000000..9c0d125254
--- /dev/null
+++ b/ext/spice/src/cspice/chbase.c
@@ -0,0 +1,401 @@
+/* chbase.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CHBASE ( Character set base ) */
+integer chbase_(void)
+{
+ /* System generated locals */
+ integer ret_val;
+
+/* $ Abstract */
+
+/* Return the base value used to encode unsigned integer values */
+/* in character strings. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CONSTANTS */
+
+/* $ Declarations */
+/* None. */
+/* $ Brief_I/O */
+
+/* The function returns the base value used to encode unsigned */
+/* integer values in character strings. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* CHBASE is the base used by ENCHAR and DECHAR to encode and decode */
+/* non-negative integers to and from character strings. Its value is */
+/* determined by the size of the character set available for a given */
+/* machine and compiler. Strictly speaking, CHBASE is one more than */
+/* the biggest positive integer which can be handled by both the */
+/* CHAR and ICHAR intrinsic functions (which are used by ENCHAR and */
+/* DECHAR). That is, CHBASE is the first positive integer for which */
+/* the logical expression */
+
+/* ( ICHAR ( CHAR ( CHBASE ) ) .EQ. CHBASE ) */
+
+/* is false. */
+
+/* Note that CHBASE can be (and probably is) different from the */
+/* number of characters in the character set used by the processor. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The function always returns a constant value, set by the user */
+/* prior to compilation. */
+
+/* CHBASE should always be at least 128 (the size of the ASCII */
+/* character set), and will usually be 256 for machines which use */
+/* eight bits to represent a single character. The following list */
+/* contains the values of CHBASE for a range of environments. */
+
+/* Environment: VAX/VMS, VAX FORTRAN */
+/* Value: 256 */
+
+/* Environment: Sun, Sun FORTRAN */
+/* Value: 256 */
+
+/* Environment: PC, MS FORTRAN */
+/* Value: 256 */
+
+/* Environment: Macintosh, Language Systems FORTRAN */
+/* Value: 256 */
+
+/* Environment: PC, Lahey F77 EM/32 Version 4.0 */
+/* Value: 256 */
+
+/* Environment: HP-UX 9000/750, FORTRAN/9000 Series 700 computers */
+/* Value: 256 */
+
+/* Environment: Silicon Graphics IRIX OS, SGI FORTRAN 77 */
+/* Value: 256 */
+
+/* Environment: DEC Alpha 3000/4000, OSF/1, DEC FORTRAN-77 */
+/* Value: 256 */
+
+/* Environment: NeXT/Mach OS, Absoft Fortran */
+/* Value: 256 */
+
+/* Environment: PC/Linux, Fort77 */
+/* Value: 128 */
+
+
+/* For other machines, the value can be determined by running */
+/* the following simple program: */
+
+/* INTEGER CHBASE */
+/* DATA CHBASE / 0 / */
+
+/* DO WHILE ( .TRUE. ) */
+
+/* IF ( ICHAR (CHAR ( CHBASE ) ) .EQ. CHBASE ) THEN */
+/* CHBASE = CHBASE + 1 */
+/* ELSE */
+/* WRITE (6,*) 'CHBASE for this machine is : ', CHBASE */
+/* STOP */
+/* END IF */
+
+/* END DO */
+/* END */
+
+/* $ Examples */
+
+/* See ENCHAR, DECHAR. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* 1. "Programming in VAX FORTRAN", Digital Equipment Corporation, */
+/* September 1984, Section 8.3, page 8-6. */
+
+/* 2. "Microsoft FORTRAN Reference", Microsoft Corporation, */
+/* 1989, Section 5.1.1, page 241. */
+
+/* 3. "Language Systems FORTRAN Reference Manual", Language Systems */
+/* Corporation, version 1.2.1, page 3-20. */
+
+/* 4. "Lahey F77L EM/32 FORTRAN Language Reference Manual", page */
+/* 222, Note 20. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* H.A. Neilan (JPL) */
+/* M.J. Spencer (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.21.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL. */
+
+/* - SPICELIB Version 2.20.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL-CC_C. */
+
+/* - SPICELIB Version 2.19.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL-64BIT-CC_C. */
+
+/* - SPICELIB Version 2.18.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-64BIT-NATIVE_C. */
+
+/* - SPICELIB Version 2.17.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-WINDOWS-64BIT-IFORT. */
+
+/* - SPICELIB Version 2.16.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-LINUX-64BIT-GFORTRAN. */
+
+/* - SPICELIB Version 2.15.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-64BIT-MS_C. */
+
+/* - SPICELIB Version 2.14.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-INTEL_C. */
+
+/* - SPICELIB Version 2.13.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-IFORT. */
+
+/* - SPICELIB Version 2.12.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-GFORTRAN. */
+
+/* - SPICELIB Version 2.11.0, 18-MAR-2009 (BVS) */
+
+/* Updated for PC-LINUX-GFORTRAN. */
+
+/* - SPICELIB Version 2.10.0, 18-MAR-2009 (BVS) */
+
+/* Updated for MAC-OSX-GFORTRAN. */
+
+/* - SPICELIB Version 2.9.0, 19-FEB-2008 (BVS) */
+
+/* Updated for PC-LINUX-IFORT. */
+
+/* - SPICELIB Version 2.8.0, 14-NOV-2006 (BVS) */
+
+/* Updated for PC-LINUX-64BIT-GCC_C. */
+
+/* - SPICELIB Version 2.7.0, 14-NOV-2006 (BVS) */
+
+/* Updated for MAC-OSX-INTEL_C. */
+
+/* - SPICELIB Version 2.6.0, 14-NOV-2006 (BVS) */
+
+/* Updated for MAC-OSX-IFORT. */
+
+/* - SPICELIB Version 2.5.0, 14-NOV-2006 (BVS) */
+
+/* Updated for PC-WINDOWS-IFORT. */
+
+/* - SPICELIB Version 2.4.0, 26-OCT-2005 (BVS) */
+
+/* Updated for SUN-SOLARIS-64BIT-GCC_C. */
+
+/* - SPICELIB Version 2.3.0, 03-JAN-2005 (BVS) */
+
+/* Updated for PC-CYGWIN_C. */
+
+/* - SPICELIB Version 2.2.0, 03-JAN-2005 (BVS) */
+
+/* Updated for PC-CYGWIN. */
+
+/* - SPICELIB Version 2.1.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 2.1.0, 05-DEC-2001 (FST) */
+
+/* Updated the value for PC-LINUX environment. */
+
+/* - SPICELIB Version 2.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 2.0.3, 24-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 2.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 2.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 2.0.0, 05-APR-1998 (NJB) */
+
+/* Added reference to the PC-LINUX environment. */
+
+/* - SPICELIB Version 1.5.0, 03-NOV-1993 (HAN) */
+
+/* Module was updated to include the character base */
+/* value for the Silicon Graphics, DEC Alpha-OSF/1, and */
+/* NeXT platforms. */
+
+/* - SPICELIB Version 1.4.0, 06-OCT-1992 (HAN) */
+
+/* Module was updated to include the character base */
+/* value for the Hewlett Packard UX 9000/750 environment, */
+/* and the value for the Sun was changed from 128 to 256. */
+/* Both changes are the result of running the program in */
+/* the Particulars section of the header on both machines. */
+
+/* - SPICELIB Version 1.3.1, 10-MAR-1999 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.3.0, 13-NOV-1991 (MJS) */
+
+/* Module was updated to include the character base */
+/* value for the Lahey FORTRAN EM/32 environment (PC). */
+
+/* - SPICELIB Version 1.2.0, 07-DEC-1990 (MJS) */
+
+/* Module was updated to include the character base */
+/* value for the Macintosh. */
+
+/* - SPICELIB Version 1.1.0, 09-MAR-1990 (HAN) */
+
+/* Module was updated to include the character base */
+/* value for the Sun. Sources for the values contained */
+/* in this module are now specified in the Literature_References */
+/* section. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* base for encoding integers in character_string */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.1.0, 05-DEC-2001 (FST) */
+
+/* It was discovered that linux distributions shipping */
+/* versions of g77 derived off of gcc versions 2.96-3.00 */
+/* suffer from in implementation change in ICHAR that */
+/* requires CHBASE to change to 128. Since restricting */
+/* CHBASE to 128 has little impact on other linux */
+/* environments utilizing other versions of g77 or fort77, */
+/* we elected to make the change to all environments */
+/* rather than complicate this issue by forking a new one. */
+
+/* - SPICELIB Version 1.4.0, 06-OCT-1992 (HAN) */
+
+/* Module was updated to include the character base */
+/* value for the Hewlett Packard UX 9000/750 environment, */
+/* and the value for the Sun was changed from 128 to 256. */
+/* Both changes are the result of running the program in */
+/* the Particulars section of the header on both machines. */
+
+/* The previous Sun value was computed on the Sun3 and was */
+/* not updated when we moved to the Sun4. Everything passed */
+/* the suite of test programs that would have indicated a bug. */
+
+/* The code was also reformatted so that a utility program can */
+/* create the file for each environment. */
+
+/* - Beta Version 1.1.0, 16-FEB-1989 (HAN) (NJB) */
+
+/* Contents of the Exceptions section was changed */
+/* to "error free" to reflect the decision that the */
+/* module will never participate in error handling. */
+
+/* Missing parentheses added to CHBASE declaration. */
+
+/* -& */
+
+/* We have provided values for several popular machines. Remove */
+/* the comment character in front of the value for your machine, */
+/* or provide your own value. Numbers are provided in a variety */
+/* of formats: decimal, hex, and binary. These last two formats */
+/* are not portable; but then, neither are the values. */
+
+
+/* VAX, VAX FORTRAN */
+/* Sun, Sun FORTRAN */
+/* IBM PC, Microsoft FORTRAN, Lahey EM/32 FORTRAN */
+/* Macintosh, Language Systems FORTRAN */
+/* HP-UX 9000/750, FORTRAN/9000 Series 700 computers */
+/* Silicon Graphics, IRIX OS, SGI FORTRAN 77 */
+/* DEC Alpha, OSF/1, DEC FORTRAN-77 */
+/* NeXT, Mach OS, Absoft Fortran 77 */
+
+ ret_val = 256;
+ return ret_val;
+} /* chbase_ */
+
diff --git a/ext/spice/src/cspice/chbder.c b/ext/spice/src/cspice/chbder.c
new file mode 100644
index 0000000000..2fc07abf9d
--- /dev/null
+++ b/ext/spice/src/cspice/chbder.c
@@ -0,0 +1,389 @@
+/* chbder.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CHBDER ( Derivatives of a Chebyshev expansion ) */
+/* Subroutine */ int chbder_(doublereal *cp, integer *degp, doublereal *x2s,
+ doublereal *x, integer *nderiv, doublereal *partdp, doublereal *dpdxs)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Local variables */
+ integer i__, j;
+ doublereal s, scale, s2;
+
+/* $ Abstract */
+
+/* Given the coefficients for the Chebyshev expansion of a */
+/* polynomial, this returns the value of the polynomial and its */
+/* first NDERIV derivatives evaluated at the input X. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* INTERPOLATION, MATH, POLYNOMIAL */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* CP I NDEG+1 Chebyshev polynomial coefficients. */
+/* DEGP I Degree of polynomial. */
+/* X2S I Transformation parameters of polynomial. */
+/* X I Value for which the polynomial is to be evaluated */
+/* NDERIV I The number of derivatives to compute */
+/* PARTDP - Workspace provided for computing derivatives */
+/* DPDXS(I) O Value of the I'th derivative of the polynomial */
+
+/* $ Detailed_Input */
+
+/* CP is an array of coefficients a polynomial with respect */
+/* to the Chebyshev basis. The polynomial to be */
+/* evaluated is assumed to be of the form: */
+
+/* CP(DEGP+1)*T(DEGP,S) + CP(DEGP)*T(DEGP-1,S) + ... */
+
+/* ... + CP(2)*T(1,S) + CP(1)*T(0,S) */
+
+/* where T(I,S) is the I'th Chebyshev polynomial */
+/* evaluated at a number S whose double precision */
+/* value lies between -1 and 1. The value of S is */
+/* computed from the input variables P(1), P(2) and X. */
+
+/* DEGP is the degree of the Chebyshev polynomial to be */
+/* evaluated. */
+
+/* X2S is an array of two parameters. These parameters are */
+/* used to transform the domain of the input variable X */
+/* into the standard domain of the Chebyshev polynomial. */
+/* X2S(1) should be a reference point in the domain of */
+/* X; X2S(2) should be the radius by which points are */
+/* allowed to deviate from the reference point and while */
+/* remaining within the domain of X. The value of */
+/* X is transformed into the value S given by */
+
+/* S = ( X - X2S(1) ) / X2S(2) */
+
+/* Typically X2S(1) is the midpoint of the interval over */
+/* which X is allowed to vary and X2S(2) is the radius */
+/* of the interval. */
+
+/* The main reason for doing this is that a Chebyshev */
+/* expansion is usually fit to data over a span */
+/* from A to B where A and B are not -1 and 1 */
+/* respectively. Thus to get the "best fit" the */
+/* data was transformed to the interval [-1,1] and */
+/* coefficients generated. These coefficients are */
+/* not rescaled to the interval of the data so that */
+/* the numerical "robustness" of the Chebyshev fit will */
+/* not be lost. Consequently, when the "best fitting" */
+/* polynomial needs to be evaluated at an intermediate */
+/* point, the point of evaluation must be transformed */
+/* in the same way that the generating points were */
+/* transformed. */
+
+/* X Value for which the polynomial is to be evaluated. */
+
+/* NDERIV is the number of derivatives to be computed by the */
+/* routine. NDERIV should be non-negative. */
+
+/* PARTDP Is a work space used by the program to compute */
+/* all of the desired derivatives. It should be declared */
+/* in the calling program as */
+
+/* DOUBLE PRECISION PARTDP(3, 0:NDERIV) */
+
+/* $ Detailed_Output */
+
+/* DPDXS(0) The value of the polynomial to be evaluated. It */
+/* is given by */
+
+/* CP(DEGP+1)*T(DEGP,S) + CP(DEGP)*T(DEGP-1,S) + ... */
+
+/* ... + CP(2)*T(1,S) + CP(1)*T(0,S) */
+
+/* where T(I,S) is the I'th Chebyshev polynomial */
+/* evaluated at a number S = ( X - P(1) )/P(2) */
+
+/* DPDXS(I) The value of the I'th derivative of the polynomial at */
+/* X. (I ranges from 1 to NDERIV) It is given by */
+
+/* [i] */
+/* (1/P(2)**I) ( CP(DEGP+1)*T (DEGP,S) */
+
+/* [i] */
+/* + CP(DEGP)*T (DEGP-1,S) + ... */
+
+/* . */
+/* . */
+/* . */
+/* [i] */
+/* ... + CP(2)*T (1,S) */
+
+/* [i] */
+/* + CP(1)*T (0,S) ) */
+
+/* [i] */
+/* where T(k,S) and T (I,S) are the k'th Chebyshev */
+/* polynomial and its i'th derivative respectively, */
+/* evaluated at the number S = ( X - X2S(1) )/X2S(2). */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine computes the value of a Chebyshev polynomial */
+/* expansion and the derivatives of the expansion with respect to X. */
+/* The polynomial is given by */
+
+/* CP(DEGP+1)*T(DEGP,S) + CP(DEGP)*T(DEGP-1,S) + ... */
+
+/* ... + CP(2)*T(1,S) + CP(1)*T(0,S) */
+
+/* where */
+
+/* S = ( X - X2S(1) ) / X2S(2) */
+
+/* and */
+
+/* T(i,S) is the i'th Chebyshev polynomial of the first kind */
+/* evaluated at S. */
+
+
+/* $ Examples */
+
+/* Depending upon the user's needs, there are 3 routines available */
+/* for evaluating Chebyshev polynomials. */
+
+/* CHBVAL for evaluating a Chebyshev polynomial when no */
+/* derivatives are desired. */
+
+/* CHBINT for evaluating a Chebyshev polynomial and its */
+/* first derivative. */
+
+/* CHBDER for evaluating a Chebyshev polynomial and a user */
+/* or application dependent number of derivatives. */
+
+/* Of these 3 the one most commonly employed by NAIF software */
+/* is CHBINT as it is used to interpolate ephemeris state */
+/* vectors which requires the evaluation of a polynomial */
+/* and its derivative. When no derivatives are desired one */
+/* should use CHBVAL, or when more than one or an unknown */
+/* number of derivatives are desired one should use CHBDER. */
+
+/* The code fragment below illustrates how this routine might */
+/* be used to obtain points for plotting a polynomial */
+/* and its derivatives. */
+
+/* fetch the pieces needed for describing the polynomial */
+/* to be evaluated. */
+
+/* READ (*,*) DEGP, ( CP(I), I = 1, DEG+1 ), NDERIV, BEG, END */
+
+/* check to see that BEG is actually less than END */
+
+/* IF ( BEG .GE. END ) THEN */
+
+/* take some appropriate action */
+
+/* ELSE */
+
+/* X2S(1) = ( END + BEG ) / 2.0D0 */
+/* X2S(2) = ( END - BEG ) / 2.0D0 */
+
+/* END IF */
+
+/* STEP = END - BEG / */
+/* X = BEG */
+
+/* DO WHILE ( X .LE. END ) */
+
+/* CALL CHBDER ( CP, DEGP, X2S , X, NDERIV, PARTDP, DPDXS ) */
+
+/* do something with the pairs ( X, DPDXS(0)),(X,DPDXS(1)), */
+/* (X,DPDXS(2)) ... (X,DPDXS(NDERIV)) */
+
+/* X = X + STEP */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* The user must be sure that the provided workspace is declared */
+/* properly in the calling routine. The proper declaration is: */
+
+/* INTEGER NDERIV */
+/* PARAMETER ( NDERIV = the desired number of derivatives ) */
+/* DOUBLE PRECISION PARTDP (3, 0:NDERIV) */
+
+/* If for some reason a parameter is not passed to this routine in */
+/* NDERIV, the user should make sure that the value of NDERIV is not */
+/* so large that the work space provided is inadequate. */
+
+/* One needs to be careful that the value (X-X2S(1)) / X2S(2) lies */
+/* between -1 and 1. Otherwise, the routine may fail spectacularly */
+/* (for example with a floating point overflow). */
+
+/* While this routine will compute derivatives of the input */
+/* polynomial, the user should consider how accurately the */
+/* derivatives of the Chebyshev fit, match the derivatives of the */
+/* function it approximates. */
+
+
+
+/* $ Exceptions */
+
+/* Error free */
+
+/* No tests are performed for exceptional values ( NDERIV negative, */
+/* DEGP negative, etc.) This routine is expected to be used at a low */
+/* level in ephemeris evaluations. For that reason it has been */
+/* elected as a routine that will not participate in error handling. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Literature_References */
+
+/* "Numerical Recipes -- The Art of Scientific Computing" by */
+/* William H. Press, Brian P. Flannery, Saul A. Teukolsky, */
+/* Willam T. Vetterling. (See Clenshaw's Recurrence Formula) */
+
+/* "The Chebyshev Polynomials" by Theodore J. Rivlin */
+
+/* "CRC Handbook of Tables for Mathematics" */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* derivatives of a chebyshev expansion */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.0.1, 16-FEB-1988 (WLT) (NJB) */
+
+/* The Error free specification was added to the routine as */
+/* well as an explanation for this designation. Examples added. */
+/* Declaration of unused variable RECIP removed. */
+/* -& */
+
+/* Local variables */
+
+
+/* Transform X to S and initialize temporary variables. */
+
+ s = (*x - x2s[0]) / x2s[1];
+ s2 = s * 2.;
+ j = *degp + 1;
+ i__1 = *nderiv;
+ for (i__ = 0; i__ <= i__1; ++i__) {
+ partdp[i__ * 3] = 0.;
+ partdp[i__ * 3 + 1] = 0.;
+ }
+
+/* Evaluate the polynomial ... */
+
+ while(j > 1) {
+ partdp[2] = partdp[1];
+ partdp[1] = partdp[0];
+ partdp[0] = cp[j - 1] + (s2 * partdp[1] - partdp[2]);
+
+/* ... and its derivatives using recursion. */
+
+ scale = 2.;
+ i__1 = *nderiv;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ partdp[i__ * 3 + 2] = partdp[i__ * 3 + 1];
+ partdp[i__ * 3 + 1] = partdp[i__ * 3];
+ partdp[i__ * 3] = partdp[(i__ - 1) * 3 + 1] * scale + partdp[i__ *
+ 3 + 1] * s2 - partdp[i__ * 3 + 2];
+ scale += 2.;
+ }
+ --j;
+ }
+ dpdxs[0] = cp[0] + (s * partdp[0] - partdp[1]);
+ scale = 1.;
+ i__1 = *nderiv;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dpdxs[i__] = partdp[(i__ - 1) * 3] * scale + partdp[i__ * 3] * s -
+ partdp[i__ * 3 + 1];
+ scale += 1;
+ }
+
+/* Scale the k'th derivative w.r.t S by (1/X2S(2)**k) so that we have */
+/* the derivatives */
+
+/* 2 3 4 5 */
+/* d P(S) d P(S) d P(S) d P(S) d P(S) */
+/* ------ ------ ------ ------ ------ */
+/* 2 3 4 5 */
+/* dX dX dX dX dX */
+
+
+/* NOTE: In the loop that follows we perform division instead of */
+/* multiplying by reciprocals so that the algorithm matches */
+/* CHBINT. If multiplication by reciprocals is performed */
+/* CHBINT and CHBDER (although mathematically equivalent) will */
+/* not produce identical results for the first derivative. */
+
+
+ scale = x2s[1];
+ i__1 = *nderiv;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dpdxs[i__] /= scale;
+ scale = x2s[1] * scale;
+ }
+ return 0;
+} /* chbder_ */
+
diff --git a/ext/spice/src/cspice/chbint.c b/ext/spice/src/cspice/chbint.c
new file mode 100644
index 0000000000..0895394abd
--- /dev/null
+++ b/ext/spice/src/cspice/chbint.c
@@ -0,0 +1,315 @@
+/* chbint.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CHBINT ( Interpolate a Chebyshev expansion ) */
+/* Subroutine */ int chbint_(doublereal *cp, integer *degp, doublereal *x2s,
+ doublereal *x, doublereal *p, doublereal *dpdx)
+{
+ integer j;
+ doublereal s, w[3], s2, dw[3];
+
+/* $ Abstract */
+
+/* Given the coefficients for the Chebyshev expansion of a */
+/* polynomial, this returns the value of the polynomial and its */
+/* derivative evaluated at the input X. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* INTERPOLATION, MATH, POLYNOMIAL */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* CP I NDEG+1 Chebyshev polynomial coefficients. */
+/* DEGP I Degree of polynomial. */
+/* X2S I Transformation parameters of polynomial. */
+/* X I Value for which the polynomial is to be evaluated */
+/* P O Value of the polynomial at X */
+/* DPDX O Value of the derivative of the polynomial at X */
+
+/* $ Detailed_Input */
+
+/* CP is an array of coefficients OF a polynomial with */
+/* respect to the Chebyshev basis. The polynomial to be */
+/* evaluated is assumed to be of the form: */
+
+/* CP(DEGP+1)*T(DEGP,S) + CP(DEGP)*T(DEGP-1,S) + ... */
+
+/* ... + CP(2)*T(1,S) + CP(1)*T(0,S) */
+
+/* where T(I,S) is the I'th Chebyshev polynomial */
+/* evaluated at a number S whose double precision */
+/* value lies between -1 and 1. The value of S is */
+/* computed from the input variables X2S(1), X2S(2) and X */
+
+/* DEGP is the degree of the Chebyshev polynomial to be */
+/* evaluated. */
+
+/* X2S is an array of two parameters. These parameters are */
+/* used to transform the domain of the input variable X */
+/* into the standard domain of the Chebyshev polynomial. */
+/* X2S(1) should be a reference point in the domain of X; */
+/* X2S(2) should be the radius by which points are */
+/* allowed to deviate from the reference point and while */
+/* remaining within the domain of X. The value of */
+/* X is transformed into the value S given by */
+
+/* S = ( X - X2S(1) ) / X2S(2) */
+
+/* Typically X2S(1) is the midpoint of the interval over */
+/* which X is allowed to vary and X2S(2) is the radius of */
+/* the interval. */
+
+/* The main reason for doing this is that a Chebyshev */
+/* expansion is usually fit to data over a span */
+/* from A to B where A and B are not -1 and 1 */
+/* respectively. Thus to get the "best fit" the */
+/* data was transformed to the interval [-1,1] and */
+/* coefficients generated. These coefficients are */
+/* not rescaled to the interval of the data so that */
+/* the numerical "robustness" of the Chebyshev fit will */
+/* not be lost. Consequently, when the "best fitting" */
+/* polynomial needs to be evaluated at an intermediate */
+/* point, the point of evaluation must be transformed */
+/* in the same way that the generating points were */
+/* transformed. */
+
+/* X Value for which the polynomial is to be evaluated. */
+
+/* $ Detailed_Output */
+
+/* P is the value of the polynomial to be evaluated. It */
+/* is given by */
+
+/* CP(DEGP+1)*T(DEGP,S) + CP(DEGP)*T(DEGP-1,S) + ... */
+
+/* ... + CP(2)*T(1,S) + CP(1)*T(0,S) */
+
+/* where T(I,S) is the I'th Chebyshev polynomial */
+/* evaluated at a number S = ( X - X2S(1) )/X2S(2) */
+
+/* DPDX is the value of the derivative of the polynomial at X. */
+/* It is given by */
+
+/* 1/X2S(2) [ CP(DEGP+1)*T'(DEGP,S) */
+/* + CP(DEGP)*T'(DEGP-1,S) + ... */
+/* . */
+/* . */
+/* . */
+/* ... + CP(2)*T'(1,S) */
+/* + CP(1)*T'(0,S) ] */
+
+/* where T(I,S) and T'(I,S) are the I'th Chebyshev */
+/* polynomial and its derivative, respectively, */
+/* evaluated at a number S = ( X - X2S(1) )/X2S(2) */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine computes the value of a Chebyshev polynomial */
+/* expansion and the derivative of the expansion with respect to X. */
+/* The polynomial is given by */
+
+/* CP(DEGP+1)*T(DEGP,S) + CP(DEGP)*T(DEGP-1,S) + ... */
+
+/* ... + CP(2)*T(1,S) + CP(1)*T(0,S) */
+
+/* where */
+
+/* S = ( X - X2S(1) ) / X2S(2) */
+
+/* and */
+
+/* T(i,S) is the i'th Chebyshev polynomial of the first kind */
+/* evaluated at S. */
+
+/* $ Examples */
+
+
+/* Depending upon the user's needs, there are 3 routines available */
+/* for evaluating Chebyshev polynomials. */
+
+/* CHBVAL for evaluating a Chebyshev polynomial when no */
+/* derivatives are desired. */
+
+/* CHBINT for evaluating a Chebyshev polynomial and its */
+/* first derivative. */
+
+/* CHBDER for evaluating a Chebyshev polynomial and a user */
+/* or application dependent number of derivatives. */
+
+/* Of these 3 the one most commonly employed by NAIF software */
+/* is CHBINT as it is used to interpolate ephemeris state */
+/* vectors which requires the evaluation of a polynomial */
+/* and its derivative. When no derivatives are desired one */
+/* should use CHBVAL, or when more than one or an unknown */
+/* number of derivatives are desired one should use CHBDER. */
+
+/* The code fragment below illustrates how this routine might */
+/* be used to obtain points for plotting a polynomial */
+/* and its derivatives. */
+
+/* fetch the pieces needed for describing the polynomial */
+/* to be evaluated. */
+
+/* READ (*,*) DEGP, ( CP(I), I = 1, DEG+1 ), BEG, END */
+
+/* check to see that BEG is actually less than END */
+
+/* IF ( BEG .GE. END ) THEN */
+
+/* take some appropriate action */
+
+/* ELSE */
+
+/* X2S(1) = ( END + BEG ) / 2.0D0 */
+/* X2S(2) = ( END - BEG ) / 2.0D0 */
+
+/* END IF */
+
+/* STEP = END - BEG / */
+/* X = BEG */
+
+/* DO WHILE ( X .LE. END ) */
+
+/* CALL CHBINT ( CP, DEGP, X2S, X, P, DPDX ) */
+
+/* do something with the pairs (X,P) and (X,DPDX) */
+
+/* X = X + STEP */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* One needs to be careful that the value (X-X2S(1)) / X2S(2) lies */
+/* between -1 and 1. Otherwise, the routine may fail spectacularly */
+/* (for example with a floating point overflow). */
+
+/* $ Exceptions */
+
+/* Error free */
+
+/* No tests are performed for exceptional values (DEGP negative, */
+/* etc.) This routine is expected to be used at a low level in */
+/* ephemeris evaluations. For that reason it has been elected as a */
+/* routine that will not participate in error handling. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Literature_References */
+
+/* "Numerical Recipes -- The Art of Scientific Computing" by */
+/* William H. Press, Brian P. Flannery, Saul A. Teukolsky, */
+/* Willam T. Vetterling. (See Clenshaw's Recurrance Formula) */
+
+/* "The Chebyshev Polynomials" by Theodore J. Rivlin */
+
+/* "CRC Handbook of Tables for Mathematics" */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* interpolate a chebyshev expansion */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.0.1, 30-DEC-1988 (WLT) */
+
+/* The Error free specification was added to the routine as */
+/* well as an explanation for this designation. Examples added. */
+
+/* -& */
+
+/* Local variables */
+
+
+/* Transform X to S and initialize temporary variables. */
+
+ s = (*x - x2s[0]) / x2s[1];
+ s2 = s * 2.;
+ j = *degp + 1;
+ w[0] = 0.;
+ w[1] = 0.;
+ dw[0] = 0.;
+ dw[1] = 0.;
+
+/* Evaluate the polynomial and its derivative using recursion. */
+
+ while(j > 1) {
+ w[2] = w[1];
+ w[1] = w[0];
+ w[0] = cp[j - 1] + (s2 * w[1] - w[2]);
+ dw[2] = dw[1];
+ dw[1] = dw[0];
+ dw[0] = w[1] * 2. + dw[1] * s2 - dw[2];
+ --j;
+ }
+ *p = cp[0] + (s * w[0] - w[1]);
+ *dpdx = w[0] + s * dw[0] - dw[1];
+
+/* Scale the derivative by 1/X2S(2) so that we have the derivative */
+
+/* d P(S) */
+/* ------ */
+/* dX */
+
+ *dpdx /= x2s[1];
+ return 0;
+} /* chbint_ */
+
diff --git a/ext/spice/src/cspice/chbval.c b/ext/spice/src/cspice/chbval.c
new file mode 100644
index 0000000000..a16b684dc3
--- /dev/null
+++ b/ext/spice/src/cspice/chbval.c
@@ -0,0 +1,285 @@
+/* chbval.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CHBVAL ( Value of a Chebsheff polynomial expansion ) */
+/* Subroutine */ int chbval_(doublereal *cp, integer *degp, doublereal *x2s,
+ doublereal *x, doublereal *p)
+{
+ integer j;
+ doublereal s, w[3], s2;
+
+/* $ Abstract */
+
+/* Given the coefficients for the Chebyshev expansion of a */
+/* polynomial, this returns the value of the polynomial evaluated */
+/* at the input X. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* INTERPOLATION, MATH, POLYNOMIAL */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* CP I NDEG+1 Chebyshev polynomial coefficients. */
+/* DEGP I Degree of polynomial. */
+/* X2S I Transformation parameters of polynomial. */
+/* X I Value for which the polynomial is to be evaluated */
+/* P O Value of the polynomial at X. */
+
+/* $ Detailed_Input */
+
+/* CP is an array of coefficients a polynomial with respect */
+/* to the Chebyshev basis. The polynomial to be */
+/* evaluated is assumed to be of the form: */
+
+/* CP(DEGP+1)*T(DEGP,S) + CP(DEGP)*T(DEGP-1,S) + ... */
+
+/* ... + CP(2)*T(1,S) + CP(1)*T(0,S) */
+
+/* where T(I,S) is the I'th Chebyshev polynomial */
+/* evaluated at a number S whose double precision */
+/* value lies between -1 and 1. The value of S is */
+/* computed from the input variables X2S(1), X2S(2) */
+/* and X. */
+
+/* DEGP is the degree of the Chebyshev polynomial to be */
+/* evaluated. */
+
+/* X2S is an array of two parameters. These parameters are */
+/* used to transform the domain of the input variable X */
+/* into the standard domain of the Chebyshev polynomial. */
+/* X2S(1) should be a reference point in the domain of X; */
+/* X2S(2) should be the radius by which points are */
+/* allowed to deviate from the reference point and while */
+/* remaining within the domain of X. The value of */
+/* X is transformed into the value S given by */
+
+/* S = ( X - X2S(1) ) / X2S(2) */
+
+/* Typically X2S(1) is the midpoint of the interval over */
+/* which X is allowed to vary and X2S(2) is the radius of */
+/* the interval. */
+
+/* The main reason for doing this is that a Chebyshev */
+/* expansion is usually fit to data over a span */
+/* from A to B where A and B are not -1 and 1 */
+/* respectively. Thus to get the "best fit" the */
+/* data was transformed to the interval [-1,1] and */
+/* coefficients generated. These coefficients are */
+/* not rescaled to the interval of the data so that */
+/* the numerical "robustness" of the Chebyshev fit will */
+/* not be lost. Consequently, when the "best fitting" */
+/* polynomial needs to be evaluated at an intermediate */
+/* point, the point of evaluation must be transformed */
+/* in the same way that the generating points were */
+/* transformed. */
+
+/* X Value for which the polynomial is to be evaluated. */
+
+/* $ Detailed_Output */
+
+/* P The value of the polynomial to be evaluated. It */
+/* is given by */
+
+/* CP(DEGP+1)*T(DEGP,S) + CP(DEGP)*T(DEGP-1,S) + ... */
+
+/* ... + CP(2)*T(1,S) + CP(1)*T(0,S) */
+
+/* where T(I,S) is the I'th Chebyshev polynomial */
+/* evaluated at a number S = ( X - X2S(1) )/X2S(2) */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine computes the value P given by */
+
+/* CP(DEGP+1)*T(DEGP,S) + CP(DEGP)*T(DEGP-1,S) + ... */
+
+/* ... + CP(2)*T(1,S) + CP(1)*T(0,S) */
+
+/* where */
+
+/* S = ( X - X2S(1) ) / X2S(2) */
+
+/* and */
+
+/* T(i,S) is the i'th Chebyshev polynomial of the first kind */
+/* evaluated at S. */
+
+/* $ Examples */
+
+
+/* Depending upon the user's needs, there are 3 routines available */
+/* for evaluating Chebyshev polynomials. */
+
+/* CHBVAL for evaluating a Chebyshev polynomial when no */
+/* derivatives are desired. */
+
+/* CHBINT for evaluating a Chebyshev polynomial and its */
+/* first derivative. */
+
+/* CHBDER for evaluating a Chebyshev polynomial and a user */
+/* or application dependent number of derivatives. */
+
+/* Of these 3 the one most commonly employed by NAIF software */
+/* is CHBINT as it is used to interpolate ephemeris state */
+/* vectors which requires the evaluation of a polynomial */
+/* and its derivative. When no derivatives are desired one */
+/* should use CHBVAL, or when more than one or an unknown */
+/* number of derivatives are desired one should use CHBDER. */
+
+/* The code fragment below illustrates how this routine might */
+/* be used to obtain points for plotting a polynomial. */
+
+/* fetch the pieces needed for describing the polynomial */
+/* to be evaluated. */
+
+/* READ (*,*) DEGP, ( CP(I), I = 1, DEG+1 ), BEG, END */
+
+/* check to see that BEG is actually less than END */
+
+/* IF ( BEG .GE. END ) THEN */
+
+/* take some appropriate action */
+
+/* ELSE */
+
+/* X2S(1) = ( END + BEG ) / 2.0D0 */
+/* X2S(2) = ( END - BEG ) / 2.0D0 */
+
+/* END IF */
+
+/* STEP = END - BEG / */
+/* X = BEG */
+
+/* DO WHILE ( X .LE. END ) */
+
+/* CALL CHBVAL ( CP, DEGP, X2S, X, P ) */
+
+/* do something with the pair (X,P) */
+
+/* X = X + STEP */
+
+/* END DO */
+
+
+/* $ Restrictions */
+
+/* One needs to be careful that the value (X-X2S(1)) / X2S(2) lies */
+/* between -1 and 1. Otherwise, the routine may fail spectacularly */
+/* (for example with a floating point overflow). */
+
+/* $ Exceptions */
+
+/* Error free */
+
+/* No tests are performed for exceptional values (DEGP negative, */
+/* etc.) This routine is expected to be used at a low level in */
+/* ephemeris evaluations. For that reason it has been elected as a */
+/* routine that will not participate in error handling. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.M. Owen (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Literature_References */
+
+/* "Numerical Recipes -- The Art of Scientific Computing" by */
+/* William H. Press, Brian P. Flannery, Saul A. Teukolsky, */
+/* Willam T. Vetterling. */
+
+/* "The Chebyshev Polynomials" by Theodore J. Rivlin */
+
+/* "CRC Handbook of Tables for Mathematics" */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WMO) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* value of a chebyshev polynomial expansion */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.0.1, 30-DEC-1988 (WLT) */
+
+/* The Error free specification was added to the routine as */
+/* well as an explanation for this designation. Examples added. */
+
+/* -& */
+
+/* Local variables */
+
+
+/* Transform X to S and initialize temporary variables. */
+
+ s = (*x - x2s[0]) / x2s[1];
+ s2 = s * 2.;
+ j = *degp + 1;
+ w[0] = 0.;
+ w[1] = 0.;
+
+/* Evaluate the polynomial using recursion. */
+
+ while(j > 1) {
+ w[2] = w[1];
+ w[1] = w[0];
+ w[0] = cp[j - 1] + (s2 * w[1] - w[2]);
+ --j;
+ }
+ *p = s * w[0] - w[1] + cp[0];
+ return 0;
+} /* chbval_ */
+
diff --git a/ext/spice/src/cspice/chckid.c b/ext/spice/src/cspice/chckid.c
new file mode 100644
index 0000000000..841c5645dd
--- /dev/null
+++ b/ext/spice/src/cspice/chckid.c
@@ -0,0 +1,276 @@
+/* chckid.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CHCKID ( Check ID string ) */
+/* Subroutine */ int chckid_(char *class__, integer *maxlen, char *id, ftnlen
+ class_len, ftnlen id_len)
+{
+ /* Builtin functions */
+ integer s_cmp(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer i__, l;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen);
+ integer chrcod;
+ extern integer lastnb_(char *, ftnlen);
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern integer frstnp_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Validate an ID string: check for non-printing characters */
+/* or excessive non-blank length. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* STRING */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* CLASS I A description of the class to which ID belongs. */
+/* MAXLEN I Maximum allowed non-blank length of ID. */
+/* ID I The ID string to be validated. */
+
+/* $ Detailed_Input */
+
+/* CLASS is a descriptive string indicating the type of */
+/* object represented by ID. Examples are */
+/* 'SPK segment identifier', 'DAF internal file name', */
+/* or 'EK table name'. */
+
+/* If the input ID is found to be invalid, CLASS is */
+/* used in the error message generated by this */
+/* routine. */
+
+/* MAXLEN is the maximum allowed non-blank length of the */
+/* input ID string. If ID has any non-blank */
+/* characters at positions greater than MAXLEN, */
+/* an error will be signalled. */
+
+/* ID is the input ID string to be checked. In order */
+/* to be considered valid, ID must contain only */
+/* printing characters and must satisfy the condition */
+
+/* LASTNB( ID ) < MAXLEN */
+/* - */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the effect of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If ID contains any nonprintable characters, the error */
+/* SPICE(NONPRINTABLECHARS) is signalled. */
+
+/* 2) If MAXLEN is non-positive, the error SPICE(INVALIDCOUNT) is */
+/* signalled. */
+
+/* 3) If ID contains any non-blank characters past position */
+/* MAXLEN, the error SPICE(IDSTRINGTOOLONG) is signalled. */
+
+/* 4) If CLASS contains any non-printing characters, the error */
+/* SPICE(NONPRINTABLECHARS) is signalled. */
+
+/* 5) CLASS is allowed to be blank. The word 'ID' is used in */
+/* place of the class string in any error messages in this */
+/* case. */
+
+/* 6) Error messages signalled by this routine have a maximum */
+/* length of 320 characters. If substitution of CLASS and */
+/* ID into the long messages causes overflow, the messages */
+/* will be truncated on the right. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine operates by side effects: it validates an ID string */
+/* and signals an error if the ID has either of the following */
+/* problems: */
+
+/* - There are non-printing characters in the ID string. */
+
+/* - The last non-blank character in the string occurs at a */
+/* location having index higher than a specified value. */
+
+/* The error message signalled by this routine contains the offending */
+/* ID string and indicates the class of item to which ID belongs. */
+/* The form of the message is: */
+
+/* The <'ID'> is invalid; */
+
+/* $ Examples */
+
+/* 1) If */
+
+/* CLASS = 'segment identifier' */
+/* MAXLEN = 40 */
+
+/* and */
+
+/* ID = 'Example EK created on March 28, 1995 by NJB/NAIF' */
+
+/* the error message */
+
+/* The segment identifier 'Example EK created on March 28, */
+/* 1995 by NJB/NAIF' is invalid; the last non-blank character */
+/* is located at position 48. */
+
+/* will be signalled. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 16-JUN-1995 (NJB) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* check an ID string */
+/* validate an ID string */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CHCKID", (ftnlen)6);
+ }
+
+/* Check CLASS before trying to use it in an error message. */
+
+ i__ = frstnp_(class__, class_len);
+ if (i__ > 0) {
+ chrcod = *(unsigned char *)&class__[i__ - 1];
+ setmsg_("The class string '#' is invalid; this string contains a non"
+ "-printing character (ICHAR = #) at position #.", (ftnlen)105);
+ errch_("#", class__, (ftnlen)1, class_len);
+ errint_("#", &chrcod, (ftnlen)1);
+ errint_("#", &i__, (ftnlen)1);
+ sigerr_("SPICE(NONPRINTABLECHARS)", (ftnlen)24);
+ chkout_("CHCKID", (ftnlen)6);
+ return 0;
+ }
+
+/* MAXLEN must be a sensible value. */
+
+ if (*maxlen < 1) {
+ setmsg_("Non-blank length limit MAXLEN should be positive but was #.",
+ (ftnlen)59);
+ errint_("#", maxlen, (ftnlen)1);
+ sigerr_("SPICE(INVALIDCOUNT)", (ftnlen)19);
+ chkout_("CHCKID", (ftnlen)6);
+ return 0;
+ }
+ l = lastnb_(id, id_len);
+
+/* The ID must not be too long. */
+
+ if (l > *maxlen) {
+ setmsg_("The # '#' is invalid; the last non-blank character is locat"
+ "ed at position #; the maximum allowed length is #.", (ftnlen)
+ 109);
+ if (s_cmp(class__, " ", class_len, (ftnlen)1) != 0) {
+ errch_("#", class__, (ftnlen)1, class_len);
+ } else {
+ errch_("#", "ID", (ftnlen)1, (ftnlen)2);
+ }
+ errch_("#", id, (ftnlen)1, id_len);
+ errint_("#", &l, (ftnlen)1);
+ errint_("#", maxlen, (ftnlen)1);
+ sigerr_("SPICE(IDSTRINGTOOLONG)", (ftnlen)22);
+ chkout_("CHCKID", (ftnlen)6);
+ return 0;
+ }
+
+/* Look for non-printing characters in ID. */
+
+ i__ = frstnp_(id, id_len);
+ if (i__ > 0) {
+ chrcod = *(unsigned char *)&id[i__ - 1];
+ setmsg_("The # '#' is invalid; this string contains a non-printing c"
+ "haracter (ICHAR = #) at position #.", (ftnlen)94);
+ if (s_cmp(class__, " ", class_len, (ftnlen)1) != 0) {
+ errch_("#", class__, (ftnlen)1, class_len);
+ } else {
+ errch_("#", "ID", (ftnlen)1, (ftnlen)2);
+ }
+ errch_("#", id, (ftnlen)1, id_len);
+ errint_("#", &chrcod, (ftnlen)1);
+ errint_("#", &i__, (ftnlen)1);
+ sigerr_("SPICE(NONPRINTABLECHARS)", (ftnlen)24);
+ chkout_("CHCKID", (ftnlen)6);
+ return 0;
+ }
+ chkout_("CHCKID", (ftnlen)6);
+ return 0;
+} /* chckid_ */
+
diff --git a/ext/spice/src/cspice/chgirf.c b/ext/spice/src/cspice/chgirf.c
new file mode 100644
index 0000000000..3de395f92f
--- /dev/null
+++ b/ext/spice/src/cspice/chgirf.c
@@ -0,0 +1,1601 @@
+/* chgirf.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static doublereal c_b6 = 0.;
+static integer c__1 = 1;
+static integer c__9 = 9;
+static integer c__21 = 21;
+
+/* $Procedure CHGIRF ( Change inertial reference frames ) */
+/* Subroutine */ int chgirf_0_(int n__, integer *refa, integer *refb,
+ doublereal *rotab, char *name__, integer *index, ftnlen name_len)
+{
+ /* Initialized data */
+
+ static logical ready = FALSE_;
+ static char frames[16*21] = "J2000 " "B1950 " "FK4 "
+ " " "DE-118 " "DE-96 " "DE-102 "
+ " " "DE-108 " "DE-111 " "DE-114 "
+ "DE-122 " "DE-125 " "DE-130 " "GALACT"
+ "IC " "DE-200 " "DE-202 " "MARSIAU "
+ " " "ECLIPJ2000 " "ECLIPB1950 " "DE-140 "
+ "DE-142 " "DE-143 ";
+ static char bases[16*21] = "J2000 " "J2000 " "B1950 "
+ " " "B1950 " "B1950 " "B1950 "
+ " " "B1950 " "B1950 " "B1950 "
+ "B1950 " "B1950 " "B1950 " "FK4 "
+ " " "J2000 " "J2000 " "J2000 "
+ " " "J2000 " "B1950 " "J2000 "
+ "J2000 " "J2000 ";
+ static char defs[80*21] = "0.0 1 "
+ " " "1152.84248596724 3 -1002."
+ "26108439117 2 1153.04066200330 3 " "0.525 "
+ "3 "
+ " " "0.53155 3 "
+ " " "0.4107 3 "
+ " " "0.1359 3 "
+ " "
+ " " "0.4775 3 "
+ " " "0.5880 3 "
+ " " "0.5529 3 "
+ " "
+ "0.5316 3 "
+ " " "0.5754 3 "
+ " " "0.5247 3 "
+ " " "117720"
+ "0.0 3 225360.0 1 1016100.0 3 "
+ " " "0.0 3 "
+ " " "0.0 3 "
+ " " "324000.0D0 3 "
+ "133610.4D0 2 -152348.4D0 3 "
+ " " "84381.448 1 "
+ " " "84404.836 1 "
+ " " "1152.71013777252 3 "
+ "-1002.25042010533 2 1153.75719544491 3 "
+ "1152.72061453864 3 -1002.25052830351 2 1153.74663857521 3 "
+ " " "1153.03919093833, 3, -1002.24822382286, 2, 1"
+ "153.42900222357, 3 ";
+ static integer dframe = 0;
+
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ static integer axis;
+ static char word[25];
+ extern /* Subroutine */ int mxmt_(doublereal *, doublereal *, doublereal *
+ );
+ static integer b, i__, j, p;
+ static doublereal angle;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), moved_(doublereal *,
+ integer *, doublereal *);
+ extern integer wdcnt_(char *, ftnlen);
+ extern /* Subroutine */ int nthwd_(char *, integer *, char *, integer *,
+ ftnlen, ftnlen);
+ static doublereal trans[189] /* was [9][21] */;
+ static char error[25];
+ extern logical eqstr_(char *, char *, ftnlen, ftnlen);
+ static doublereal radang;
+ extern integer esrchc_(char *, integer *, char *, ftnlen, ftnlen),
+ isrchc_(char *, integer *, char *, ftnlen, ftnlen);
+ extern /* Subroutine */ int nparsd_(char *, doublereal *, char *, integer
+ *, ftnlen, ftnlen), sigerr_(char *, ftnlen), nparsi_(char *,
+ integer *, char *, integer *, ftnlen, ftnlen), chkout_(char *,
+ ftnlen), rotate_(doublereal *, integer *, doublereal *);
+ static doublereal tmpmat[9] /* was [3][3] */;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen), rotmat_(doublereal *, doublereal *, integer *,
+ doublereal *), convrt_(doublereal *, char *, char *, doublereal *
+ , ftnlen, ftnlen);
+ extern logical return_(void);
+ static integer loc;
+ extern /* Subroutine */ int mxm_(doublereal *, doublereal *, doublereal *)
+ ;
+
+/* $ Abstract */
+
+/* Support changes among a standard set of inertial coordinate */
+/* reference frames. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* FRAMES */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* COORDINATES */
+/* EPHEMERIS */
+/* FRAMES */
+/* MATRIX */
+/* ROTATION */
+/* TRANSFORMATION */
+/* VECTOR */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* This file contains the number of inertial reference */
+/* frames that are currently known by the SPICE toolkit */
+/* software. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* FRAMES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* NINERT P Number of known inertial reference frames. */
+
+/* $ Parameters */
+
+/* NINERT is the number of recognized inertial reference */
+/* frames. This value is needed by both CHGIRF */
+/* ZZFDAT, and FRAMEX. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 10-OCT-1996 (WLT) */
+
+/* -& */
+/* $ Brief_I/O */
+
+/* Variable I/O Entry */
+/* -------- --- -------------------------------------------------- */
+/* REFA I IRFROT */
+/* REFB I IRFROT */
+/* ROTAB O IRFROT */
+/* NAME I/O IRFNUM, IRFNAM, IRFDEF */
+/* INDEX I/O IRFNUM, IRFNAM */
+
+/* $ Detailed_Input */
+
+/* See entry points IRFROT, IRFNUM, IRFNAM, and IRFDEF. */
+
+/* $ Detailed_Output */
+
+/* See entry points IRFROT, IRFNUM, and IRFNAM. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If CHGIRF is called directly, the signal SPICE(BOGUSENTRY) */
+/* is signalled. */
+
+/* 2) See entry points IRFROT, IRFNUM, IRFNAM, and IRFDEF for */
+/* exceptions specific to those routines. */
+
+/* $ Particulars */
+
+/* CHGIRF exists only as an umbrella for data to be shared */
+/* by its entry points (IRFROT, IRFNUM, IRFNAM, and IRFDEF). */
+/* It should never be called directly. */
+
+/* $ Examples */
+
+/* See entry points IRFROT, IRFNUM, IRFNAM, and IRFDEF. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* [1] Jay Lieske, ``Precession Matrix Based on IAU (1976) */
+/* System of Astronomical Constants,'' Astron. Astrophys. */
+/* 73, 282-284 (1979). */
+
+/* [2] E.M. Standish, Jr., ``Orientation of the JPL Ephemerides, */
+/* DE 200/LE 200, to the Dynamical Equinox of J2000,'' */
+/* Astron. Astrophys. 114, 297-302 (1982). */
+
+/* [3] E.M. Standish, Jr., ``Conversion of Ephemeris Coordinates */
+/* from the B1950 System to the J2000 System,'' JPL IOM */
+/* 314.6-581, 24 June 1985. */
+
+/* [4] E.M. Standish, Jr., ``The Equinox Offsets of the JPL */
+/* Ephemeris,'' JPL IOM 314.6-929, 26 February 1988. */
+
+/* [5] Jay Lieske, ``Expressions for the Precession Quantities */
+/* Based upon the IAU (1976) System of Astronomical */
+/* Constants'' Astron. Astrophys. 58, 1-16 (1977). */
+
+/* [6] Laura Bass and Robert Cesarone "Mars Observer Planetary */
+/* Constants and Models" JPL D-3444 November 1990. */
+
+/* [7] "Explanatory Supplement to the Astronomical Almanac" */
+/* edited by P. Kenneth Seidelmann. University Science */
+/* Books, 20 Edgehill Road, Mill Valley, CA 94941 (1992) */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.3.0, 25-AUG-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in CONVRT, ROTMAT and MXM calls. */
+
+/* - SPICELIB Version 4.2.1, 04-JAN-2002 (EDW) */
+
+/* Added DE-143 to header description for IRFROT. */
+
+/* - SPICELIB Version 4.2.0, 10-APR-1997 (WLT) */
+
+/* A descriptive diagnostic was added to the entry points */
+/* IRFROT and IRFDEF. Before they simply signalled the error */
+/* with no diagnostic. */
+
+/* - SPICELIB Version 4.1.0, 14-OCT-1996 (WLT) */
+
+/* The number of inertial frames recognized is now stored */
+/* in the include file ninert.inc. */
+
+/* - SPICELIB Version 4.0.0, 20-MAY-1996 (WLT) */
+
+/* The inertial frame DE-143 was added to the list of recognized */
+/* inertial frames. */
+
+/* - SPICELIB Version 3.0.0, 20-MAR-1995 (WLT) */
+
+/* The inertial frames DE-140 and DE-142 were added to the */
+/* list of recognized inertial frames. */
+
+/* - SPICELIB Version 2.0.0, 30-JUL-1993 (WLT) */
+
+/* The transformation from J2000 to B1950 was upgraded */
+/* so that the transformation matrix produced matches */
+/* the matrix given in [1]. */
+
+/* The frame MARSIAU was added to the list */
+/* of recognized frames. This is the standard mars */
+/* referenced inertial frame used by the Mars Observer */
+/* project. */
+
+/* Values for the obliquity of the ecliptic were taken */
+/* from the Explanatory Supplement [7] to the Astronomical */
+/* Almanac (1992) at both the epochs J2000 and B1950 and */
+/* used to define the mean ecliptic and equinox frames */
+/* ECLIPJ2000 and ECLIPB1950. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* change inertial reference frames */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 4.3.0, 25-AUG-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in CONVRT, ROTMAT and MXM calls. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+
+/* Each frame is defined in terms of another frame, except for */
+/* the root frame, which is defined in terms of itself. For now, */
+/* the root frame is the standard IAU reference frame, J2000, */
+/* defined by the Earth mean equator and dynamical equinox of */
+/* Julian year 2000. */
+
+/* Each definition consists of a series of rotations, each */
+/* through some angle (in arc seconds) and about some axis. */
+/* The rotations are listed in the opposite order in which */
+/* they are to be performed, so as to correspond more closely */
+/* to conventional notation. For example, the definition */
+
+/* FRAMES(i) = 'F2' */
+/* BASES(i) = 'F1' */
+/* DEFS(i) = '22.34 3 31.21 2 0.449 1' */
+
+/* means that a vector in frame F1 is converted to the equivalent */
+/* vector in frame F2 by applying the following rotation: */
+
+/* - - */
+/* v = ( [ 22.34 ] [ 31.21 ] [ 0.449 ] ) v */
+/* F2 3 2 1 F1 */
+
+/* where the notation */
+
+/* [ theta ] */
+/* a */
+
+/* means ``rotate through angle theta about axis a.'' */
+
+/* New frames may be added by: */
+
+/* 1) Increasing the value of MAXF. */
+
+/* 2) Adding new values for FRAMES, BASES, and DEFS. */
+
+/* The actual transformations (TRANS) will be computed during */
+/* initialization. */
+
+/* Note that BASES must be the name of a previously defined */
+/* reference frame, and that no frame should appear more than */
+/* once in FRAMES. */
+
+/* Note also that the list of valid reference frames maintained */
+/* by CHGIRF must be updated whenever new frames are added. */
+
+ /* Parameter adjustments */
+ if (rotab) {
+ }
+
+ /* Function Body */
+ switch(n__) {
+ case 1: goto L_irfrot;
+ case 2: goto L_irfnum;
+ case 3: goto L_irfnam;
+ case 4: goto L_irfdef;
+ }
+
+
+/* The root frame is mostly for show. Rotate by 0 arc seconds */
+/* about the x-axis to obtain the identity matrix. */
+
+
+/* The B1950 reference frame is obtained by precessing the J2000 */
+/* frame backwards from Julian year 2000 to Besselian year 1950, */
+/* using the 1976 IAU precession model. */
+
+/* The rotation from B1950 to J2000 is */
+
+/* [ -z ] [ theta ] [ -zeta ] */
+/* 3 2 3 */
+
+/* So the rotation from J2000 to B1950 is the transpose, */
+
+/* [ zeta ] [ -theta ] [ z ] */
+/* 3 2 3 */
+
+/* The values for z, theta, and zeta are taken directly from */
+/* are computed from the formulas given in table 5 of [5]. */
+
+/* z = 1153.04066200330" */
+/* theta = -1002.26108439117" */
+/* zeta = 1152.84248596724" */
+
+
+/* The FK4 reference frame is derived from the B1950 frame by */
+/* applying the equinox offset determined by Fricke. This is just */
+/* the rotation */
+
+/* [ 0.525" ] */
+/* 3 */
+
+
+/* The DE-118 reference frame is nearly identical to the FK4 */
+/* reference frame. It is also derived from the B1950 frame. */
+/* Only the offset is different: */
+
+/* [ 0.53155" ] */
+/* 3 */
+
+/* In [2], Standish uses two separate rotations, */
+
+/* [ 0.00073" ] P [ 0.5316" ] */
+/* 3 3 */
+
+/* (where P is the precession matrix used above to define the */
+/* B1950 frame). The major effect of the second rotation is to */
+/* correct for truncating the magnitude of the first rotation. */
+/* At his suggestion, we will use the untruncated value, and */
+/* stick to a single rotation. */
+
+
+/* Most of the other DE reference frames may be defined relative */
+/* to either the DE-118 or B1950 frames. The values below are taken */
+/* from [4]. */
+
+/* DE number Offset from DE-118 Offset from B1950 */
+/* --------- ------------------ ----------------- */
+/* 96 +0.1209" +0.4107" */
+/* 102 +0.3956" +0.1359" */
+/* 108 +0.0541" +0.4775" */
+/* 111 -0.0564" +0.5880" */
+/* 114 -0.0213" +0.5529" */
+/* 122 +0.0000" +0.5316" */
+/* 125 -0.0438" +0.5754" */
+/* 130 +0.0069" +0.5247" */
+
+/* We will use B1950 for now, since the offsets generally have */
+/* more significant digits. */
+
+
+/* The Galactic System II reference frame is defined by the */
+/* following rotations: */
+
+/* o o o */
+/* [ 327 ] [ 62.6 ] [ 282.25 ] */
+/* 3 1 3 */
+
+/* In the absence of better information, we will assume that */
+/* it is derived from the FK4 frame. Converting the angles from */
+/* degrees to arc seconds, */
+
+/* o */
+/* 327 = 1177200" */
+/* o */
+/* 62.6 = 225360" */
+/* o */
+/* 282.25 = 1016100" */
+
+
+/* According to Standish, the various DE-200 frames are identical */
+/* with J2000, because he rotates the ephemerides before releasing */
+/* them (in order to avoid problems like the one that this routine */
+/* is designed to solve). Because we have to have something, we */
+/* will use */
+
+/* o */
+/* [ 0.0 ] */
+/* 3 */
+
+
+/* The values for the transformation from J2000 to MARSIAU_MO */
+/* are derived from the constants given for the pole of Mars */
+/* on page 8-2 of reference [6]. */
+
+
+/* The value for the obliquity of the ecliptic at J2000 is */
+/* taken from page 114 of [7] equation 3.222-1. This agrees */
+/* with the expression given in [5] */
+
+
+/* The value for the obliquity of the ecliptic at B1950 is */
+/* taken from page 171 of [7]. */
+
+
+/* The frame for DE-140 is simply DE-400 rotated by the rotation: */
+
+/* 0.9999256765384668 0.0111817701197967 0.0048589521583895 */
+/* -0.0111817701797229 0.9999374816848701 -0.0000271545195858 */
+/* -0.0048589520204830 -0.0000271791849815 0.9999881948535965 */
+
+/* Note that the DE-400 frame is J2000. */
+
+/* The transpose of this is the frame from DE140 to DE400. To get */
+/* the euler angles below, the matrix given above was copied into */
+/* a matrix XFORM. */
+
+/* This matrix was transposed to give the transformation from */
+/* DE-140 to J2000. */
+
+/* CALL XPOSE ( XFORM, XFORM ) */
+
+/* Using the SPICE routine M2EUL, the euler representation of the */
+/* transformation from DE140 to J2000 was constructed. */
+
+/* CALL M2EUL ( XFORM, 3, 2, 3, A1, A2, A3 ) */
+
+/* Angles were converted to the range from -180 to 180 degrees */
+/* and converted to arcseconds. At this point we have the */
+/* euler representation from DE-140 to J2000. */
+
+/* [ A1 ] [ A2 ] [ A3 ] */
+/* 3 2 3 */
+
+/* To get the Euler representation of the transformation from */
+/* J2000 to DE-140 we use. */
+
+/* [ -A3 ] [ -A2 ] [ -A1 ] */
+/* 3 2 3 */
+
+/* This method was used because it yields a nicer form of */
+/* representation than the straight forward transformation. */
+/* Note that these numbers are quite close to the values used */
+/* for the transformation from J2000 to B1950 */
+
+
+/* The frame for DE-142 is simply DE-402 rotated by the rotation: */
+
+/* 0.9999256765402605 0.0111817697320531 0.0048589526815484 */
+/* -0.0111817697907755 0.9999374816892126 -0.0000271547693170 */
+/* -0.0048589525464121 -0.0000271789392288 0.9999881948510477 */
+
+/* Note that the DE-402 frame is J2000. */
+
+/* The Euler angles giving the transformation for J2000 to */
+/* DE-142 were constructed in the same way as the transformation */
+/* from J2000 to DE140. Only the input matrix changed to use the */
+/* one given above. */
+
+
+/* The frame for DE-143 is simply DE-403 rotated by the rotation: */
+
+/* 0.9999256765435852 0.0111817743077255 0.0048589414674762 */
+/* -0.0111817743300355 0.9999374816382505 -0.0000271622115251 */
+/* -0.0048589414161348 -0.0000271713942366 0.9999881949053349 */
+
+/* Note that the DE-403 frame is J2000. */
+
+/* The Euler angles giving the transformation for J2000 to */
+/* DE-143 were constructed in the same way as the transformation */
+/* from J2000 to DE140. Only the input matrix changed to use the */
+/* one given above. */
+
+
+/* Until defined (by a call to IRFDEF), the default frame is */
+/* undefined. */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CHGIRF", (ftnlen)6);
+ }
+ sigerr_("SPICE(BOGUSENTRY)", (ftnlen)17);
+ chkout_("CHGIRF", (ftnlen)6);
+ return 0;
+/* $Procedure IRFROT ( Inertial reference frame rotation ) */
+
+L_irfrot:
+/* $ Abstract */
+
+/* Compute the matrix needed to rotate vectors between two */
+/* standard inertial reference frames. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* FRAMES */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* COORDINATES */
+/* EPHEMERIS */
+/* FRAMES */
+/* MATRIX */
+/* ROTATION */
+/* TRANSFORMATION */
+/* VECTOR */
+
+/* $ Declarations */
+
+/* INTEGER REFA */
+/* INTEGER REFB */
+/* DOUBLE PRECISION ROTAB ( 3,3 ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* REFA, */
+/* REFB I Indices of target reference frames (A,B). */
+/* MATRIX O Rotation from frame A to frame B. */
+
+/* $ Detailed_Input */
+
+/* REFA, */
+/* REFB are the indices of two standard inertial reference */
+/* frames. The complete set of supported frames is shown */
+/* below. */
+
+/* Index Name Description */
+/* ----- -------- -------------------------------- */
+/* 1 J2000 Earth mean equator, dynamical */
+/* equinox of J2000 */
+
+/* 2 B1950 Earth mean equator, dynamical */
+/* equinox of B1950 */
+
+/* 3 FK4 Fundamental Catalog (4) */
+
+/* 4 DE-118 JPL Developmental Ephemeris (118) */
+
+/* 5 DE-96 JPL Developmental Ephemeris ( 96) */
+
+/* 6 DE-102 JPL Developmental Ephemeris (102) */
+
+/* 7 DE-108 JPL Developmental Ephemeris (108) */
+
+/* 8 DE-111 JPL Developmental Ephemeris (111) */
+
+/* 9 DE-114 JPL Developmental Ephemeris (114) */
+
+/* 10 DE-122 JPL Developmental Ephemeris (122) */
+
+/* 11 DE-125 JPL Developmental Ephemeris (125) */
+
+/* 12 DE-130 JPL Developmental Ephemeris (130) */
+
+/* 13 GALACTIC Galactic System II */
+
+/* 14 DE-200 JPL Developmental Ephemeris (200) */
+
+/* 15 DE-202 JPL Developmental Ephemeris (202) */
+
+/* 16 MARSIAU Mars Observer inertial frame */
+/* defined relative to MARS. */
+
+/* 17 ECLIPJ2000 Earth mean ecliptic and equinox */
+/* of the epoch J2000 */
+
+/* 18 ECLIPB1950 Earth mean ecliptic and equinox */
+/* of the Besselian date 1950. */
+
+/* 19 DE-140 JPL Developmental Ephemeris (140) */
+
+/* 20 DE-142 JPL Developmental Ephemeris (142) */
+
+/* 21 DE-143 JPL Developmental Ephemeris (143) */
+
+/* $ Detailed_Output */
+
+/* ROTAB is the rotation which, when applied to a vector v */
+/* in reference frame A, */
+/* _ _ */
+/* v = (ROTAB) v */
+/* B A */
+
+/* yields the same vector in reference frame B. The */
+/* inverse rotation is performed by applying the */
+/* transpose, */
+/* _ T _ */
+/* v = (ROTAB) v */
+/* A B */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If either REFA or REFB is outside the range [1,MAXF], */
+/* where MAXF is the number of supported frames, the error */
+/* SPICE(IRFNOTREC) is signalled. */
+
+/* $ Particulars */
+
+/* IRFROT exists primarily for use by the ephemeris and star */
+/* catalog readers in the SPICELIB toolkit library. */
+
+/* $ Examples */
+
+/* In the following code fragment, IRFROT is used to rotate */
+/* vectors originally referenced to the DE-118 coordinate frame */
+/* to equivalent vectors referenced to the IAU standard J2000 */
+/* reference frame. */
+
+/* CALL IRFROT ( 4, 1, R ) */
+
+/* CALL MXV ( R, SC1950, SC2000 ) */
+/* CALL MXV ( R, MP1950, MP2000 ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* See subroutine CHGIRF. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.2.1, 04-JAN-2002 (EDW) */
+
+/* Added DE-143 to header description for IRFROT. */
+
+/* - SPICELIB Version 4.2.0, 10-APR-1997 (WLT) */
+
+/* A descriptive diagnostic was added to the entry points */
+/* IRFROT and IRFDEF. Before they simply signalled the error */
+/* with no diagnostic. */
+
+/* - SPICELIB Version 4.1.0, 14-OCT-1996 (WLT) */
+
+/* The number of inertial frames recognized is now stored */
+/* in the include file ninert.inc. */
+
+/* - SPICELIB Version 4.0.0, 20-MAY-1996 (WLT) */
+
+/* The inertial frame DE-143 was added to the list of recognized */
+/* inertial frames. */
+
+/* - SPICELIB Version 3.0.0, 20-MAR-1995 (WLT) */
+
+/* The inertial frames DE-140 and DE-142 were added to the */
+/* list of recognized inertial frames. */
+
+/* - SPICELIB Version 2.0.0, 30-JUL-1993 (WLT) */
+
+/* The transformation from J2000 to B1950 was upgraded */
+/* so that the transformation matrix produced matches */
+/* the matrix given in [1]. */
+
+/* The frame MARSIAU was added to the list */
+/* of recognized frames. This is the standard mars */
+/* referenced inertial frame used by the Mars Observer */
+/* project. */
+
+/* Values for the obliquity of the ecliptic were taken */
+/* from the Explanatory Supplement [7] to the Astronomical */
+/* Almanac (1992) at both the epochs J2000 and B1950 and */
+/* used to define the mean ecliptic and equinox frames */
+/* ECLIPJ2000 and ECLIPB1950. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* inertial reference frame rotation */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("IRFROT", (ftnlen)6);
+ }
+
+/* If it has not been done already, construct the transformation */
+/* from the root frame to each supported reference frame. */
+
+/* Begin by constructing the identity matrix (rotating by zero */
+/* radians about the x-axis). Apply the rotations indicated in */
+/* the frame definition (from right to left) to get the incremental */
+/* rotation from the base frame. The final rotation is */
+
+/* R = (R ) (R ) */
+/* root->frame base->frame root->base */
+
+ if (! ready) {
+ for (i__ = 1; i__ <= 21; ++i__) {
+ rotate_(&c_b6, &c__1, &trans[(i__1 = i__ * 9 - 9) < 189 && 0 <=
+ i__1 ? i__1 : s_rnge("trans", i__1, "chgirf_", (ftnlen)
+ 868)]);
+ for (j = wdcnt_(defs + ((i__1 = i__ - 1) < 21 && 0 <= i__1 ? i__1
+ : s_rnge("defs", i__1, "chgirf_", (ftnlen)870)) * 80, (
+ ftnlen)80); j >= 2; j += -2) {
+ nthwd_(defs + ((i__1 = i__ - 1) < 21 && 0 <= i__1 ? i__1 :
+ s_rnge("defs", i__1, "chgirf_", (ftnlen)872)) * 80, &
+ j, word, &loc, (ftnlen)80, (ftnlen)25);
+ nparsi_(word, &axis, error, &p, (ftnlen)25, (ftnlen)25);
+ i__2 = j - 1;
+ nthwd_(defs + ((i__1 = i__ - 1) < 21 && 0 <= i__1 ? i__1 :
+ s_rnge("defs", i__1, "chgirf_", (ftnlen)875)) * 80, &
+ i__2, word, &loc, (ftnlen)80, (ftnlen)25);
+ nparsd_(word, &angle, error, &p, (ftnlen)25, (ftnlen)25);
+ convrt_(&angle, "ARCSECONDS", "RADIANS", &radang, (ftnlen)10,
+ (ftnlen)7);
+ rotmat_(&trans[(i__1 = i__ * 9 - 9) < 189 && 0 <= i__1 ? i__1
+ : s_rnge("trans", i__1, "chgirf_", (ftnlen)880)], &
+ radang, &axis, tmpmat);
+ moved_(tmpmat, &c__9, &trans[(i__1 = i__ * 9 - 9) < 189 && 0
+ <= i__1 ? i__1 : s_rnge("trans", i__1, "chgirf_", (
+ ftnlen)881)]);
+ }
+ b = isrchc_(bases + (((i__1 = i__ - 1) < 21 && 0 <= i__1 ? i__1 :
+ s_rnge("bases", i__1, "chgirf_", (ftnlen)885)) << 4), &
+ i__, frames, (ftnlen)16, (ftnlen)16);
+ mxm_(&trans[(i__1 = i__ * 9 - 9) < 189 && 0 <= i__1 ? i__1 :
+ s_rnge("trans", i__1, "chgirf_", (ftnlen)887)], &trans[(
+ i__2 = b * 9 - 9) < 189 && 0 <= i__2 ? i__2 : s_rnge(
+ "trans", i__2, "chgirf_", (ftnlen)887)], tmpmat);
+ moved_(tmpmat, &c__9, &trans[(i__1 = i__ * 9 - 9) < 189 && 0 <=
+ i__1 ? i__1 : s_rnge("trans", i__1, "chgirf_", (ftnlen)
+ 888)]);
+ }
+ ready = TRUE_;
+ }
+
+/* If the transformations have been defined, we can proceed with */
+/* the business at hand: determining the rotation from one frame */
+/* to another. To get from frame A to frame B, the rotation is */
+
+/* T */
+/* R = (R ) (R ) */
+/* A->B root->B root->A */
+
+/* If A and B are the same frame, the rotation is just the identity. */
+/* In theory, computing */
+
+/* T */
+/* R = (R ) (R ) */
+/* A->A root->A root->A */
+
+/* should work, but why risk roundoff problems? */
+
+ if (*refa < 1 || *refa > 21) {
+ setmsg_("A request has been made to obtain the transformation from i"
+ "nertial reference frame # to inertial reference frame #. Unf"
+ "ortunately # is not the id-code of a known inertial frame. ",
+ (ftnlen)178);
+ errint_("#", refa, (ftnlen)1);
+ errint_("#", refb, (ftnlen)1);
+ errint_("#", refa, (ftnlen)1);
+ sigerr_("SPICE(IRFNOTREC)", (ftnlen)16);
+ } else if (*refb < 1 || *refb > 21) {
+ setmsg_("A request has been made to obtain the transformation from i"
+ "nertial reference frame # to inertial reference frame #. Unf"
+ "ortunately # is not the id-code of a known inertial frame. ",
+ (ftnlen)178);
+ errint_("#", refa, (ftnlen)1);
+ errint_("#", refb, (ftnlen)1);
+ errint_("#", refb, (ftnlen)1);
+ sigerr_("SPICE(IRFNOTREC)", (ftnlen)16);
+ } else if (*refa == *refb) {
+ rotate_(&c_b6, &c__1, rotab);
+ } else {
+ mxmt_(&trans[(i__1 = *refb * 9 - 9) < 189 && 0 <= i__1 ? i__1 :
+ s_rnge("trans", i__1, "chgirf_", (ftnlen)943)], &trans[(i__2 =
+ *refa * 9 - 9) < 189 && 0 <= i__2 ? i__2 : s_rnge("trans",
+ i__2, "chgirf_", (ftnlen)943)], rotab);
+ }
+ chkout_("IRFROT", (ftnlen)6);
+ return 0;
+/* $Procedure IRFNUM ( Inertial reference frame number ) */
+
+L_irfnum:
+/* $ Abstract */
+
+/* Return the index of one of the standard inertial reference */
+/* frames supported by IRFROT. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* FRAMES */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* COORDINATES */
+/* EPHEMERIS */
+/* FRAMES */
+/* MATRIX */
+/* ROTATION */
+/* TRANSFORMATION */
+/* VECTOR */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) NAME */
+/* INTEGER INDEX */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* NAME I Name of standard inertial reference frame. */
+/* INDEX O Index of frame. */
+
+/* $ Detailed_Input */
+
+/* NAME is the name of one of the standard inertial */
+/* reference frames supported by IRFROT, or */
+/* 'DEFAULT'. */
+
+/* $ Detailed_Output */
+
+/* INDEX is the index of the frame specified by NAME. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If NAME is not recognized, INDEX is zero. */
+
+/* 2) If no default frame has been specified, INDEX is zero. */
+
+/* $ Particulars */
+
+/* IRFNUM is supplied as a convenience, to allow users to refer to */
+/* the various standard inertial reference frames by name. */
+
+/* $ Examples */
+
+/* In the following example, the rotation from DE-118 to FK4 is */
+/* computed without knowing the indices of these frames. */
+
+/* CALL IRFNUM ( 'DE-118', A ) */
+/* CALL IRFNUM ( 'FK4', B ) */
+
+/* CALL IRFROT ( A, B, ROTAB ) */
+
+/* IRFNUM can be used to rotate vectors into the default frame, */
+/* as illustrated by the following code fragment. */
+
+/* CALL IRFNUM ( 'FK4', A ) */
+/* CALL IRFNUM ( 'DEFAULT', B ) */
+
+/* CALL IRFROT ( A, B, ROTAB ) */
+/* CALL MXV ( ROTAB, OLDVEC, NEWVEC ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* See subroutine CHGIRF. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.2.1, 04-JAN-2002 (EDW) */
+
+/* Added DE-143 to header description for IRFROT. */
+
+/* - SPICELIB Version 4.2.0, 10-APR-1997 (WLT) */
+
+/* A descriptive diagnostic was added to the entry points */
+/* IRFROT and IRFDEF. Before they simply signalled the error */
+/* with no diagnostic. */
+
+/* - SPICELIB Version 4.1.0, 14-OCT-1996 (WLT) */
+
+/* The number of inertial frames recognized is now stored */
+/* in the include file ninert.inc. */
+
+/* - SPICELIB Version 4.0.0, 20-MAY-1996 (WLT) */
+
+/* The inertial frame DE-143 was added to the list of recognized */
+/* inertial frames. */
+
+/* - SPICELIB Version 3.0.0, 20-MAR-1995 (WLT) */
+
+/* The inertial frames DE-140 and DE-142 were added to the */
+/* list of recognized inertial frames. */
+
+/* - SPICELIB Version 2.0.0, 30-JUL-1993 (WLT) */
+
+/* The transformation from J2000 to B1950 was upgraded */
+/* so that the transformation matrix produced matches */
+/* the matrix given in [1]. */
+
+/* The frame MARSIAU was added to the list */
+/* of recognized frames. This is the standard mars */
+/* referenced inertial frame used by the Mars Observer */
+/* project. */
+
+/* Values for the obliquity of the ecliptic were taken */
+/* from the Explanatory Supplement [7] to the Astronomical */
+/* Almanac (1992) at both the epochs J2000 and B1950 and */
+/* used to define the mean ecliptic and equinox frames */
+/* ECLIPJ2000 and ECLIPB1950. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* inertial reference frame number */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("IRFNUM", (ftnlen)6);
+ }
+ if (eqstr_(name__, "DEFAULT", name_len, (ftnlen)7)) {
+ *index = dframe;
+ } else {
+ *index = esrchc_(name__, &c__21, frames, name_len, (ftnlen)16);
+ }
+ chkout_("IRFNUM", (ftnlen)6);
+ return 0;
+/* $Procedure IRFNAM ( Inertial reference frame name ) */
+
+L_irfnam:
+/* $ Abstract */
+
+/* Return the name of one of the standard inertial reference */
+/* frames supported by IRFROT. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* FRAMES */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* COORDINATES */
+/* EPHEMERIS */
+/* FRAMES */
+/* MATRIX */
+/* ROTATION */
+/* TRANSFORMATION */
+/* VECTOR */
+
+/* $ Declarations */
+
+/* INTEGER INDEX */
+/* CHARACTER*(*) NAME */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* INDEX I Index of standard inertial reference frame. */
+/* NAME O Name of frame. */
+
+/* $ Detailed_Input */
+
+/* INDEX is the index of one of the standard inertial */
+/* reference frames supported by IRFROT. */
+
+/* $ Detailed_Output */
+
+/* NAME is the name of the frame specified by INDEX. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If INDEX is not the index of a supported frame, NAME is blank. */
+
+/* $ Particulars */
+
+/* IRFNAM is supplied as a convenience, to allow users to determine */
+/* the names of standard inertial reference frames referred to only */
+/* by index (as in the segment descriptors of a GEF ephemeris file). */
+
+/* $ Examples */
+
+/* In the following example, the identity of a rotation from DE-118 */
+/* to FK4 is deduced from the indices used to create the rotation. */
+
+/* CALL IRFROT ( A, B, ROTAB ) */
+
+/* CALL IRFNAM ( A, NAME(1) ) */
+/* CALL IRFNAM ( B, NAME(2) ) */
+
+/* WRITE (6,*) 'Rotation from ' // NAME(1) // ' to ' // NAME(2) */
+
+/* Note that the name of the default reference frame can only be */
+/* recovered from the number: */
+
+/* CALL IRFNUM ( 'DEFAULT', DINDEX ) */
+/* CALL IRFNAM ( DINDEX, DNAME ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* See subroutine CHGIRF. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.2.1, 04-JAN-2002 (EDW) */
+
+/* Added DE-143 to header description for IRFROT. */
+
+/* - SPICELIB Version 4.2.0, 10-APR-1997 (WLT) */
+
+/* A descriptive diagnostic was added to the entry points */
+/* IRFROT and IRFDEF. Before they simply signalled the error */
+/* with no diagnostic. */
+
+/* - SPICELIB Version 4.1.0, 14-OCT-1996 (WLT) */
+
+/* The number of inertial frames recognized is now stored */
+/* in the include file ninert.inc. */
+
+/* - SPICELIB Version 4.0.0, 20-MAY-1996 (WLT) */
+
+/* The inertial frame DE-143 was added to the list of recognized */
+/* inertial frames. */
+
+/* - SPICELIB Version 3.0.0, 20-MAR-1995 (WLT) */
+
+/* The inertial frames DE-140 and DE-142 were added to the */
+/* list of recognized inertial frames. */
+
+/* - SPICELIB Version 2.0.0, 30-JUL-1993 (WLT) */
+
+/* The transformation from J2000 to B1950 was upgraded */
+/* so that the transformation matrix produced matches */
+/* the matrix given in [1]. */
+
+/* The frame MARSIAU was added to the list */
+/* of recognized frames. This is the standard mars */
+/* referenced inertial frame used by the Mars Observer */
+/* project. */
+
+/* Values for the obliquity of the ecliptic were taken */
+/* from the Explanatory Supplement [7] to the Astronomical */
+/* Almanac (1992) at both the epochs J2000 and B1950 and */
+/* used to define the mean ecliptic and equinox frames */
+/* ECLIPJ2000 and ECLIPB1950. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* inertial reference frame name */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("IRFNAM", (ftnlen)6);
+ }
+ if (*index < 1 || *index > 21) {
+ s_copy(name__, " ", name_len, (ftnlen)1);
+ } else {
+ s_copy(name__, frames + (((i__1 = *index - 1) < 21 && 0 <= i__1 ?
+ i__1 : s_rnge("frames", i__1, "chgirf_", (ftnlen)1348)) << 4),
+ name_len, (ftnlen)16);
+ }
+ chkout_("IRFNAM", (ftnlen)6);
+ return 0;
+/* $Procedure IRFDEF ( Inertial reference frame, default ) */
+
+L_irfdef:
+/* $ Abstract */
+
+/* Specify a standard inertial reference frame as the default */
+/* frame for a program. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* FRAMES */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* COORDINATES */
+/* EPHEMERIS */
+/* FRAMES */
+/* MATRIX */
+/* ROTATION */
+/* TRANSFORMATION */
+/* VECTOR */
+
+/* $ Declarations */
+
+/* INTEGER INDEX */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* INDEX I Index of default frame. */
+
+/* $ Detailed_Input */
+
+/* INDEX is the index of one of the standard inertial */
+/* reference frames supported by IRFROT. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If INDEX is outside the range [1,MAXF], where MAXF is the */
+/* number of supported frames, the error SPICE(IRFNOTREC) is */
+/* signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* IRFDEF allows tools to be written at a relatively high level */
+/* without requiring the reference frame to be tramp coupled or */
+/* placed in global memory. */
+
+/* $ Examples */
+
+/* Typically, the calling program will select a default frame */
+/* during initialization, */
+
+/* C */
+/* C Use J2000 for all ephemeris, star data. */
+/* C */
+/* CALL IRFDEF ( 1 ) */
+
+/* and recover the default frame at lower levels, */
+
+/* C */
+/* C Rotate all vectors into the default frame. */
+/* C */
+/* CALL IRFNUM ( 'DEFAULT', REFD ) */
+
+/* DO I = 1, NVEC */
+/* CALL IRFROT ( REFIN, REFD, ROT ) */
+/* CALL MXV ROT, VEC, VEC ) */
+/* END DO */
+
+/* Note that many utilities accept 'DEFAULT' as the name of */
+/* an inertial reference frame, */
+
+/* CALL SPKEZ ( TARGET, ..., 'DEFAULT', ... ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* See subroutine CHGIRF. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.2.1, 04-JAN-2002 (EDW) */
+
+/* Added DE-143 to header description for IRFROT. */
+
+/* - SPICELIB Version 4.2.0, 10-APR-1997 (WLT) */
+
+/* A descriptive diagnostic was added to the entry points */
+/* IRFROT and IRFDEF. Before they simply signalled the error */
+/* with no diagnostic. */
+
+/* - SPICELIB Version 4.1.0, 14-OCT-1996 (WLT) */
+
+/* The number of inertial frames recognized is now stored */
+/* in the include file ninert.inc. */
+
+/* - SPICELIB Version 4.0.0, 20-MAY-1996 (WLT) */
+
+/* The inertial frame DE-143 was added to the list of recognized */
+/* inertial frames. */
+
+/* - SPICELIB Version 3.0.0, 20-MAR-1995 (WLT) */
+
+/* The inertial frames DE-140 and DE-142 were added to the */
+/* list of recognized inertial frames. */
+
+/* - SPICELIB Version 2.0.0, 30-JUL-1993 (WLT) */
+
+/* The transformation from J2000 to B1950 was upgraded */
+/* so that the transformation matrix produced matches */
+/* the matrix given in [1]. */
+
+/* The frame MARSIAU was added to the list */
+/* of recognized frames. This is the standard mars */
+/* referenced inertial frame used by the Mars Observer */
+/* project. */
+
+/* Values for the obliquity of the ecliptic were taken */
+/* from the Explanatory Supplement [7] to the Astronomical */
+/* Almanac (1992) at both the epochs J2000 and B1950 and */
+/* used to define the mean ecliptic and equinox frames */
+/* ECLIPJ2000 and ECLIPB1950. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* inertial reference frame default */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("IRFDEF", (ftnlen)6);
+ }
+
+/* There's not much to do, except save the value for later use. */
+
+ if (*index < 1 || *index > 21) {
+ setmsg_("The reference frame with id-code # is not a recognized iner"
+ "tial reference frame. ", (ftnlen)81);
+ errint_("#", index, (ftnlen)1);
+ sigerr_("SPICE(IRFNOTREC)", (ftnlen)16);
+ } else {
+ dframe = *index;
+ }
+ chkout_("IRFDEF", (ftnlen)6);
+ return 0;
+} /* chgirf_ */
+
+/* Subroutine */ int chgirf_(integer *refa, integer *refb, doublereal *rotab,
+ char *name__, integer *index, ftnlen name_len)
+{
+ return chgirf_0_(0, refa, refb, rotab, name__, index, name_len);
+ }
+
+/* Subroutine */ int irfrot_(integer *refa, integer *refb, doublereal *rotab)
+{
+ return chgirf_0_(1, refa, refb, rotab, (char *)0, (integer *)0, (ftnint)0)
+ ;
+ }
+
+/* Subroutine */ int irfnum_(char *name__, integer *index, ftnlen name_len)
+{
+ return chgirf_0_(2, (integer *)0, (integer *)0, (doublereal *)0, name__,
+ index, name_len);
+ }
+
+/* Subroutine */ int irfnam_(integer *index, char *name__, ftnlen name_len)
+{
+ return chgirf_0_(3, (integer *)0, (integer *)0, (doublereal *)0, name__,
+ index, name_len);
+ }
+
+/* Subroutine */ int irfdef_(integer *index)
+{
+ return chgirf_0_(4, (integer *)0, (integer *)0, (doublereal *)0, (char *)
+ 0, index, (ftnint)0);
+ }
+
diff --git a/ext/spice/src/cspice/chkin_c.c b/ext/spice/src/cspice/chkin_c.c
new file mode 100644
index 0000000000..7589a27df6
--- /dev/null
+++ b/ext/spice/src/cspice/chkin_c.c
@@ -0,0 +1,218 @@
+/*
+
+-Procedure chkin_c ( module Check In )
+
+-Abstract
+
+ Inform the CSPICE error handling mechanism of entry into a
+ routine.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ ERROR
+
+-Keywords
+
+ ERROR
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+
+
+ void chkin_c ( ConstSpiceChar * module )
+
+/*
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- ---------------------------------------------------
+ module I The name of the calling routine.
+
+-Detailed_Input
+
+ module is the name of the routine calling chkin_c. The
+ named routine is supposed to be `checking in'
+ when it calls chkin_c; that is, the call should be
+ the first executable statement following the
+ reference to the function return_c() (which should be
+ the first executable statement).
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) The error SPICE(EMPTYSTRING) is signalled if the input
+ string does not contain at least one character, since the
+ input string cannot be converted to a Fortran-style string
+ in this case.
+
+ 2) The error SPICE(NULLPOINTER) is signalled if the input string
+ pointer is null.
+
+ The underlying f2c'd CSPICE routine chkin_ does not signal errors;
+ rather it writes error messages, so as to avoid recursion. The
+ errors detected by chkin_ are:
+
+ 3) If the traceback storage area overflows, the short error
+ message "SPICE(TRACEBACKOVERFLOW)" is written to the error
+ output device.
+
+ 4) If the input argument module is blank, the short error message
+ SPICE(BLANKMODULENAME) is written to the error output device.
+
+-Files
+
+ None.
+
+-Particulars
+
+ This routine is part of the CSPICE error handling mechanism.
+
+ Conceptually, the effect of this routine is to `push' the
+ supplied module name onto a stack. The routine chkout_c performs
+ the inverse, or `pop', operation.
+
+ Every routine that participates in the traceback scheme should
+ have a call to chkin_c as the second executable statement. The
+ first executable statements should be:
+
+ if ( return_c() )
+ {
+ return;
+ }
+ else
+ {
+ chkin_c ( module );
+ }
+
+
+ Here module is the name of the routine in which this code appears.
+
+ The line of code preceding the exit or any return statement should
+ be
+
+ chkout_c ( module );
+
+
+ All CSPICE routines should call chkin_c and chkout_c, unless they
+ are classified as `error free'. Programs linked with CSPICE
+ may also use chkin_c and chkout_c.
+
+ Routines that don't call chkin_c and chkout_c won't appear in the
+ traceback.
+
+ All routines that call chkin_c must also call chkout_c, or else the
+ trace mechanism will become very confused and require therapy.
+
+ It is possible to disable check-ins (and check-outs) by calling
+ the trcoff_c. chkin_c and chkout_c will return immediately
+ upon entry after trcoff_c has been called. It is not possible to
+ re-enable check-ins and check-outs after calling trcoff_c. Routines
+ that don't call chkin_c and chkout_c won't appear in the traceback.
+
+-Examples
+
+ See `Particulars' for an example of how to call this routine.
+
+-Restrictions
+
+ Routines that call this routine must call chkout_c immediately
+ prior to any return or exit statement.
+
+ module names are assumed to have no embedded blanks.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ K.R. Gehringer (JPL)
+ N.J. Bachman (JPL)
+
+-Version
+
+ -CSPICE Version 2.0.3, 23-JUL-2001 (NJB)
+
+ Tabs removed from source file.
+
+ -CSPICE Version 2.0.2, 25-MAR-1998 (EDW)
+
+ Minor corrections to header.
+
+ -CSPICE Version 2.0.1, 08-FEB-1998 (EDW)
+
+ Corrected and clarified header entries.
+
+ -CSPICE Version 2.0.0, 09-JAN-1998 (NJB)
+
+ Input argument filename was changed to type ConstSpiceChar *.
+
+ Re-implemented routine without dynamically allocated, temporary
+ strings.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (EDW)
+
+-Index_Entries
+
+ module check in
+
+-&
+*/
+
+{ /* Begin chkin_c */
+
+
+ /*
+ Check the input string module to make sure the pointer is non-null
+ and the string length is non-zero. Use discovery check-in. If an
+ error is found, this wrapper will be called recursively, but that
+ should not cause a problem.
+ */
+ CHKFSTR ( CHK_DISCOVER, "chkin_c", module );
+
+
+ /*
+ Call the f2c'd Fortran routine.
+ */
+ chkin_ ( ( char * ) module,
+ ( ftnlen ) strlen(module) );
+
+
+
+} /* end chkin_c */
diff --git a/ext/spice/src/cspice/chkout_c.c b/ext/spice/src/cspice/chkout_c.c
new file mode 100644
index 0000000000..275eeacab4
--- /dev/null
+++ b/ext/spice/src/cspice/chkout_c.c
@@ -0,0 +1,215 @@
+/*
+
+-Procedure chkout_c ( Module Check Out )
+
+-Abstract
+
+ Inform the CSPICE error handling mechanism of exit from a
+ routine.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ ERROR
+
+-Keywords
+
+ ERROR
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+
+
+ void chkout_c ( ConstSpiceChar * module )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ module I The name of the calling routine.
+
+-Detailed_Input
+
+ module is the name of the routine calling chkout_c. The
+ named routine is supposed to be `checking out'
+ when it calls chkout_c; that is, the call should be
+ the last executable statement preceding any exit
+ from the routine.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+
+-Exceptions
+
+ chkout_c does not signal errors; rather it writes error messages,
+ so as to avoid recursion.
+
+ 1) If the input module name module does not match the name popped
+ from the trace stack, the short error message
+ SPICE(NAMESDONOTMATCH) is written to the error output device.
+
+ 2) If the trace stack is empty, the short error message
+ SPICE(TRACESTACKEMPTY) is written to the error output device.
+
+-Files
+
+ None.
+
+-Particulars
+
+ This routine is part of the CSPICE error handling mechanism.
+
+ Conceptually, the effect of this routine is to `pop' a module
+ name from a stack. The routine chkin_c performs the inverse, or
+ `push' operation.
+
+ Every routine that participates in the traceback scheme should
+ have a call to chkin_c as the second executable statement.
+ The first executable statements should be:
+
+ if ( return_c() )
+ {
+ return;
+ }
+ else
+ {
+ chkin_c ( module );
+ }
+
+
+ Here module is the name of the routine in which this code appears.
+
+ The line of code preceding the exit or any return statement
+ should be
+
+ chkout_c ( module );
+
+ All CSPICE routines should call chkin_c and chkout_c, unless they
+ are classified as `error free'. Programs linked with CSPICE
+ may also use chkin_c and chkout_c.
+
+ Routines that don't call chkin_c and chkout_c won't appear in the
+ traceback.
+
+ All routines that call chkin_c must also call chkout_c, or else the
+ trace mechanism will become very confused and need alot of therapy.
+
+ It is possible to disable check-ins (and check-outs) by calling
+ the trcoff_c. chkin_c and chkout_c will return immediately
+ upon entry after trcoff_c has been called. It is not possible to
+ re-enable check-ins and check-outs after calling trcoff_c. Routines
+ that don't call chkin_c and chkout_c won't appear in the traceback.
+
+-Examples
+
+ 1) Call chkout_c before a return statement:
+
+ if ( failed() )
+ {
+ chkout_c ( module );
+ return;
+ }
+
+
+ 2) Call chkout_c before an exit statement:
+
+ chkout_c ( module );
+ exit;
+
+
+ 3) Only ONE call to chkout_c is needed here:
+
+ chkout_c ( module ) ;
+ return;
+
+
+-Restrictions
+
+ Routines that call this routine must call chkin_c as the second
+ executable statement. (The first is a call to return_c() ).
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+
+-Version
+
+ -CSPICE Version 2.0.1, 08-FEB-1998 (EDW)
+
+ Corrected and clarified header entries.
+
+ -CSPICE Version 2.0.0, 09-JAN-1998 (NJB)
+
+ Input argument filename was changed to type ConstSpiceChar *.
+
+ Re-implemented routine without dynamically allocated, temporary
+ strings.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (EDW)
+
+-Index_Entries
+
+ module check out
+
+-&
+*/
+
+{ /* Begin chkout_c */
+
+ /*
+ Check the input string module to make sure the pointer is non-null
+ and the string length is non-zero. Use discovery check-in. If an
+ error is found, this wrapper will be called recursively, but that
+ should not cause a problem.
+ */
+ CHKFSTR ( CHK_DISCOVER, "chkout_c", module );
+
+ /*
+ Call the f2c'd Fortran routine.
+ */
+ chkout_ ( ( char * ) module,
+ ( ftnlen ) strlen(module) );
+
+
+} /* End chkout_c */
diff --git a/ext/spice/src/cspice/cidfrm_c.c b/ext/spice/src/cspice/cidfrm_c.c
new file mode 100644
index 0000000000..cb635acdf9
--- /dev/null
+++ b/ext/spice/src/cspice/cidfrm_c.c
@@ -0,0 +1,216 @@
+/*
+
+-Procedure cidfrm_c ( center SPK ID frame )
+
+-Abstract
+
+ Retrieve frame ID code and name to associate with a frame center.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ FRAMES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+
+
+ void cidfrm_c ( SpiceInt cent,
+ SpiceInt lenout,
+ SpiceInt * frcode,
+ SpiceChar * frname,
+ SpiceBoolean * found )
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ cent I An object to associate a frame with.
+ lenout I Available space in output string frname.
+ frcode O The ID code of the frame associated with cent.
+ frname O The name of the frame with ID frcode.
+ found O SPICETRUE if the requested information is available.
+
+-Detailed_Input
+
+ cent is the ID code for object for which there is a
+ preferred reference frame.
+
+ lenout is the available space in the output string frname,
+ including room for the terminating null character.
+
+-Detailed_Output
+
+ frcode is the frame ID code to associate with the object
+ specified by cent.
+
+ frname is the name of the frame that should be associated
+ with the object specified by cent.
+
+ found is SPICETRUE if the appropriate frame ID code and frame
+ name can be determined. Otherwise found is returned
+ with the value SPICEFALSE.
+
+-Parameters
+
+ None.
+
+-Files
+
+ None.
+
+-Exceptions
+
+ None.
+
+-Particulars
+
+ This routine allows the user to determine the frame that should
+ be associated with a particular object. For example, if you
+ need the frame to associate with the Io, you can call cidfrm_c
+ to determine the frame name and ID code for the bodyfixed frame
+ of Io.
+
+ The preferred frame to use with an object is specified via one
+ of the kernel pool variables:
+
+ OBJECT__FRAME
+
+ where is the decimal representation of the integer cent.
+
+ For those PCK objects that have "built-in" frame names this
+ routine returns the corresponding "IAU" frame and frame ID code.
+
+-Examples
+
+ Suppose that you want to determine the state of a target in the
+ preferred reference frame of some observer. This routine can be
+ used in conjunction with spkezr_c to compute the state.
+
+ #include
+ #include
+ #include "SpiceUsr.h"
+
+ #define LENOUT 32
+ .
+ .
+ .
+
+ cidfrm_c ( obs, LENOUT, &frcode, frname, &found );
+
+ if ( !found )
+ {
+ printf ( "The bodyfixed frame for object %d\n"
+ "could not be identified.\n",
+ obs );
+ exit(1);
+ }
+
+ spkezr_c ( targ, et, frname, abcorr, obs, state, < );
+
+
+-Restrictions
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 22-JUL-1999 (NJB) (WLT)
+
+-Index_Entries
+
+ Fetch reference frame attributes
+
+-&
+*/
+
+{ /* Begin cidfrm_c */
+
+ /*
+ Local variables
+ */
+ logical fnd;
+
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "cidfrm_c" );
+
+
+ /*
+ Check the output string to make sure the pointer is non-null and that
+ there is room for at least one character plus a null terminator.
+ */
+ CHKOSTR ( CHK_STANDARD, "cidfrm_c", frname, lenout );
+
+
+ /*
+ Call the f2c'd routine.
+ */
+
+ cidfrm_ ( ( integer * ) ¢,
+ ( integer * ) frcode,
+ ( char * ) frname,
+ ( logical * ) &fnd,
+ ( ftnlen ) lenout-1 );
+
+ /*
+ Convert the output string from Fortran to C style.
+ */
+ F2C_ConvertStr ( lenout, frname );
+
+
+ /*
+ Set the SpiceBoolean found flag.
+ */
+
+ *found = fnd;
+
+
+ chkout_c ( "cidfrm_c" );
+
+} /* End cidfrm_c */
diff --git a/ext/spice/src/cspice/ckbsr.c b/ext/spice/src/cspice/ckbsr.c
new file mode 100644
index 0000000000..a4b8e1aa04
--- /dev/null
+++ b/ext/spice/src/cspice/ckbsr.c
@@ -0,0 +1,4222 @@
+/* ckbsr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__50000 = 50000;
+static integer c__1000 = 1000;
+static integer c__5 = 5;
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKBSR ( C-kernel, buffer segments for readers ) */
+/* Subroutine */ int ckbsr_0_(int n__, char *fname, integer *handle, integer *
+ inst, doublereal *sclkdp, doublereal *tol, logical *needav,
+ doublereal *descr, char *segid, logical *found, ftnlen fname_len,
+ ftnlen segid_len)
+{
+ /* Initialized data */
+
+ static logical fresub = FALSE_;
+ static integer nft = 0;
+ static integer nit = 0;
+ static integer next = 0;
+ static integer savep = 0;
+ static doublereal savtol = 0.;
+ static char status[40] = "BOGUS ENTRY ";
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+ doublereal d__1, d__2;
+
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_rnge(char *, integer, char *, integer), s_cmp(char *, char *,
+ ftnlen, ftnlen);
+
+ /* Local variables */
+ integer head, tail;
+ static doublereal itlb[100], itub[100];
+ integer cost;
+ static doublereal reqt;
+ integer i__, j;
+ extern /* Subroutine */ int dafgn_(char *, ftnlen);
+ integer cheap, p;
+ extern /* Subroutine */ int dafgs_(doublereal *);
+ static doublereal alpha, omega;
+ static integer itbeg[100], slbeg;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafps_(integer *,
+ integer *, doublereal *, integer *, doublereal *);
+ static integer fthan[1000];
+ static doublereal stdcd[100000] /* was [2][50000] */;
+ char doing[40], stack[40*2];
+ static integer sticd[300000] /* was [6][50000] */;
+ extern doublereal dpmin_(void), dpmax_(void);
+ extern /* Subroutine */ int moved_(doublereal *, integer *, doublereal *);
+ static integer ithfs[100], sthan[50000];
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *);
+ static integer itlfs[100];
+ extern /* Subroutine */ int lnkan_(integer *, integer *);
+ extern integer lnktl_(integer *, integer *);
+ static integer itins[100], ftnum[1000], itexp[100];
+ extern /* Subroutine */ int daffna_(logical *), dafbbs_(integer *),
+ daffpa_(logical *);
+ extern logical failed_(void);
+ extern /* Subroutine */ int dafbfs_(integer *), cleard_(integer *,
+ doublereal *), dafcls_(integer *);
+ logical fndhan;
+ static logical avneed;
+ extern /* Subroutine */ int lnkila_(integer *, integer *, integer *),
+ dafopr_(char *, integer *, ftnlen);
+ static integer findex;
+ extern /* Subroutine */ int lnkilb_(integer *, integer *, integer *);
+ extern integer isrchi_(integer *, integer *, integer *);
+ static integer iindex;
+ static logical itchkp[100];
+ extern /* Subroutine */ int lnkini_(integer *, integer *);
+ extern integer lnknfn_(integer *);
+ static logical newsch;
+ extern /* Subroutine */ int lnkfsl_(integer *, integer *, integer *),
+ sigerr_(char *, ftnlen), chkout_(char *, ftnlen);
+ extern integer intmax_(void);
+ integer minexp;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen);
+ static char stidnt[40*50000];
+ char urgent[40];
+ static doublereal itprvd[500] /* was [5][100] */;
+ static integer itprvf[100];
+ integer nxtseg;
+ extern integer lnkprv_(integer *, integer *);
+ static char itprvi[40*100];
+ extern integer lnknxt_(integer *, integer *);
+ extern logical return_(void);
+ static integer itprvh[100], itruex[100], stpool[100012] /* was [2][
+ 50006] */, scinst;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ doublereal dcd[2];
+ integer icd[6];
+ static logical fnd;
+ integer new__;
+ static integer top;
+
+/* $ Abstract */
+
+/* Load and unload files for use by the readers. Buffer segments */
+/* for readers. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Entry points */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I CKLPF */
+/* HANDLE I,O CKLPF, CKUPF, CKSNS */
+/* INST I CKBSS */
+/* SCLKDP I CKBSS */
+/* TOL I CKBSS */
+/* NEEDAV I CKBSS */
+/* DESCR O CKSNS */
+/* SEGID O CKSNS */
+/* FOUND O CKSNS */
+
+/* $ Detailed_Input */
+
+/* FNAME is the name of a binary C-kernel file to be loaded. */
+
+/* HANDLE on input is the handle of a binary C-kernel file to be */
+/* unloaded. */
+
+
+/* The purpose of entry points CKBSS and CKSNS is to search for */
+/* segments in CK files matching certain criteria. The four */
+/* quantities below establish these search criteria. */
+
+
+/* INST is the NAIF ID of an instrument. */
+
+/* SCLKDP is an encoded spacecraft clock time. */
+
+/* TOL is a time tolerance, measured in the same units as */
+/* encoded spacecraft clock. */
+
+/* NEEDAV indicates whether or not angular velocity data are */
+/* required. */
+
+/* If true, only segments containing pointing and angular */
+/* velocity data will be checked. If false, segments */
+/* containing just pointing data will also be considered. */
+
+
+/* A segment matches the CKBSS/CKSNS search criteria when the */
+/* following statements are true. */
+
+/* 1) INST matches the instrument number for the segment. */
+
+/* 2) The time interval [SCLKDP - TOL, SCLKDP + TOL] intersects */
+/* the time interval of the segment. */
+
+/* 3) If angular velocity data are required, as indicated by */
+/* NEEDAV, the segment contains angular velocity data. */
+
+
+/* $ Detailed_Output */
+
+/* HANDLE on output is the handle of the C-kernel file */
+/* containing a located segment. */
+
+/* DESCR is the packed descriptor of a located segment. */
+
+/* SEGID is the identifier of a located segment. */
+
+/* FOUND indicates whether a requested segment was found or not. */
+
+/* $ Parameters */
+
+/* FTSIZE is the maximum number of pointing files that can */
+/* be loaded by CKLPF at any given time for use by the */
+/* readers. */
+
+/* ITSIZE is the maximum number of instruments whose segments */
+/* are buffered by CKSNS. */
+
+/* STSIZE is the maximum number of segments that can be buffered */
+/* at any given time by CKSNS. */
+
+/* $ Exceptions */
+
+/* 1) If CKBSR is called directly, the error SPICE(CKBOGUSENTRY) */
+/* is signaled. */
+
+/* 2) See entry points CKLPF, CKUPF, CKBSS, and CKSNS for exceptions */
+/* specific to them. */
+
+/* $ Files */
+
+/* C-kernel pointing files are indicated by filename before loading */
+/* (see CKLPF) and handle after loading (all other places). */
+
+/* $ Particulars */
+
+/* CKBSR serves as an umbrella, allowing data to be shared by its */
+/* entry points: */
+
+/* CKLPF Load pointing file. */
+/* CKUPF Unload pointing file. */
+/* CKBSS Begin search for segment. */
+/* CKSNS Select next segment. */
+
+/* Before a file can be read by the C-kernel readers, it must be */
+/* loaded by CKLPF, which among other things load the file into */
+/* the DAF subsystem. */
+
+/* Up to FTSIZE files may be loaded for use simultaneously, and a */
+/* file only has to be loaded once to become a potential search */
+/* target for any number of subsequent reads. */
+
+/* Once a C-kernel has been loaded, it is assigned a file */
+/* handle, which is used to keep track of the file internally, and */
+/* which is used by the calling program to refer to the file in all */
+/* subsequent calls to CK routines. */
+
+/* A file may be removed from the list of files for potential */
+/* searching by unloading it via a call to CKUPF. */
+
+/* CKBSS and CKSNS are used together to search through loaded files */
+/* for segments. */
+
+/* CKBSS sets up the search. You tell it the instrument and time */
+/* that you are interested in, and whether you require segments */
+/* containing angular velocity data. */
+
+/* CKSNS finds segments matching the search criteria set up by */
+/* CKBSS. Last-loaded files get searched first, and individual files */
+/* are searched backwards. */
+
+/* When an applicable segment is found, CKSNS returns that segment's */
+/* descriptor and identifier, along with the handle of the file */
+/* containing the segment. */
+
+/* Subsequent calls to CKSNS continue the search, picking up where */
+/* the previous call to this routine left off. */
+
+/* CKSNS uses information on loaded files to manage a buffer */
+/* of saved segment descriptors and identifiers. The buffer is used */
+/* to speed up access time by minimizing file reads. */
+
+/* $ Examples */
+
+/* Suppose that pointing data for the Voyager 2 narrow angle camera */
+/* for a certain interval of time are contained in three separate */
+/* files: ORIGINAL.CK contains an original complete set of pointing */
+/* data and UPDATE_1.CK and UPDATE_2.CK contain two separate pointing */
+/* updates for certain pictures in the same time period. */
+
+/* In the following example, pointing from the C-kernel is extracted */
+/* in two different ways for the purpose of comparing the two */
+/* updates: */
+
+/* First, the original pointing file and one of the update files are */
+/* both loaded and pointing is retrieved for all of the pictures. */
+/* The update file is searched through first, and if no data for the */
+/* desired picture is located, then the original file provides the */
+/* requested pointing. */
+
+/* Then, the first update file is unloaded, the second update file */
+/* is loaded, and the same search is performed, as above. */
+
+/* Throughout the two searches, a ficticious non-SPICELIB routine */
+/* named WRTABL writes an entry into a table that contains */
+/* the pointing of the camera and the file from which the pointing */
+/* came, if such pointing was found. WRERR, another ficticious, */
+/* non-SPICELIB routine writes an error message if no such pointing */
+/* was found. */
+
+/* It is assumed that an array (FDS) exists that contains character */
+/* representations of the spacecraft clock time for each picture, */
+/* and that there are NPICS pictures. */
+
+/* INTEGER NPICS */
+/* PARAMETER ( NPICS = 100 ) */
+
+/* INTEGER HANDLE */
+/* INTEGER HNORIG */
+/* INTEGER HUPDT */
+/* INTEGER UPDATE */
+/* INTEGER INST */
+/* INTEGER SC */
+/* INTEGER I */
+
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION SCLKDP */
+/* DOUBLE PRECISION TOL */
+/* DOUBLE PRECISION CLKOUT */
+/* DOUBLE PRECISION CMAT ( 3, 3 ) */
+/* DOUBLE PRECISION AV ( 3 ) */
+
+/* CHARACTER*(12) FDS ( NPICS ) */
+/* CHARACTER*(25) FNAME */
+/* CHARACTER*(40) SEGID */
+/* CHARACTER*(12) OUTFDS */
+/* CHARACTER*(12) TOLSTR */
+/* CHARACTER*(25) UDFILE ( 2 ) */
+
+/* LOGICAL PFOUND */
+/* LOGICAL SFOUND */
+/* LOGICAL NEEDAV */
+
+
+/* UDFILE ( 1 ) = 'UPDATE_1.CK' */
+/* UDFILE ( 2 ) = 'UPDATE_2.CK' */
+
+/* C */
+/* C The NAIF integer ID codes for the Voyager 2 spacecraft */
+/* C and the narrow angle camera on Voyager 2 are -32 and */
+/* C -32001, respectively. */
+/* C */
+/* SC = -32 */
+/* INST = -32001 */
+/* C */
+/* C Load the Voyager SCLK file. */
+/* C */
+/* CALL FURNSH ( 'VG2_SCLK.TSC' ) */
+
+/* C */
+/* C Allow a time tolerance of 400 line counts. Convert */
+/* C the tolerance to 'ticks', the units of encoded spacecraft */
+/* C clock time. */
+/* C */
+/* TOLSTR = '0:00:400' */
+/* CALL SCTIKS ( SC, TOLSTR, TOL ) */
+
+/* C */
+/* C Don't care about angular velocity data. */
+/* C */
+/* NEEDAV = .FALSE. */
+
+/* C */
+/* C Load the original CK file first. */
+/* C */
+/* CALL CKLPF ( 'ORIGINAL.CK', HNORIG ) */
+
+
+/* DO UPDATE = 1, 2 */
+/* C */
+/* C Load the update file. Last-loaded files get searched */
+/* C first, so the update file will be searched before */
+/* C the original file. */
+/* C */
+/* CALL CKLPF ( UDFILE ( UPDATE ), HUPDT ) */
+
+/* DO I = 1, NPICS */
+
+/* C */
+/* C Encode the character string representation of */
+/* C spacecraft clock time in FDS. */
+/* C */
+/* CALL SCENCD ( SC, FDS( I ), SCLKDP ) */
+
+/* C */
+/* C Begin a search for this instrument and time, and */
+/* C get the first applicable segment. */
+/* C */
+/* CALL CKBSS ( INST, SCLKDP, TOL, NEEDAV ) */
+/* CALL CKSNS ( HANDLE, DESCR, SEGID, SFOUND ) */
+
+/* C */
+/* C Keep trying candidate segments until a segment can */
+/* C produce a pointing instance within the specified */
+/* C time tolerance of SCLKDP, the encoded spacecraft */
+/* C clock time. */
+/* C */
+/* PFOUND = .FALSE. */
+
+/* DO WHILE ( SFOUND .AND. ( .NOT. PFOUND ) ) */
+
+/* CALL CKPFS ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
+/* . CMAT, AV, CLKOUT, PFOUND ) */
+
+/* IF ( PFOUND ) THEN */
+
+/* C Get the name of the file from whence the */
+/* C pointing instance came, decode the spacecraft */
+/* C clock time associated with the instance, and */
+/* C write the results to the table. */
+/* C */
+/* CALL DAFHFN ( HANDLE, FNAME ) */
+/* CALL SCDECD ( SC, CLKOUT, OUTFDS ) */
+
+/* CALL WRTABL ( FDS( I ), OUTFDS, CMAT, FNAME ) */
+
+/* ELSE */
+/* C */
+/* C Look for another candidate segment. */
+/* C */
+/* CALL CKSNS ( HANDLE, DESCR, SEGID, SFOUND ) */
+
+/* END IF */
+
+/* END DO */
+
+/* IF ( .NOT. PFOUND ) THEN */
+
+/* CALL WRERR ( FDS( I ) ) */
+
+/* END IF */
+
+/* END DO */
+
+/* C */
+/* C Unload the update file. The original file stays loaded. */
+/* C */
+/* CALL CKUPF ( HUPDT ) */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* 1) If Fortran I/O errors occur while searching a loaded CK */
+/* file, the internal state of this suite of routines may */
+/* be corrupted. It may be possible to correct the state */
+/* by unloading the pertinent CK files and then re-loading */
+/* them. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* J.M. Lynch (JPL) */
+/* J.E. McLean (JPL) */
+/* B.V. Semenov (JPL) */
+/* M.J. Spencer (JPL) */
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.4.0, 07-APR-2010 (NJB) */
+
+/* Increased STSIZE to 50000. */
+
+/* - SPICELIB Version 4.3.1, 28-FEB-2008 (BVS) */
+
+/* Corrected the contents of the Required_Reading section */
+/* of the CKHAVE entry point header. */
+
+/* - SPICELIB Version 4.3.0, 23-OCT-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments in */
+/* MOVED calls in entry points CKUPF and CKSNS. Replaced header */
+/* reference to LDPOOL with reference to FURNSH. */
+
+/* - SPICELIB Version 4.2.0, 30-DEC-2004 (NJB) */
+
+/* Increased STSIZE to 20000. */
+
+/* - SPICELIB Version 4.1.0, 20-NOV-2001 (NJB) */
+
+/* Bug fixes: */
+
+/* 1) When a segment list is freed because the entire list */
+/* is contributed by a single CK file, and the list is */
+/* too large to be buffered, the corresponding instrument */
+/* table pointer is now set to null. */
+
+/* 2) An algorithm change has eliminated a bug caused by not */
+/* updating the current instrument index when instrument */
+/* table entries having empty segment lists were compressed */
+/* out of the instrument table. Previously the instrument */
+/* table pointer IINDEX could go stale after the */
+/* compression. */
+
+/* 3) When a already loaded kernel is re-opened with DAFOPR, */
+/* it now has its link count reset to 1 via a call to */
+/* DAFCLS. */
+
+/* 4) The load routine CKLPF now resets all file numbers when */
+/* the next file number reaches INTMAX()-1, thereby */
+/* avoiding arithmetic overflow. */
+
+/* 5) The unload routine CKUPF now calls RETURN() on entry and */
+/* returns if so directed. */
+
+/* 6) In CKSNS, DAF calls are followed by tests of FAILED() */
+/* in order to ensure that the main state loop terminates. */
+
+/* The "re-use interval" feature was introduced to improve speed */
+/* in the case where repeated, consecutive requests are satisified */
+/* by the same segment. */
+
+/* The segment list cost algorithm was modified slightly: */
+/* the contribution of a file search to the cost of a list */
+/* is included only when the file search is completed. The */
+/* cost of finding the re-use interval is accounted for when */
+/* unbuffered searches are required. */
+
+/* The file table size has been increased to 1000, in order */
+/* to take advantage of the DAF system's new ability to load */
+/* 1000 files. */
+
+/* The instrument table size has been increased to 100 in order */
+/* to decrease the chance of thrashing due to swapping segment */
+/* lists for different bodies. */
+
+/* Various small updates and corrections were made to the */
+/* comments throughout the file. */
+
+/* - SPICELIB Version 4.0.0, 17-FEB-2000 (WLT) */
+
+/* Added the Entry point CKHAVE */
+
+/* - SPICELIB Version 3.0.0, 03-MAR-1999 (WLT) */
+
+/* The parameter STSIZE was increased from 1000 to 4000 to */
+/* avoid the buffering error that exists in the CKBSR. */
+
+/* - SPICELIB Version 2.0.0, 25-NOV-1992 (JML) */
+
+/* 1) When loading a file, CKLPF now checks if the file table is */
+/* full only after determining that the file is not currently */
+/* loaded. Previously, if the file table was full and an attempt */
+/* was made to reload a file, an error was signaled. A new */
+/* exception was added as a result of this change. */
+
+/* 2) A bug in the way that CKLPF and CKUPF clean up the instrument */
+/* tables after a file is unloaded was fixed. */
+
+/* 3) Variable declarations were added to the example program */
+/* so that it can now be compiled. */
+
+/* 4) The length of the elements in the array of segment */
+/* indentifiers ( STIDNT ) was changed from 56 to 40. */
+
+/* - SPICELIB Version 1.1.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.1.0, 01-NOV-1990 (JML) */
+
+/* An intial value was assigned to the variable STATUS so */
+/* that an error will be signaled if CKSNS is called */
+/* without CKBSS ever having been called to initiate the */
+/* search. */
+
+/* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* buffer ck segments for readers */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 4.3.0, 23-OCT-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments in */
+/* MOVED calls in entry points CKUPF and CKSNS. Replaced header */
+/* reference to LDPOOL with reference to FURNSH. */
+
+/* - SPICELIB Version 4.2.0, 30-DEC-2004 (NJB) */
+
+/* Increased STSIZE to 20000. */
+
+/* - SPICELIB Version 4.1.0, 20-NOV-2001 (NJB) */
+
+/* Bug fixes: */
+
+/* 1) When a segment list is freed because the entire list */
+/* is contributed by a single CK file, and the list is */
+/* too large to be buffered, the corresponding instrument */
+/* table pointer is now set to null. */
+
+/* 2) An algorithm change has eliminated a bug caused by not */
+/* updating the current instrument index when instrument */
+/* table entries having empty segment lists were compressed */
+/* out of the instrument. Previously the instrument table */
+/* pointer IINDEX could go stale after the compression. */
+
+/* 3) When a already loaded kernel is re-opened with DAFOPR, */
+/* it now has its link count reset to 1 via a call to */
+/* DAFCLS. */
+
+/* 4) The load routine CKLPF now resets all file numbers when */
+/* the next file number reaches INTMAX()-1, thereby */
+/* avoiding arithmetic overflow. */
+
+/* 5) The unload routine CKUPF now calls RETURN() on entry and */
+/* returns if so directed. */
+
+/* 6) In CKSNS, DAF calls are followed by tests of FAILED() */
+/* in order to ensure that the main state loop terminates. */
+
+/* The "re-use interval" feature was introduced to improve speed */
+/* in the case where repeated, consecutive requests are satisified */
+/* by the same segment. For each instrument, the associated */
+/* re-use interval marks the time interval containing the previous */
+/* request time for which the previously returned segment provides */
+/* the highest-priority data available. */
+/* The segment list cost algorithm was modified slightly: */
+/* the contribution of a file search to the cost of a list */
+/* is included only when the file search is completed. The */
+/* cost of finding the re-use interval is accounted for when */
+/* unbuffered searches are required. */
+
+/* The file table size has been increased to 1000, in order */
+/* to take advantage of the DAF system's new ability to load */
+/* 1000 files. */
+
+/* The instrument table size has been increased to 100 in order */
+/* to decrease the chance of thrashing due to swapping segment */
+/* lists for different instruments. */
+
+/* Various small updates and corrections were made to the */
+/* comments throughout the file. */
+
+/* In order to simplify the source code, the in-line singly */
+/* linked list implementation of the segment table has been */
+/* replaced by an implementation relying on the SPICELIB */
+/* doubly linked list routines. */
+
+
+/* - SPICELIB Version 2.0.0, 25-NOV-1992 (JML) */
+
+/* 1) When loading a file, CKLPF now checks if the file table is */
+/* full only after determining that the file is not currently */
+/* loaded. Previously, if the file table was full and an attempt */
+/* was made to reload a file, an error was signaled. A new */
+/* exception was added as a result of this change. */
+
+/* 2) A bug in the way that CKLPF and CKUPF clean up the instrument */
+/* tables after a file is unloaded was fixed. */
+
+/* 3) Variable declarations were added to the example program */
+/* so that it can now be compiled. */
+
+/* 4) The length of the elements in the array of segment */
+/* indentifiers ( STIDNT ) was changed from 56 to 40. */
+
+/* - SPICELIB Version 1.1.0, 01-NOV-1990 (JML) */
+
+/* An intial value was assigned to the variable STATUS so */
+/* that an error will be signaled if CKSNS is called */
+/* without CKBSS ever having been called to initiate the */
+/* search. */
+
+
+/* - Beta Version 1.1.0, 28-AUG-1990 (MJS) (JEM) */
+
+/* The following changes were made as a result of the */
+/* NAIF CK Code and Documentation Review: */
+
+/* 1) The variable SCLK was changed to SCLKDP. */
+/* 2) The variable IDENT was changed to SEGID. */
+/* 3) The parameterized values for FTSIZE and ITSIZE were */
+/* increased from 5 to 20. */
+/* 4) The paramterized value for STSIZE was increased from 100 */
+/* to 1000. */
+/* 5) The local variables INTDES and DPDES were changed to */
+/* ICD and DCD. */
+/* 6) The extended SAVE statement was broken in to single */
+/* SAVE statements. */
+/* 7) Header and internal documentation was corrected and */
+/* updated. */
+
+/* - Beta Version 1.0.0, 14-MAR-1990 (RET) (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* ND is the number of double precision components in an */
+/* unpacked C-kernel descriptor. */
+
+/* NI is the number of integer components in an unpacked */
+/* C-kernel descriptor. */
+
+/* DSCSIZ is the number of components in a packed C-kernel */
+/* descriptor. All DAF summaries have this formulaic */
+/* relationship between the number of its integer and */
+/* double precision components and the number of packed */
+/* components. */
+
+
+/* Constants used in the doubly linked list structure: */
+
+
+/* Local variables */
+
+
+/* The file table contains the handle and file number of each file */
+/* that has been loaded for use with the CK readers. File */
+/* numbers begin at one, and are incremented until they reach a */
+/* value of INTMAX() - 1, at which point they are mapped to the */
+/* range 1:NFT, where NFT is the number of loaded CK files. */
+
+/* A file number is similar to a file handle, but it is assigned */
+/* and used exclusively by this module. The purpose of file numbers */
+/* is to keep track of the order in which files are loaded and the */
+/* order in which they are searched. */
+
+/* All names begin with FT. */
+
+/* HAN Handle */
+/* NUM File number */
+
+/* NFT is the number of currently loaded CK files. NEXT is */
+/* incremented whenever a new file is loaded to give the file */
+/* number for that file. FINDEX is the index of whatever file is */
+/* of current interest. */
+
+/* New files are added at the end of the table. As files are */
+/* removed, succeeding files are moved forward to take up the */
+/* slack. This keeps the table ordered by file number. */
+
+
+/* The instrument table contains the beginning of the list of the */
+/* stored segments for each spacecraft/instrument pair, and the */
+/* expense at which that list was constructed. (The expense of an */
+/* instrument list is the number of segment descriptors examined */
+/* during the construction of the list.) It also contains the */
+/* highest and lowest file numbers searched during the construction */
+/* of the list. */
+
+/* For each instrument, the time bounds of the "re-use interval" */
+/* of the last segment found are stored. This interval is the */
+/* maximal interval containing the epoch of the last request for */
+/* data for this instrument, such that the interval is not masked */
+/* by higher-priority segments. The handle, segment descriptor, */
+/* and segment identifier returned on the last request are also */
+/* stored. */
+
+/* The reuse-interval is computed without regard to presence of */
+/* angular velocity: all segments seen while searching for */
+/* a segment satisfying a request are used to define the bounds */
+/* of the re-use interval. */
+
+/* Re-use intervals are defined on the *first* search following */
+/* a setup call to CKBSS. If a search is resumed (multiple calls */
+/* to CKSNS are made consecutively), the re-use interval becomes */
+/* invalid after the first CKSNS call. */
+
+/* All names begin with IT. */
+
+/* INS Spacecraft/instrument number */
+/* EXP Expense */
+/* HFS Highest file (number) searched */
+/* LFS Lowest file (number) searched */
+/* BEG Beginning of segment list */
+/* LB Lower bound of effective coverage interval of */
+/* previous segment returned. */
+/* UB Upper bound of effective coverage interval of */
+/* previous segment returned. */
+/* PRVD Previous descriptor. */
+/* PRVF Previous descriptor angular velocity flag. Angular */
+/* velocity is present when ITPRVF is non-zero. */
+/* PRVI Previous segment identifier returned. */
+/* PRVH Previous handle returned. */
+/* CHKP Logical indicating that previous segment should */
+/* be checked to see whether it satisfies a request. */
+/* RUEX Expense of the re-use interval. */
+
+/* NIT is the number of instruments for which segments are currently */
+/* being stored in the table. IINDEX is the index of whatever */
+/* instrument is of current interest at any given time. */
+
+/* New instruments are added at the end of the table. As instruments */
+/* are removed, the last instrument is moved forward to take up the */
+/* slack. This keeps the entries in the table contiguous. */
+
+
+/* The segment table contains the handle, descriptor, and identifier */
+/* for each segment that has been found so far. */
+
+/* The segment table is implemented as a set of arrays indexed by */
+/* a SPICE doubly linked list structure. For each instrument */
+/* in the instrument table, there is a segment table list; each */
+/* node of a list points to data associated with a segment. In */
+/* each list, the head node corresponds to the highest-priority */
+/* segment in that list, and segment priority decreases in the */
+/* forward direction. */
+
+/* All names begin with ST. */
+
+/* IDNT Identifier */
+/* DCD Double Precision component of descriptor */
+/* HAN Handle */
+/* ICD Integer component of descriptor */
+/* POOL Doubly linked list pool. */
+
+/* New segments are added to the front or end of an instrument list */
+/* as appropriate, according to the rules spelled out under */
+/* entry point CKSNS. */
+
+
+/* Other local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+ /* Parameter adjustments */
+ if (descr) {
+ }
+
+ /* Function Body */
+ switch(n__) {
+ case 1: goto L_cklpf;
+ case 2: goto L_ckupf;
+ case 3: goto L_ckbss;
+ case 4: goto L_cksns;
+ case 5: goto L_ckhave;
+ }
+
+
+/* Nobody has any business calling CKBSR directly. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("CKBSR", (ftnlen)5);
+ sigerr_("SPICE(CKBOGUSENTRY)", (ftnlen)19);
+ chkout_("CKBSR", (ftnlen)5);
+ return 0;
+/* $Procedure CKLPF ( C-kernel, load pointing file ) */
+
+L_cklpf:
+/* $ Abstract */
+
+/* Load a CK pointing file for use by the CK readers. Return that */
+/* file's handle, to be used by other CK routines to refer to the */
+/* file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) FNAME */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I Name of the CK file to be loaded. */
+/* HANDLE O Loaded file's handle. */
+/* FTSIZE P Maximum number of loaded CK files. */
+
+/* $ Detailed_Input */
+
+/* FNAME is the name of a C-kernel file to be loaded. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is an integer handle assigned to the file upon loading. */
+/* Almost every other CK routine will subsequently use */
+/* this number to refer to the file. */
+
+/* $ Parameters */
+
+/* FTSIZE is the maximum number of CK files that may */
+/* be loaded simultaneously under any circumstances. */
+/* FTSIZE is currently set to match the maximum number */
+/* of DAF files that may be loaded simultaneously. */
+
+/* $ Exceptions */
+
+/* 1) If an attempt is made to open more DAF files than is specified */
+/* by the parameter FTSIZE in DAFAH, an error is signaled by a */
+/* routine in the call tree of this routine. */
+
+/* 2) If an attempt is made to load more files than is specified */
+/* by the local paramater FTSIZE, and if the DAF system has */
+/* room to load another file, the error SPICE(CKTOOMANYFILES) */
+/* signaled. The current setting of FTSIZE does not allow this */
+/* situation to arise: the DAF system will trap the error */
+/* before this routine has the chance. */
+
+/* 3) If the file specified by FNAME can not be opened, an error */
+/* is signaled by a routine that this routine calls. */
+
+/* 4) If the file specified by FNAME has already been loaded, */
+/* it will become the "last-loaded" file. The readers */
+/* search the last-loaded file first. */
+
+/* $ Files */
+
+/* The C-kernel file specified by FNAME is loaded. The file is */
+/* assigned an integer handle by CKLPF. Other CK routines will refer */
+/* to this file by its handle. */
+
+/* $ Particulars */
+
+/* See Particulars above, in CKBSR. */
+
+/* If there is room for a new file, CKLPF opens the file for */
+/* reading. This routine must be called prior to a call to CKGP or */
+/* CKGPAV. */
+
+/* CK readers search files loaded with CKLPF in the reverse order */
+/* in which they were loaded. That is, last-loaded files are */
+/* searched first. */
+
+/* $ Examples */
+
+/* See the Example above, in CKBSR. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* J.M. Lynch (JPL) */
+/* J.E. McLean (JPL) */
+/* M.J. Spencer (JPL) */
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.1.0, 20-NOV-2001 (NJB) */
+
+/* Bug fixes: */
+
+/* 1) When an already loaded kernel is opened with DAFOPR, */
+/* it now has its link count reset to 1 via a call to */
+/* DAFCLS. */
+
+/* 2) This routine now resets all file numbers when */
+/* the next file number reaches INTMAX()-1, thereby avoiding */
+/* arithmetic overflow. The numbers in the file table */
+/* are replaced with consecutive integers in the range */
+/* 1 : NFT, such that the ordering of the numbers is not */
+/* changed. The HFS and LFS arrays are updated accordingly. */
+
+/* Also, the flags indicating validity of the re-use intervals */
+/* are set to .FALSE. here. */
+
+/* - SPICELIB Version 4.0.0, 17-FEB-2000 (WLT) */
+
+/* Added the Entry point CKHAVE */
+
+/* - SPICELIB Version 3.0.0, 03-MAR-1999 (WLT) */
+
+/* The parameter STSIZE was increased from 1000 to 4000 to */
+/* avoid the buffering error that exists in the CKBSR. */
+
+/* - SPICELIB Version 2.0.0, 25-NOV-1992 (JML) */
+
+/* 1) When loading a file, CKLPF now checks if the file table is */
+/* full only after determining that the file is not currently */
+/* loaded. Previously, if the file table was full and an attempt */
+/* was made to reload a file, an error was signaled. A new */
+/* exception was added as a result of this change. */
+
+/* 2) A bug in the way that CKLPF and CKUPF clean up the instrument */
+/* tables after a file is unloaded was fixed. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* load ck pointing file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 4.1.0, 20-NOV-2001 (NJB) */
+
+/* Bug fixes: */
+
+/* 1) When a loaded kernel is opened with DAFOPR, */
+/* it now has its link count reset to 1 via a call to */
+/* DAFCLS. */
+
+/* 2) This routine now resets all file numbers when */
+/* the next file number reaches INTMAX()-1, thereby avoiding */
+/* arithmetic overflow. The numbers in the file table */
+/* are replaced with consecutive integers in the range */
+/* 1 : NFT, such that the ordering of the numbers is not */
+/* changed. The HFS and LFS arrays are updated accordingly. */
+/* HFS and LFS entries that have gone stale are set to zero. */
+
+/* Also, the flags indicating validity of the re-use intervals */
+/* are set to .FALSE. here. */
+
+/* - SPICELIB Version 2.0.0, 25-NOV-1992 (JML) */
+
+/* Temp version for testing purposes. */
+
+/* 1) When loading a file, CKLPF now checks if the file table is */
+/* full only after determining that the file is not currently */
+/* loaded. Previously, if the file table was full and an attempt */
+/* was made to reload a file, an error was signaled. A new */
+/* exception was added as a result of this change. */
+
+/* 2) A bug in the way that CKLPF and CKUPF clean up the instrument */
+/* tables after a file is unloaded was fixed. */
+
+/* If as the result of loading a file that was previously loaded, */
+/* there are no more segments buffered for a particular */
+/* instrument, the counter variable for the instruments is no */
+/* longer incremented. */
+
+/* The following code fragment changed: */
+
+/* IF ( ITBEG( I ) .EQ. 0 ) THEN */
+
+/* . */
+/* . */
+/* . */
+/* NIT = NIT - 1 */
+
+/* END IF */
+
+/* I = I + 1 */
+
+/* This is the fix: */
+
+/* IF ( ITBEG( I ) .EQ. 0 ) THEN */
+
+/* . */
+/* . */
+/* . */
+/* NIT = NIT - 1 */
+
+/* ELSE */
+
+/* I = I + 1 */
+
+/* END IF */
+
+/* - Beta Version 1.1.0, 28-AUG-1990 (MJS) (JEM) */
+
+/* Header documentation was updated, and error handling was */
+/* modified. */
+
+/* - Beta Version 1.0.0, 14-MAR-1990 (RET) (IMU) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKLPF", (ftnlen)5);
+ }
+
+/* Don't allow a search to continue after loading a file; a new */
+/* search should be re-started. */
+
+ s_copy(status, "BOGUS ENTRY", (ftnlen)40, (ftnlen)11);
+
+/* Since a current search cannot be continued at this point, */
+/* free the left-over partial list searched in the */
+/* 'CHECK PARTIAL LIST' state, if the list is present. */
+
+ if (fresub) {
+
+/* Return the partial list to the free list. */
+
+ tail = lnktl_(&slbeg, stpool);
+ lnkfsl_(&slbeg, &tail, stpool);
+ fresub = FALSE_;
+ }
+
+/* Any time we load a file, there is a possibility that the */
+/* re-use intervals are invalid because they're been superseded */
+/* by higher-priority data. Since we're not going to examine */
+/* the loaded file, simply indicate that all of the re-use */
+/* intervals are invalid. */
+
+ i__1 = nit;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ itchkp[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("itchkp",
+ i__2, "ckbsr_", (ftnlen)1260)] = FALSE_;
+ }
+
+/* Nothing works unless at least one file has been loaded, so */
+/* this is as good a place as any to initialize the free list */
+/* whenever the instrument table is empty. */
+
+ if (nit == 0) {
+ lnkini_(&c__50000, stpool);
+ }
+
+/* To load a new file, first try to open it for reading. */
+
+ dafopr_(fname, handle, fname_len);
+ if (failed_()) {
+ chkout_("CKLPF", (ftnlen)5);
+ return 0;
+ }
+
+/* Determine if the file is already in the table. */
+
+ findex = isrchi_(handle, &nft, fthan);
+ if (findex > 0) {
+
+/* The last call we made to DAFOPR added another DAF link to */
+/* the CK file. Remove this link. */
+
+ dafcls_(handle);
+
+/* Handle is already in the table. Remove it. */
+
+ --nft;
+ i__1 = nft;
+ for (i__ = findex; i__ <= i__1; ++i__) {
+ fthan[(i__2 = i__ - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("fthan"
+ , i__2, "ckbsr_", (ftnlen)1300)] = fthan[(i__3 = i__) <
+ 1000 && 0 <= i__3 ? i__3 : s_rnge("fthan", i__3, "ckbsr_",
+ (ftnlen)1300)];
+ ftnum[(i__2 = i__ - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("ftnum"
+ , i__2, "ckbsr_", (ftnlen)1301)] = ftnum[(i__3 = i__) <
+ 1000 && 0 <= i__3 ? i__3 : s_rnge("ftnum", i__3, "ckbsr_",
+ (ftnlen)1301)];
+ }
+
+/* Unlink any segments that came from this file. */
+
+ i__ = 1;
+ while(i__ <= nit) {
+ p = itbeg[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itbeg", i__1, "ckbsr_", (ftnlen)1311)];
+ while(p > 0) {
+
+/* Find the successor of P, if any. */
+
+ nxtseg = lnknxt_(&p, stpool);
+ if (sthan[(i__1 = p - 1) < 50000 && 0 <= i__1 ? i__1 : s_rnge(
+ "sthan", i__1, "ckbsr_", (ftnlen)1319)] == *handle) {
+
+/* The segment corresponding to node P came from */
+/* the file we're unloading. Delete the node for */
+/* P from the segment list for instrument I; if P happens */
+/* to be the head node for instrument I's segment list, */
+/* make the successor of P the head of the list. */
+
+ lnkfsl_(&p, &p, stpool);
+ if (p == itbeg[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1
+ : s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)1329)])
+ {
+ itbeg[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)1330)]
+ = nxtseg;
+ }
+ }
+
+/* Update P. */
+
+ p = nxtseg;
+ }
+
+/* If the list for this instrument is now empty, shorten the */
+/* current table by one: put all the entries for the last */
+/* instrument in the table into the space occupied by the */
+/* one we've deleted. */
+
+ if (itbeg[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itbeg", i__1, "ckbsr_", (ftnlen)1347)] <= 0) {
+
+/* Because all of the re-use intervals are invalid, we need */
+/* not copy the saved items associated with them. The */
+/* items not copied are */
+
+/* ITCHKP */
+/* ITLB */
+/* ITPRVD */
+/* ITPRVF */
+/* ITPRVH */
+/* ITPRVI */
+/* ITRUEX */
+/* ITUB */
+
+ itins[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itins", i__1, "ckbsr_", (ftnlen)1362)] = itins[(i__2
+ = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("itins",
+ i__2, "ckbsr_", (ftnlen)1362)];
+ itexp[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itexp", i__1, "ckbsr_", (ftnlen)1363)] = itexp[(i__2
+ = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("itexp",
+ i__2, "ckbsr_", (ftnlen)1363)];
+ ithfs[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "ithfs", i__1, "ckbsr_", (ftnlen)1364)] = ithfs[(i__2
+ = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("ithfs",
+ i__2, "ckbsr_", (ftnlen)1364)];
+ itlfs[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itlfs", i__1, "ckbsr_", (ftnlen)1365)] = itlfs[(i__2
+ = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("itlfs",
+ i__2, "ckbsr_", (ftnlen)1365)];
+ itbeg[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itbeg", i__1, "ckbsr_", (ftnlen)1366)] = itbeg[(i__2
+ = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("itbeg",
+ i__2, "ckbsr_", (ftnlen)1366)];
+ --nit;
+ } else {
+ ++i__;
+ }
+ }
+ } else {
+
+/* This is a new file. Make sure that there are unused slots */
+/* in the file table. */
+
+ if (nft == 1000) {
+ dafcls_(handle);
+ setmsg_("Number of files loaded is at a maximum, as specified by"
+ " the parameter FTSIZE, the value of which is #. You will"
+ " need to either load fewer files, or change the paramete"
+ "r FTSIZE.", (ftnlen)176);
+ errint_("#", &c__1000, (ftnlen)1);
+ sigerr_("SPICE(CKTOOMANYFILES)", (ftnlen)21);
+ chkout_("CKLPF", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Determine the next file number. */
+
+ if (next < intmax_() - 1) {
+ ++next;
+ } else {
+
+/* The user is to be congratulated: we've run out of file */
+/* numbers. */
+
+/* Re-set the valid file numbers so they lie in the range 1:NFT, */
+/* with the Ith file in the file table having file number I. */
+/* First update the LFS and HFS components of the instrument table */
+/* according to this mapping. */
+
+/* Set any instrument table entries that are lower than FTNUM(1) */
+/* to zero. */
+
+ i__1 = nit;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+
+/* Re-map the HFS table for the Ith instrument. */
+
+ j = isrchi_(&ithfs[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("ithfs", i__2, "ckbsr_", (ftnlen)1425)], &nft,
+ ftnum);
+ if (j > 0) {
+
+/* The highest file searched for instrument I is the Jth */
+/* file in the file table. */
+
+ ithfs[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "ithfs", i__2, "ckbsr_", (ftnlen)1432)] = j;
+ } else {
+
+/* The highest file searched for instrument I is not in the */
+/* file table. This occurs when the highest file searched */
+/* has been unloaded. Note that this assigment makes all */
+/* files appear to be "new" when a lookup for instrument */
+/* I is performed. */
+
+ ithfs[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "ithfs", i__2, "ckbsr_", (ftnlen)1442)] = 0;
+ }
+
+/* Re-map the LFS table for the Ith instrument. */
+
+ j = isrchi_(&itlfs[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("itlfs", i__2, "ckbsr_", (ftnlen)1449)], &nft,
+ ftnum);
+ if (j > 0) {
+
+/* The lowest file searched for instrument I is the Jth file */
+/* in the file table. */
+
+ itlfs[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "itlfs", i__2, "ckbsr_", (ftnlen)1456)] = j;
+ } else {
+
+/* The lowest file searched for instrument I is not in the */
+/* file table. This occurs when the lowest file searched */
+/* has been unloaded. Zero out both the lowest and */
+/* highest file searched to force reconstruction of the */
+/* list. */
+
+ itlfs[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "itlfs", i__2, "ckbsr_", (ftnlen)1466)] = 0;
+ ithfs[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "ithfs", i__2, "ckbsr_", (ftnlen)1467)] = 0;
+ }
+ }
+
+/* Re-map the file number table itself. */
+
+ i__1 = nft;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ ftnum[(i__2 = i__ - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("ftnum"
+ , i__2, "ckbsr_", (ftnlen)1478)] = i__;
+ }
+
+/* Assign a new file number. */
+
+ next = nft + 1;
+ }
+
+/* Now add this file to file table. */
+
+ ++nft;
+ fthan[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("fthan", i__1,
+ "ckbsr_", (ftnlen)1493)] = *handle;
+ ftnum[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftnum", i__1,
+ "ckbsr_", (ftnlen)1494)] = next;
+ chkout_("CKLPF", (ftnlen)5);
+ return 0;
+/* $Procedure CKUPF ( C-kernel, Unload pointing file ) */
+
+L_ckupf:
+/* $ Abstract */
+
+/* Unload a CK pointing file so that it will no longer be searched */
+/* by the readers. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of CK file to be unloaded */
+
+/* $ Detailed_Input */
+
+/* HANDLE Integer handle assigned to the file upon loading. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) Unloading a file that has not been loaded is a no-op. */
+/* No error is signaled. */
+
+/* $ Files */
+
+/* The file referred to by HANDLE is unloaded. */
+
+/* $ Particulars */
+
+/* See Particulars section above, in CKBSR. */
+
+/* Unloading a file with CKUPF removes that file from consideration */
+/* by the CK readers. In doing so, it frees up space for another */
+/* file to be loaded. */
+
+/* $ Examples */
+
+/* See the Example above, in CKBSR. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* J.M. Lynch (JPL) */
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.2.0, 08-SEP-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in MOVED call. */
+
+/* - SPICELIB Version 4.1.0, 20-NOV-2001 (NJB) */
+
+/* Bug fixes: */
+
+/* 1) This routine now calls RETURN() on entry and */
+/* returns if so directed. */
+
+/* Also, the flags indicating validity of those re-use intervals */
+/* whose data comes from the unloaded file are set to .FALSE. */
+
+/* - SPICELIB Version 4.0.0, 17-FEB-2000 (WLT) */
+
+/* Added the Entry point CKHAVE */
+
+/* - SPICELIB Version 3.0.0, 03-MAR-1999 (WLT) */
+
+/* The parameter STSIZE was increased from 1000 to 4000 to */
+/* avoid the buffering error that exists in the CKBSR. */
+
+/* - SPICELIB Version 2.0.0, 25-NOV-1992 (JML) */
+
+/* 1) A bug in the way that CKLPF and CKUPF clean up the instrument */
+/* tables after a file is unloaded was fixed. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* unload ck pointing file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 4.2.0, 08-SEP-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in MOVED call. */
+
+/* - SPICELIB Version 4.1.0, 20-NOV-2001 (NJB) */
+
+/* Bug fixes: */
+
+/* 1) This routine now calls RETURN() on entry and */
+/* returns if so directed. */
+
+/* Also, the flags indicating validity of those re-use intervals */
+/* whose data comes from the unloaded file are set to .FALSE. */
+
+/* - SPICELIB Version 2.0.0, 25-NOV-1992 (JML) */
+
+/* 1) A bug in the way that CKLPF and CKUPF clean up the instrument */
+/* tables after a file is unloaded was fixed. */
+
+/* If as the result of unloading a file there are no more */
+/* segments buffered for a particular instrument, the counter */
+/* variable for the instruments in the instrument table is no */
+/* longer incremented. */
+
+/* The following code fragment changed: */
+
+/* IF ( ITBEG( I ) .EQ. 0 ) THEN */
+
+/* . */
+/* . */
+/* . */
+/* NIT = NIT - 1 */
+
+/* END IF */
+
+/* I = I + 1 */
+
+/* This is the fix: */
+
+/* IF ( ITBEG( I ) .EQ. 0 ) THEN */
+
+/* . */
+/* . */
+/* . */
+/* NIT = NIT - 1 */
+
+/* ELSE */
+
+/* I = I + 1 */
+
+/* END IF */
+
+/* - Beta Version 1.0.1, 29-AUG-1990 (MJS) (JEM) */
+
+/* Comments were updated. */
+
+/* - Beta Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+ if (return_()) {
+ return 0;
+ }
+ chkin_("CKUPF", (ftnlen)5);
+
+/* Don't allow a search to continue after unloading a file; a new */
+/* search should be re-started. */
+
+ s_copy(status, "BOGUS ENTRY", (ftnlen)40, (ftnlen)11);
+
+/* Since a current search cannot be continued at this point, */
+/* free the left-over partial list searched in the */
+/* 'CHECK PARTIAL LIST' state, if the list is present. */
+
+ if (fresub) {
+
+/* Return the partial list to the free list. */
+
+ tail = lnktl_(&slbeg, stpool);
+ lnkfsl_(&slbeg, &tail, stpool);
+ fresub = FALSE_;
+ }
+
+/* All of the stored segments from the file must be removed */
+/* from the segment table (by returning the corresponding nodes */
+/* to the segment table pool.) */
+
+/* Don't do anything if the given handle is not in the file table. */
+
+ findex = isrchi_(handle, &nft, fthan);
+ if (findex == 0) {
+ chkout_("CKUPF", (ftnlen)5);
+ return 0;
+ }
+
+
+/* First get rid of the entry in the file table. Close the file */
+/* before wiping out the handle. */
+
+ dafcls_(&fthan[(i__1 = findex - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "fthan", i__1, "ckbsr_", (ftnlen)1760)]);
+ --nft;
+ i__1 = nft;
+ for (i__ = findex; i__ <= i__1; ++i__) {
+ fthan[(i__2 = i__ - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("fthan",
+ i__2, "ckbsr_", (ftnlen)1766)] = fthan[(i__3 = i__) < 1000 &&
+ 0 <= i__3 ? i__3 : s_rnge("fthan", i__3, "ckbsr_", (ftnlen)
+ 1766)];
+ ftnum[(i__2 = i__ - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("ftnum",
+ i__2, "ckbsr_", (ftnlen)1767)] = ftnum[(i__3 = i__) < 1000 &&
+ 0 <= i__3 ? i__3 : s_rnge("ftnum", i__3, "ckbsr_", (ftnlen)
+ 1767)];
+ }
+
+/* Check each instrument list individually. Note that the first */
+/* node on each list, having no predecessor, must be handled */
+/* specially. */
+
+ i__ = 1;
+ while(i__ <= nit) {
+ p = itbeg[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("itbeg",
+ i__1, "ckbsr_", (ftnlen)1779)];
+ while(p > 0) {
+ nxtseg = lnknxt_(&p, stpool);
+ if (sthan[(i__1 = p - 1) < 50000 && 0 <= i__1 ? i__1 : s_rnge(
+ "sthan", i__1, "ckbsr_", (ftnlen)1785)] == *handle) {
+ if (p == itbeg[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)1787)]) {
+ itbeg[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itbeg", i__1, "ckbsr_", (ftnlen)1788)] = nxtseg;
+ }
+
+/* Free this segment table entry. */
+
+ lnkfsl_(&p, &p, stpool);
+ }
+ p = nxtseg;
+ }
+
+/* If the list for this instrument is now empty, shorten the */
+/* current table by one: put all the entries for the last */
+/* instrument in the table into the space occupied by the */
+/* one we've deleted. */
+
+ if (itbeg[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("itbeg",
+ i__1, "ckbsr_", (ftnlen)1807)] == 0) {
+ if (i__ != nit) {
+ itins[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itins", i__1, "ckbsr_", (ftnlen)1811)] = itins[(i__2
+ = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("itins",
+ i__2, "ckbsr_", (ftnlen)1811)];
+ itexp[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itexp", i__1, "ckbsr_", (ftnlen)1812)] = itexp[(i__2
+ = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("itexp",
+ i__2, "ckbsr_", (ftnlen)1812)];
+ ithfs[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "ithfs", i__1, "ckbsr_", (ftnlen)1813)] = ithfs[(i__2
+ = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("ithfs",
+ i__2, "ckbsr_", (ftnlen)1813)];
+ itlfs[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itlfs", i__1, "ckbsr_", (ftnlen)1814)] = itlfs[(i__2
+ = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("itlfs",
+ i__2, "ckbsr_", (ftnlen)1814)];
+ itbeg[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itbeg", i__1, "ckbsr_", (ftnlen)1815)] = itbeg[(i__2
+ = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("itbeg",
+ i__2, "ckbsr_", (ftnlen)1815)];
+ itlb[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itlb", i__1, "ckbsr_", (ftnlen)1816)] = itlb[(i__2 =
+ nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("itlb",
+ i__2, "ckbsr_", (ftnlen)1816)];
+ itub[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itub", i__1, "ckbsr_", (ftnlen)1817)] = itub[(i__2 =
+ nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("itub",
+ i__2, "ckbsr_", (ftnlen)1817)];
+ itprvf[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itprvf", i__1, "ckbsr_", (ftnlen)1818)] = itprvf[(
+ i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "itprvf", i__2, "ckbsr_", (ftnlen)1818)];
+ itprvh[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itprvh", i__1, "ckbsr_", (ftnlen)1819)] = itprvh[(
+ i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "itprvh", i__2, "ckbsr_", (ftnlen)1819)];
+ s_copy(itprvi + ((i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itprvi", i__1, "ckbsr_", (ftnlen)1820)) * 40,
+ itprvi + ((i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("itprvi", i__2, "ckbsr_", (ftnlen)1820)) * 40,
+ (ftnlen)40, (ftnlen)40);
+ itchkp[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itchkp", i__1, "ckbsr_", (ftnlen)1821)] = itchkp[(
+ i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "itchkp", i__2, "ckbsr_", (ftnlen)1821)];
+ itruex[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itruex", i__1, "ckbsr_", (ftnlen)1822)] = itruex[(
+ i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "itruex", i__2, "ckbsr_", (ftnlen)1822)];
+ moved_(&itprvd[(i__1 = nit * 5 - 5) < 500 && 0 <= i__1 ? i__1
+ : s_rnge("itprvd", i__1, "ckbsr_", (ftnlen)1824)], &
+ c__5, &itprvd[(i__2 = i__ * 5 - 5) < 500 && 0 <= i__2
+ ? i__2 : s_rnge("itprvd", i__2, "ckbsr_", (ftnlen)
+ 1824)]);
+ }
+ --nit;
+ } else {
+ ++i__;
+ }
+ }
+
+/* Any time we unload a file, we may be removing the file */
+/* providing data for the re-use interval for one or more */
+/* instruments. For each instrument, if the handle associated */
+/* with the re-use interval happens to be that of the file */
+/* we're unloading, indicate that the re-use interval is invalid. */
+
+ i__1 = nit;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ if (itchkp[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge("itch"
+ "kp", i__2, "ckbsr_", (ftnlen)1847)]) {
+ if (itprvh[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "itprvh", i__2, "ckbsr_", (ftnlen)1849)] == *handle) {
+ itchkp[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "itchkp", i__2, "ckbsr_", (ftnlen)1850)] = FALSE_;
+ }
+ }
+ }
+ chkout_("CKUPF", (ftnlen)5);
+ return 0;
+/* $Procedure CKBSS ( C-kernel, begin search for segment ) */
+
+L_ckbss:
+/* $ Abstract */
+
+/* Initiate search through loaded files to find segments applicable */
+/* to the spacecraft instrument and time specified. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+
+/* INTEGER INST */
+/* DOUBLE PRECISION SCLKDP */
+/* DOUBLE PRECISION TOL */
+/* LOGICAL NEEDAV */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* INST I Spacecraft and instrument ID. */
+/* SCLKDP I Encoded spacecraft clock time. */
+/* TOL I Time tolerance. */
+/* NEEDAV I Is there a need for angular velocity? */
+
+/* $ Detailed_Input */
+
+/* CKBSS sets up a search for segments. The four quantities below */
+/* establish the search criteria. */
+
+
+/* INST is the NAIF ID of an instrument. */
+
+/* SCLKDP is an encoded spacecraft clock time. */
+
+/* TOL is a time tolerance, measured in the same units as */
+/* encoded spacecraft clock. */
+
+/* NEEDAV indicates whether or not angular velocity data is */
+/* required. */
+
+/* If true, only segments containing pointing and angular */
+/* velocity data will be checked. If false, segments */
+/* containing just pointing data will also be considered. */
+
+
+/* A segment matches the CKBSS/CKSNS search criteria when the */
+/* following statements are true. */
+
+/* 1) INST matches the instrument number for the segment. */
+
+/* 2) The time interval [SCLKDP - TOL, SCLKDP + TOL] intersects */
+/* the time interval of the segment. */
+
+/* 3) If angular velocity data is required, as indicated by */
+/* NEEDAV, the segment contains angular velocity data. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If no files have been loaded, the error SPICE(NOLOADEDFILES) */
+/* is signaled. */
+
+/* $ Files */
+
+/* All files loaded by CKLPF are potential search targets for */
+/* CKSNS. */
+
+/* $ Particulars */
+
+/* CKBSS sets up a search for segments by CKSNS. It records the */
+/* instrument and time to be searched for, and whether to require */
+/* segments containing angular velocity data. If angular velocity */
+/* data are required, only segments containing angular velocity */
+/* data will be returned by CKSNS. If angular velocity data are */
+/* not required, segments returned by CKSNS may or may not contain */
+/* angular velocity data. */
+
+/* CKBSS determines the first task that CKSNS will have to perform */
+/* if it is called to get an applicable segment. */
+
+/* $ Examples */
+
+/* See Examples in CKBSR. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* M.J. Spencer (JPL) */
+/* J.E. McLean (JPL) */
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.1.0, 20-NOV-2001 (NJB) */
+
+/* Updated to support new doubly-linked list implementation: */
+/* partial segment list that cannot be buffered is now */
+/* deallocated here rather than in CKSNS. Minor changes to */
+/* comments were made as well. */
+
+/* - SPICELIB Version 4.0.0, 17-FEB-2000 (WLT) */
+
+/* Added the Entry point CKHAVE */
+
+/* - SPICELIB Version 3.0.0, 03-MAR-1999 (WLT) */
+
+/* The parameter STSIZE was increased from 1000 to 4000 to */
+/* avoid the buffering error that exists in the CKBSR. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* begin search for ck segment */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 4.1.0, 20-NOV-2001 (NJB) */
+
+/* Updated to support new doubly-linked list implementation: */
+/* partial segment list that cannot be buffered is now */
+/* deallocated here rather than in CKSNS. Minor changes to */
+/* comments were made as well. */
+
+/* - Beta Version 1.1.0, 28-AUG-1990 (MJS) (JEM) */
+
+/* The following changes were made as a result of the */
+/* NAIF CK Code and Documentation Review: */
+
+/* 1) The variable SCLK was changed to SCLKDP. */
+/* 2) Header documentation was updated. */
+
+/* - Beta Version 1.0.0, 20-APR-1990 (RET) (IMU) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKBSS", (ftnlen)5);
+ }
+
+/* If we're starting a new search after passing through the */
+/* 'CHECK PARTIAL LIST' state, free the left-over partial list */
+/* that was searched in that state, if necessary. */
+
+ if (fresub) {
+
+/* Return the partial list to the free list. */
+
+ tail = lnktl_(&slbeg, stpool);
+ lnkfsl_(&slbeg, &tail, stpool);
+ fresub = FALSE_;
+ }
+
+/* Make copies of the instrument ID code and angular velocity flag. */
+/* Save the request time itself. */
+
+/* And form the endpoints of the acceptable time interval using the */
+/* input time and time tolerance. */
+
+ scinst = *inst;
+ alpha = *sclkdp - *tol;
+ omega = *sclkdp + *tol;
+ avneed = *needav;
+ reqt = *sclkdp;
+ savtol = *tol;
+
+/* There must be at least one file loaded. */
+
+ if (nft == 0) {
+ setmsg_("At least one CK file needs must be loaded by CKLPF before b"
+ "eginning a search.", (ftnlen)77);
+ sigerr_("SPICE(NOLOADEDFILES)", (ftnlen)20);
+ chkout_("CKBSS", (ftnlen)5);
+ return 0;
+ }
+
+/* The stack of suspended tasks is empty. */
+
+ top = 0;
+
+/* Is the instrument already in the instrument table? The answer */
+/* determines what the first task for CKSNS will be. */
+
+ iindex = isrchi_(&scinst, &nit, itins);
+ if (iindex == 0) {
+ s_copy(status, "NEW INSTRUMENT", (ftnlen)40, (ftnlen)14);
+ } else {
+
+/* Set the status so that CKSNS will determine whether to check */
+/* the segment list, search new files, or return data from the */
+/* re-use interval. */
+
+ s_copy(status, "?", (ftnlen)40, (ftnlen)1);
+ }
+
+/* Indicate a new search has started. */
+
+ newsch = TRUE_;
+ chkout_("CKBSS", (ftnlen)5);
+ return 0;
+/* $Procedure CKSNS ( C-kernel, Select next segment ) */
+
+L_cksns:
+/* $ Abstract */
+
+/* Search through loaded files to find a segment matching the */
+/* requested instrument, time, and need for angular velocity. */
+/* Buffer segment descriptors, identifiers, and handles in the */
+/* process to minimize file reads. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* DOUBLE PRECISION DESCR ( * ) */
+/* CHARACTER*(*) SEGID */
+/* LOGICAL FOUND */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE O Handle of file containing the applicable segment. */
+/* DESCR O Descriptor of the applicable segment. */
+/* SEGID O Identifier of the applicable segment. */
+/* FOUND O True if a segment was found. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is an integer handle of the file containing the */
+/* segment matching the instrument and time */
+/* specifications made in the last call to CKBSS. */
+
+/* DESCR, */
+/* SEGID are the descriptor and identifier of the segment found */
+/* which matches the instrument and time specifications */
+/* made in the last call to CKBSS. */
+
+/* FOUND is true if an applicable segment was found. False */
+/* otherwise. If FOUND is false, the values of the */
+/* other arguments are meaningless. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If CKSNS is called without CKBSS ever having been called, */
+/* the error 'SPICE(CALLCKBSSFIRST)' is signaled. */
+
+/* 2) If no segment is found that matches the search criteria, */
+/* FOUND is set to false, but the values of HANDLE, DESCR, */
+/* and SEGID will be meaningless. */
+
+/* $ Files */
+
+/* All files loaded by CKLPF are potential search targets for */
+/* CKSNS. The files are all referred to by their integer handles. */
+
+/* $ Particulars */
+
+/* CKSNS is used to locate segments based on the search criteria */
+/* established by the most recent call to CKBSS. When a segment */
+/* is found it will have the following characteristics: */
+
+/* 1) Its instrument will match the instrument specified in the */
+/* call to CKBSS. */
+
+/* 2) Its time interval will intersect the time interval */
+
+/* [SCLKDP - TOL, SCLKDP + TOL], */
+
+/* where SCLKDP and TOL were specified in the call to CKBSS. */
+
+/* 3) If there is a need for angular velocity data, as specified */
+/* by NEEDAV in the call to CKBSS, a returned segment */
+/* will contain angular velocity data. If there is no need */
+/* for such data, the returned segment may or may not contain */
+/* angular velocity data. */
+
+/* The first call to CKSNS following a call to CKBSS starts a search */
+/* through loaded files and either returns the first applicable */
+/* segment, or indicates that no segment was found. */
+
+/* CKSNS searches through last-loaded files first. Individual */
+/* files are searched backwards, so that segments that were inserted */
+/* last into the file get checked first. */
+
+/* Subsequent calls to CKSNS pick up the search exactly where the */
+/* previous calls left off. If a segment is not found, future calls */
+/* will also indicate that no segment could be found, until a new */
+/* search is begun. */
+
+/* CKSNS also buffers segment descriptors and identifiers, to */
+/* attempt to minimize file reads. */
+
+/* $ Examples */
+
+/* See Examples in CKBSR. */
+
+/* $ Restrictions */
+
+/* 1) This subroutine assumes that a search has been initiated by */
+/* a call to CKBSS. */
+
+/* 2) When a CK file is loaded or unloaded, a new search must */
+/* be started via a call to CKBSS before this routine may */
+/* be called. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* J.E. McLean (JPL) */
+/* M.J. Spencer (JPL) */
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.2.0, 08-SEP-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in MOVED call. */
+
+/* - SPICELIB Version 4.1.0, 20-NOV-2001 (NJB) */
+
+/* Bug fixes: */
+
+/* 1) When a segment list is freed because the entire list */
+/* is contributed by a single CK file, and the list is */
+/* too large to be buffered, the corresponding intrument */
+/* table pointer is now set to null. */
+
+/* 2) An algorithm change has eliminated a bug caused by not */
+/* updating the current instrument index when instrument */
+/* table entries having empty segment lists were compressed */
+/* out of the instrument table. Previously the instrument */
+/* table pointer IINDEX could go stale after the */
+/* compression. */
+
+/* 3) DAF calls are now followed by tests of FAILED() */
+/* in order to ensure that the main state loop terminates. */
+
+/* The "re-use interval" feature was introduced to improve speed */
+/* in the case where repeated, consecutive requests are satisified */
+/* by the same segment. */
+
+/* The segment list cost algorithm was modified slightly: */
+/* the contribution of a file search to the cost of a list */
+/* is included only when the file search is completed. The */
+/* cost of finding the re-use interval is accounted for when */
+/* unbuffered searches are required. */
+
+/* The file table size has been increased to 1000, in order */
+/* to take advantage of the DAF system's new ability to load */
+/* 1000 files. */
+
+/* The instrument table size has been increased to 100 in order to */
+/* decrease the chance of thrashing due to swapping segment */
+/* lists for different bodies. */
+
+/* Various small updates and corrections were made to the */
+/* comments throughout the file. */
+
+/* - SPICELIB Version 4.0.0, 17-FEB-2000 (WLT) */
+
+/* Added the Entry point CKHAVE */
+
+/* - SPICELIB Version 3.0.0, 03-MAR-1999 (WLT) */
+
+/* The parameter STSIZE was increased from 1000 to 4000 to */
+/* avoid the buffering error that exists in the CKBSR. */
+
+/* - SPICELIB Version 1.1.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.1.0, 01-NOV-1990 (JML) */
+
+/* A check on the initial value of the variable STATUS */
+/* was added in order to detect the situation in which */
+/* CKBSS was never called to initiate a search. */
+
+
+/* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* select next ck segment */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 4.2.0, 08-SEP-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in MOVED call. */
+
+/* - SPICELIB Version 4.1.0, 20-NOV-2001 (NJB) */
+
+/* Bug fixes: */
+
+/* 1) When a segment list is freed because the entire list */
+/* is contributed by a single CK file, and the list is */
+/* too large to be buffered, the corresponding instrument */
+/* table pointer is now set to null. */
+
+/* 2) An algorithm change has eliminated a bug caused by not */
+/* updating the current instrument index when instrument */
+/* table entries having empty segment lists were compressed */
+/* out of the instrument table. Previously the instrument */
+/* table pointer IINDEX could go stale after the */
+/* compression. */
+
+/* 3) DAF calls are now followed by tests of FAILED() */
+/* in order to ensure that the main state loop terminates. */
+
+/* The "re-use interval" feature was introduced to improve speed */
+/* in the case where repeated, consecutive requests are satisified */
+/* by the same segment. */
+
+/* The segment list cost algorithm was modified slightly: */
+/* the contribution of a file search to the cost of a list */
+/* is included only when the file search is completed. The */
+/* cost of finding the re-use interval is accounted for when */
+/* unbuffered searches are required. */
+
+/* The file table size has been increased to 1000, in order */
+/* to take advantage of the DAF system's new ability to load */
+/* 1000 files. */
+
+/* The instrument table size has been increased to 100 in order to */
+/* decrease the chance of thrashing due to swapping segment */
+/* lists for different instruments. */
+
+/* Various small updates and corrections were made to the */
+/* comments throughout the file. */
+
+
+/* - SPICELIB Version 1.1.0, 01-NOV-1990 (JML) */
+
+/* A check on the initial value of the variable STATUS */
+/* was added in order to detect the situation in which */
+/* CKBSS was never called to initiate a search. */
+
+
+/* - Beta Version 1.1.0, 28-AUG-1990 (MJS) (JEM) */
+
+/* The following changes were made as a result of the */
+/* NAIF CK Code and Documentation Review: */
+
+/* 1) The variable IDENT was changed to SEGID. */
+/* 2) The local variables INTDES and DPDES were changed to */
+/* ICD and DCD. */
+/* 3) Header and internal documentation was corrected and */
+/* updated. */
+
+/* - Beta Version 1.0.0, 20-APR-1990 (RET) (IMU) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKSNS", (ftnlen)5);
+ }
+
+/* Nothing's been found yet. */
+
+ *found = FALSE_;
+
+/* Initialize the segment list pointer to the saved value from */
+/* the previous pass through this routine, if any. */
+
+ p = savep;
+
+/* CKSNS buffers segment descriptors and identifiers, to */
+/* attempt to minimize file reads. Buffering segments involves */
+/* maintaining three tables: the file table, the instrument table, */
+/* and the segment table. CKSNS is broken down into various tasks, */
+/* described in the code below, which perform these manipulations. */
+
+/* A description of the components of each table is provided in */
+/* the declarations section of CKBSR. */
+
+/* Basically, the buffering is performed as follows: once a request */
+/* for a segment for a particular instrument is made, if there are */
+/* no adequate entries in the buffer already, a search is made */
+/* through loaded files for applicable segments. Every segment */
+/* pertaining to that instrument in a searched file is buffered, */
+/* before a check of the current buffer is made. If the search */
+/* doesn't turn up a segment matching the specified search criteria */
+/* the next file is searched and new segments are added to the list, */
+/* and so on. */
+
+/* The information in the segment table (ST) is stored in a */
+/* doubly-linked list. Each node in the list contains several */
+/* individual pieces of data, which are stored in parallel */
+/* arrays. */
+
+/* In the following loop, we will try to simplify things by */
+/* doing exactly one thing on each pass through the loop. */
+/* After each pass, the status of the loop (STATUS) will be */
+/* adjusted to reflect the next thing that needs to be done. */
+/* The first task is set by CKBSS. */
+
+/* Occasionally, the current task will have to be interrupted */
+/* until another task can be carried out. (For example, when */
+/* collecting new segments, an interrupt might place a segment */
+/* at the front or end of the current instrument list; when placing */
+/* the segment on the list, a second interrupt might free */
+/* room in the segment table in order to allow the addition */
+/* to proceed.) In this case, the current task will be saved and */
+/* restored after the more urgent task has been completed. */
+
+/* The loop can terminate in only one of two ways (unless an error */
+/* occurs). First, if an applicable segment is found in the segment */
+/* table, the handle, descriptor, and identifier for the segment */
+/* are returned immediately. Second, if the table does not contain */
+/* an applicable segment, and if no files remain to be searched, */
+/* the loop terminates normally, and no data are returned. */
+
+/* The status is saved on exit, however, so that subsequent calls */
+/* will resume a search exactly where previous calls left off. */
+
+/* Each status is described below. */
+
+/* 'NEW INSTRUMENT' */
+
+/* This indicates that the specified spacecraft/instrument has */
+/* no segments stored for it at all. It must be added to the */
+/* instrument table. (This is followed immediately by an */
+/* OLD FILES search, in which every file loaded is considered an */
+/* old file.) */
+
+/* 'NEW FILES' */
+
+/* This indicates that at least one new file has been added */
+/* since the last time the segment list for the specified */
+/* instrument was searched. Find the oldest of these new files, */
+/* and begin a NEW SEGMENTS search in forward order for */
+/* segments to add to the front of the list. */
+
+/* 'NEW SEGMENTS' */
+
+/* Continue a NEW FILES search, adding segments for the specified */
+/* instrument to the front of the list. */
+
+/* 'OLD FILES' */
+
+/* This indicates that although the list has been searched */
+/* and found to contain no applicable segment, some of the */
+/* older files remain to be searched. Find the newest of these */
+/* old files, and begin an OLD SEGMENTS search in backward order. */
+
+/* 'OLD SEGMENTS' */
+
+/* Continue an OLD FILES search, adding segments for the specified */
+/* instrument to the end of the list. */
+
+/* 'CHECK LIST' */
+
+/* This indicates that the list is ready to be searched, */
+/* either because no new files have been added, or because */
+/* segments from a new file or an old file have recently */
+/* been added. */
+
+/* The list is never checked until all new files have been */
+/* searched. */
+
+/* If an applicable segment is found, it is returned. */
+
+/* 'MAKE ROOM' (Interrupt) */
+
+/* This indicates that one of the instruments must be removed, */
+/* along with its stored segments, to make room for another */
+/* instrument or segment. The instrument (other than the */
+/* specified instrument) with the smallest expense is selected */
+/* for this honor. */
+
+/* 'ADD TO FRONT' (Interrupt) */
+
+/* This indicates that a segment has been found (during the */
+/* course of a NEW FILES search) and must be added to the front */
+/* of the list. */
+
+/* 'ADD TO END' (Interrupt) */
+
+/* This indicates that a segment has been found (during the */
+/* course of an OLD FILES search) and must be added to the end */
+/* of the list. */
+
+/* 'PREPARE PARTIAL LIST' */
+
+/* This indicates that an attempt to 'MAKE ROOM' failed when */
+/* trying to 'ADD TO END' because all of the segments in the */
+/* table were for the instrument being searched on. The partial */
+/* list is found that contains all of the segments that were in */
+/* the process of being added to the table for the current old */
+/* file. Next a 'CHECK PARTIAL LIST' is performed. Following */
+/* that, a 'SEARCH W/O BUFF' is performed on all unsearched */
+/* files. */
+
+/* 'CHECK PARTIAL LIST' */
+
+/* This indicates that a portion of the list can't be buffered. */
+/* Before this portion is freed, it is to be checked for */
+/* applicable segments. */
+
+/* 'SEARCH W/O BUFF' */
+
+/* This indicates that the segment table was too small to handle */
+/* all of the segments for the current instrument, and that the */
+/* remaining unchecked old files should be searched for applicable */
+/* segments, without buffering the segments. */
+
+/* 'SUSPEND' */
+
+/* This indicates that the current task (DOING) should be */
+/* interrupted until a more urgent task (URGENT) can be */
+/* carried out. The current task is placed on a stack for */
+/* safekeeping. */
+
+/* 'RESUME' */
+
+/* This indicates that the most recently interrupted task */
+/* should be resumed immediately. */
+
+/* '?' */
+
+/* This indicates that the next task is not immediately */
+/* apparent: if new files exist, they should be searched; */
+/* otherwise the list should be checked. */
+
+/* 'HOPELESS' */
+
+/* This indicates that the table does not contain an applicable */
+/* segment, and no files remain to be searched. */
+
+/* 'BOGUS ENTRY' */
+
+/* This is the initial value of STATUS and indicates that no */
+/* call to CKBSS was ever made. If this is the case then an */
+/* error will be signaled. */
+
+ if (s_cmp(status, "BOGUS ENTRY", (ftnlen)40, (ftnlen)11) == 0) {
+ setmsg_("Must begin a search by calling CKBSS first.", (ftnlen)43);
+ sigerr_("SPICE(CALLCKBSSFIRST)", (ftnlen)21);
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+ while(s_cmp(status, "HOPELESS", (ftnlen)40, (ftnlen)8) != 0) {
+
+/* If new files have been added, they have to be searched. */
+/* Otherwise, go right to the list of stored segments. */
+
+ if (s_cmp(status, "?", (ftnlen)40, (ftnlen)1) == 0) {
+
+/* There are two ways to get to this point. */
+
+/* 1) Status may have been set to '?' by CKBSS. */
+
+/* 2) Status was set to '?' by the NEW SEGMENTS block */
+/* of code as the result of finishing the read of */
+/* a new file. */
+
+ if (ithfs[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "ithfs", i__1, "ckbsr_", (ftnlen)2678)] < ftnum[(i__2 =
+ nft - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("ftnum",
+ i__2, "ckbsr_", (ftnlen)2678)]) {
+ s_copy(status, "NEW FILES", (ftnlen)40, (ftnlen)9);
+ } else {
+
+/* Much of the time, the segment used to satisfy the */
+/* previous request will also satisfy the current */
+/* request. Check whether this is the case. */
+
+ if (itchkp[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itchkp", i__1, "ckbsr_", (ftnlen)2688)]) {
+
+/* The previous segment found for the current instrument */
+/* is a viable candidate for the current request. See */
+/* whether the request time REQT falls into the time */
+/* interval for which this segment provides the */
+/* highest-priority coverage. */
+
+/* We treat the re-use interval as topologically open */
+/* because one or both endpoints may belong to */
+/* higher-priority segments. */
+
+ if (reqt > itlb[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itlb", i__1, "ckbsr_", (ftnlen)
+ 2700)] + savtol && reqt < itub[(i__2 = iindex - 1)
+ < 100 && 0 <= i__2 ? i__2 : s_rnge("itub", i__2,
+ "ckbsr_", (ftnlen)2700)] - savtol) {
+
+/* The request time falls into the portion of */
+/* the re-use interval that isn't blocked by */
+/* higher-priority segments, when the coverage of */
+/* those segments is extended in either direction */
+/* by TOL. */
+
+ if (! avneed || itprvf[(i__1 = iindex - 1) < 100 && 0
+ <= i__1 ? i__1 : s_rnge("itprvf", i__1, "ckb"
+ "sr_", (ftnlen)2709)] != 0) {
+
+/* This segment has angular velocity if we */
+/* need it. The segment satisfies the */
+/* request. */
+
+ *handle = itprvh[(i__1 = iindex - 1) < 100 && 0 <=
+ i__1 ? i__1 : s_rnge("itprvh", i__1,
+ "ckbsr_", (ftnlen)2716)];
+ s_copy(segid, itprvi + ((i__1 = iindex - 1) < 100
+ && 0 <= i__1 ? i__1 : s_rnge("itprvi",
+ i__1, "ckbsr_", (ftnlen)2717)) * 40,
+ segid_len, (ftnlen)40);
+ moved_(&itprvd[(i__1 = iindex * 5 - 5) < 500 && 0
+ <= i__1 ? i__1 : s_rnge("itprvd", i__1,
+ "ckbsr_", (ftnlen)2719)], &c__5, descr);
+ *found = TRUE_;
+
+/* We can only use the re-use interval once on */
+/* a given search. If this search is continued, */
+/* we'll have to check the list. Prepare now. */
+
+ savep = itbeg[(i__1 = iindex - 1) < 100 && 0 <=
+ i__1 ? i__1 : s_rnge("itbeg", i__1, "ckb"
+ "sr_", (ftnlen)2728)];
+ s_copy(status, "CHECK LIST", (ftnlen)40, (ftnlen)
+ 10);
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+
+/* We needed angular velocity data but didn't have */
+/* it if we reached this point. */
+
+ }
+
+/* Adjust the expense here. If the expense of the list */
+/* contains a component due to the cost of finding the */
+/* unbuffered segment providing data for re-use, subtract */
+/* that component from the expense. */
+
+ itexp[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itexp", i__1, "ckbsr_", (ftnlen)2747)] =
+ itexp[(i__2 = iindex - 1) < 100 && 0 <= i__2 ?
+ i__2 : s_rnge("itexp", i__2, "ckbsr_", (ftnlen)
+ 2747)] - itruex[(i__3 = iindex - 1) < 100 && 0 <=
+ i__3 ? i__3 : s_rnge("itruex", i__3, "ckbsr_", (
+ ftnlen)2747)];
+ itruex[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itruex", i__1, "ckbsr_", (ftnlen)2748)] =
+ 0;
+
+/* The re-use interval becomes invalid if it didn't */
+/* satisfy the request. The validity flag gets */
+/* re-set below. */
+
+/* At this point, the previous segment is not a candidate */
+/* to satisfy the request---at least not until we've done */
+/* some file searches to verify that */
+
+/* - The previous segment is still available. */
+
+/* - The previous segment hasn't been superseded by a */
+/* more recently loaded segment. */
+
+/* Carry on with the usual search algorithm. */
+
+ itchkp[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itchkp", i__1, "ckbsr_", (ftnlen)2766)] =
+ FALSE_;
+ }
+
+/* If the segment list for this instrument is empty, make */
+/* sure the expense is reset to 0. */
+
+ if (itbeg[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)2774)] == 0) {
+ itexp[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itexp", i__1, "ckbsr_", (ftnlen)2775)] =
+ 0;
+ }
+
+/* Prepare to look at the first segment in the list for */
+/* this instrument. */
+
+ p = itbeg[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)2782)];
+ s_copy(status, "CHECK LIST", (ftnlen)40, (ftnlen)10);
+ }
+ } else if (s_cmp(status, "NEW INSTRUMENT", (ftnlen)40, (ftnlen)14) ==
+ 0) {
+
+/* New instruments are added to the end of the instrument */
+/* table. If the table is full, one of the current occupants */
+/* must be removed to make room for the new one. */
+
+/* Setting LFS to one more than the highest current file */
+/* number means the 'OLD FILES' search that follows will */
+/* begin with the last-loaded file. */
+
+/* There is one way to get here: */
+
+/* 1) The variable STATUS was set to NEW INSTRUMENT prior */
+/* in CKBSS. */
+
+/* Find the cheapest slot in the instrument table to store */
+/* the initial information about this instrument. */
+
+/* NOTE: This used to be handled by the MAKE ROOM section. */
+/* However, trying to handle this special case there was */
+/* just more trouble than it was worth. */
+
+ if (nit < 100) {
+
+/* If the instrument table isn't full, the cheapest place is */
+/* just the next unused row of the table. */
+
+ ++nit;
+ cheap = nit;
+ } else {
+
+/* The instrument table is full. Find the least */
+/* expensive instrument in the table and remove it. */
+
+ cheap = 1;
+ minexp = itexp[0];
+ i__1 = nit;
+ for (i__ = 2; i__ <= i__1; ++i__) {
+ if (itexp[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("itexp", i__2, "ckbsr_", (ftnlen)2829)] <
+ minexp) {
+ cheap = i__;
+ minexp = itexp[(i__2 = i__ - 1) < 100 && 0 <= i__2 ?
+ i__2 : s_rnge("itexp", i__2, "ckbsr_", (
+ ftnlen)2831)];
+ }
+ }
+
+/* If there are any segments associated with the */
+/* least expensive instrument, we put them back on the free */
+/* list. */
+
+ head = itbeg[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)2841)];
+ if (head > 0) {
+ tail = -lnkprv_(&head, stpool);
+ lnkfsl_(&head, &tail, stpool);
+ }
+ }
+
+/* Set up a table entry for the new instrument. */
+
+ itins[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("iti"
+ "ns", i__1, "ckbsr_", (ftnlen)2855)] = scinst;
+ itexp[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("ite"
+ "xp", i__1, "ckbsr_", (ftnlen)2856)] = 0;
+ ithfs[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("ith"
+ "fs", i__1, "ckbsr_", (ftnlen)2857)] = ftnum[(i__2 = nft -
+ 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("ftnum", i__2,
+ "ckbsr_", (ftnlen)2857)];
+ itlfs[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("itl"
+ "fs", i__1, "ckbsr_", (ftnlen)2858)] = ftnum[(i__2 = nft -
+ 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("ftnum", i__2,
+ "ckbsr_", (ftnlen)2858)] + 1;
+ itbeg[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("itb"
+ "eg", i__1, "ckbsr_", (ftnlen)2859)] = 0;
+ itchkp[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itchkp", i__1, "ckbsr_", (ftnlen)2860)] = FALSE_;
+ iindex = cheap;
+
+/* The following items associated with the re-use interval */
+/* need not be initialized at this point: */
+
+/* ITRUEX */
+/* ITLB */
+/* ITUB */
+/* ITPRVF */
+/* ITPRVH */
+/* ITPRVI */
+/* ITPRVD */
+
+/* However, we'll give these items initial values to */
+/* help prevent compilation warnings from zealous */
+/* compilers. */
+
+ itruex[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itruex", i__1, "ckbsr_", (ftnlen)2879)] = 0;
+ itlb[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("itlb",
+ i__1, "ckbsr_", (ftnlen)2880)] = dpmin_();
+ itub[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("itub",
+ i__1, "ckbsr_", (ftnlen)2881)] = dpmax_();
+ itprvf[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itprvf", i__1, "ckbsr_", (ftnlen)2882)] = 0;
+ itprvh[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itprvh", i__1, "ckbsr_", (ftnlen)2883)] = 0;
+ s_copy(itprvi + ((i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itprvi", i__1, "ckbsr_", (ftnlen)2884)) * 40,
+ " ", (ftnlen)40, (ftnlen)1);
+ cleard_(&c__5, &itprvd[(i__1 = cheap * 5 - 5) < 500 && 0 <= i__1 ?
+ i__1 : s_rnge("itprvd", i__1, "ckbsr_", (ftnlen)2885)]);
+
+/* Now search all of the files for segments relating to */
+/* this instrument. */
+
+ s_copy(status, "OLD FILES", (ftnlen)40, (ftnlen)9);
+ } else if (s_cmp(status, "NEW FILES", (ftnlen)40, (ftnlen)9) == 0) {
+
+/* When new files exist, they should be searched in forward */
+/* order, beginning with the oldest new file not yet searched. */
+/* All new files must be searched before the list can be */
+/* checked, to ensure that the best (newest) segments are */
+/* being used. */
+
+/* Begin a forward search, and prepare to look for individual */
+/* segments from the file. */
+
+/* The only way to get here is to have STATUS set to */
+/* the value NEW FILES in the STATUS .EQ. '?' block */
+/* of the IF structure. */
+
+/* Find the next file to search; set FINDEX to the */
+/* corresponding file table entry. */
+ findex = 1;
+ while(ithfs[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("ithfs", i__1, "ckbsr_", (ftnlen)2914)] >= ftnum[(
+ i__2 = findex - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "ftnum", i__2, "ckbsr_", (ftnlen)2914)]) {
+ ++findex;
+ }
+ ithfs[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "ithfs", i__1, "ckbsr_", (ftnlen)2920)] = ftnum[(i__2 =
+ findex - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("ftnum",
+ i__2, "ckbsr_", (ftnlen)2920)];
+ dafbfs_(&fthan[(i__1 = findex - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("fthan", i__1, "ckbsr_", (ftnlen)2922)]);
+ if (failed_()) {
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+ s_copy(status, "NEW SEGMENTS", (ftnlen)40, (ftnlen)12);
+
+/* The cost of the list contributed by the new file is */
+/* zero so far. */
+
+ cost = 0;
+ } else if (s_cmp(status, "NEW SEGMENTS", (ftnlen)40, (ftnlen)12) == 0)
+ {
+
+/* New files are searched in forward order. Segments, when */
+/* found, are inserted at the front of the list. Invisible */
+/* segments (initial time > final time) are ignored. */
+
+/* Each segment examined, whether applicable or not, adds to */
+/* the expense of the list. */
+
+/* The only way to get here is from the NEW FILES block */
+/* of the IF structure. */
+ daffna_(&fnd);
+ if (failed_()) {
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+ if (! fnd) {
+
+/* We're out of segments in the current file. Decide */
+/* whether we need to examine another new file, or */
+/* whether we're ready to check the list. */
+
+ s_copy(status, "?", (ftnlen)40, (ftnlen)1);
+ itexp[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itexp", i__1, "ckbsr_", (ftnlen)2964)] = itexp[(i__2
+ = iindex - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "itexp", i__2, "ckbsr_", (ftnlen)2964)] + cost;
+ } else {
+ dafgs_(descr);
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ if (failed_()) {
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+ if (icd[0] == scinst && dcd[0] <= dcd[1]) {
+ s_copy(doing, "NEW SEGMENTS", (ftnlen)40, (ftnlen)12);
+ s_copy(urgent, "ADD TO FRONT", (ftnlen)40, (ftnlen)12);
+ s_copy(status, "SUSPEND", (ftnlen)40, (ftnlen)7);
+ }
+ ++cost;
+ }
+
+/* If we haven't reset the status, we'll return for another */
+/* 'NEW SEGMENTS' pass. */
+
+ } else if (s_cmp(status, "OLD FILES", (ftnlen)40, (ftnlen)9) == 0) {
+
+/* When old files must be searched (because the segments in */
+/* the list are inadequate), they should be searched in */
+/* backward order, beginning with the newest old file not */
+/* yet searched. The segment list will be re-checked */
+/* after each file is searched. If a match is found, */
+/* the search terminates, so some old files may not be */
+/* searched. */
+
+/* Begin a backwards search, and prepare to look for */
+/* individual segments from the file. */
+
+/* You can get to this block in two ways. */
+
+/* 1) We can have a NEW INSTRUMENT. */
+
+/* 2) We have checked the current list (CHECK LIST) for */
+/* this instrument, didn't find an applicable segment and */
+/* have some files left that have not been seached. */
+ findex = nft;
+ while(itlfs[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itlfs", i__1, "ckbsr_", (ftnlen)3016)] <= ftnum[(
+ i__2 = findex - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "ftnum", i__2, "ckbsr_", (ftnlen)3016)]) {
+ --findex;
+ }
+ dafbbs_(&fthan[(i__1 = findex - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("fthan", i__1, "ckbsr_", (ftnlen)3020)]);
+ if (failed_()) {
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+ s_copy(status, "OLD SEGMENTS", (ftnlen)40, (ftnlen)12);
+
+/* The next thing we'll do is search through all the segments */
+/* of this file for those that applicable to this instrument. */
+/* The cost of the list contributed by the current file is */
+/* zero so far. */
+
+ cost = 0;
+
+/* Old files are searched in backward order. Segments, when */
+/* found, are inserted at the end of the list. Invisible */
+/* segments (initial time > final time) are ignored. */
+
+/* Each segment examined, whether applicable or not, adds to */
+/* the expense of the list. */
+
+ } else if (s_cmp(status, "OLD SEGMENTS", (ftnlen)40, (ftnlen)12) == 0)
+ {
+
+/* There is only one way to get here---from the */
+/* block 'OLD FILES'. Note we do not add to the */
+/* expense of the list for this instrument until we've */
+/* completely searched this file. */
+
+ daffpa_(&fnd);
+ if (failed_()) {
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+ if (! fnd) {
+
+/* All of the segments in this file have been exhausted. */
+/* Change the lowest file searched indicator for this */
+/* instrument to be the current file, and go check the */
+/* current list. */
+
+ itlfs[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itlfs", i__1, "ckbsr_", (ftnlen)3066)] = ftnum[(i__2
+ = findex - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "ftnum", i__2, "ckbsr_", (ftnlen)3066)];
+ itexp[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itexp", i__1, "ckbsr_", (ftnlen)3067)] = itexp[(i__2
+ = iindex - 1) < 100 && 0 <= i__2 ? i__2 : s_rnge(
+ "itexp", i__2, "ckbsr_", (ftnlen)3067)] + cost;
+ p = itbeg[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)3068)];
+ s_copy(status, "CHECK LIST", (ftnlen)40, (ftnlen)10);
+ } else {
+ dafgs_(descr);
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ if (failed_()) {
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+ if (icd[0] == scinst && dcd[0] <= dcd[1]) {
+ s_copy(doing, "OLD SEGMENTS", (ftnlen)40, (ftnlen)12);
+ s_copy(urgent, "ADD TO END", (ftnlen)40, (ftnlen)10);
+ s_copy(status, "SUSPEND", (ftnlen)40, (ftnlen)7);
+ }
+ ++cost;
+ }
+ } else if (s_cmp(status, "CHECK LIST", (ftnlen)40, (ftnlen)10) == 0) {
+
+/* Okay, all the new files (and maybe an old file or two) */
+/* have been searched. Time to look at the list of segments */
+/* stored for the instrument, to see if there is one applicable */
+/* to the specified epoch and need for angular velocity data. */
+
+/* If so, return it. If not, try another old file. If there */
+/* are no more old files, give up the ghost. */
+
+/* There are two ways to get to this point. */
+
+/* 1) From the '?' block. */
+/* 2) From the 'OLD SEGMENTS' block. */
+
+/* For every segment examined, adjust the re-use interval */
+/* associated with the current instrument. */
+
+/* P always points to the current segment in the list. Reject */
+/* a segment if there is a need for angular velocity data and */
+/* the segment doesn't have it. */
+
+/* If this is a new search, initialize the re-use interval. */
+/* If we're resuming a search, the re-use interval is invalid. */
+
+ if (newsch) {
+ itlb[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itlb", i__1, "ckbsr_", (ftnlen)3123)] = dpmin_();
+ itub[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itub", i__1, "ckbsr_", (ftnlen)3124)] = dpmax_();
+ }
+ while(p > 0) {
+ if (newsch) {
+
+/* Trim the re-use interval if the request time lies */
+/* outside of the current segment. */
+
+ if (reqt > stdcd[(i__1 = (p << 1) - 1) < 100000 && 0 <=
+ i__1 ? i__1 : s_rnge("stdcd", i__1, "ckbsr_", (
+ ftnlen)3135)]) {
+
+/* REQT is to the right of the coverage interval of */
+/* this segment. Trim the re-use interval on the */
+/* left, if necessary. */
+
+/* Computing MAX */
+ d__1 = itlb[(i__2 = iindex - 1) < 100 && 0 <= i__2 ?
+ i__2 : s_rnge("itlb", i__2, "ckbsr_", (ftnlen)
+ 3141)], d__2 = stdcd[(i__3 = (p << 1) - 1) <
+ 100000 && 0 <= i__3 ? i__3 : s_rnge("stdcd",
+ i__3, "ckbsr_", (ftnlen)3141)];
+ itlb[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itlb", i__1, "ckbsr_", (ftnlen)3141)]
+ = max(d__1,d__2);
+ } else if (reqt < stdcd[(i__1 = (p << 1) - 2) < 100000 &&
+ 0 <= i__1 ? i__1 : s_rnge("stdcd", i__1, "ckbsr_",
+ (ftnlen)3144)]) {
+
+/* REQT is to the left of the coverage interval of */
+/* this segment. Trim the re-use interval on the */
+/* right, if necessary. */
+
+/* Computing MIN */
+ d__1 = itub[(i__2 = iindex - 1) < 100 && 0 <= i__2 ?
+ i__2 : s_rnge("itub", i__2, "ckbsr_", (ftnlen)
+ 3150)], d__2 = stdcd[(i__3 = (p << 1) - 2) <
+ 100000 && 0 <= i__3 ? i__3 : s_rnge("stdcd",
+ i__3, "ckbsr_", (ftnlen)3150)];
+ itub[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itub", i__1, "ckbsr_", (ftnlen)3150)]
+ = min(d__1,d__2);
+ }
+ }
+ if (omega >= stdcd[(i__1 = (p << 1) - 2) < 100000 && 0 <=
+ i__1 ? i__1 : s_rnge("stdcd", i__1, "ckbsr_", (ftnlen)
+ 3157)] && alpha <= stdcd[(i__2 = (p << 1) - 1) <
+ 100000 && 0 <= i__2 ? i__2 : s_rnge("stdcd", i__2,
+ "ckbsr_", (ftnlen)3157)]) {
+
+/* The segment coverage interval intersects the request */
+/* interval ALPHA:OMEGA. */
+
+ if (! avneed || sticd[(i__1 = p * 6 - 3) < 300000 && 0 <=
+ i__1 ? i__1 : s_rnge("sticd", i__1, "ckbsr_", (
+ ftnlen)3163)] != 0) {
+
+/* This segment satisfies the request. */
+
+ dafps_(&c__2, &c__6, &stdcd[(i__1 = (p << 1) - 2) <
+ 100000 && 0 <= i__1 ? i__1 : s_rnge("stdcd",
+ i__1, "ckbsr_", (ftnlen)3167)], &sticd[(i__2 =
+ p * 6 - 6) < 300000 && 0 <= i__2 ? i__2 :
+ s_rnge("sticd", i__2, "ckbsr_", (ftnlen)3167)]
+ , descr);
+ s_copy(segid, stidnt + ((i__1 = p - 1) < 50000 && 0 <=
+ i__1 ? i__1 : s_rnge("stidnt", i__1, "ckbsr_"
+ , (ftnlen)3170)) * 40, segid_len, (ftnlen)40);
+ *handle = sthan[(i__1 = p - 1) < 50000 && 0 <= i__1 ?
+ i__1 : s_rnge("sthan", i__1, "ckbsr_", (
+ ftnlen)3171)];
+ *found = TRUE_;
+
+/* If the segment actually contains the request */
+/* time, and if this is a new search, set the */
+/* re-use interval. We require the request time */
+/* to be in the interior of the interval: it */
+/* cannot be one of the endpoints. */
+
+ if (newsch && reqt > stdcd[(i__1 = (p << 1) - 2) <
+ 100000 && 0 <= i__1 ? i__1 : s_rnge("stdcd",
+ i__1, "ckbsr_", (ftnlen)3181)] && reqt <
+ stdcd[(i__2 = (p << 1) - 1) < 100000 && 0 <=
+ i__2 ? i__2 : s_rnge("stdcd", i__2, "ckbsr_",
+ (ftnlen)3181)]) {
+
+/* Set the re-use interval for the current */
+/* instrument. */
+
+/* Computing MAX */
+ d__1 = itlb[(i__2 = iindex - 1) < 100 && 0 <=
+ i__2 ? i__2 : s_rnge("itlb", i__2, "ckbs"
+ "r_", (ftnlen)3188)], d__2 = stdcd[(i__3 =
+ (p << 1) - 2) < 100000 && 0 <= i__3 ?
+ i__3 : s_rnge("stdcd", i__3, "ckbsr_", (
+ ftnlen)3188)];
+ itlb[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itlb", i__1, "ckbsr_", (
+ ftnlen)3188)] = max(d__1,d__2);
+/* Computing MIN */
+ d__1 = itub[(i__2 = iindex - 1) < 100 && 0 <=
+ i__2 ? i__2 : s_rnge("itub", i__2, "ckbs"
+ "r_", (ftnlen)3189)], d__2 = stdcd[(i__3 =
+ (p << 1) - 1) < 100000 && 0 <= i__3 ?
+ i__3 : s_rnge("stdcd", i__3, "ckbsr_", (
+ ftnlen)3189)];
+ itub[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itub", i__1, "ckbsr_", (
+ ftnlen)3189)] = min(d__1,d__2);
+
+/* Save the returned output items, in case this */
+/* segment may satisfy the next request. */
+
+ itprvh[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itprvh", i__1, "ckbsr_", (
+ ftnlen)3195)] = *handle;
+ s_copy(itprvi + ((i__1 = iindex - 1) < 100 && 0 <=
+ i__1 ? i__1 : s_rnge("itprvi", i__1,
+ "ckbsr_", (ftnlen)3196)) * 40, segid, (
+ ftnlen)40, segid_len);
+ itprvf[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itprvf", i__1, "ckbsr_", (
+ ftnlen)3197)] = sticd[(i__2 = p * 6 - 3) <
+ 300000 && 0 <= i__2 ? i__2 : s_rnge(
+ "sticd", i__2, "ckbsr_", (ftnlen)3197)];
+ moved_(descr, &c__5, &itprvd[(i__1 = iindex * 5 -
+ 5) < 500 && 0 <= i__1 ? i__1 : s_rnge(
+ "itprvd", i__1, "ckbsr_", (ftnlen)3199)]);
+ itchkp[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itchkp", i__1, "ckbsr_", (
+ ftnlen)3201)] = TRUE_;
+ }
+
+/* Go ahead and move the pointer up before returning */
+/* so that the search for the next applicable segment */
+/* will start at the right place. */
+
+ savep = stpool[(i__1 = (p << 1) + 10) < 100012 && 0 <=
+ i__1 ? i__1 : s_rnge("stpool", i__1, "ckbsr_"
+ , (ftnlen)3210)];
+
+/* Indicate the first pass of this search has been */
+/* completed. */
+
+ newsch = FALSE_;
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Get the next node. We avoid LNKNXT here in order */
+/* to speed up the operation. */
+
+ p = stpool[(i__1 = (p << 1) + 10) < 100012 && 0 <= i__1 ?
+ i__1 : s_rnge("stpool", i__1, "ckbsr_", (ftnlen)3228)]
+ ;
+ }
+
+/* If we're still here we didn't have information for this */
+/* instrument in the segment list. */
+
+/* If there are more files, search them. */
+/* Otherwise, things are hopeless, set the status that way. */
+
+ if (itlfs[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itlfs", i__1, "ckbsr_", (ftnlen)3239)] > ftnum[0]) {
+ s_copy(status, "OLD FILES", (ftnlen)40, (ftnlen)9);
+ } else {
+ s_copy(status, "HOPELESS", (ftnlen)40, (ftnlen)8);
+ }
+ } else if (s_cmp(status, "MAKE ROOM", (ftnlen)40, (ftnlen)9) == 0) {
+
+/* When adding a new segment to a full table, one of the */
+/* current instruments must be dropped. The ideal */
+/* candidate is the one whose list was constructed at the */
+/* lowest expense. The candidate should be removed from */
+/* the instrument table, and its list transferred to the */
+/* segment table pool. */
+
+/* There is ``room'' if the segment table pool contains at */
+/* least one free node. */
+
+/* It is possible that a single instrument requires more */
+/* than the entire segment table for its own segments. */
+/* Two things might happen in such a case: */
+
+/* 1) If the list under consideration was being added to at */
+/* the end, then a search is continued without buffering */
+/* any segments. */
+
+/* 2) If the list was being added to at the beginning, then */
+/* that means there was a NEW FILES search going on, and */
+/* so a brand new list is constructed for the instrument, */
+/* much as in a 'NEW INSTRUMENT' task. */
+
+/* There are two different ways to get to this point. */
+
+/* 1) From 'ADD TO FRONT' if the segment table pool is full. */
+/* 2) From 'ADD TO END' if the segment table pool is full. */
+
+/* Try to make room by deleting a segment list. CHEAP will */
+/* be the index of the "cheapest" segment list in the */
+/* instrument table. */
+
+ minexp = intmax_();
+ cheap = 0;
+ i__1 = nit;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ if (i__ != iindex) {
+ if (itexp[(i__2 = i__ - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("itexp", i__2, "ckbsr_", (ftnlen)3288)] <
+ minexp || cheap == 0) {
+
+/* This list is the cheapest seen so far, */
+/* possibly because it's the first one */
+/* considered. At the moment, it's as good */
+/* a candidate for removal as any. */
+
+ cheap = i__;
+ minexp = itexp[(i__2 = i__ - 1) < 100 && 0 <= i__2 ?
+ i__2 : s_rnge("itexp", i__2, "ckbsr_", (
+ ftnlen)3297)];
+ }
+ }
+ }
+ if (cheap == 0) {
+
+/* If there are no deleteable segments, the Thing To */
+/* Do depends on the task that was suspended before */
+/* entering MAKE ROOM. */
+
+ if (s_cmp(stack + ((i__1 = top - 1) < 2 && 0 <= i__1 ? i__1 :
+ s_rnge("stack", i__1, "ckbsr_", (ftnlen)3312)) * 40,
+ "ADD TO END", (ftnlen)40, (ftnlen)10) == 0) {
+
+/* The segment meta-data from the current file cannot */
+/* be buffered. We'll search the partial list of */
+/* segments from this file, then proceed to search */
+/* the rest of the file and any other old files, until */
+/* we find an applicable segment or run out of segments. */
+
+ s_copy(status, "PREPARE PARTIAL LIST", (ftnlen)40, (
+ ftnlen)20);
+ } else {
+
+/* STACK(TOP) is set to 'ADD TO FRONT'. */
+
+/* If there is no room left in the table in the middle */
+/* of an attempt to add to the front of the list, just */
+/* start from scratch by effectively initiating a 'NEW */
+/* INSTRUMENT' task. */
+
+/* Return the current list to the segment table pool. */
+/* Note this list is non-empty. */
+
+ p = itbeg[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)3335)];
+ tail = -lnkprv_(&p, stpool);
+ lnkfsl_(&p, &tail, stpool);
+
+/* Re-initialize the table for this instrument, and */
+/* initiate an 'OLD FILES' search, just as in 'NEW */
+/* INSTRUMENT'. */
+
+ itexp[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itexp", i__1, "ckbsr_", (ftnlen)3344)] =
+ 0;
+ ithfs[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("ithfs", i__1, "ckbsr_", (ftnlen)3345)] =
+ ftnum[(i__2 = nft - 1) < 1000 && 0 <= i__2 ? i__2
+ : s_rnge("ftnum", i__2, "ckbsr_", (ftnlen)3345)];
+ itlfs[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itlfs", i__1, "ckbsr_", (ftnlen)3346)] =
+ ftnum[(i__2 = nft - 1) < 1000 && 0 <= i__2 ? i__2
+ : s_rnge("ftnum", i__2, "ckbsr_", (ftnlen)3346)]
+ + 1;
+ s_copy(status, "OLD FILES", (ftnlen)40, (ftnlen)9);
+ }
+
+/* Unwind the stack; we've set the target states already. */
+
+ top = 0;
+ } else {
+
+/* Return this cheapest list to the segment pool. This */
+/* list could be empty. */
+
+ head = itbeg[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)3362)];
+ if (head > 0) {
+ tail = -lnkprv_(&head, stpool);
+ lnkfsl_(&head, &tail, stpool);
+ }
+
+/* Fill the deleted instrument's space in the table with */
+/* the final entry in the table. */
+
+ if (cheap != nit) {
+ itins[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itins", i__1, "ckbsr_", (ftnlen)3378)] =
+ itins[(i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("itins", i__2, "ckbsr_", (ftnlen)3378)];
+ itexp[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itexp", i__1, "ckbsr_", (ftnlen)3379)] =
+ itexp[(i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("itexp", i__2, "ckbsr_", (ftnlen)3379)];
+ ithfs[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("ithfs", i__1, "ckbsr_", (ftnlen)3380)] =
+ ithfs[(i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("ithfs", i__2, "ckbsr_", (ftnlen)3380)];
+ itlfs[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itlfs", i__1, "ckbsr_", (ftnlen)3381)] =
+ itlfs[(i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("itlfs", i__2, "ckbsr_", (ftnlen)3381)];
+ itbeg[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)3382)] =
+ itbeg[(i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("itbeg", i__2, "ckbsr_", (ftnlen)3382)];
+ itlb[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itlb", i__1, "ckbsr_", (ftnlen)3383)] =
+ itlb[(i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("itlb", i__2, "ckbsr_", (ftnlen)3383)];
+ itub[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itub", i__1, "ckbsr_", (ftnlen)3384)] =
+ itub[(i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("itub", i__2, "ckbsr_", (ftnlen)3384)];
+ itprvh[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itprvh", i__1, "ckbsr_", (ftnlen)3385)] =
+ itprvh[(i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2
+ : s_rnge("itprvh", i__2, "ckbsr_", (ftnlen)3385)];
+ s_copy(itprvi + ((i__1 = cheap - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itprvi", i__1, "ckbsr_", (ftnlen)
+ 3386)) * 40, itprvi + ((i__2 = nit - 1) < 100 &&
+ 0 <= i__2 ? i__2 : s_rnge("itprvi", i__2, "ckbsr_"
+ , (ftnlen)3386)) * 40, (ftnlen)40, (ftnlen)40);
+ itprvf[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itprvf", i__1, "ckbsr_", (ftnlen)3387)] =
+ itprvf[(i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2
+ : s_rnge("itprvf", i__2, "ckbsr_", (ftnlen)3387)];
+ itchkp[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itchkp", i__1, "ckbsr_", (ftnlen)3388)] =
+ itchkp[(i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2
+ : s_rnge("itchkp", i__2, "ckbsr_", (ftnlen)3388)];
+ itruex[(i__1 = cheap - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itruex", i__1, "ckbsr_", (ftnlen)3389)] =
+ itruex[(i__2 = nit - 1) < 100 && 0 <= i__2 ? i__2
+ : s_rnge("itruex", i__2, "ckbsr_", (ftnlen)3389)];
+ moved_(&itprvd[(i__1 = nit * 5 - 5) < 500 && 0 <= i__1 ?
+ i__1 : s_rnge("itprvd", i__1, "ckbsr_", (ftnlen)
+ 3391)], &c__5, &itprvd[(i__2 = cheap * 5 - 5) <
+ 500 && 0 <= i__2 ? i__2 : s_rnge("itprvd", i__2,
+ "ckbsr_", (ftnlen)3391)]);
+ }
+ if (iindex == nit) {
+ iindex = cheap;
+ }
+
+/* One less instrument now. */
+
+ --nit;
+ s_copy(status, "RESUME", (ftnlen)40, (ftnlen)6);
+ }
+
+/* Either we made room by freeing a non-empty segment list, */
+/* or we're going to work without additional space. In the */
+/* latter case, the state is now 'OLD FILES' or */
+/* 'PREPARE PARTIAL LIST'. */
+
+ } else if (s_cmp(status, "ADD TO FRONT", (ftnlen)40, (ftnlen)12) == 0)
+ {
+
+/* The current segment information should be linked in at */
+/* the head of the segment list for the current instrument, */
+/* and the pertinent instrument table entry should point */
+/* to the new head of the list. */
+
+/* The only way to get here is from the block NEW SEGMENTS */
+/* after suspending that task. */
+ if (lnknfn_(stpool) == 0) {
+ s_copy(doing, "ADD TO FRONT", (ftnlen)40, (ftnlen)12);
+ s_copy(urgent, "MAKE ROOM", (ftnlen)40, (ftnlen)9);
+ s_copy(status, "SUSPEND", (ftnlen)40, (ftnlen)7);
+ } else {
+
+/* Allocate a node and link it to the front of the list */
+/* for the current instrument. */
+
+ lnkan_(stpool, &new__);
+ sthan[(i__1 = new__ - 1) < 50000 && 0 <= i__1 ? i__1 : s_rnge(
+ "sthan", i__1, "ckbsr_", (ftnlen)3437)] = fthan[(i__2
+ = findex - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "fthan", i__2, "ckbsr_", (ftnlen)3437)];
+ dafgn_(stidnt + ((i__1 = new__ - 1) < 50000 && 0 <= i__1 ?
+ i__1 : s_rnge("stidnt", i__1, "ckbsr_", (ftnlen)3439))
+ * 40, (ftnlen)40);
+ dafus_(descr, &c__2, &c__6, &stdcd[(i__1 = (new__ << 1) - 2) <
+ 100000 && 0 <= i__1 ? i__1 : s_rnge("stdcd", i__1,
+ "ckbsr_", (ftnlen)3441)], &sticd[(i__2 = new__ * 6 -
+ 6) < 300000 && 0 <= i__2 ? i__2 : s_rnge("sticd",
+ i__2, "ckbsr_", (ftnlen)3441)]);
+ if (failed_()) {
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+
+/* If the current list is empty, this append operation */
+/* is a no-op. */
+
+ lnkilb_(&new__, &itbeg[(i__1 = iindex - 1) < 100 && 0 <= i__1
+ ? i__1 : s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)3452)
+ ], stpool);
+ itbeg[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itbeg", i__1, "ckbsr_", (ftnlen)3453)] = new__;
+ s_copy(status, "RESUME", (ftnlen)40, (ftnlen)6);
+ }
+ } else if (s_cmp(status, "ADD TO END", (ftnlen)40, (ftnlen)10) == 0) {
+
+/* The current segment information should be linked in at */
+/* the tail of the segment list for the current instrument. */
+
+/* The only way to get to this task is from the OLD SEGMENTS */
+/* block after suspending that task. */
+
+ if (lnknfn_(stpool) == 0) {
+ s_copy(doing, "ADD TO END", (ftnlen)40, (ftnlen)10);
+ s_copy(urgent, "MAKE ROOM", (ftnlen)40, (ftnlen)9);
+ s_copy(status, "SUSPEND", (ftnlen)40, (ftnlen)7);
+ } else {
+
+/* Allocate a new node in the segment table pool. */
+
+ lnkan_(stpool, &new__);
+ sthan[(i__1 = new__ - 1) < 50000 && 0 <= i__1 ? i__1 : s_rnge(
+ "sthan", i__1, "ckbsr_", (ftnlen)3480)] = fthan[(i__2
+ = findex - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "fthan", i__2, "ckbsr_", (ftnlen)3480)];
+ dafgn_(stidnt + ((i__1 = new__ - 1) < 50000 && 0 <= i__1 ?
+ i__1 : s_rnge("stidnt", i__1, "ckbsr_", (ftnlen)3482))
+ * 40, (ftnlen)40);
+ dafus_(descr, &c__2, &c__6, &stdcd[(i__1 = (new__ << 1) - 2) <
+ 100000 && 0 <= i__1 ? i__1 : s_rnge("stdcd", i__1,
+ "ckbsr_", (ftnlen)3484)], &sticd[(i__2 = new__ * 6 -
+ 6) < 300000 && 0 <= i__2 ? i__2 : s_rnge("sticd",
+ i__2, "ckbsr_", (ftnlen)3484)]);
+ if (failed_()) {
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+ if (itbeg[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)3491)] <= 0) {
+
+/* This is the first node in the list for this */
+/* instrument. */
+
+ itbeg[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)3496)] =
+ new__;
+ } else {
+
+/* Link the new node to the tail of the list. */
+
+ tail = -lnkprv_(&itbeg[(i__1 = iindex - 1) < 100 && 0 <=
+ i__1 ? i__1 : s_rnge("itbeg", i__1, "ckbsr_", (
+ ftnlen)3502)], stpool);
+ lnkila_(&tail, &new__, stpool);
+ }
+ s_copy(status, "RESUME", (ftnlen)40, (ftnlen)6);
+ }
+ } else if (s_cmp(status, "PREPARE PARTIAL LIST", (ftnlen)40, (ftnlen)
+ 20) == 0) {
+
+/* When the segment table is completely full, continue */
+/* the search by looking through the unchecked portion */
+/* of the segment list for the current instrument, and */
+/* then searching old, unchecked files without buffering */
+/* their segments. */
+
+/* The only way to get here is from the MAKE ROOM state */
+/* via the block ADD TO END. If you get here there is no */
+/* free space in the segment table pool. */
+
+/* At this point, we need to initialize the cost of */
+/* the re-use interval. */
+
+ itruex[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itruex", i__1, "ckbsr_", (ftnlen)3527)] = 0;
+
+/* Find the portion of the current instrument's segment list */
+/* which comes from the current file of interest. SLBEG */
+/* will point to the beginning of this sublist. */
+
+ slbeg = itbeg[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)3534)];
+ fndhan = FALSE_;
+ while(! fndhan && slbeg > 0) {
+ fndhan = sthan[(i__1 = slbeg - 1) < 50000 && 0 <= i__1 ? i__1
+ : s_rnge("sthan", i__1, "ckbsr_", (ftnlen)3539)] ==
+ fthan[(i__2 = findex - 1) < 1000 && 0 <= i__2 ? i__2 :
+ s_rnge("fthan", i__2, "ckbsr_", (ftnlen)3539)];
+ if (! fndhan) {
+
+/* Get the next node. We avoid LNKNXT here in order */
+/* to speed up the operation. */
+
+ slbeg = stpool[(i__1 = (slbeg << 1) + 10) < 100012 && 0 <=
+ i__1 ? i__1 : s_rnge("stpool", i__1, "ckbsr_", (
+ ftnlen)3546)];
+ }
+ }
+
+/* If the list contains segments from the current file, */
+/* check that portion of the list. */
+
+/* Otherwise, finish searching old files without buffering */
+/* anything. */
+
+ if (slbeg > 0) {
+
+/* The partial list from the current node onwards is to be */
+/* returned to the free list. Save this node, since */
+/* we'll finish searching the list before freeing the */
+/* partial list. */
+
+ p = slbeg;
+
+/* Record the fact that we'll need to free the partial list */
+/* later. */
+
+ fresub = TRUE_;
+
+/* It may be that the partial list we're going to delete is */
+/* the entire segment list for this instrument. If so, the */
+/* corresponding instrument table entry should be set to */
+/* a non-positive value to indicate an empty segment list. */
+
+ if (p == itbeg[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)3580)]) {
+ itbeg[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itbeg", i__1, "ckbsr_", (ftnlen)3582)] =
+ 0;
+
+/* Also in this case, we must initialize the time */
+/* bounds for this instrument. */
+
+ itlb[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itlb", i__1, "ckbsr_", (ftnlen)3588)] =
+ dpmin_();
+ itub[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itub", i__1, "ckbsr_", (ftnlen)3589)] =
+ dpmax_();
+ }
+ s_copy(status, "CHECK PARTIAL LIST", (ftnlen)40, (ftnlen)18);
+ } else {
+ s_copy(status, "SEARCH W/O BUFF", (ftnlen)40, (ftnlen)15);
+ }
+ } else if (s_cmp(status, "CHECK PARTIAL LIST", (ftnlen)40, (ftnlen)18)
+ == 0) {
+
+/* The only ways to get here are from the */
+/* 'PREPARE PARTIAL LIST' state, or by resuming a search of */
+/* the partial list. */
+
+/* The portion of the segment list from the current file */
+/* is to be checked. */
+
+/* BEG points to the current segment in the temporary portion */
+/* of the list. */
+
+/* Reject a segment if there is a need for angular velocity */
+/* data and the segment doesn't have it. */
+
+ while(p > 0) {
+
+/* If this is a new search, update the re-use interval */
+/* and its expense. */
+
+ if (newsch) {
+
+/* Every segment seen from the current file contributes */
+/* to the expense of the re-use interval. */
+
+ itruex[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itruex", i__1, "ckbsr_", (ftnlen)3628)] =
+ itruex[(i__2 = iindex - 1) < 100 && 0 <= i__2 ?
+ i__2 : s_rnge("itruex", i__2, "ckbsr_", (ftnlen)
+ 3628)] + 1;
+
+/* Trim the re-use interval if the request time lies */
+/* outside the coverage of the current segment. */
+
+ if (reqt > stdcd[(i__1 = (p << 1) - 1) < 100000 && 0 <=
+ i__1 ? i__1 : s_rnge("stdcd", i__1, "ckbsr_", (
+ ftnlen)3634)]) {
+
+/* REQT is to the right of the coverage interval of */
+/* this segment. Trim the re-use interval on the */
+/* left, if necessary. */
+
+/* Computing MAX */
+ d__1 = itlb[(i__2 = iindex - 1) < 100 && 0 <= i__2 ?
+ i__2 : s_rnge("itlb", i__2, "ckbsr_", (ftnlen)
+ 3640)], d__2 = stdcd[(i__3 = (p << 1) - 1) <
+ 100000 && 0 <= i__3 ? i__3 : s_rnge("stdcd",
+ i__3, "ckbsr_", (ftnlen)3640)];
+ itlb[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itlb", i__1, "ckbsr_", (ftnlen)3640)]
+ = max(d__1,d__2);
+ } else if (reqt < stdcd[(i__1 = (p << 1) - 2) < 100000 &&
+ 0 <= i__1 ? i__1 : s_rnge("stdcd", i__1, "ckbsr_",
+ (ftnlen)3643)]) {
+
+/* REQT is to the left of the coverage interval of */
+/* this segment. Trim the re-use interval on the */
+/* right, if necessary. */
+
+/* Computing MIN */
+ d__1 = itub[(i__2 = iindex - 1) < 100 && 0 <= i__2 ?
+ i__2 : s_rnge("itub", i__2, "ckbsr_", (ftnlen)
+ 3649)], d__2 = stdcd[(i__3 = (p << 1) - 2) <
+ 100000 && 0 <= i__3 ? i__3 : s_rnge("stdcd",
+ i__3, "ckbsr_", (ftnlen)3649)];
+ itub[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itub", i__1, "ckbsr_", (ftnlen)3649)]
+ = min(d__1,d__2);
+ }
+ }
+
+/* We've updated the re-use interval if so required. */
+
+ if (omega >= stdcd[(i__1 = (p << 1) - 2) < 100000 && 0 <=
+ i__1 ? i__1 : s_rnge("stdcd", i__1, "ckbsr_", (ftnlen)
+ 3658)] && alpha <= stdcd[(i__2 = (p << 1) - 1) <
+ 100000 && 0 <= i__2 ? i__2 : s_rnge("stdcd", i__2,
+ "ckbsr_", (ftnlen)3658)]) {
+
+/* The segment coverage interval intersects the request */
+/* interval ALPHA:OMEGA. */
+
+ if (! avneed || sticd[(i__1 = p * 6 - 3) < 300000 && 0 <=
+ i__1 ? i__1 : s_rnge("sticd", i__1, "ckbsr_", (
+ ftnlen)3664)] != 0) {
+
+/* This segment satisfies the request. Set the */
+/* output arguments. */
+
+ dafps_(&c__2, &c__6, &stdcd[(i__1 = (p << 1) - 2) <
+ 100000 && 0 <= i__1 ? i__1 : s_rnge("stdcd",
+ i__1, "ckbsr_", (ftnlen)3669)], &sticd[(i__2 =
+ p * 6 - 6) < 300000 && 0 <= i__2 ? i__2 :
+ s_rnge("sticd", i__2, "ckbsr_", (ftnlen)3669)]
+ , descr);
+ s_copy(segid, stidnt + ((i__1 = p - 1) < 50000 && 0 <=
+ i__1 ? i__1 : s_rnge("stidnt", i__1, "ckbsr_"
+ , (ftnlen)3672)) * 40, segid_len, (ftnlen)40);
+ *handle = sthan[(i__1 = p - 1) < 50000 && 0 <= i__1 ?
+ i__1 : s_rnge("sthan", i__1, "ckbsr_", (
+ ftnlen)3673)];
+ *found = TRUE_;
+
+/* If this is the first pass performed for the */
+/* current search, then we can set the re-use */
+/* interval. The re-use interval becomes invalid */
+/* after the first pass. */
+
+/* If the segment actually contains the request */
+/* time, set the re-use interval. We require */
+/* the request time to be in the interior of the */
+/* interval: it cannot be one of the endpoints. */
+
+ if (newsch && reqt > stdcd[(i__1 = (p << 1) - 2) <
+ 100000 && 0 <= i__1 ? i__1 : s_rnge("stdcd",
+ i__1, "ckbsr_", (ftnlen)3687)] && reqt <
+ stdcd[(i__2 = (p << 1) - 1) < 100000 && 0 <=
+ i__2 ? i__2 : s_rnge("stdcd", i__2, "ckbsr_",
+ (ftnlen)3687)]) {
+
+/* Adjust the re-use interval for the current */
+/* instrument. */
+
+/* Computing MAX */
+ d__1 = itlb[(i__2 = iindex - 1) < 100 && 0 <=
+ i__2 ? i__2 : s_rnge("itlb", i__2, "ckbs"
+ "r_", (ftnlen)3694)], d__2 = stdcd[(i__3 =
+ (p << 1) - 2) < 100000 && 0 <= i__3 ?
+ i__3 : s_rnge("stdcd", i__3, "ckbsr_", (
+ ftnlen)3694)];
+ itlb[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itlb", i__1, "ckbsr_", (
+ ftnlen)3694)] = max(d__1,d__2);
+/* Computing MIN */
+ d__1 = itub[(i__2 = iindex - 1) < 100 && 0 <=
+ i__2 ? i__2 : s_rnge("itub", i__2, "ckbs"
+ "r_", (ftnlen)3695)], d__2 = stdcd[(i__3 =
+ (p << 1) - 1) < 100000 && 0 <= i__3 ?
+ i__3 : s_rnge("stdcd", i__3, "ckbsr_", (
+ ftnlen)3695)];
+ itub[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itub", i__1, "ckbsr_", (
+ ftnlen)3695)] = min(d__1,d__2);
+
+/* Save the returned output items, in case this */
+/* segment may satisfy the next request. */
+
+ itprvh[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itprvh", i__1, "ckbsr_", (
+ ftnlen)3700)] = *handle;
+ s_copy(itprvi + ((i__1 = iindex - 1) < 100 && 0 <=
+ i__1 ? i__1 : s_rnge("itprvi", i__1,
+ "ckbsr_", (ftnlen)3701)) * 40, segid, (
+ ftnlen)40, segid_len);
+ itprvf[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itprvf", i__1, "ckbsr_", (
+ ftnlen)3702)] = sticd[(i__2 = p * 6 - 3) <
+ 300000 && 0 <= i__2 ? i__2 : s_rnge(
+ "sticd", i__2, "ckbsr_", (ftnlen)3702)];
+ moved_(descr, &c__5, &itprvd[(i__1 = iindex * 5 -
+ 5) < 500 && 0 <= i__1 ? i__1 : s_rnge(
+ "itprvd", i__1, "ckbsr_", (ftnlen)3704)]);
+ itchkp[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itchkp", i__1, "ckbsr_", (
+ ftnlen)3706)] = TRUE_;
+
+/* Update the expense of the list to reflect */
+/* the cost of locating this segment. */
+
+ itexp[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itexp", i__1, "ckbsr_", (
+ ftnlen)3711)] = itexp[(i__2 = iindex - 1)
+ < 100 && 0 <= i__2 ? i__2 : s_rnge("itexp"
+ , i__2, "ckbsr_", (ftnlen)3711)] + itruex[
+ (i__3 = iindex - 1) < 100 && 0 <= i__3 ?
+ i__3 : s_rnge("itruex", i__3, "ckbsr_", (
+ ftnlen)3711)];
+ }
+
+/* We've set the re-use interval. */
+
+/* Go ahead and move the pointer up before returning */
+/* so that the search for the next applicable segment */
+/* will start at the right place. */
+
+/* We avoid LNKNXT here in order to speed up the */
+/* operation. */
+
+ savep = stpool[(i__1 = (p << 1) + 10) < 100012 && 0 <=
+ i__1 ? i__1 : s_rnge("stpool", i__1, "ckbsr_"
+ , (ftnlen)3724)];
+
+/* We cannot free the partial list yet, because */
+/* we may return to search it again if the current */
+/* segment doesn't have pointing that satisfies */
+/* the caller's request. The list will be freed */
+/* at the start of the next search if it's not */
+/* freed at the end of this block or in the */
+/* 'SEARCH W/O BUFFERING' block. */
+
+/* Indicate the first pass of this search has been */
+/* completed. */
+
+ newsch = FALSE_;
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+
+/* Getting here implies angular velocity was */
+/* requested but was not present in the segment. */
+
+ }
+
+/* The current segment didn't match. Look at the next */
+/* segment in the list. */
+
+ p = stpool[(i__1 = (p << 1) + 10) < 100012 && 0 <= i__1 ?
+ i__1 : s_rnge("stpool", i__1, "ckbsr_", (ftnlen)3753)]
+ ;
+ }
+
+/* We're done looking at the partial list. */
+
+/* Return the partial list to the segment table pool. */
+/* P at this point is the negative of the list head. */
+/* The list tail is (by the spec of the SPICELIB doubly */
+/* linked list routines) the negative of the predecessor */
+/* of the head. */
+
+/* Note the list is always non-empty at this point. */
+
+ i__1 = -p;
+ tail = -lnkprv_(&i__1, stpool);
+ lnkfsl_(&slbeg, &tail, stpool);
+ fresub = FALSE_;
+
+/* Search the remaining files. */
+
+ s_copy(status, "SEARCH W/O BUFF", (ftnlen)40, (ftnlen)15);
+ } else if (s_cmp(status, "SEARCH W/O BUFF", (ftnlen)40, (ftnlen)15) ==
+ 0) {
+
+/* The only ways to get here are from the */
+/* 'PREPARE PARTIAL LIST' and 'CHECK PARTIAL LIST' states. */
+
+/* When the segment table is full with the current instrument's */
+/* segments and any freed up portions have been checked, */
+/* continue the search for applicable segments in old files, */
+/* without buffering any of the segments in the segment table. */
+
+/* Recall that a search is already in progress and that a */
+/* segment is currently under consideration (FND = .TRUE.). */
+
+ while(findex > 0) {
+ while(fnd) {
+ if (newsch) {
+
+/* Each segment found contributes to the expense of */
+/* the re-use interval. */
+
+ itruex[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("itruex", i__1, "ckbsr_", (ftnlen)
+ 3801)] = itruex[(i__2 = iindex - 1) < 100 &&
+ 0 <= i__2 ? i__2 : s_rnge("itruex", i__2,
+ "ckbsr_", (ftnlen)3801)] + 1;
+ }
+ dafgs_(descr);
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ if (failed_()) {
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+ if (scinst == icd[0]) {
+
+/* This is a segment for the instrument of interest. */
+ if (newsch) {
+
+/* Update the re-use interval for this instrument. */
+
+ if (reqt > dcd[1]) {
+
+/* REQT is to the right of the coverage interval */
+/* of this segment. Trim the re-use interval */
+/* on the left, if necessary. */
+
+/* Computing MAX */
+ d__1 = itlb[(i__2 = iindex - 1) < 100 && 0 <=
+ i__2 ? i__2 : s_rnge("itlb", i__2,
+ "ckbsr_", (ftnlen)3828)];
+ itlb[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itlb", i__1, "ckbsr_",
+ (ftnlen)3828)] = max(d__1,dcd[1]);
+ } else if (reqt < dcd[0]) {
+
+/* REQT is to the left of the coverage interval */
+/* of this segment. Trim the re-use interval */
+/* on the right, if necessary. */
+
+/* Computing MIN */
+ d__1 = itub[(i__2 = iindex - 1) < 100 && 0 <=
+ i__2 ? i__2 : s_rnge("itub", i__2,
+ "ckbsr_", (ftnlen)3837)];
+ itub[(i__1 = iindex - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("itub", i__1, "ckbsr_",
+ (ftnlen)3837)] = min(d__1,dcd[0]);
+ }
+ }
+
+/* We've trimmed the re-use interval if necessary. */
+
+ if (omega >= dcd[0] && alpha <= dcd[1]) {
+
+/* The segment coverage interval intersects the */
+/* request interval ALPHA:OMEGA. */
+
+ if (! avneed || icd[3] != 0) {
+
+/* This segment satisfies the request. Set */
+/* the output arguments. */
+
+ dafps_(&c__2, &c__6, dcd, icd, descr);
+ dafgn_(segid, segid_len);
+ *handle = fthan[(i__1 = findex - 1) < 1000 &&
+ 0 <= i__1 ? i__1 : s_rnge("fthan",
+ i__1, "ckbsr_", (ftnlen)3861)];
+ *found = TRUE_;
+ if (newsch) {
+
+/* Adjust the re-use interval for the current */
+/* instrument. */
+
+/* Computing MAX */
+ d__1 = itlb[(i__2 = iindex - 1) < 100 &&
+ 0 <= i__2 ? i__2 : s_rnge("itlb",
+ i__2, "ckbsr_", (ftnlen)3869)];
+ itlb[(i__1 = iindex - 1) < 100 && 0 <=
+ i__1 ? i__1 : s_rnge("itlb", i__1,
+ "ckbsr_", (ftnlen)3869)] = max(
+ d__1,dcd[0]);
+/* Computing MIN */
+ d__1 = itub[(i__2 = iindex - 1) < 100 &&
+ 0 <= i__2 ? i__2 : s_rnge("itub",
+ i__2, "ckbsr_", (ftnlen)3870)];
+ itub[(i__1 = iindex - 1) < 100 && 0 <=
+ i__1 ? i__1 : s_rnge("itub", i__1,
+ "ckbsr_", (ftnlen)3870)] = min(
+ d__1,dcd[1]);
+
+/* Save the returned output items, in case */
+/* this segment may satisfy the next request. */
+
+ itprvh[(i__1 = iindex - 1) < 100 && 0 <=
+ i__1 ? i__1 : s_rnge("itprvh",
+ i__1, "ckbsr_", (ftnlen)3876)] = *
+ handle;
+ s_copy(itprvi + ((i__1 = iindex - 1) <
+ 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itprvi", i__1, "ckbsr_", (ftnlen)
+ 3877)) * 40, segid, (ftnlen)40,
+ segid_len);
+ itprvf[(i__1 = iindex - 1) < 100 && 0 <=
+ i__1 ? i__1 : s_rnge("itprvf",
+ i__1, "ckbsr_", (ftnlen)3878)] =
+ icd[3];
+ moved_(descr, &c__5, &itprvd[(i__1 =
+ iindex * 5 - 5) < 500 && 0 <=
+ i__1 ? i__1 : s_rnge("itprvd",
+ i__1, "ckbsr_", (ftnlen)3880)]);
+ itchkp[(i__1 = iindex - 1) < 100 && 0 <=
+ i__1 ? i__1 : s_rnge("itchkp",
+ i__1, "ckbsr_", (ftnlen)3883)] =
+ TRUE_;
+
+/* Update the expense of the list to reflect */
+/* cost of locating this segment. */
+
+ itexp[(i__1 = iindex - 1) < 100 && 0 <=
+ i__1 ? i__1 : s_rnge("itexp",
+ i__1, "ckbsr_", (ftnlen)3889)] =
+ itexp[(i__2 = iindex - 1) < 100 &&
+ 0 <= i__2 ? i__2 : s_rnge("itexp"
+ , i__2, "ckbsr_", (ftnlen)3889)]
+ + itruex[(i__3 = iindex - 1) <
+ 100 && 0 <= i__3 ? i__3 : s_rnge(
+ "itruex", i__3, "ckbsr_", (ftnlen)
+ 3889)];
+ }
+
+/* The re-use interval is set. */
+
+/* Go ahead and point to the next segment in the */
+/* file in case an attempt is made to continue */
+/* the search: you want to pick up exactly where */
+/* you left off. */
+
+ daffpa_(&fnd);
+
+/* Indicate the first pass of this search has */
+/* been completed. */
+
+ newsch = FALSE_;
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+ }
+
+/* Getting here implies angular velocity was */
+/* requested but was not present in the segment. */
+
+ }
+
+/* The current segment's coverage didn't intersect */
+/* the request interval. */
+
+ }
+
+/* The current segment didn't contain data for the */
+/* specified instrument. */
+
+/* Look at the next segment in the current file. */
+
+ daffpa_(&fnd);
+ }
+
+/* Try the next oldest file. */
+
+ --findex;
+ if (findex > 0) {
+ dafbbs_(&fthan[(i__1 = findex - 1) < 1000 && 0 <= i__1 ?
+ i__1 : s_rnge("fthan", i__1, "ckbsr_", (ftnlen)
+ 3938)]);
+ daffpa_(&fnd);
+ }
+ }
+
+/* There's nothing nowhere if you get to here. */
+
+ itruex[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "itruex", i__1, "ckbsr_", (ftnlen)3948)] = 0;
+ s_copy(status, "HOPELESS", (ftnlen)40, (ftnlen)8);
+ } else if (s_cmp(status, "SUSPEND", (ftnlen)40, (ftnlen)7) == 0) {
+
+/* When a task is suspended, the current activity is placed on */
+/* a stack, to be restored later. Two levels are provided, */
+/* since some interrupts can be interrupted by others. */
+
+ ++top;
+ s_copy(stack + ((i__1 = top - 1) < 2 && 0 <= i__1 ? i__1 : s_rnge(
+ "stack", i__1, "ckbsr_", (ftnlen)3959)) * 40, doing, (
+ ftnlen)40, (ftnlen)40);
+ s_copy(status, urgent, (ftnlen)40, (ftnlen)40);
+ } else if (s_cmp(status, "RESUME", (ftnlen)40, (ftnlen)6) == 0) {
+ s_copy(status, stack + ((i__1 = top - 1) < 2 && 0 <= i__1 ? i__1 :
+ s_rnge("stack", i__1, "ckbsr_", (ftnlen)3964)) * 40, (
+ ftnlen)40, (ftnlen)40);
+ --top;
+ }
+ }
+
+/* Can only get here if status is 'HOPELESS', in which case a */
+/* segment was not found. */
+
+ *found = FALSE_;
+
+/* If we didn't find a segment, don't attempt to use saved */
+/* outputs from a previous call. IINDEX will always be set */
+/* at this point. Also, make sure the expense of the re-use */
+/* interval is zeroed out. */
+
+ if (iindex > 0) {
+ itchkp[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("itchkp"
+ , i__1, "ckbsr_", (ftnlen)3985)] = FALSE_;
+ itruex[(i__1 = iindex - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("itruex"
+ , i__1, "ckbsr_", (ftnlen)3986)] = 0;
+ }
+
+/* For safety, indicate the first pass of this search has been */
+/* completed. Normally, we won't return here before CKBSS is */
+/* called again, but it's possible. */
+
+ newsch = FALSE_;
+ chkout_("CKSNS", (ftnlen)5);
+ return 0;
+/* $Procedure CKHAVE ( C-kernels --- Have some ) */
+
+L_ckhave:
+/* $ Abstract */
+
+/* Determine whether or not any C-kernels are currently loaded. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* C-KERNEL */
+
+/* $ Declarations */
+
+/* LOGICAL FOUND */
+
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* FOUND O TRUE if at least one C-kernel is loaded. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* FOUND is returned with the value TRUE if at least one */
+/* C-kernel is currently loaded. Otherwise it returns */
+/* the value FALSE. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This entry point allows the user to query the set of "loaded" */
+/* C-kernels to make sure that at least one C-kernel has been loaded. */
+/* This allows you to avoid making a search of an empty set of */
+/* loaded kernels which forces a SPICELIB error to be signaled. */
+
+/* $ Examples */
+
+/* Suppose you want to call on of the C-kernel readers, but wish */
+/* to handle the exceptional case of "no kernels loaded" so that */
+/* the SPICELIB exception handling mechanism is avoided in the */
+/* case of an empty set of loaded kernels. The code fragment */
+/* below shows how you might do this: */
+
+/* CALL CKHAVE ( LOADED ) */
+
+/* IF ( LOADED ) THEN */
+
+/* CALL CKGP ( ... ) */
+
+/* ELSE */
+
+/* take some kind of "reasonable action" */
+
+/* END IF */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.0.2, 28-FEB-2008 (BVS) */
+
+/* Corrected the contents of the Required_Reading section. */
+
+/* - SPICELIB Version 4.0.1, 31-OCT-2001 (NJB) */
+
+/* Typo corrected. */
+
+/* - SPICELIB Version 4.0.0, 17-FEB-2000 (WLT) */
+
+/* Added the Entry point CKHAVE */
+
+/* - SPICELIB Version 3.0.0, 03-MAR-1999 (WLT) */
+
+
+/* -& */
+/* $ Index_Entries */
+
+/* Determine whether any C-kernels are loaded */
+
+/* -& */
+ *found = nft > 0;
+ return 0;
+} /* ckbsr_ */
+
+/* Subroutine */ int ckbsr_(char *fname, integer *handle, integer *inst,
+ doublereal *sclkdp, doublereal *tol, logical *needav, doublereal *
+ descr, char *segid, logical *found, ftnlen fname_len, ftnlen
+ segid_len)
+{
+ return ckbsr_0_(0, fname, handle, inst, sclkdp, tol, needav, descr, segid,
+ found, fname_len, segid_len);
+ }
+
+/* Subroutine */ int cklpf_(char *fname, integer *handle, ftnlen fname_len)
+{
+ return ckbsr_0_(1, fname, handle, (integer *)0, (doublereal *)0, (
+ doublereal *)0, (logical *)0, (doublereal *)0, (char *)0, (
+ logical *)0, fname_len, (ftnint)0);
+ }
+
+/* Subroutine */ int ckupf_(integer *handle)
+{
+ return ckbsr_0_(2, (char *)0, handle, (integer *)0, (doublereal *)0, (
+ doublereal *)0, (logical *)0, (doublereal *)0, (char *)0, (
+ logical *)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int ckbss_(integer *inst, doublereal *sclkdp, doublereal *
+ tol, logical *needav)
+{
+ return ckbsr_0_(3, (char *)0, (integer *)0, inst, sclkdp, tol, needav, (
+ doublereal *)0, (char *)0, (logical *)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int cksns_(integer *handle, doublereal *descr, char *segid,
+ logical *found, ftnlen segid_len)
+{
+ return ckbsr_0_(4, (char *)0, handle, (integer *)0, (doublereal *)0, (
+ doublereal *)0, (logical *)0, descr, segid, found, (ftnint)0,
+ segid_len);
+ }
+
+/* Subroutine */ int ckhave_(logical *found)
+{
+ return ckbsr_0_(5, (char *)0, (integer *)0, (integer *)0, (doublereal *)0,
+ (doublereal *)0, (logical *)0, (doublereal *)0, (char *)0, found,
+ (ftnint)0, (ftnint)0);
+ }
+
diff --git a/ext/spice/src/cspice/ckcls.c b/ext/spice/src/cspice/ckcls.c
new file mode 100644
index 0000000000..73af55223d
--- /dev/null
+++ b/ext/spice/src/cspice/ckcls.c
@@ -0,0 +1,209 @@
+/* ckcls.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CKCLS ( CK, Close file ) */
+/* Subroutine */ int ckcls_(integer *handle)
+{
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_cmp(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ logical found;
+ extern /* Subroutine */ int daffna_(logical *);
+ extern logical failed_(void);
+ extern /* Subroutine */ int dafbfs_(integer *), dafcls_(integer *);
+ char access[5];
+ extern /* Subroutine */ int errhan_(char *, integer *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Close an open CK file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of the CK file to be closed. */
+
+/* $ Detailed_Input */
+
+/* HANDLE The handle of the CK file that is to be closed. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If there are no segments in the file the error */
+/* SPICE(NOSEGMENTSFOUND) will be signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* Close the CK file attached to HANDLE. */
+
+/* $ Examples */
+
+/* Suppose that you want to create a new CK file called 'new.ck' */
+/* that contains a single type 3 CK segment and has room for at */
+/* least 5000 comment characters. The following code fragment should */
+/* take care of this for you, assuming that all of the variables */
+/* passed to the CK type 3 segment writer have appropriate values. */
+
+/* NAME = 'new.ck' */
+/* IFNAME = 'Test CK file' */
+
+/* CALL CKOPN ( NAME, IFNAME, 5000, HANDLE ) */
+/* CALL CKW03 ( HANDLE, BEGTIM, ENDTIM, INST, REF, AVFLAG, */
+/* . SEGID, NREC, SCLKDP, QUATS, AVVS, NINTS, */
+/* . STARTS ) */
+/* CALL CKCLS ( HANDLE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.2.0, 07-SEP-2001 (EDW) */
+
+/* Removed DAFHLU call; replaced ERRFNM call with ERRHAN. */
+
+/* - SPICELIB Version 1.1.0, 17-FEB-2000 (FST) */
+
+/* Removed the call to ZZFIXID. This will make all C-kernels */
+/* created with future versions of the toolkit possess the */
+/* unambiguous ID word 'DAF/CK '. */
+
+/* - SPICELIB Version 1.0.0, 27-JAN-1995 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* close a ck file */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local Variables */
+
+
+/* Standard SPICELIB error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("CKCLS", (ftnlen)5);
+
+/* Get the access method for the file. Currently, if HANDLE < 0, the */
+/* access method is 'WRITE'. If HANDLE > 0, the access method is */
+/* 'READ'. In the future this should make use of the private entry */
+/* in the handle manager umbrella, ZZDDHNFO. */
+
+ if (*handle < 0) {
+ s_copy(access, "WRITE", (ftnlen)5, (ftnlen)5);
+ } else if (*handle > 0) {
+ s_copy(access, "READ", (ftnlen)5, (ftnlen)4);
+ }
+
+/* Fix the ID word if the file is open for writing and close the */
+/* file, or just close the file. */
+
+ if (s_cmp(access, "WRITE", (ftnlen)5, (ftnlen)5) == 0) {
+
+/* Check to see if there are any segments in the file. If there */
+/* are no segments, we signal an error. This probably indicates a */
+/* programming error of some sort anyway. Why would you create a */
+/* file and put nothing in it? */
+
+ dafbfs_(handle);
+ daffna_(&found);
+ if (failed_()) {
+ chkout_("CKCLS", (ftnlen)5);
+ return 0;
+ }
+ if (! found) {
+ setmsg_("No segments were found in the CK file '#'. There must b"
+ "e at least one segment in the file when this subroutine "
+ "is called.", (ftnlen)121);
+ errhan_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(NOSEGMENTSFOUND)", (ftnlen)22);
+ chkout_("CKCLS", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Close the file. */
+
+ dafcls_(handle);
+
+/* No need to check FAILED() here, since we just return. The caller */
+/* should check it though. */
+
+ chkout_("CKCLS", (ftnlen)5);
+ return 0;
+} /* ckcls_ */
+
diff --git a/ext/spice/src/cspice/ckcls_c.c b/ext/spice/src/cspice/ckcls_c.c
new file mode 100644
index 0000000000..e0b81d3c7c
--- /dev/null
+++ b/ext/spice/src/cspice/ckcls_c.c
@@ -0,0 +1,148 @@
+/*
+
+-Procedure ckcls_c ( CK, Close file )
+
+-Abstract
+
+ Close an open CK file.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ CK
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+
+ void ckcls_c ( SpiceInt handle )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ handle I Handle of the CK file to be closed.
+
+-Detailed_Input
+
+ handle The handle of the CK file that is to be closed.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If there are no segments in the file the error
+ SPICE(NOSEGMENTSFOUND) will be signalled.
+
+-Files
+
+ See Detailed_Input.
+
+-Particulars
+
+ Close the CK file attached to handle.
+
+-Examples
+
+ Suppose that you want to create a new CK file called "new.ck"
+ that contains a single type 3 CK segment and has room for at
+ least 5000 comment characters. The following code fragment should
+ take care of this for you, assuming that all of the variables
+ passed to the CK type 3 segment writer have appropriate values.
+
+ name = "new.ck";
+ ifname = "Test CK file";
+
+ ckopn_c ( name, ifname, 5000, &handle );
+
+ ckw03_c ( handle, begtim, endtim, inst,
+ ref, avflag, segid, nrec,
+ sclkdp, quats, avvs, nints, starts );
+
+ ckcls_c ( handle );
+
+
+-Restrictions
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (NJB)
+ K.R. Gehringer (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.1, 08-MAR-2002 (EDW)
+
+ Corrected header typo. Examples" to Examples.
+
+ -CSPICE Version 1.0.0, 08-FEB-1998 (NJB)
+
+ Based on SPICELIB Version 1.0.0, 26-JAN-1995 (KRG)
+
+-Index_Entries
+
+ close a ck file
+
+-&
+*/
+
+{ /* Begin ckcls_c */
+
+
+ /*
+ Participate in error handling.
+ */
+ chkin_c ( "ckcls_c");
+
+
+ ckcls_ ( ( integer * ) &handle );
+
+
+ chkout_c ( "ckcls_c");
+
+} /* End ckcls_c */
+
diff --git a/ext/spice/src/cspice/ckcov.c b/ext/spice/src/cspice/ckcov.c
new file mode 100644
index 0000000000..effdacbd71
--- /dev/null
+++ b/ext/spice/src/cspice/ckcov.c
@@ -0,0 +1,902 @@
+/* ckcov.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKCOV ( CK coverage ) */
+/* Subroutine */ int ckcov_(char *ck, integer *idcode, logical *needav, char *
+ level, doublereal *tol, char *timsys, doublereal *cover, ftnlen
+ ck_len, ftnlen level_len, ftnlen timsys_len)
+{
+ /* System generated locals */
+ integer i__1;
+ doublereal d__1;
+
+ /* Builtin functions */
+ integer s_cmp(char *, char *, ftnlen, ftnlen), s_rnge(char *, integer,
+ char *, integer);
+
+ /* Local variables */
+ char arch[80];
+ logical avok;
+ extern /* Subroutine */ int sct2e_(integer *, doublereal *, doublereal *);
+ integer i__;
+ extern /* Subroutine */ int dafgs_(doublereal *);
+ integer clkid;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ doublereal descr[5];
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *), errch_(char *, char *, ftnlen, ftnlen);
+ doublereal dctol[2];
+ logical istdb, found;
+ extern /* Subroutine */ int errdp_(char *, doublereal *, ftnlen);
+ integer dtype;
+ extern logical eqstr_(char *, char *, ftnlen, ftnlen);
+ doublereal dc[2];
+ integer ic[6];
+ extern /* Subroutine */ int daffna_(logical *);
+ extern logical failed_(void);
+ extern /* Subroutine */ int dafbfs_(integer *);
+ doublereal et;
+ integer handle, segbeg;
+ extern /* Subroutine */ int dafcls_(integer *), ckmeta_(integer *, char *,
+ integer *, ftnlen);
+ integer segend;
+ extern /* Subroutine */ int getfat_(char *, char *, char *, ftnlen,
+ ftnlen, ftnlen), dafopr_(char *, integer *, ftnlen), sigerr_(char
+ *, ftnlen);
+ logical seglvl;
+ extern /* Subroutine */ int chkout_(char *, ftnlen), setmsg_(char *,
+ ftnlen), wninsd_(doublereal *, doublereal *, doublereal *),
+ errint_(char *, integer *, ftnlen);
+ char kertyp[80];
+ extern logical return_(void);
+ extern /* Subroutine */ int zzckcv01_(integer *, integer *, integer *,
+ integer *, doublereal *, char *, doublereal *, ftnlen), zzckcv02_(
+ integer *, integer *, integer *, integer *, doublereal *, char *,
+ doublereal *, ftnlen), zzckcv03_(integer *, integer *, integer *,
+ integer *, doublereal *, char *, doublereal *, ftnlen), zzckcv04_(
+ integer *, integer *, integer *, integer *, doublereal *, char *,
+ doublereal *, ftnlen), zzckcv05_(integer *, integer *, integer *,
+ integer *, doublereal *, doublereal *, char *, doublereal *,
+ ftnlen);
+
+/* $ Abstract */
+
+/* Find the coverage window for a specified object in a specified CK */
+/* file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CELLS */
+/* DAF */
+/* CK */
+/* TIME */
+/* WINDOWS */
+
+/* $ Keywords */
+
+/* POINTING */
+/* TIME */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* CK I Name of CK file. */
+/* IDCODE I ID code of object. */
+/* NEEDAV I Flag indicating whether angular velocity is needed. */
+/* LEVEL I Coverage level: 'SEGMENT' OR 'INTERVAL'. */
+/* TOL I Tolerance in ticks. */
+/* TIMSYS I Time system used to represent coverage. */
+/* COVER I/O Window giving coverage for IDCODE. */
+
+/* $ Detailed_Input */
+
+/* CK is the name of a C-kernel. */
+
+/* IDCODE is the integer ID code of an object, normally */
+/* a spacecraft structure or instrument, for which */
+/* pointing data are expected to exist in the */
+/* specified CK file. */
+
+/* NEEDAV is a logical variable indicating whether only */
+/* segments having angular velocity are to be */
+/* considered when determining coverage. When */
+/* NEEDAV is .TRUE., segments without angular */
+/* velocity don't contribute to the coverage */
+/* window; when NEEDAV is .FALSE., all segments for */
+/* IDCODE may contribute to the coverage window. */
+
+
+/* LEVEL is the level (granularity) at which the coverage */
+/* is examined. Allowed values and corresponding */
+/* meanings are: */
+
+/* 'SEGMENT' The output coverage window */
+/* contains intervals defined by the */
+/* start and stop times of segments */
+/* for the object designated by */
+/* IDCODE. */
+
+/* 'INTERVAL' The output coverage window */
+/* contains interpolation intervals */
+/* of segments for the object */
+/* designated by IDCODE. For type 1 */
+/* segments, which don't have */
+/* interpolation intervals, each */
+/* epoch associated with a pointing */
+/* instance is treated as a singleton */
+/* interval; these intervals are */
+/* added to the coverage window. */
+
+/* All interpolation intervals are */
+/* considered to lie within the */
+/* segment bounds for the purpose of */
+/* this summary: if an interpolation */
+/* interval extends beyond the */
+/* segment coverage interval, only */
+/* its intersection with the segment */
+/* coverage interval is considered to */
+/* contribute to the total coverage. */
+
+
+/* TOL is a tolerance value expressed in ticks of the */
+/* spacecraft clock associated with IDCODE. Before */
+/* each interval is inserted into the coverage */
+/* window, the interval is intersected with the */
+/* segment coverage interval, then if the */
+/* intersection is non-empty, it is expanded by TOL: */
+/* the left endpoint of the intersection interval is */
+/* reduced by TOL and the right endpoint is increased */
+/* by TOL. Adjusted interval endpoints, when */
+/* expressed as encoded SCLK, never are less than */
+/* zero ticks. Any intervals that overlap as a */
+/* result of the expansion are merged. */
+
+/* The coverage window returned when TOL > 0 */
+/* indicates the coverage provided by the file to the */
+/* CK readers CKGPAV and CKGP when that value of TOL */
+/* is passed to them as an input. */
+
+
+/* TIMSYS is a string indicating the time system used */
+/* in the output coverage window. TIMSYS may */
+/* have the values: */
+
+/* 'SCLK' Elements of COVER are expressed in */
+/* encoded SCLK ("ticks"), where the */
+/* clock is associated with the object */
+/* designated by IDCODE. */
+
+/* 'TDB' Elements of COVER are expressed as */
+/* seconds past J2000 TDB. */
+
+
+/* COVER is an initialized SPICELIB window data structure. */
+/* COVER optionally may contain coverage data on */
+/* input; on output, the data already present in */
+/* COVER will be combined with coverage found for the */
+/* object designated by IDCODE in the file CK. */
+
+/* If COVER contains no data on input, its size and */
+/* cardinality still must be initialized. */
+
+/* $ Detailed_Output */
+
+/* COVER is a SPICELIB window data structure which */
+/* represents the merged coverage for IDCODE. When */
+/* the coverage level is 'INTERVAL', this is the set */
+/* of time intervals for which data for IDCODE are */
+/* present in the file CK, merged with the set of */
+/* time intervals present in COVER on input. The */
+/* merged coverage is represented as the union of one */
+/* or more disjoint time intervals. The window COVER */
+/* contains the pairs of endpoints of these */
+/* intervals. */
+
+/* When the coverage level is 'SEGMENT', COVER is */
+/* computed in a manner similar to that described */
+/* above, but the coverage intervals used in the */
+/* computation are those of segments rather than */
+/* interpolation intervals within segments. */
+
+/* When TOL is > 0, the intervals comprising the */
+/* coverage window for IDCODE are expanded by TOL and */
+/* any intervals overlapping as a result are merged. */
+/* The resulting window is returned in COVER. The */
+/* expanded window in no case extends beyond the */
+/* segment bounds in either direction by more than */
+/* TOL. */
+
+/* The interval endpoints contained in COVER are */
+/* encoded spacecraft clock times if TIMSYS is */
+/* 'SCLK'; otherwise the times are converted from */
+/* encoded spacecraft clock to seconds past J2000 */
+/* TDB. */
+
+/* See the Examples section below for a complete */
+/* example program showing how to retrieve the */
+/* endpoints from COVER. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file has transfer format, the error */
+/* SPICE(INVALIDFORMAT) is signaled. */
+
+/* 2) If the input file is not a transfer file but has architecture */
+/* other than DAF, the error SPICE(BADARCHTYPE) is signaled. */
+
+/* 3) If the input file is a binary DAF file of type other than */
+/* CK, the error SPICE(BADFILETYPE) is signaled. */
+
+/* 4) If the CK file cannot be opened or read, the error will */
+/* be diagnosed by routines called by this routine. The output */
+/* window will not be modified. */
+
+/* 5) If the size of the output WINDOW argument COVER is */
+/* insufficient to contain the actual number of intervals in the */
+/* coverage window for IDCODE, the error will be diagnosed by */
+/* routines called by this routine. */
+
+/* 6) If TOL is negative, the error SPICE(VALUEOUTOFRANGE) is */
+/* signaled. */
+
+/* 7) If LEVEL is not recognized, the error SPICE(INVALIDOPTION) */
+/* is signaled. */
+
+/* 8) If TIMSYS is not recognized, the error SPICE(NOTSUPPORTED) */
+/* is signaled. */
+
+/* 9) If a time conversion error occurs, the error will be */
+/* diagnosed by a routine in the call tree of this routine. */
+
+/* 10) If the output time system is TDB, the CK subsystem must be */
+/* able to map IDCODE to the ID code of the associated */
+/* spacecraft clock. If this mapping cannot be performed, the */
+/* error will be diagnosed by a routine in the call tree of this */
+/* routine. */
+
+/* $ Files */
+
+/* This routine reads a C-kernel. */
+
+/* If the output time system is 'TDB', then a leapseconds kernel */
+/* and an SCLK kernel for the spacecraft clock associated with */
+/* IDCODE must be loaded before this routine is called. */
+
+/* If the ID code of the clock associated with IDCODE is not */
+/* equal to */
+
+/* IDCODE / 1000 */
+
+/* then the kernel variable */
+
+/* CK__SCLK */
+
+/* must be present in the kernel pool to identify the clock */
+/* associated with IDCODE. This variable must contain the ID code */
+/* to be used for conversion between SCLK and TDB. Normally this */
+/* variable is provided in a text kernel loaded via FURNSH. */
+
+/* $ Particulars */
+
+/* This routine provides an API via which applications can determine */
+/* the coverage a specified CK file provides for a specified */
+/* object. */
+
+/* $ Examples */
+
+/* 1) Display the interval-level coverage for each object in a */
+/* specified CK file. Use tolerance of zero ticks. Do not */
+/* request angular velocity. Express the results in the TDB time */
+/* system. */
+
+/* Find the set of objects in the file. Loop over the contents */
+/* of the ID code set: find the coverage for each item in the */
+/* set and display the coverage. */
+
+
+/* PROGRAM CKCVR */
+/* IMPLICIT NONE */
+
+/* C */
+/* C SPICELIB functions */
+/* C */
+/* INTEGER WNCARD */
+/* INTEGER CARDI */
+/* C */
+/* C Local parameters */
+/* C */
+/* C */
+/* C Declare the coverage window. Make enough room */
+/* C for MAXIV intervals. */
+/* C */
+/* INTEGER FILSIZ */
+/* PARAMETER ( FILSIZ = 255 ) */
+
+/* INTEGER LBCELL */
+/* PARAMETER ( LBCELL = -5 ) */
+
+/* INTEGER MAXIV */
+/* PARAMETER ( MAXIV = 100000 ) */
+
+/* INTEGER WINSIZ */
+/* PARAMETER ( WINSIZ = 2 * MAXIV ) */
+
+/* INTEGER TIMLEN */
+/* PARAMETER ( TIMLEN = 50 ) */
+
+/* INTEGER MAXOBJ */
+/* PARAMETER ( MAXOBJ = 1000 ) */
+
+/* C */
+/* C Local variables */
+/* C */
+/* CHARACTER*(FILSIZ) CK */
+/* CHARACTER*(FILSIZ) LSK */
+/* CHARACTER*(FILSIZ) SCLK */
+/* CHARACTER*(TIMLEN) TIMSTR */
+
+/* DOUBLE PRECISION B */
+/* DOUBLE PRECISION COVER ( LBCELL : WINSIZ ) */
+/* DOUBLE PRECISION E */
+
+/* INTEGER I */
+/* INTEGER IDS ( LBCELL : MAXOBJ ) */
+/* INTEGER J */
+/* INTEGER NIV */
+
+/* C */
+/* C Load a leapseconds kernel and SCLK kernel for output */
+/* C time conversion. Note that we assume a single spacecraft */
+/* C clock is associated with all of the objects in the CK. */
+/* C */
+/* CALL PROMPT ( 'Name of leapseconds kernel > ', LSK ) */
+/* CALL FURNSH ( LSK ) */
+
+/* CALL PROMPT ( 'Name of SCLK kernel > ', SCLK ) */
+/* CALL FURNSH ( SCLK ) */
+
+/* C */
+/* C Get name of CK file. */
+/* C */
+/* CALL PROMPT ( 'Name of CK file > ', CK ) */
+
+/* C */
+/* C Initialize the set IDS. */
+/* C */
+/* CALL SSIZEI ( MAXOBJ, IDS ) */
+
+/* C */
+/* C Initialize the window COVER. */
+/* C */
+/* CALL SSIZED ( WINSIZ, COVER ) */
+
+/* C */
+/* C Find the set of objects in the CK file. */
+/* C */
+/* CALL CKOBJ ( CK, IDS ) */
+
+/* C */
+/* C We want to display the coverage for each object. Loop */
+/* C over the contents of the ID code set, find the coverage */
+/* C for each item in the set, and display the coverage. */
+/* C */
+/* DO I = 1, CARDI( IDS ) */
+/* C */
+/* C Find the coverage window for the current */
+/* C object. Empty the coverage window each time */
+/* C so we don't include data for the previous object. */
+/* C */
+/* CALL SCARDD ( 0, COVER ) */
+/* CALL CKCOV ( CK, IDS(I), .FALSE., */
+/* . 'INTERVAL', 0.D0, 'TDB', COVER ) */
+
+/* C */
+/* C Get the number of intervals in the coverage */
+/* C window. */
+/* C */
+/* NIV = WNCARD( COVER ) */
+
+/* C */
+/* C Display a simple banner. */
+/* C */
+/* WRITE (*,*) '========================================' */
+/* WRITE (*,*) 'Coverage for object ', IDS(I) */
+
+/* C */
+/* C Convert the coverage interval start and stop */
+/* C times to TDB calendar strings. */
+/* C */
+/* DO J = 1, NIV */
+/* C */
+/* C Get the endpoints of the Jth interval. */
+/* C */
+/* CALL WNFETD ( COVER, J, B, E ) */
+/* C */
+/* C Convert the endpoints to TDB calendar */
+/* C format time strings and display them. */
+/* C */
+/* CALL TIMOUT ( B, */
+/* . 'YYYY MON DD HR:MN:SC.###### ' // */
+/* . '(TDB) ::TDB', */
+/* . TIMSTR ) */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) 'Interval: ', J */
+/* WRITE (*,*) 'Start: ', TIMSTR */
+
+/* CALL TIMOUT ( E, */
+/* . 'YYYY MON DD HR:MN:SC.###### ' // */
+/* . '(TDB) ::TDB', */
+/* . TIMSTR ) */
+/* WRITE (*,*) 'Stop: ', TIMSTR */
+/* WRITE (*,*) ' ' */
+
+/* END DO */
+
+/* WRITE (*,*) '========================================' */
+
+/* END DO */
+
+/* END */
+
+
+/* 2) Find the segment-level coverage for the object designated by */
+/* IDCODE provided by the set of CK files loaded via a */
+/* metakernel. (The metakernel must also specify leapseconds and */
+/* SCLK kernels.) Use tolerance of zero ticks. Do not request */
+/* angular velocity. Express the results in the TDB time system. */
+
+/* PROGRAM CKMET */
+/* IMPLICIT NONE */
+/* C */
+/* C SPICELIB functions */
+/* C */
+/* INTEGER WNCARD */
+
+/* C */
+/* C Local parameters */
+/* C */
+/* INTEGER LBCELL */
+/* PARAMETER ( LBCELL = -5 ) */
+
+/* INTEGER FILSIZ */
+/* PARAMETER ( FILSIZ = 255 ) */
+
+/* INTEGER LNSIZE */
+/* PARAMETER ( LNSIZE = 80 ) */
+
+/* INTEGER MAXCOV */
+/* PARAMETER ( MAXCOV = 100000 ) */
+
+/* INTEGER TIMLEN */
+/* PARAMETER ( TIMLEN = 50 ) */
+
+/* C */
+/* C Local variables */
+/* C */
+/* CHARACTER*(FILSIZ) FILE */
+/* CHARACTER*(LNSIZE) IDCH */
+/* CHARACTER*(FILSIZ) META */
+/* CHARACTER*(FILSIZ) SOURCE */
+/* CHARACTER*(TIMLEN) TIMSTR */
+/* CHARACTER*(LNSIZE) TYPE */
+
+/* DOUBLE PRECISION B */
+/* DOUBLE PRECISION COVER ( LBCELL : 2*MAXCOV ) */
+/* DOUBLE PRECISION E */
+
+/* INTEGER COUNT */
+/* INTEGER HANDLE */
+/* INTEGER I */
+/* INTEGER IDCODE */
+/* INTEGER NIV */
+
+/* LOGICAL FOUND */
+
+/* C */
+/* C Prompt for the metakernel name; load the metakernel. */
+/* C The metakernel lists the CK files whose coverage */
+/* C for IDCODE we'd like to determine. The metakernel */
+/* C must also specify a leapseconds kernel and an SCLK */
+/* C kernel for the clock associated with IDCODE. */
+/* C */
+/* CALL PROMPT ( 'Enter name of metakernel > ', META ) */
+
+/* CALL FURNSH ( META ) */
+
+/* C */
+/* C Get the ID code of interest. */
+/* C */
+/* CALL PROMPT ( 'Enter ID code > ', IDCH ) */
+
+/* CALL PRSINT ( IDCH, IDCODE ) */
+
+/* C */
+/* C Initialize the coverage window. */
+/* C */
+/* CALL SSIZED ( MAXCOV, COVER ) */
+
+/* C */
+/* C Find out how many kernels are loaded. Loop over the */
+/* C kernels: for each loaded CK file, add its coverage */
+/* C for IDCODE, if any, to the coverage window. */
+/* C */
+/* CALL KTOTAL ( 'CK', COUNT ) */
+
+/* DO I = 1, COUNT */
+
+/* CALL KDATA ( I, 'CK', FILE, TYPE, */
+/* . SOURCE, HANDLE, FOUND ) */
+
+/* CALL CKCOV ( FILE, IDCODE, .FALSE., */
+/* . 'SEGMENT', 0.0, 'TDB', COVER ) */
+
+/* END DO */
+
+/* C */
+/* C Display results. */
+/* C */
+/* C Get the number of intervals in the coverage */
+/* C window. */
+/* C */
+/* NIV = WNCARD( COVER ) */
+
+/* C */
+/* C Display a simple banner. */
+/* C */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) 'Coverage for object ', IDCODE */
+
+/* C */
+/* C Convert the coverage interval start and stop */
+/* C times to TDB calendar strings. */
+/* C */
+/* DO I = 1, NIV */
+/* C */
+/* C Get the endpoints of the Ith interval. */
+/* C */
+/* CALL WNFETD ( COVER, I, B, E ) */
+/* C */
+/* C Convert the endpoints to TDB calendar */
+/* C format time strings and display them. */
+/* C */
+/* CALL TIMOUT ( B, */
+/* . 'YYYY MON DD HR:MN:SC.###### ' // */
+/* . '(TDB) ::TDB', */
+/* . TIMSTR ) */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) 'Interval: ', I */
+/* WRITE (*,*) 'Start: ', TIMSTR */
+
+/* CALL TIMOUT ( E, */
+/* . 'YYYY MON DD HR:MN:SC.###### ' // */
+/* . '(TDB) ::TDB', */
+/* . TIMSTR ) */
+/* WRITE (*,*) 'Stop: ', TIMSTR */
+/* WRITE (*,*) ' ' */
+
+/* END DO */
+
+/* END */
+
+
+/* $ Restrictions */
+
+/* 1) When this routine is used to accumulate coverage for IDCODE */
+/* provided by multiple CK files, the inputs NEEDAV, LEVEL, TOL, */
+/* and TIMSYS must have the same values for all files in order */
+/* for the result to be meaningful. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 30-NOV-2007 (NJB) */
+
+/* Corrected bug in first program in header Examples section: */
+/* program now empties the coverage window prior to collecting */
+/* data for the current object. Updated examples to use WNCARD */
+/* rather than CARDD. */
+
+/* - SPICELIB Version 1.0.0, 07-JAN-2005 (NJB) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get coverage window for ck object */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("CKCOV", (ftnlen)5);
+
+/* Check tolerance value. */
+
+ if (*tol < 0.) {
+ setmsg_("Tolerance must be non-negative; actual value was #.", (
+ ftnlen)51);
+ errdp_("#", tol, (ftnlen)1);
+ sigerr_("SPICE(VALUEOUTOFRANGE)", (ftnlen)22);
+ chkout_("CKCOV", (ftnlen)5);
+ return 0;
+ }
+
+/* Use a logical flag to indicate whether this is a segment-level */
+/* coverage description. */
+
+ seglvl = eqstr_(level, "SEGMENT", level_len, (ftnlen)7);
+
+/* Check coverage level keyword. */
+
+ if (! (seglvl || eqstr_(level, "INTERVAL", level_len, (ftnlen)8))) {
+ setmsg_("Allowed values of LEVEL are # and #; actual value was #.", (
+ ftnlen)56);
+ errch_("#", "SEGMENT", (ftnlen)1, (ftnlen)7);
+ errch_("#", "INTERVAL", (ftnlen)1, (ftnlen)8);
+ errch_("#", level, (ftnlen)1, level_len);
+ sigerr_("SPICE(INVALIDOPTION)", (ftnlen)20);
+ chkout_("CKCOV", (ftnlen)5);
+ return 0;
+ }
+
+/* See whether GETFAT thinks we've got a CK file. */
+
+ getfat_(ck, arch, kertyp, ck_len, (ftnlen)80, (ftnlen)80);
+ if (s_cmp(arch, "XFR", (ftnlen)80, (ftnlen)3) == 0) {
+ setmsg_("Input file # has architecture #. The file must be a binary "
+ "CK file to be readable by this routine. If the input file i"
+ "s an CK file in transfer format, run TOBIN on the file to co"
+ "nvert it to binary format.", (ftnlen)205);
+ errch_("#", ck, (ftnlen)1, ck_len);
+ errch_("#", arch, (ftnlen)1, (ftnlen)80);
+ sigerr_("SPICE(INVALIDFORMAT)", (ftnlen)20);
+ chkout_("CKCOV", (ftnlen)5);
+ return 0;
+ } else if (s_cmp(arch, "DAF", (ftnlen)80, (ftnlen)3) != 0) {
+ setmsg_("Input file # has architecture #. The file must be a binary "
+ "CK file to be readable by this routine. Binary CK files hav"
+ "e DAF architecture. If you expected the file to be a binary"
+ " CK file, the problem may be due to the file being an old no"
+ "n-native file lacking binary file format information. It's a"
+ "lso possible the file has been corrupted.", (ftnlen)340);
+ errch_("#", ck, (ftnlen)1, ck_len);
+ errch_("#", arch, (ftnlen)1, (ftnlen)80);
+ sigerr_("SPICE(INVALIDARCHTYPE)", (ftnlen)22);
+ chkout_("CKCOV", (ftnlen)5);
+ return 0;
+ } else if (s_cmp(kertyp, "CK", (ftnlen)80, (ftnlen)2) != 0) {
+ setmsg_("Input file # has file type #. The file must be a binary CK "
+ "file to be readable by this routine. If you expected the fil"
+ "e to be a binary CK file, the problem may be due to the file"
+ " being an old non-native file lacking binary file format inf"
+ "ormation. It's also possible the file has been corrupted.", (
+ ftnlen)296);
+ errch_("#", ck, (ftnlen)1, ck_len);
+ errch_("#", kertyp, (ftnlen)1, (ftnlen)80);
+ sigerr_("SPICE(INVALIDFILETYPE)", (ftnlen)22);
+ chkout_("CKCOV", (ftnlen)5);
+ return 0;
+ }
+
+/* Set a logical flag indicating whether the time systm is SCLK. */
+
+ istdb = eqstr_(timsys, "TDB", timsys_len, (ftnlen)3);
+
+/* Check time system. */
+
+ if (! istdb) {
+ if (! eqstr_(timsys, "SCLK", timsys_len, (ftnlen)4)) {
+ setmsg_("Time system spec TIMSYS was #; allowed values are SCLK "
+ "and TDB.", (ftnlen)63);
+ errch_("#", timsys, (ftnlen)1, timsys_len);
+ sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
+ chkout_("CKCOV", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* If the output time system is TDB, find the clock ID associated */
+/* with IDCODE. */
+
+ if (istdb) {
+ ckmeta_(idcode, "SCLK", &clkid, (ftnlen)4);
+ if (failed_()) {
+ chkout_("CKCOV", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Open the file for reading. */
+
+ dafopr_(ck, &handle, ck_len);
+ if (failed_()) {
+ chkout_("CKCOV", (ftnlen)5);
+ return 0;
+ }
+
+/* We will examine each segment descriptor in the file, and */
+/* we'll update our coverage bounds according to the data found */
+/* in these descriptors. */
+
+/* If TOL > 0, we'll apply TOL after we've found the coverage */
+/* for the zero-tolerance case. */
+
+/* If the time system is TDB, we'll convert the times to TDB */
+/* at the end of this routine. */
+
+/* Start a forward search. */
+
+ dafbfs_(&handle);
+
+/* Find the next DAF array. */
+
+ daffna_(&found);
+ while(found) {
+
+/* Note: we check FAILED() at the bottom of this loop; this */
+/* routine returns if FAILED() returns .TRUE. at that point. */
+
+/* Fetch and unpack the segment descriptor. */
+
+ dafgs_(descr);
+ dafus_(descr, &c__2, &c__6, dc, ic);
+
+/* Let AVOK indicate whether the segment satisfies the */
+/* angular velocity restriction. */
+
+ avok = ic[3] == 1 || ! (*needav);
+ if (ic[0] == *idcode && avok) {
+
+/* This segment is for the body of interest. If angular */
+/* velocity is needed, this segment has it. */
+
+ if (seglvl) {
+
+/* This is a segment-level summary. */
+
+/* Insert the coverage bounds into the coverage window. */
+/* Adjust the interval using the tolerance. */
+
+/* Computing MAX */
+ d__1 = dc[0] - *tol;
+ dctol[0] = max(d__1,0.);
+ dctol[1] = dc[1] + *tol;
+
+/* Convert the time to TDB if necessary. */
+
+ if (istdb) {
+
+/* Convert the time bounds to TDB before inserting */
+/* into the window. */
+
+ for (i__ = 1; i__ <= 2; ++i__) {
+ sct2e_(&clkid, &dctol[(i__1 = i__ - 1) < 2 && 0 <=
+ i__1 ? i__1 : s_rnge("dctol", i__1, "ckcov_",
+ (ftnlen)868)], &et);
+ dctol[(i__1 = i__ - 1) < 2 && 0 <= i__1 ? i__1 :
+ s_rnge("dctol", i__1, "ckcov_", (ftnlen)869)]
+ = et;
+ }
+ }
+ if (dctol[0] <= dctol[1]) {
+ wninsd_(dctol, &dctol[1], cover);
+ }
+ } else {
+
+/* We're looking for an interval-level coverage window. */
+/* This information must be retrieved in a */
+/* data-type-dependent fashion. The coverage routines */
+/* we'll call will, if necessary, adjust intervals by TOL */
+/* and convert interval times to TDB. */
+
+ dtype = ic[2];
+ segbeg = ic[4];
+ segend = ic[5];
+ if (dtype == 1) {
+ zzckcv01_(&handle, &segbeg, &segend, &clkid, tol, timsys,
+ cover, timsys_len);
+ } else if (dtype == 2) {
+ zzckcv02_(&handle, &segbeg, &segend, &clkid, tol, timsys,
+ cover, timsys_len);
+ } else if (dtype == 3) {
+ zzckcv03_(&handle, &segbeg, &segend, &clkid, tol, timsys,
+ cover, timsys_len);
+ } else if (dtype == 4) {
+ zzckcv04_(&handle, &segbeg, &segend, &clkid, tol, timsys,
+ cover, timsys_len);
+ } else if (dtype == 5) {
+
+/* Note: this calling sequence is exceptional; the */
+/* segment bounds are an input. */
+
+ zzckcv05_(&handle, &segbeg, &segend, &clkid, dc, tol,
+ timsys, cover, timsys_len);
+ } else {
+ setmsg_("Supported CK data types are 1, 2, 3, 4, 5. Dat"
+ "a type of segment: #. This problem may indicate "
+ "that you need to update your SPICE Toolkit.", (
+ ftnlen)138);
+ errint_("#", &dtype, (ftnlen)1);
+ sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
+ chkout_("CKCOV", (ftnlen)5);
+ return 0;
+ }
+ }
+ }
+ daffna_(&found);
+ if (failed_()) {
+ chkout_("CKCOV", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* COVER now represents the coverage of the entire file at the */
+/* granularity indicated by LEVEL, combined with the coverage */
+/* contained in COVER on input. */
+
+/* Release the file. */
+
+ dafcls_(&handle);
+ chkout_("CKCOV", (ftnlen)5);
+ return 0;
+} /* ckcov_ */
+
diff --git a/ext/spice/src/cspice/ckcov_c.c b/ext/spice/src/cspice/ckcov_c.c
new file mode 100644
index 0000000000..62c260009a
--- /dev/null
+++ b/ext/spice/src/cspice/ckcov_c.c
@@ -0,0 +1,648 @@
+/*
+
+-Procedure ckcov_c ( CK coverage )
+
+-Abstract
+
+ Find the coverage window for a specified object in a specified CK
+ file.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CELLS
+ DAF
+ CK
+ TIME
+ WINDOWS
+
+-Keywords
+
+ POINTING
+ TIME
+ UTILITY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ void ckcov_c ( ConstSpiceChar * ck,
+ SpiceInt idcode,
+ SpiceBoolean needav,
+ ConstSpiceChar * level,
+ SpiceDouble tol,
+ ConstSpiceChar * timsys,
+ SpiceCell * cover )
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ ck I Name of CK file.
+ idcode I ID code of object.
+ needav I Flag indicating whether angular velocity is needed.
+ level I Coverage level: "SEGMENT" OR "INTERVAL".
+ tol I Tolerance in ticks.
+ timsys I Time system used to represent coverage.
+ cover I/O Window giving coverage for `idcode'.
+
+-Detailed_Input
+
+ ck is the name of a C-kernel.
+
+ idcode is the integer ID code of an object, normally a
+ spacecraft structure or instrument, for which
+ pointing data are expected to exist in the specified
+ CK file.
+
+ needav is a logical variable indicating whether only
+ segments having angular velocity are to be considered
+ when determining coverage. When `needav' is
+ SPICETRUE, segments without angular velocity don't
+ contribute to the coverage window; when `needav' is
+ SPICEFALSE, all segments for `idcode' may contribute
+ to the coverage window.
+
+
+ level is the level (granularity) at which the coverage
+ is examined. Allowed values and corresponding
+ meanings are:
+
+ "SEGMENT" The output coverage window contains
+ intervals defined by the start and
+ stop times of segments for the object
+ designated by `idcode'.
+
+ "INTERVAL" The output coverage window contains
+ interpolation intervals of segments
+ for the object designated by
+ `idcode'. For type 1 segments, which
+ don't have interpolation intervals,
+ each epoch associated with a pointing
+ instance is treated as a singleton
+ interval; these intervals are added
+ to the coverage window.
+
+ All interpolation intervals are
+ considered to lie within the segment
+ bounds for the purpose of this
+ summary: if an interpolation
+ interval extends beyond the segment
+ coverage interval, only its
+ intersection with the segment
+ coverage interval is considered to
+ contribute to the total coverage.
+
+ tol is a tolerance value expressed in ticks of the
+ spacecraft clock associated with IDCODE. Before each
+ interval is inserted into the coverage window, the
+ interval is intersected with the segment coverage
+ interval, then if the intersection is non-empty, it
+ is expanded by `tol': the left endpoint of the
+ intersection interval is reduced by `tol' and the
+ right endpoint is increased by `tol'. Adjusted
+ interval endpoints, when expressed as encoded SCLK,
+ never are less than zero ticks. Any intervals that
+ overlap as a result of the expansion are merged.
+
+ The coverage window returned when tol > 0 indicates
+ the coverage provided by the file to the CK readers
+ ckgpav_c and ckgp_c when that value of `tol' is
+ passed to them as an input.
+
+
+ timsys is a string indicating the time system used in the
+ output coverage window. `timsys' may have the
+ values:
+
+ "SCLK" Elements of `cover' are expressed in
+ encoded SCLK ("ticks"), where the
+ clock is associated with the object
+ designated by `idcode'.
+
+ "TDB" Elements of `cover' are expressed as
+ seconds past J2000 TDB.
+
+
+ cover is an initialized CSPICE window data structure.
+ `cover' optionally may contain coverage data on
+ input; on output, the data already present in `cover'
+ will be combined with coverage found for the object
+ designated by `idcode' in the file `ck'.
+
+ If `cover' contains no data on input, its size and
+ cardinality still must be initialized.
+
+-Detailed_Output
+
+ cover is a CSPICE window data structure which represents
+ the merged coverage for `idcode'. When the coverage
+ level is "INTERVAL", this is the set of time
+ intervals for which data for `idcode' are present in
+ the file `ck', merged with the set of time intervals
+ present in `cover' on input. The merged coverage is
+ represented as the union of one or more disjoint time
+ intervals. The window `cover' contains the pairs of
+ endpoints of these intervals.
+
+ When the coverage level is "SEGMENT", `cover' is
+ computed in a manner similar to that described above,
+ but the coverage intervals used in the computation
+ are those of segments rather than interpolation
+ intervals within segments.
+
+ When `tol' is > 0, the intervals comprising the
+ coverage window for `idcode' are expanded by `tol'
+ and any intervals overlapping as a result are merged.
+ The resulting window is returned in `cover'. The
+ expanded window in no case extends beyond the segment
+ bounds in either direction by more than `tol'.
+
+ The interval endpoints contained in `cover' are
+ encoded spacecraft clock times if `timsys' is "SCLK";
+ otherwise the times are converted from encoded
+ spacecraft clock to seconds past J2000 TDB.
+
+ See the Examples section below for a complete example
+ program showing how to retrieve the endpoints from
+ `cover'.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the input file has transfer format, the error
+ SPICE(INVALIDFORMAT) is signaled.
+
+ 2) If the input file is not a transfer file but has architecture
+ other than DAF, the error SPICE(BADARCHTYPE) is signaled.
+
+ 3) If the input file is a binary DAF file of type other than
+ CK, the error SPICE(BADFILETYPE) is signaled.
+
+ 4) If the CK file cannot be opened or read, the error will
+ be diagnosed by routines called by this routine. The output
+ window will not be modified.
+
+ 5) If the size of the output window argument `cover' is
+ insufficient to contain the actual number of intervals in the
+ coverage window for `idcode', the error will be diagnosed by
+ routines called by this routine.
+
+ 6) If `tol' is negative, the error SPICE(VALUEOUTOFRANGE) is
+ signaled.
+
+ 7) If `level' is not recognized, the error SPICE(INVALIDOPTION)
+ is signaled.
+
+ 8) If `timsys' is not recognized, the error SPICE(INVALIDOPTION)
+ is signaled.
+
+ 9) If a time conversion error occurs, the error will be
+ diagnosed by a routine in the call tree of this routine.
+
+ 10) If the output time system is TDB, the CK subsystem must be
+ able to map `idcode' to the ID code of the associated
+ spacecraft clock. If this mapping cannot be performed, the
+ error will be diagnosed by a routine in the call tree of this
+ routine.
+
+ 11) The error SPICE(EMPTYSTRING) is signaled if any of the input
+ strings `ck', `level', or `timsys' do not contain at least one
+ character, since such an input string cannot be converted to a
+ Fortran-style string in this case.
+
+ 12) The error SPICE(NULLPOINTER) is signaled if the if any of the input
+ strings `ck', `level', or `timsys' are null.
+
+
+-Files
+
+ This routine reads a C-kernel.
+
+ If the output time system is "TDB", then a leapseconds kernel
+ and an SCLK kernel for the spacecraft clock associated with
+ `idcode' must be loaded before this routine is called.
+
+ If the ID code of the clock associated with `idcode' is not
+ equal to
+
+ idcode / 1000
+
+ then the kernel variable
+
+ CK__SCLK
+
+ must be present in the kernel pool to identify the clock
+ associated with `idcode'. This variable must contain the ID code
+ to be used for conversion between SCLK and TDB. Normally this
+ variable is provided in a text kernel loaded via furnsh_c.
+
+-Particulars
+
+ This routine provides an API via which applications can determine
+ the coverage a specified CK file provides for a specified
+ object.
+
+-Examples
+
+ 1) Display the interval-level coverage for each object in a
+ specified CK file. Use tolerance of zero ticks. Do not request
+ angular velocity. Express the results in the TDB time system.
+
+ Find the set of objects in the file. Loop over the contents of
+ the ID code set: find the coverage for each item in the set and
+ display the coverage.
+
+
+ #include
+ #include "SpiceUsr.h"
+
+ int main()
+ {
+
+ /.
+ Local parameters
+ ./
+ #define FILSIZ 256
+ #define MAXIV 100000
+ #define WINSIZ ( 2 * MAXIV )
+ #define TIMLEN 51
+ #define MAXOBJ 1000
+
+ /.
+ Local variables
+ ./
+ SPICEDOUBLE_CELL ( cover, WINSIZ );
+ SPICEINT_CELL ( ids, MAXOBJ );
+
+ SpiceChar ck [ FILSIZ ];
+ SpiceChar lsk [ FILSIZ ];
+ SpiceChar sclk [ FILSIZ ];
+ SpiceChar timstr [ TIMLEN ];
+
+ SpiceDouble b;
+ SpiceDouble e;
+
+ SpiceInt i;
+ SpiceInt j;
+ SpiceInt niv;
+ SpiceInt obj;
+
+
+ /.
+ Load a leapseconds kernel and SCLK kernel for output time
+ conversion. Note that we assume a single spacecraft clock is
+ associated with all of the objects in the CK.
+ ./
+ prompt_c ( "Name of leapseconds kernel > ", FILSIZ, lsk );
+ furnsh_c ( lsk );
+
+ prompt_c ( "Name of SCLK kernel > ", FILSIZ, sclk );
+ furnsh_c ( sclk );
+
+ /.
+ Get name of CK file.
+ ./
+ prompt_c ( "Name of CK file > ", FILSIZ, ck );
+
+ /.
+ Find the set of objects in the CK file.
+ ./
+ ckobj_c ( ck, &ids );
+
+ /.
+ We want to display the coverage for each object. Loop over
+ the contents of the ID code set, find the coverage for
+ each item in the set, and display the coverage.
+ ./
+ for ( i = 0; i < card_c( &ids ); i++ )
+ {
+ /.
+ Find the coverage window for the current object.
+ Empty the coverage window each time so we don't
+ include data for the previous object.
+ ./
+ obj = SPICE_CELL_ELEM_I( &ids, i );
+
+ scard_c ( 0, &cover );
+ ckcov_c ( ck, obj, SPICEFALSE,
+ "INTERVAL", 0.0, "TDB", &cover );
+
+ /.
+ Get the number of intervals in the coverage window.
+ ./
+ niv = wncard_c( &cover );
+
+ /.
+ Display a simple banner.
+ ./
+ printf ( "%s\n", "========================================" );
+
+ printf ( "Coverage for object %ld\n", obj );
+
+ /.
+ Convert the coverage interval start and stop times to TDB
+ calendar strings.
+ ./
+ for ( j = 0; j < niv; j++ )
+ {
+ /.
+ Get the endpoints of the jth interval.
+ ./
+ wnfetd_c ( &cover, j, &b, &e );
+
+ /.
+ Convert the endpoints to TDB calendar
+ format time strings and display them.
+ ./
+ timout_c ( b,
+ "YYYY MON DD HR:MN:SC.###### (TDB) ::TDB",
+ TIMLEN,
+ timstr );
+
+ printf ( "\n"
+ "Interval: %ld\n"
+ "Start: %s\n",
+ j,
+ timstr );
+
+ timout_c ( e,
+ "YYYY MON DD HR:MN:SC.###### (TDB) ::TDB",
+ TIMLEN,
+ timstr );
+ printf ( "Stop: %s\n", timstr );
+
+ }
+ printf ( "%s\n", "========================================" );
+
+ }
+ return ( 0 );
+ }
+
+
+ 2) Find the segment-level coverage for the object designated by
+ IDCODE provided by the set of CK files loaded via a metakernel.
+ (The metakernel must also specify leapseconds and SCLK kernels.)
+ Use tolerance of zero ticks. Do not request angular velocity.
+ Express the results in the TDB time system.
+
+
+ #include
+ #include "SpiceUsr.h"
+
+ int main()
+ {
+
+ /.
+ Local parameters
+ ./
+ #define FILSIZ 256
+ #define LNSIZE 81
+ #define MAXCOV 100000
+ #define WINSIZ ( 2 * MAXCOV )
+ #define TIMLEN 51
+
+ /.
+ Local variables
+ ./
+ SPICEDOUBLE_CELL ( cover, WINSIZ );
+
+ SpiceBoolean found;
+
+ SpiceChar file [ FILSIZ ];
+ SpiceChar idch [ LNSIZE ];
+ SpiceChar meta [ FILSIZ ];
+ SpiceChar source [ FILSIZ ];
+ SpiceChar timstr [ TIMLEN ];
+ SpiceChar type [ LNSIZE ];
+
+ SpiceDouble b;
+ SpiceDouble e;
+
+ SpiceInt count;
+ SpiceInt handle;
+ SpiceInt i;
+ SpiceInt idcode;
+ SpiceInt niv;
+
+
+ /.
+ Prompt for the metakernel name; load the metakernel.
+ The metakernel lists the CK files whose coverage
+ for `idcode' we'd like to determine. The metakernel
+ must also specify a leapseconds kernel and an SCLK
+ kernel for the clock associated with `idcode'.
+ ./
+ prompt_c ( "Name of metakernel > ", FILSIZ, meta );
+ furnsh_c ( meta );
+
+ /.
+ Get the ID code of interest.
+ ./
+ prompt_c ( "Enter ID code > ", LNSIZE, idch );
+ prsint_c ( idch, &idcode );
+
+ /.
+ Find out how many kernels are loaded. Loop over the
+ kernels: for each loaded CK file, add its coverage
+ for `idcode', if any, to the coverage window.
+ ./
+ ktotal_c ( "CK", &count );
+
+ for ( i = 0; i < count; i++ )
+ {
+ kdata_c ( i, "CK", FILSIZ,
+ LNSIZE, FILSIZ, file,
+ type, source, &handle, &found );
+
+ ckcov_c ( file, idcode, SPICEFALSE,
+ "SEGMENT", 0.0, "TDB", &cover );
+ }
+
+ /.
+ Display results.
+
+ Get the number of intervals in the coverage window.
+ ./
+ niv = wncard_c( &cover );
+
+ /.
+ Display a simple banner.
+ ./
+ printf ( "\nCoverage for object %ld\n", idcode );
+
+ /.
+ Convert the coverage interval start and stop times to TDB
+ calendar strings.
+ ./
+ for ( i = 0; i < niv; i++ )
+ {
+ /.
+ Get the endpoints of the ith interval.
+ ./
+ wnfetd_c ( &cover, i, &b, &e );
+
+ /.
+ Convert the endpoints to TDB calendar
+ format time strings and display them.
+ ./
+ timout_c ( b,
+ "YYYY MON DD HR:MN:SC.###### (TDB) ::TDB",
+ TIMLEN,
+ timstr );
+
+ printf ( "\n"
+ "Interval: %ld\n"
+ "Start: %s\n",
+ i,
+ timstr );
+
+ timout_c ( e,
+ "YYYY MON DD HR:MN:SC.###### (TDB) ::TDB",
+ TIMLEN,
+ timstr );
+ printf ( "Stop: %s\n", timstr );
+
+ }
+ return ( 0 );
+ }
+
+
+-Restrictions
+
+ 1) When this routine is used to accumulate coverage for `idcode'
+ provided by multiple CK files, the inputs `needav', `level', `tol',
+ and `timsys' must have the same values for all files in order
+ for the result to be meaningful.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.1, 30-NOV-2007 (NJB)
+
+ Corrected bug in first example program in header:
+ program now empties result window prior to collecting
+ data for each object. Updated examples to use wncard_c
+ rather than card_c. Updated second example to demonstrate
+ segment-level summary capability.
+
+ -CSPICE Version 1.0.0, 07-JAN-2005 (NJB)
+
+-Index_Entries
+
+ get coverage window for ck object
+
+-&
+*/
+
+{ /* Begin ckcov_c */
+
+
+ /*
+ Local variables
+ */
+ logical need;
+
+
+ /*
+ Participate in error tracing.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+ chkin_c ( "ckcov_c" );
+
+ /*
+ Check the input string `ck' to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "ckcov_c", ck );
+
+ /*
+ Check the input string `level' to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "ckcov_c", level );
+
+ /*
+ Check the input string `timsys' to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "ckcov_c", timsys );
+
+ /*
+ Make sure cell data type is d.p.
+ */
+ CELLTYPECHK ( CHK_STANDARD, "ckcov_c", SPICE_DP, cover );
+
+ /*
+ Initialize the cell if necessary.
+ */
+ CELLINIT ( cover );
+
+ /*
+ Call the f2c'd Fortran routine.
+ */
+ need = needav;
+
+ ckcov_ ( ( char * ) ck,
+ ( integer * ) &idcode,
+ ( logical * ) &need,
+ ( char * ) level,
+ ( doublereal * ) &tol,
+ ( char * ) timsys,
+ ( doublereal * ) (cover->base),
+ ( ftnlen ) strlen(ck),
+ ( ftnlen ) strlen(level),
+ ( ftnlen ) strlen(timsys) );
+
+ /*
+ Sync the output cell.
+ */
+ if ( !failed_c() )
+ {
+ zzsynccl_c ( F2C, cover );
+ }
+
+ chkout_c ( "ckcov_c" );
+
+} /* End ckcov_c */
diff --git a/ext/spice/src/cspice/cke01.c b/ext/spice/src/cspice/cke01.c
new file mode 100644
index 0000000000..3c4d59df2d
--- /dev/null
+++ b/ext/spice/src/cspice/cke01.c
@@ -0,0 +1,387 @@
+/* cke01.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CKE01 ( CK evaluate pointing record, data type 1 ) */
+/* Subroutine */ int cke01_(logical *needav, doublereal *record, doublereal *
+ cmat, doublereal *av, doublereal *clkout)
+{
+ extern /* Subroutine */ int chkin_(char *, ftnlen), chkout_(char *,
+ ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int q2m_(doublereal *, doublereal *);
+
+/* $ Abstract */
+
+/* Evaluate a pointing record returned by CKR01 from a CK data type 1 */
+/* segment. Return the C-matrix and optionally the angular velocity */
+/* vector associated with the time CLKOUT. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+/* ROTATION */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* NEEDAV I True if angular velocity vector is required. */
+/* RECORD I Data type 1 pointing record. */
+/* CMAT O C-matrix. */
+/* AV O Angular velocity vector. */
+/* CLKOUT O Output spacecraft clock time. */
+
+/* $ Detailed_Input */
+
+/* NEEDAV is true when angular velocity data is requested. */
+
+/* RECORD is a set of double precision numbers returned by CKR01 */
+/* that contain sufficient information from a data type */
+/* 1 pointing segment to evaluate the C-matrix and */
+/* possibly the angular velocity vector (if NEEDAV is */
+/* true) for a particular instance. */
+
+/* The contents of RECORD are as follows: */
+
+/* RECORD( 1 ) = CLKOUT */
+
+/* RECORD( 2 ) = q0 */
+/* RECORD( 3 ) = q1 */
+/* RECORD( 4 ) = q2 */
+/* RECORD( 5 ) = q3 */
+
+/* RECORD( 6 ) = Av1 ] */
+/* RECORD( 7 ) = Av2 |-- Optional */
+/* RECORD( 8 ) = Av3 ] */
+
+
+/* The quantities q0 - q3 represent a quaternion. */
+/* The quantities Av1, Av2, and Av3 represent the angular */
+/* velocity vector. */
+
+/* CLKOUT is the encoded spacecraft clock time */
+/* associated with the quaternion and, optionally, the */
+/* angular velocity vector. */
+
+/* $ Detailed_Output */
+
+/* CMAT is a rotation matrix that transforms the components of */
+/* of a vector expressed in the reference frame given in */
+/* the segment to components expressed in the instrument */
+/* fixed frame at time CLKOUT. */
+
+/* Thus, if a vector v has components x, y, z in the */
+/* reference frame, then v has components x', y', z' in */
+/* the instrument fixed frame at time CLKOUT: */
+
+/* [ x' ] [ ] [ x ] */
+/* | y' | = | CMAT | | y | */
+/* [ z' ] [ ] [ z ] */
+
+/* If the x', y', z' components are known, use the */
+/* transpose of the C-matrix to determine x, y, z as */
+/* follows. */
+
+/* [ x ] [ ]T [ x' ] */
+/* | y | = | CMAT | | y' | */
+/* [ z ] [ ] [ z' ] */
+/* (Transpose of CMAT) */
+
+/* AV is the angular velocity vector. This is returned only */
+/* if it has been requested, as indicated by NEEDAV. In */
+/* other words, if NEEDAV is true, the angular velocity */
+/* portion of RECORD must be present. */
+
+/* The angular velocity vector is the vector whose */
+/* direction gives the right-handed axis about which */
+/* the reference frame tied to the instrument is */
+/* instantaneously rotating at time CLKOUT. */
+
+/* The angular velocity vector is returned in component */
+/* form */
+
+/* AV = [ AV1 , AV2 , AV3 ] */
+
+/* which is in terms of the reference coordinate frame */
+/* specified in the segment descriptor. */
+
+/* The magnitude of AV is the magnitude of the instantane- */
+/* ous velocity of the rotation, in radians per second. */
+
+/* CLKOUT The encoded spacecraft clock time associated with the */
+/* returned C-matrix and, optionally, the returned angular */
+/* velocity vector. */
+
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) No checking is done to determine whether RECORD is a valid */
+/* record. */
+
+/* 2) If NEEDAV is true, then RECORD is assumed to contain angular */
+/* velocity data. No checking is performed to verify this */
+/* assumption. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* For a detailed description of the structure of a type 1 pointing */
+/* segment, see the CK Required Reading file. */
+
+/* The only real work done by CKE01 is to convert the pointing */
+/* portion of the record from quaternion form to C-matrix form. */
+
+/* The angular velocity vector will only be returned if it has been */
+/* requested. In other words, if NEEDAV is true, the routine will */
+/* expect the angular velocity component of the record to be present. */
+
+/* $ Examples */
+
+/* A call to a CKEnn routine is almost always preceded by a call to */
+/* the corresponding CKRnn routine, which gets the logical record */
+/* that CKEnn evaluates. */
+
+/* The following code fragment searches through a file represented */
+/* by HANDLE for all segments applicable to the Voyager 2 wide angle */
+/* camera, for a particular spacecraft clock time, which have data */
+/* type 1. It then evaluates the pointing for that epoch and prints */
+/* the result. */
+
+/* C */
+/* C - Get the spacecraft clock time. Must encode it for use */
+/* C in the C-kernel. */
+/* C */
+/* C - Set the time tolerance high to catch anything close to */
+/* C the input time. */
+/* C */
+/* C - We don't need angular velocity data. */
+/* C */
+
+/* SC = -32 */
+/* INST = -32002 */
+/* TOL = 1000.D0 */
+/* NEEDAV = .FALSE. */
+/* DTYPE = 1 */
+/* C */
+/* C Load the Voyager 2 spacecraft clock kernel and the C-kernel. */
+/* C */
+/* CALL FURNSH ( 'VGR_SCLK.TSC' ) */
+/* CALL DAFOPR ( 'VGR2_CK.BC', HANDLE ) */
+/* C */
+/* C Convert the input request time to ticks. */
+/* C */
+/* WRITE (*,*) 'Enter spacecraft clock time string:' */
+/* READ (*,FMT='(A)') SCLKCH */
+/* CALL SCENCD ( SC, SCLKCH, SCLKDP ) */
+
+/* C */
+/* C Search from the beginning through all segments. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( SFND ) */
+
+/* DO WHILE ( SFND ) */
+
+/* CALL DAFGN ( IDENT ) */
+/* CALL DAFGS ( DESCR ) */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* IF ( INST .EQ. ICD( 1 ) */
+/* . DTYPE .EQ. ICD( 3 ) */
+/* . .AND. SCLKDP + TOL .GE. DCD( 1 ) */
+/* . .AND. SCLKDP - TOL .LE. DCD( 2 ) ) THEN */
+
+/* CALL CKR01 ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
+/* . RECORD, FOUND ) */
+
+/* IF ( FOUND ) THEN */
+
+/* CALL CKE01 ( NEEDAV, RECORD, CMAT, AV, CLKOUT ) */
+
+/* WRITE (*,*) 'Segment descriptor and identifier:' */
+/* WRITE (*,*) DCD, ICD */
+/* WRITE (*,*) IDENT */
+
+/* WRITE (*,*) 'C-matrix:' */
+/* WRITE (*,*) CMAT */
+
+/* END IF */
+
+/* END IF */
+
+/* CALL DAFFNA ( SFND ) */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* 1) None. */
+
+/* $ Author_and_Institution */
+
+/* J.E. McLean (JPL) */
+/* M.J. Spencer (JPL) */
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.2.1, 22-AUG-2006 (EDW) */
+
+/* Replaced header references to LDPOOL with references */
+/* to FURNSH. */
+
+/* - SPICELIB Version 1.2.0, 14-NOV-1995 (WLT) */
+
+/* Changed "inertial frame" to simply reference frame to */
+/* reflect new capabilities of the SPICE system. */
+
+/* - SPICELIB Version 1.1.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.1.0, 30-AUG-1991 (MJS) (JML) */
+
+/* 1) Previously, in the standard SPICE error handling, the */
+/* logical function RETURN was not written as a function; */
+/* it is now written as a function. */
+
+/* 2) The example program was changed so that the tolerance */
+/* and data type are used in selecting which segments to read. */
+
+/* 3) It was specified that the angular velocity vector */
+/* gives the right-handed axis about which the instrument */
+/* frame rotates. */
+
+/* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
+
+/* The example program was corrected so that the input */
+/* instrument code was tested against ICD(1) instead of */
+/* ICD(3). */
+
+/* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* evaluate ck type_1 pointing data record */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.2.0, 14-NOV-1995 (WLT) */
+
+/* Changed "inertial frame" to simply reference frame to */
+/* reflect new capabilities of the SPICE system. */
+
+/* This change affects only documentation not code. */
+
+/* - SPICELIB Version 1.1.0, 30-AUG-1991 (MJS) (JML) */
+
+/* 1) In the standard SPICE error handling, the line: */
+
+/* IF ( RETURN ) THEN */
+
+/* was changed to */
+
+/* IF ( RETURN() ) THEN */
+
+/* 2) The example program was changed so that the tolerance */
+/* and data type are used in selecting which segments to read. */
+
+/* 3) It was specified that the angular velocity vector */
+/* gives the right-handed axis about which the instrument */
+/* frame rotates. */
+
+/* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
+
+/* 1) The example program was corrected so that the input */
+/* instrument code was tested against ICD(1) instead of */
+/* ICD(3). */
+/* 2) SCLK was removed from the Required Reading section. */
+
+/* - Beta Version 1.1.0, 29-AUG-1990 (MJS) (JEM) */
+
+/* The following changes were made as a result of the */
+/* NAIF CK Code and Documentation Review: */
+
+/* 1) The argument SCLK was removed from the calling sequence. */
+/* 2) Header was updated. */
+/* 3) The call to the routine QUAT2M_3 was replaced by a call to */
+/* the routine Q2M. */
+
+/* - Beta Version 1.0.0, 18-MAY-1990 (RET) (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKE01", (ftnlen)5);
+ }
+
+/* Dissect the record. */
+
+ *clkout = record[0];
+ q2m_(&record[1], cmat);
+ if (*needav) {
+ av[0] = record[5];
+ av[1] = record[6];
+ av[2] = record[7];
+ }
+ chkout_("CKE01", (ftnlen)5);
+ return 0;
+} /* cke01_ */
+
diff --git a/ext/spice/src/cspice/cke02.c b/ext/spice/src/cspice/cke02.c
new file mode 100644
index 0000000000..902a557e44
--- /dev/null
+++ b/ext/spice/src/cspice/cke02.c
@@ -0,0 +1,389 @@
+/* cke02.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__4 = 4;
+
+/* $Procedure CKE02 ( C-kernel, evaluate pointing record, data type 2 ) */
+/* Subroutine */ int cke02_(logical *needav, doublereal *record, doublereal *
+ cmat, doublereal *av, doublereal *clkout)
+{
+ doublereal time, quat[4];
+ extern /* Subroutine */ int vequ_(doublereal *, doublereal *), mxmt_(
+ doublereal *, doublereal *, doublereal *);
+ doublereal cbase[9] /* was [3][3] */, angle;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), vequg_(doublereal *,
+ integer *, doublereal *);
+ extern doublereal vnorm_(doublereal *);
+ extern /* Subroutine */ int axisar_(doublereal *, doublereal *,
+ doublereal *);
+ doublereal avtemp[3];
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int q2m_(doublereal *, doublereal *);
+ doublereal rot[9] /* was [3][3] */;
+
+/* $ Abstract */
+
+/* Evaluate a pointing record returned by CKR02 from a CK data type 2 */
+/* segment. Return the C-matrix and angular velocity vector associated */
+/* with the time CLKOUT. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* ROTATION */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* NEEDAV I True if angular velocity is requested. */
+/* RECORD I Data type 2 pointing record. */
+/* CMAT O C-matrix. */
+/* AV O Angular velocity vector. */
+/* CLKOUT O SCLK associated with C-matrix. */
+
+/* $ Detailed_Input */
+
+/* NEEDAV is true if angular velocity is requested. */
+
+/* RECORD is a set of double precision numbers returned by CKR02 */
+/* that contain sufficient information from a data type */
+/* 2 pointing segment to evaluate the C-matrix and the */
+/* angular velocity vector for a particular instance. */
+
+/* The contents of RECORD are as follows: */
+
+/* RECORD( 1 ) = start SCLKDP of interval */
+
+/* RECORD( 2 ) = SCLK for which pointing was found */
+
+/* RECORD( 3 ) = seconds / tick rate */
+
+/* RECORD( 4 ) = q0 */
+/* RECORD( 5 ) = q1 */
+/* RECORD( 6 ) = q2 */
+/* RECORD( 7 ) = q3 */
+
+/* RECORD( 8 ) = av1 */
+/* RECORD( 9 ) = av2 */
+/* RECORD( 10 ) = av3 */
+
+/* The quantities q0 - q3 are the components of the */
+/* quaternion that represents the C - matrix associated */
+/* with the start of the interval. The quantities av1, */
+/* av2, and av3 are the components of the angular velocity */
+/* vector. */
+
+/* $ Detailed_Output */
+
+
+/* CMAT is a rotation matrix that transforms the components */
+/* of a vector expressed in the inertial frame given in */
+/* the segment to components expressed in the instrument */
+/* fixed frame at the returned time. */
+
+/* Thus, if a vector v has components x, y, z in the */
+/* inertial frame, then v has components x', y', z' in the */
+/* instrument fixed frame where: */
+
+/* [ x' ] [ ] [ x ] */
+/* | y' | = | CMAT | | y | */
+/* [ z' ] [ ] [ z ] */
+
+/* If the x', y', z' components are known, use the */
+/* transpose of the C-matrix to determine x, y, z as */
+/* follows. */
+
+/* [ x ] [ ]T [ x' ] */
+/* | y | = | CMAT | | y' | */
+/* [ z ] [ ] [ z' ] */
+/* (Transpose of CMAT) */
+
+/* AV is the angular velocity vector. The angular velocity */
+/* contained in RECORD is returned only if NEEDAV is true. */
+
+/* The direction of the angular velocity vector gives */
+/* the right-handed axis about which the instrument fixed */
+/* reference frame is rotating. The magnitude of AV is */
+/* the magnitude of the instantaneous velocity of the */
+/* rotation, in radians per second. */
+
+/* The angular velocity vector is returned in component */
+/* form */
+
+/* AV = [ AV1 , AV2 , AV3 ] */
+
+/* which is in terms of the inertial coordinate frame */
+/* specified in the segment descriptor. */
+
+/* CLKOUT is the encoded SCLK associated with the returned */
+/* C-matrix and angular velocity vector. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) No checking is done to determine whether RECORD is valid. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* For a detailed description of the structure of a type 2 pointing */
+/* segment, see the CK Required Reading. */
+
+/* Pointing data in a type 2 segment consists of intervals during */
+/* which the orientation of the spacecraft structure can be described */
+/* by an initial C-matrix and a constant angular velocity vector. */
+/* From the information contained in the pointing record returned by */
+/* CKR02, this subroutine calculates and returns the C-matrix */
+/* associated with the time returned by CKR02. It also returns the */
+/* angular velocity vector contained in the pointing record. */
+
+/* $ Examples */
+
+/* A call to a CKEnn routine is almost always preceded by a call to */
+/* the corresponding CKRnn routine, which gets the logical record */
+/* that CKEnn evaluates. */
+
+/* The following code fragment searches through a file (represented */
+/* by HANDLE) for all segments applicable to the Voyager 2 wide angle */
+/* camera, for a particular spacecraft clock time, that are of data */
+/* types 1 or 2. It then evaluates the pointing for that epoch and */
+/* prints the result. */
+
+
+/* SC = -32 */
+/* INST = -32002 */
+/* C */
+/* C Load the Voyager 2 spacecraft clock kernel and the C-kernel. */
+/* C */
+/* CALL FURNSH ( 'VGR_SCLK.TSC' ) */
+/* CALL DAFOPR ( 'VGR2_CK.BC', HANDLE ) */
+
+/* C */
+/* C Get the spacecraft clock time. Must encode it for use */
+/* C in the C-kernel. */
+/* C */
+
+/* WRITE (*,*) 'Enter spacecraft clock time string:' */
+/* READ (*,FMT='(A)') SCLKCH */
+/* CALL SCENCD ( SC, SCLKCH, SCLKDP ) */
+
+/* C */
+/* C Search from the beginning through all segments. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( SFND ) */
+
+/* DO WHILE ( SFND ) */
+
+/* CALL DAFGN ( IDENT ) */
+/* CALL DAFGS ( DESCR ) */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* IF ( INST .EQ. ICD( 1 ) .AND. */
+/* . SCLKDP + TOL .GE. DCD( 1 ) .AND. */
+/* . SCLKDP - TOL .LE. DCD( 2 ) ) THEN */
+
+/* DTYPE = ICD ( 3 ) */
+
+/* IF ( DTYPE .EQ. 1 ) THEN */
+
+/* CALL CKR01 ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
+/* . RECORD, FOUND ) */
+
+/* IF ( FOUND ) THEN */
+/* CALL CKE01 ( NEEDAV, RECORD, CMAT, AV, CLKOUT ) */
+/* END IF */
+
+/* ELSE IF ( DTYPE .EQ. 2 ) THEN */
+
+/* CALL CKR02 ( HANDLE, DESCR, SCLKDP, TOL, */
+/* . RECORD, FOUND ) */
+
+/* IF ( FOUND ) THEN */
+/* CALL CKE02 ( NEEDAV, RECORD, CMAT, AV, CLKOUT ) */
+/* END IF */
+
+/* END IF */
+
+/* IF ( FOUND ) THEN */
+
+/* WRITE (*,*) 'Segment descriptor and identifier:' */
+/* WRITE (*,*) DCD, ICD */
+/* WRITE (*,*) IDENT */
+
+/* WRITE (*,*) 'C-matrix:' */
+/* WRITE (*,*) CMAT */
+
+/* END IF */
+
+/* END IF */
+
+/* CALL DAFFNA ( SFND ) */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.M. Lynch (JPL) */
+/* W.L. Taber (JPL) */
+/* E.D. Wright (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.3, 31-JAN-2008 (BVS) */
+
+/* Removed non-standard end-of-declarations marker */
+/* 'C%&END_DECLARATIONS' from comments. */
+
+/* - SPICELIB Version 1.0.2, 22-AUG-2006 (EDW) */
+
+/* Replaced references to LDPOOL with references */
+/* to FURNSH. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 30-AUG-1991 (JML) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* evaluate ck type_2 pointing data record */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKE02", (ftnlen)5);
+ }
+
+/* Copy the returned encoded SCLK time into CLKOUT. */
+
+ *clkout = record[1];
+/* The quaternion stored in RECORD represents the C - matrix */
+/* corresponding to the start time of the interval. The angular */
+/* velocity vector is constant throughout the interval and gives */
+/* the axis and rate by which the spacecraft is rotating. */
+
+/* Copy the quaternion and the angular velocity from RECORD. */
+
+/* RECORD ( 4 ) = q0 */
+/* RECORD ( 5 ) = q1 */
+/* RECORD ( 6 ) = q2 */
+/* RECORD ( 7 ) = q3 */
+
+/* RECORD ( 8 ) = av1 */
+/* RECORD ( 9 ) = av2 */
+/* RECORD ( 10 ) = av3 */
+
+ vequg_(&record[3], &c__4, quat);
+ vequ_(&record[7], avtemp);
+
+/* Calculate the angle of the rotation. */
+
+/* RECORD ( 1 ) = The start time of the interval. */
+/* RECORD ( 2 ) = The time that pointing was returned for. */
+/* RECORD ( 3 ) = The number of seconds per SCLK tick. */
+
+ time = (record[1] - record[0]) * record[2];
+ angle = time * vnorm_(avtemp);
+
+/* Construct a matrix which rotates vectors by ANGLE radians about */
+/* AVTEMP. */
+
+ axisar_(avtemp, &angle, rot);
+
+/* Convert the quaternion to a C - matrix. */
+
+ q2m_(quat, cbase);
+
+/* Rotate each of the axis vectors of the spacecraft instrument frame */
+/* by ANGLE radians about AVTEMP. (AVTEMP is given in the same */
+/* inertial frame as the C - matrix.) The resulting matrix is the */
+/* transpose of the requested C - matrix. */
+
+/* [ ] [ ] T [ ] T */
+/* [ ROT ] * [ CBASE ] = [ CMAT ] */
+/* [ ] [ ] [ ] */
+
+/* OR */
+
+/* [ ] [ ] T [ ] */
+/* [ CBASE ] * [ ROT ] = [ CMAT ] */
+/* [ ] [ ] [ ] */
+
+ mxmt_(cbase, rot, cmat);
+
+/* Return the angular velocity only if it is requested. */
+
+ if (*needav) {
+ vequ_(avtemp, av);
+ }
+ chkout_("CKE02", (ftnlen)5);
+ return 0;
+} /* cke02_ */
+
diff --git a/ext/spice/src/cspice/cke03.c b/ext/spice/src/cspice/cke03.c
new file mode 100644
index 0000000000..3fd51057f8
--- /dev/null
+++ b/ext/spice/src/cspice/cke03.c
@@ -0,0 +1,545 @@
+/* cke03.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__4 = 4;
+static integer c__3 = 3;
+
+/* $Procedure CKE03 ( C-kernel, evaluate pointing record, data type 3 ) */
+/* Subroutine */ int cke03_(logical *needav, doublereal *record, doublereal *
+ cmat, doublereal *av, doublereal *clkout)
+{
+ /* System generated locals */
+ doublereal d__1;
+
+ /* Local variables */
+ doublereal frac, axis[3];
+ extern /* Subroutine */ int vequ_(doublereal *, doublereal *), mtxm_(
+ doublereal *, doublereal *, doublereal *), mxmt_(doublereal *,
+ doublereal *, doublereal *);
+ doublereal cmat1[9] /* was [3][3] */, cmat2[9] /* was [3][3] */, t,
+ angle, delta[9] /* was [3][3] */;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), moved_(doublereal *,
+ integer *, doublereal *), vlcom_(doublereal *, doublereal *,
+ doublereal *, doublereal *, doublereal *);
+ doublereal q1[4], q2[4], t1, t2;
+ extern logical failed_(void);
+ extern /* Subroutine */ int raxisa_(doublereal *, doublereal *,
+ doublereal *), axisar_(doublereal *, doublereal *, doublereal *),
+ chkout_(char *, ftnlen);
+ doublereal av1[3], av2[3];
+ extern logical return_(void);
+ extern /* Subroutine */ int q2m_(doublereal *, doublereal *);
+ doublereal rot[9] /* was [3][3] */;
+
+/* $ Abstract */
+
+/* Evaluate a pointing record returned by CKR03 from a CK type 3 */
+/* segment. Return the C-matrix and angular velocity vector associated */
+/* with the time CLKOUT. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* ROTATION */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* NEEDAV I True if angular velocity is requested. */
+/* RECORD I Data type 3 pointing record. */
+/* CMAT O C-matrix. */
+/* AV O Angular velocity vector. */
+/* CLKOUT O SCLK associated with C-matrix. */
+
+/* $ Detailed_Input */
+
+/* NEEDAV is true if angular velocity is requested. */
+
+/* RECORD is a set of double precision numbers returned by CKR03 */
+/* that contain sufficient information from a type 3 CK */
+/* segment to evaluate the C-matrix and the angular */
+/* velocity vector at a particular time. Depending on */
+/* the contents of RECORD, this routine will either */
+/* interpolate between two pointing instances that */
+/* bracket a request time, or it will simply return the */
+/* pointing given by a single pointing instance. */
+
+/* When pointing at the request time can be determined */
+/* by linearly interpolating between the two pointing */
+/* instances that bracket that time, the bracketing */
+/* pointing instances are returned in RECORD as follows: */
+
+/* RECORD( 1 ) = Left bracketing SCLK time. */
+
+/* RECORD( 2 ) = lq0 \ */
+/* RECORD( 3 ) = lq1 \ Left bracketing */
+/* RECORD( 4 ) = lq2 / quaternion. */
+/* RECORD( 5 ) = lq3 / */
+
+/* RECORD( 6 ) = lav1 \ Left bracketing */
+/* RECORD( 7 ) = lav2 | angular velocity */
+/* RECORD( 8 ) = lav3 / ( optional ) */
+
+/* RECORD( 9 ) = Right bracketing SCLK time. */
+
+/* RECORD( 10 ) = rq0 \ */
+/* RECORD( 11 ) = rq1 \ Right bracketing */
+/* RECORD( 12 ) = rq2 / quaternion. */
+/* RECORD( 13 ) = rq3 / */
+
+/* RECORD( 14 ) = rav1 \ Right bracketing */
+/* RECORD( 15 ) = rav2 | angular velocity */
+/* RECORD( 16 ) = rav3 / ( optional ) */
+
+/* RECORD( 17 ) = pointing request time */
+
+/* The quantities lq0 - lq3 and rq0 - rq3 are the */
+/* components of the quaternions that represent the */
+/* C-matrices associated with the times that bracket */
+/* the requested time. */
+
+/* The quantities lav1, lav2, lav3 and rav1, rav2, rav3 */
+/* are the components of the angular velocity vectors at */
+/* the respective bracketing times. The components of the */
+/* angular velocity vectors are specified relative to the */
+/* inertial reference frame of the segment. */
+
+/* When the routine is to simply return the pointing */
+/* given by a particular pointing instance, then the */
+/* values of that pointing instance are returned in both */
+/* parts of RECORD ( i.e. RECORD(1-9) and RECORD(10-16) ). */
+
+/* $ Detailed_Output */
+
+/* CMAT is a rotation matrix that transforms the components */
+/* of a vector expressed in the inertial frame given in */
+/* the segment to components expressed in the instrument */
+/* fixed frame at the returned time. */
+
+/* Thus, if a vector v has components x, y, z in the */
+/* inertial frame, then v has components x', y', z' in the */
+/* instrument fixed frame where: */
+
+/* [ x' ] [ ] [ x ] */
+/* | y' | = | CMAT | | y | */
+/* [ z' ] [ ] [ z ] */
+
+/* If the x', y', z' components are known, use the */
+/* transpose of the C-matrix to determine x, y, z as */
+/* follows. */
+
+/* [ x ] [ ]T [ x' ] */
+/* | y | = | CMAT | | y' | */
+/* [ z ] [ ] [ z' ] */
+/* (Transpose of CMAT) */
+
+/* AV is the angular velocity vector of the instrument fixed */
+/* frame defined by CMAT. The angular velocity is */
+/* returned only if NEEDAV is true. */
+
+/* The direction of the angular velocity vector gives */
+/* the right-handed axis about which the instrument fixed */
+/* reference frame is rotating. The magnitude of AV is */
+/* the magnitude of the instantaneous velocity of the */
+/* rotation, in radians per second. */
+
+/* The angular velocity vector is returned in component */
+/* form */
+
+/* AV = [ AV1 , AV2 , AV3 ] */
+
+/* which is in terms of the inertial coordinate frame */
+/* specified in the segment descriptor. */
+
+/* CLKOUT is the encoded SCLK associated with the returned */
+/* C-matrix and angular velocity vector. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) No explicit checking is done to determine whether RECORD is */
+/* valid. However, routines in the call tree of this routine */
+/* may signal errors if inputs are invalid or otherwise */
+/* in appropriate. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* If the array RECORD contains pointing instances that bracket the */
+/* request time then CKE03 will linearly interpolate between those */
+/* two values to obtain pointing at the request time. If the */
+/* pointing instances in RECORD are for the same time, then this */
+/* routine will simply unpack the record and convert the quaternion */
+/* to a C-matrix. */
+
+/* The linear interpolation performed by this routine is defined */
+/* as follows: */
+
+/* 1) Let t be the time for which pointing is requested and */
+/* let CMAT1 and CMAT2 be C-matrices associated with times */
+/* t1 and t2 where: */
+
+/* t1 < t2, and t1 <= t, and t <= t2. */
+
+/* 2) Assume that the spacecraft frame rotates about a fixed */
+/* axis at a constant angular rate from time t1 to time t2. */
+/* The angle and rotation axis can be obtained from the */
+/* rotation matrix ROT12 where: */
+
+/* T T */
+/* CMAT2 = ROT12 * CMAT1 */
+
+/* or */
+/* T */
+/* ROT12 = CMAT2 * CMAT1 */
+
+
+/* ROT12 ==> ( ANGLE, AXIS ) */
+
+
+/* 3) To obtain pointing at time t, rotate the spacecraft frame */
+/* about the vector AXIS from its orientation at time t1 by the */
+/* angle THETA where: */
+
+/* ( t - t1 ) */
+/* THETA = ANGLE * ----------- */
+/* ( t2 - t1 ) */
+
+/* 4) Thus if ROT1t is the matrix that rotates vectors by the */
+/* angle THETA about the vector AXIS, then the output C-matrix */
+/* is given by: */
+
+/* T T */
+/* CMAT = ROT1t * CMAT1 */
+
+/* T */
+/* CMAT = CMAT1 * ROT1t */
+
+
+/* 5) The angular velocity is treated independently of the */
+/* C-matrix. If it is requested, then the AV at time t is */
+/* the weighted average of the angular velocity vectors at */
+/* the times t1 and t2: */
+
+/* ( t - t1 ) */
+/* W = ----------- */
+/* ( t2 - t1 ) */
+
+
+/* AV = ( 1 - W ) * AV1 + W * AV2 */
+
+/* $ Examples */
+
+/* The CKRnn routines are usually used in tandem with the CKEnn */
+/* routines, which evaluate the record returned by CKRnn to give */
+/* the pointing information and output time. */
+
+/* The following code fragment searches through all of the segments */
+/* in a file applicable to the Mars Observer spacecraft bus that */
+/* are of data type 3, for a particular spacecraft clock time. */
+/* It then evaluates the pointing for that epoch and prints the */
+/* result. */
+
+/* CHARACTER*(20) SCLKCH */
+/* CHARACTER*(20) SCTIME */
+/* CHARACTER*(40) IDENT */
+
+/* INTEGER I */
+/* INTEGER SC */
+/* INTEGER INST */
+/* INTEGER HANDLE */
+/* INTEGER DTYPE */
+/* INTEGER ICD ( 6 ) */
+
+/* DOUBLE PRECISION SCLKDP */
+/* DOUBLE PRECISION TOL */
+/* DOUBLE PRECISION CLKOUT */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION RECORD ( 17 ) */
+/* DOUBLE PRECISION CMAT ( 3, 3 ) */
+/* DOUBLE PRECISION AV ( 3 ) */
+
+/* LOGICAL NEEDAV */
+/* LOGICAL FND */
+/* LOGICAL SFND */
+
+
+/* SC = -94 */
+/* INST = -94000 */
+/* DTYPE = 3 */
+/* NEEDAV = .FALSE. */
+
+/* C */
+/* C Load the MO SCLK kernel and the C-kernel. */
+/* C */
+/* CALL FURNSH ( 'MO_SCLK.TSC' ) */
+/* CALL DAFOPR ( 'MO_CK.BC', HANDLE ) */
+/* C */
+/* C Get the spacecraft clock time. Then encode it for use */
+/* C in the C-kernel. */
+/* C */
+/* WRITE (*,*) 'Enter spacecraft clock time string:' */
+/* READ (*,FMT='(A)') SCLKCH */
+
+/* CALL SCENCD ( SC, SCLKCH, SCLKDP ) */
+/* C */
+/* C Use a tolerance of 2 seconds ( half of the nominal */
+/* C separation between MO pointing instances ). */
+/* C */
+/* CALL SCTIKS ( SC, '0000000002:000', TOL ) */
+
+/* C */
+/* C Search from the beginning of the CK file through all */
+/* C of the segments. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( SFND ) */
+
+/* FND = .FALSE. */
+
+/* DO WHILE ( ( SFND ) .AND. ( .NOT. FND ) ) */
+
+/* C */
+/* C Get the segment identifier and descriptor. */
+/* C */
+
+/* CALL DAFGN ( IDENT ) */
+/* CALL DAFGS ( DESCR ) */
+/* C */
+/* C Unpack the segment descriptor into its integer and */
+/* C double precision components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* C */
+/* C Determine if this segment should be processed. */
+/* C */
+/* IF ( ( INST .EQ. ICD( 1 ) ) .AND. */
+/* . ( SCLKDP + TOL .GE. DCD( 1 ) ) .AND. */
+/* . ( SCLKDP - TOL .LE. DCD( 2 ) ) .AND. */
+/* . ( DTYPE .EQ. ICD( 3 ) ) ) THEN */
+
+
+/* CALL CKR03 ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
+/* . RECORD, FND ) */
+
+/* IF ( FND ) THEN */
+
+/* CALL CKE03 (NEEDAV,RECORD,CMAT,AV,CLKOUT) */
+
+/* CALL SCDECD ( SC, CLKOUT, SCTIME ) */
+
+/* WRITE (*,*) */
+/* WRITE (*,*) 'Segment identifier: ', IDENT */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'Pointing returned for time: ', */
+/* . SCTIME */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'C-matrix:' */
+/* WRITE (*,*) */
+/* WRITE (*,*) ( CMAT(1,I), I = 1, 3 ) */
+/* WRITE (*,*) ( CMAT(2,I), I = 1, 3 ) */
+/* WRITE (*,*) ( CMAT(3,I), I = 1, 3 ) */
+/* WRITE (*,*) */
+
+/* END IF */
+
+/* END IF */
+
+/* CALL DAFFNA ( SFND ) */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* 1) No explicit checking is done on the input RECORD. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.M. Lynch (JPL) */
+/* F.S. Turner (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1, 22-AUG-2006 (EDW) */
+
+/* Replaced references to LDPOOL with references */
+/* to FURNSH. */
+
+/* - SPICELIB Version 2.0.0, 13-JUN-2002 (FST) */
+
+/* This routine now participates in error handling properly. */
+
+/* - SPICELIB Version 1.0.0, 25-NOV-1992 (JML) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* evaluate ck type_3 pointing data record */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 13-JUN-2002 (FST) */
+
+/* Calls to CHKIN and CHKOUT in the standard SPICE error */
+/* handling style were added. Versions prior to 2.0.0 */
+/* were error free, however changes to RAXISA from error */
+/* free to error signaling forced this update. */
+
+/* Additionally, FAILED is now checked after the call to */
+/* RAXISA. This prevents garbage from being placed into */
+/* the output arguments. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKE03", (ftnlen)5);
+ }
+
+/* Unpack the record, for easier reading. */
+
+ t = record[16];
+ t1 = record[0];
+ t2 = record[8];
+ moved_(&record[1], &c__4, q1);
+ moved_(&record[5], &c__3, av1);
+ moved_(&record[9], &c__4, q2);
+ moved_(&record[13], &c__3, av2);
+
+/* If T1 and T2 are the same then no interpolation or extrapolation */
+/* is performed. Simply convert the quaternion to a C-matrix and */
+/* return. */
+
+ if (t1 == t2) {
+ q2m_(q1, cmat);
+ *clkout = t1;
+ if (*needav) {
+ vequ_(av1, av);
+ }
+ chkout_("CKE03", (ftnlen)5);
+ return 0;
+ }
+
+/* Interpolate between the two pointing instances to obtain pointing */
+/* at the request time. */
+
+
+/* Calculate what fraction of the interval the request time */
+/* represents. */
+
+ frac = (t - t1) / (t2 - t1);
+
+/* Convert the left and right quaternions to C-matrices. */
+
+ q2m_(q1, cmat1);
+ q2m_(q2, cmat2);
+
+/* Find the matrix that rotates the spacecraft instrument frame from */
+/* the orientation specified by CMAT1 to that specified by CMAT2. */
+/* Then find the axis and angle of that rotation matrix. */
+
+/* T T */
+/* CMAT2 = ROT * CMAT1 */
+
+/* T */
+/* ROT = CMAT2 * CMAT1 */
+
+ mtxm_(cmat2, cmat1, rot);
+ raxisa_(rot, axis, &angle);
+ if (failed_()) {
+ chkout_("CKE03", (ftnlen)5);
+ return 0;
+ }
+
+/* Calculate the matrix that rotates vectors about the vector AXIS */
+/* by the angle ANGLE * FRAC. */
+
+ d__1 = angle * frac;
+ axisar_(axis, &d__1, delta);
+
+/* The interpolated pointing at the request time is given by CMAT */
+/* where: */
+
+/* T T */
+/* CMAT = DELTA * CMAT1 */
+
+/* and */
+/* T */
+/* CMAT = CMAT1 * DELTA */
+
+ mxmt_(cmat1, delta, cmat);
+
+/* Set CLKOUT equal to the time that pointing is being returned. */
+
+ *clkout = t;
+
+/* If angular velocity is requested then take a weighted average */
+/* of the angular velocities at the left and right endpoints. */
+
+ if (*needav) {
+ d__1 = 1. - frac;
+ vlcom_(&d__1, av1, &frac, av2, av);
+ }
+ chkout_("CKE03", (ftnlen)5);
+ return 0;
+} /* cke03_ */
+
diff --git a/ext/spice/src/cspice/cke04.c b/ext/spice/src/cspice/cke04.c
new file mode 100644
index 0000000000..158f849661
--- /dev/null
+++ b/ext/spice/src/cspice/cke04.c
@@ -0,0 +1,566 @@
+/* cke04.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__4 = 4;
+
+/* $Procedure CKE04 ( C-kernel, evaluate pointing record, type 4 ) */
+/* Subroutine */ int cke04_(logical *needav, doublereal *record, doublereal *
+ cmat, doublereal *av, doublereal *clkout)
+{
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer ideg[7];
+ doublereal qout[4];
+ integer i__;
+ doublereal q[4];
+ extern /* Subroutine */ int vhatg_(doublereal *, integer *, doublereal *);
+ integer basadd;
+ extern /* Subroutine */ int chbval_(doublereal *, integer *, doublereal *,
+ doublereal *, doublereal *), q2m_(doublereal *, doublereal *);
+
+/* $ Abstract */
+
+/* Evaluate a pointing record returned by CKR04 from a CK type 4 */
+/* segment. Return the C-matrix and angular velocity vector */
+/* associated with the time CLKOUT. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* Declarations of the CK data type specific and general CK low */
+/* level routine parameters. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* 1) If new CK types are added, the size of the record passed */
+/* between CKRxx and CKExx must be registered as separate */
+/* parameter. If this size will be greater than current value */
+/* of the CKMRSZ parameter (which specifies the maximum record */
+/* size for the record buffer used inside CKPFS) then it should */
+/* be assigned to CKMRSZ as a new value. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Literature_References */
+
+/* CK Required Reading. */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 19-AUG-2002 (NJB) */
+
+/* Updated to support CK type 5. */
+
+/* - SPICELIB Version 1.0.0, 05-APR-1999 (BVS) */
+
+/* -& */
+
+/* Number of quaternion components and number of quaternion and */
+/* angular rate components together. */
+
+
+/* CK Type 1 parameters: */
+
+/* CK1DTP CK data type 1 ID; */
+
+/* CK1RSZ maximum size of a record passed between CKR01 */
+/* and CKE01. */
+
+
+/* CK Type 2 parameters: */
+
+/* CK2DTP CK data type 2 ID; */
+
+/* CK2RSZ maximum size of a record passed between CKR02 */
+/* and CKE02. */
+
+
+/* CK Type 3 parameters: */
+
+/* CK3DTP CK data type 3 ID; */
+
+/* CK3RSZ maximum size of a record passed between CKR03 */
+/* and CKE03. */
+
+
+/* CK Type 4 parameters: */
+
+/* CK4DTP CK data type 4 ID; */
+
+/* CK4PCD parameter defining integer to DP packing schema that */
+/* is applied when seven number integer array containing */
+/* polynomial degrees for quaternion and angular rate */
+/* components packed into a single DP number stored in */
+/* actual CK records in a file; the value of must not be */
+/* changed or compatibility with existing type 4 CK files */
+/* will be lost. */
+
+/* CK4MXD maximum Chebychev polynomial degree allowed in type 4 */
+/* records; the value of this parameter must never exceed */
+/* value of the CK4PCD; */
+
+/* CK4SFT number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 4 */
+/* CK record that passed between routines CKR04 and CKE04; */
+
+/* CK4RSZ maximum size of type 4 CK record passed between CKR04 */
+/* and CKE04; CK4RSZ is computed as follows: */
+
+/* CK4RSZ = ( CK4MXD + 1 ) * QAVSIZ + CK4SFT */
+
+
+/* CK Type 5 parameters: */
+
+
+/* CK5DTP CK data type 5 ID; */
+
+/* CK5MXD maximum polynomial degree allowed in type 5 */
+/* records. */
+
+/* CK5MET number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 5 */
+/* CK record that passed between routines CKR05 and CKE05; */
+
+/* CK5MXP maximum packet size for any subtype. Subtype 2 */
+/* has the greatest packet size, since these packets */
+/* contain a quaternion, its derivative, an angular */
+/* velocity vector, and its derivative. See ck05.inc */
+/* for a description of the subtypes. */
+
+/* CK5RSZ maximum size of type 5 CK record passed between CKR05 */
+/* and CKE05; CK5RSZ is computed as follows: */
+
+/* CK5RSZ = ( CK5MXD + 1 ) * CK5MXP + CK5MET */
+
+
+
+/* Maximum record size that can be handled by CKPFS. This value */
+/* must be set to the maximum of all CKxRSZ parameters (currently */
+/* CK4RSZ.) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* NEEDAV I True if angular velocity is requested. */
+/* RECORD I Data type 4 pointing record. */
+/* CMAT O C-matrix. */
+/* AV O Angular velocity vector. */
+/* CLKOUT O SCLK associated with C-matrix. */
+
+/* $ Detailed_Input */
+
+/* NEEDAV is true if angular velocity is requested. */
+
+/* RECORD is a set of double precision numbers returned by */
+/* CKR04. RECORD must have the following structure: */
+
+/* --------------------------------------------------- */
+/* | Encoded onboard time which is the closest | */
+/* | to SCLKDP and belongs to one of approximation | */
+/* | intervals | */
+/* --------------------------------------------------- */
+/* | encoded SCLK time of the midpoint of | */
+/* | interpolation interval | */
+/* --------------------------------------------------- */
+/* | radii of interpolation interval | */
+/* | expressed as double precision SCLK ticks | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for q0 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for q1 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for q2 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for q3 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for AV1 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for AV2 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for AV3 | */
+/* --------------------------------------------------- */
+/* | q0 Cheby coefficients | */
+/* --------------------------------------------------- */
+/* | q1 Cheby coefficients | */
+/* --------------------------------------------------- */
+/* | q2 Cheby coefficients | */
+/* --------------------------------------------------- */
+/* | q3 Cheby coefficients | */
+/* --------------------------------------------------- */
+/* | AV1 Cheby coefficients (optional) | */
+/* --------------------------------------------------- */
+/* | AV2 Cheby coefficients (optional) | */
+/* --------------------------------------------------- */
+/* | AV3 Cheby coefficients (optional) | */
+/* --------------------------------------------------- */
+
+/* $ Detailed_Output */
+
+/* CMAT is a rotation matrix that transforms the components */
+/* of a vector expressed in the inertial frame given in */
+/* the segment to components expressed in the instrument */
+/* fixed frame at the returned time. */
+
+/* Thus, if a vector v has components x, y, z in the */
+/* inertial frame, then v has components x', y', z' in */
+/* the instrument fixed frame where: */
+
+/* [ x' ] [ ] [ x ] */
+/* | y' | = | CMAT | | y | */
+/* [ z' ] [ ] [ z ] */
+
+/* If the x', y', z' components are known, use the */
+/* transpose of the C-matrix to determine x, y, z as */
+/* follows. */
+
+/* [ x ] [ ]T [ x' ] */
+/* | y | = | CMAT | | y' | */
+/* [ z ] [ ] [ z' ] */
+/* (Transpose of CMAT) */
+
+/* AV is the angular velocity vector of the instrument fixed */
+/* frame defined by CMAT. The angular velocity is */
+/* returned only if NEEDAV is true. */
+
+/* The direction of the angular velocity vector gives */
+/* the right-handed axis about which the instrument fixed */
+/* reference frame is rotating. The magnitude of AV is */
+/* the magnitude of the instantaneous velocity of the */
+/* rotation, in radians per second. */
+
+/* The angular velocity vector is returned in component */
+/* form */
+
+/* AV = [ AV1 , AV2 , AV3 ] */
+
+/* which is in terms of the inertial coordinate frame */
+/* specified in the segment descriptor. */
+
+/* CLKOUT is the encoded SCLK associated with the returned */
+/* C-matrix and angular velocity vector. */
+
+/* $ Parameters */
+
+/* See 'ckparam.inc'. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* No checking is done to determine whether RECORD is valid. */
+
+/* $ Particulars */
+
+/* For a detailed description of the structure of a type 4 pointing */
+/* segment, see the CK Required Reading file. */
+
+/* The work done by CKE04 is to calculate quaternion and angular */
+/* velocity components using Chebyshev polynomial approximation */
+/* parameters. The second step of evaluation is to convert the */
+/* pointing portion of the record from quaternion form to C-matrix */
+/* form. */
+
+/* The angular velocity vector will only be returned if it has been */
+/* requested. In other words, if NEEDAV is true, the routine will */
+/* expect the angular velocity component of the record to be */
+/* present. */
+
+/* $ Examples */
+
+/* The CKRnn routines are usually used in tandem with the CKEnn */
+/* routines, which evaluate the record returned by CKRnn to give */
+/* the pointing information and output time. */
+
+/* The following code fragment searches through all of the segments */
+/* in a file applicable to the Mars Global Surveyor spacecraft bus */
+/* that are of data type 4, for a particular spacecraft clock time. */
+/* It then evaluates the pointing for that epoch and prints the */
+/* result. */
+
+/* C */
+/* C CK parameters include file. */
+/* C */
+/* INCLUDE 'ckparam.inc' */
+/* C */
+/* C Declarations */
+/* C */
+/* CHARACTER*(20) SCLKCH */
+/* CHARACTER*(20) SCTIME */
+/* CHARACTER*(40) IDENT */
+
+/* DOUBLE PRECISION AV ( 3 ) */
+/* DOUBLE PRECISION CLKOUT */
+/* DOUBLE PRECISION CMAT ( 3, 3 ) */
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION RECORD ( CK4RSZ ) */
+/* DOUBLE PRECISION SCLKDP */
+/* DOUBLE PRECISION TOL */
+
+/* INTEGER HANDLE */
+/* INTEGER I */
+/* INTEGER ICD ( 6 ) */
+/* INTEGER INST */
+/* INTEGER SC */
+
+/* LOGICAL FND */
+/* LOGICAL NEEDAV */
+/* LOGICAL SFND */
+/* C */
+/* C Initial values. */
+/* C */
+/* SC = -94 */
+/* INST = -94000 */
+/* NEEDAV = .FALSE. */
+/* C */
+/* C Load the MGS SCLK kernel and the C-kernel. */
+/* C */
+/* CALL FURNSH( 'MGS_SCLK.TSC' ) */
+/* CALL DAFOPR( 'MGS_CK4.BC', HANDLE ) */
+/* C */
+/* C Get the spacecraft clock time. Then encode it for use */
+/* C in the C-kernel. */
+/* C */
+/* CALL PROMPT( 'Enter SCLK string: ', SCLKCH ) */
+/* CALL SCENCD( SC, SCLKCH, SCLKDP ) */
+/* C */
+/* C Use a tolerance of 2 seconds (half of the nominal */
+/* C separation between MGS pointing instances ). */
+/* C */
+/* CALL SCTIKS ( SC, '0000000002:000', TOL ) */
+/* C */
+/* C Search from the beginning of the CK file through all */
+/* C of the segments. */
+/* C */
+/* CALL DAFBFS( HANDLE ) */
+/* CALL DAFFNA( SFND ) */
+
+/* FND = .FALSE. */
+
+/* DO WHILE ( ( SFND ) .AND. ( .NOT. FND ) ) */
+/* C */
+/* C Get the segment identifier and descriptor. */
+/* C */
+/* CALL DAFGN( IDENT ) */
+/* CALL DAFGS( DESCR ) */
+/* C */
+/* C Unpack the segment descriptor into its integer and */
+/* C double precision components. */
+/* C */
+/* CALL DAFUS( DESCR, 2, 6, DCD, ICD ) */
+/* C */
+/* C Determine if this segment should be processed. */
+/* C */
+/* IF ( ( INST .EQ. ICD( 1 ) ) .AND. */
+/* . ( SCLKDP + TOL .GE. DCD( 1 ) ) .AND. */
+/* . ( SCLKDP - TOL .LE. DCD( 2 ) ) .AND. */
+/* . ( CK4DTP .EQ. ICD( 3 ) ) ) THEN */
+/* C */
+/* C Find CK 4 record covering requested time. */
+/* C */
+/* CALL CKR04( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
+/* . RECORD, FND ) */
+
+/* IF ( FND ) THEN */
+/* C */
+/* C Compute pointing using found CK 4 record. */
+/* C */
+/* CALL CKE04( NEEDAV, RECORD, CMAT, AV, CLKOUT) */
+
+/* CALL SCDECD( SC, CLKOUT, SCTIME ) */
+
+/* WRITE (*,*) */
+/* WRITE (*,*) 'Segment identifier: ', IDENT */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'Pointing returned for time: ', */
+/* . SCTIME */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'C-matrix:' */
+/* WRITE (*,*) */
+/* WRITE (*,*) ( CMAT(1,I), I = 1, 3 ) */
+/* WRITE (*,*) ( CMAT(2,I), I = 1, 3 ) */
+/* WRITE (*,*) ( CMAT(3,I), I = 1, 3 ) */
+/* WRITE (*,*) */
+
+/* END IF */
+
+/* END IF */
+
+/* CALL DAFFNA ( SFND ) */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* 1) No checking is done on the input RECORD. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* Y.K. Zaiko (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 22-AUG-2006 (EDW) */
+
+/* Replaced references to LDPOOL with references */
+/* to FURNSH. */
+
+/* - SPICELIB Version 1.0.0, 05-MAY-1999 (YKZ) (BVS) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* evaluate CK type_4 pointing data record */
+
+/* -& */
+
+/* Local variables */
+
+
+/* Initial values. */
+
+ av[0] = 0.;
+ av[1] = 0.;
+ av[2] = 0.;
+
+/* Read numbers of polynomial coefficients from input record to */
+/* local integer array. */
+
+ for (i__ = 1; i__ <= 7; ++i__) {
+ ideg[(i__1 = i__ - 1) < 7 && 0 <= i__1 ? i__1 : s_rnge("ideg", i__1,
+ "cke04_", (ftnlen)365)] = (integer) record[i__ + 2];
+ }
+
+/* Evaluate polynomial function for quaternion components at time */
+/* RECORD( 1 ). */
+
+ basadd = 11;
+ for (i__ = 1; i__ <= 4; ++i__) {
+ i__3 = ideg[(i__1 = i__ - 1) < 7 && 0 <= i__1 ? i__1 : s_rnge("ideg",
+ i__1, "cke04_", (ftnlen)376)] - 1;
+ chbval_(&record[basadd - 1], &i__3, &record[1], record, &q[(i__2 =
+ i__ - 1) < 4 && 0 <= i__2 ? i__2 : s_rnge("q", i__2, "cke04_",
+ (ftnlen)376)]);
+ basadd += ideg[(i__1 = i__ - 1) < 7 && 0 <= i__1 ? i__1 : s_rnge(
+ "ideg", i__1, "cke04_", (ftnlen)378)];
+ }
+
+/* Normalize quaternion. */
+
+ vhatg_(q, &c__4, qout);
+
+/* Convert the quaternion to a C-matrix. */
+
+ q2m_(qout, cmat);
+ *clkout = record[0];
+
+/* Check if angular velocities have to be evaluated, then */
+/* evaluate them. */
+
+ if (*needav) {
+ for (i__ = 5; i__ <= 7; ++i__) {
+ i__3 = ideg[(i__1 = i__ - 1) < 7 && 0 <= i__1 ? i__1 : s_rnge(
+ "ideg", i__1, "cke04_", (ftnlen)402)] - 1;
+ chbval_(&record[basadd - 1], &i__3, &record[1], record, &av[(i__2
+ = i__ - 5) < 3 && 0 <= i__2 ? i__2 : s_rnge("av", i__2,
+ "cke04_", (ftnlen)402)]);
+ basadd += ideg[(i__1 = i__ - 1) < 7 && 0 <= i__1 ? i__1 : s_rnge(
+ "ideg", i__1, "cke04_", (ftnlen)404)];
+ }
+ }
+
+/* All done. */
+
+ return 0;
+} /* cke04_ */
+
diff --git a/ext/spice/src/cspice/cke05.c b/ext/spice/src/cspice/cke05.c
new file mode 100644
index 0000000000..a344f20314
--- /dev/null
+++ b/ext/spice/src/cspice/cke05.c
@@ -0,0 +1,1067 @@
+/* cke05.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__4 = 4;
+
+/* $Procedure CKE05 ( C-Kernel, evaluate, type 5 ) */
+/* Subroutine */ int cke05_(logical *needav, doublereal *record, doublereal *
+ cmat, doublereal *av, doublereal *clkout)
+{
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+ doublereal d__1;
+
+ /* Builtin functions */
+ integer i_dnnt(doublereal *), s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ doublereal mags, qneg[4], rate;
+ integer from;
+ extern /* Subroutine */ int vequ_(doublereal *, doublereal *);
+ doublereal work[912] /* was [456][2] */;
+ integer i__, j, n;
+ doublereal q[4];
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ doublereal vbuff[6];
+ extern /* Subroutine */ int vhatg_(doublereal *, integer *, doublereal *),
+ moved_(doublereal *, integer *, doublereal *), errdp_(char *,
+ doublereal *, ftnlen), vsclg_(doublereal *, doublereal *, integer
+ *, doublereal *);
+ doublereal state[8];
+ extern doublereal vdotg_(doublereal *, doublereal *, integer *);
+ extern /* Subroutine */ int vsubg_(doublereal *, doublereal *, integer *,
+ doublereal *), qdq2av_(doublereal *, doublereal *, doublereal *);
+ doublereal dq[4], ds[4];
+ integer ub, to;
+ doublereal locrec[228], sclddq[4];
+ extern /* Subroutine */ int lgrind_(integer *, doublereal *, doublereal *,
+ doublereal *, doublereal *, doublereal *, doublereal *);
+ doublereal sclkdp, radtrm[4];
+ integer packsz;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ extern doublereal lgrint_(integer *, doublereal *, doublereal *,
+ doublereal *, doublereal *), vdistg_(doublereal *, doublereal *,
+ integer *);
+ integer prvder;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen), chkout_(char *, ftnlen), vminug_(doublereal *,
+ integer *, doublereal *);
+ extern doublereal vnormg_(doublereal *, integer *);
+ extern /* Subroutine */ int xpsgip_(integer *, integer *, doublereal *),
+ vsclip_(doublereal *, doublereal *), hrmint_(integer *,
+ doublereal *, doublereal *, doublereal *, doublereal *,
+ doublereal *, doublereal *);
+ extern logical return_(void);
+ integer newptr;
+ extern /* Subroutine */ int q2m_(doublereal *, doublereal *);
+ integer xstart, subtyp, ystart, prvptr;
+
+/* $ Abstract */
+
+/* Evaluate a single data record from a type 5 CK segment. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* Declare parameters specific to CK type 05. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 20-AUG-2002 (NJB) */
+
+/* -& */
+
+/* CK type 5 subtype codes: */
+
+
+/* Subtype 0: Hermite interpolation, 8-element packets. Quaternion */
+/* and quaternion derivatives only, no angular velocity */
+/* vector provided. Quaternion elements are listed */
+/* first, followed by derivatives. Angular velocity is */
+/* derived from the quaternions and quaternion */
+/* derivatives. */
+
+
+/* Subtype 1: Lagrange interpolation, 4-element packets. Quaternion */
+/* only. Angular velocity is derived by differentiating */
+/* the interpolating polynomials. */
+
+
+/* Subtype 2: Hermite interpolation, 14-element packets. */
+/* Quaternion and angular angular velocity vector, as */
+/* well as derivatives of each, are provided. The */
+/* quaternion comes first, then quaternion derivatives, */
+/* then angular velocity and its derivatives. */
+
+
+/* Subtype 3: Lagrange interpolation, 7-element packets. Quaternion */
+/* and angular velocity vector provided. The quaternion */
+/* comes first. */
+
+
+/* Packet sizes associated with the various subtypes: */
+
+
+/* End of file ck05.inc. */
+
+/* $ Abstract */
+
+/* Declarations of the CK data type specific and general CK low */
+/* level routine parameters. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* 1) If new CK types are added, the size of the record passed */
+/* between CKRxx and CKExx must be registered as separate */
+/* parameter. If this size will be greater than current value */
+/* of the CKMRSZ parameter (which specifies the maximum record */
+/* size for the record buffer used inside CKPFS) then it should */
+/* be assigned to CKMRSZ as a new value. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Literature_References */
+
+/* CK Required Reading. */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 19-AUG-2002 (NJB) */
+
+/* Updated to support CK type 5. */
+
+/* - SPICELIB Version 1.0.0, 05-APR-1999 (BVS) */
+
+/* -& */
+
+/* Number of quaternion components and number of quaternion and */
+/* angular rate components together. */
+
+
+/* CK Type 1 parameters: */
+
+/* CK1DTP CK data type 1 ID; */
+
+/* CK1RSZ maximum size of a record passed between CKR01 */
+/* and CKE01. */
+
+
+/* CK Type 2 parameters: */
+
+/* CK2DTP CK data type 2 ID; */
+
+/* CK2RSZ maximum size of a record passed between CKR02 */
+/* and CKE02. */
+
+
+/* CK Type 3 parameters: */
+
+/* CK3DTP CK data type 3 ID; */
+
+/* CK3RSZ maximum size of a record passed between CKR03 */
+/* and CKE03. */
+
+
+/* CK Type 4 parameters: */
+
+/* CK4DTP CK data type 4 ID; */
+
+/* CK4PCD parameter defining integer to DP packing schema that */
+/* is applied when seven number integer array containing */
+/* polynomial degrees for quaternion and angular rate */
+/* components packed into a single DP number stored in */
+/* actual CK records in a file; the value of must not be */
+/* changed or compatibility with existing type 4 CK files */
+/* will be lost. */
+
+/* CK4MXD maximum Chebychev polynomial degree allowed in type 4 */
+/* records; the value of this parameter must never exceed */
+/* value of the CK4PCD; */
+
+/* CK4SFT number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 4 */
+/* CK record that passed between routines CKR04 and CKE04; */
+
+/* CK4RSZ maximum size of type 4 CK record passed between CKR04 */
+/* and CKE04; CK4RSZ is computed as follows: */
+
+/* CK4RSZ = ( CK4MXD + 1 ) * QAVSIZ + CK4SFT */
+
+
+/* CK Type 5 parameters: */
+
+
+/* CK5DTP CK data type 5 ID; */
+
+/* CK5MXD maximum polynomial degree allowed in type 5 */
+/* records. */
+
+/* CK5MET number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 5 */
+/* CK record that passed between routines CKR05 and CKE05; */
+
+/* CK5MXP maximum packet size for any subtype. Subtype 2 */
+/* has the greatest packet size, since these packets */
+/* contain a quaternion, its derivative, an angular */
+/* velocity vector, and its derivative. See ck05.inc */
+/* for a description of the subtypes. */
+
+/* CK5RSZ maximum size of type 5 CK record passed between CKR05 */
+/* and CKE05; CK5RSZ is computed as follows: */
+
+/* CK5RSZ = ( CK5MXD + 1 ) * CK5MXP + CK5MET */
+
+
+
+/* Maximum record size that can be handled by CKPFS. This value */
+/* must be set to the maximum of all CKxRSZ parameters (currently */
+/* CK4RSZ.) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* NEEDAV I True if angular velocity is requested. */
+/* RECORD I-O Data type 5 record. */
+/* CMAT O C-matrix. */
+/* AV O Angular velocity vector. */
+/* CLKOUT O SCLK associated with C-matrix. */
+
+/* $ Detailed_Input */
+
+/* NEEDAV is true if angular velocity is requested. */
+
+/* RECORD is a record from a type 5 CK segment which, when */
+/* evaluated at the epoch contained in its first */
+/* element, will give the attitude and angular velocity */
+/* of a spacecraft structure or instrument relative to a */
+/* base reference frame. */
+
+/* The structure of the record is as follows: */
+
+/* +----------------------+ */
+/* | evaluation epoch | */
+/* +----------------------+ */
+/* | subtype code | */
+/* +----------------------+ */
+/* | number of packets (n)| */
+/* +----------------------+ */
+/* | nominal SCLK rate | */
+/* +----------------------+ */
+/* | packet 1 | */
+/* +----------------------+ */
+/* | packet 2 | */
+/* +----------------------+ */
+/* . */
+/* . */
+/* . */
+/* +----------------------+ */
+/* | packet n | */
+/* +----------------------+ */
+/* | epochs 1--n | */
+/* +----------------------+ */
+
+/* See the CK Required Reading or the include file */
+/* ck05.inc for details on CK type 5 packet contents. */
+
+
+/* $ Detailed_Output */
+
+/* RECORD has been modified due to its use as a workspace array. */
+/* The contents are undefined. */
+
+
+/* CMAT is a rotation matrix that transforms the components */
+/* of a vector expressed in the base frame given in */
+/* the segment to components expressed in the instrument */
+/* fixed frame at the returned time. */
+
+/* Thus, if a vector v has components x, y, z in the */
+/* base frame, then v has components x', y', z' in the */
+/* instrument fixed frame where: */
+
+/* [ x' ] [ ] [ x ] */
+/* | y' | = | CMAT | | y | */
+/* [ z' ] [ ] [ z ] */
+
+/* If the x', y', z' components are known, use the */
+/* transpose of the C-matrix to determine x, y, z as */
+/* follows. */
+
+/* [ x ] [ ]T [ x' ] */
+/* | y | = | CMAT | | y' | */
+/* [ z ] [ ] [ z' ] */
+/* (Transpose of CMAT) */
+
+
+/* AV is the angular velocity vector of the instrument fixed */
+/* frame defined by CMAT. The angular velocity is */
+/* returned only if NEEDAV is true. */
+
+/* The direction of the angular velocity vector gives */
+/* the right-handed axis about which the instrument fixed */
+/* reference frame is rotating. The magnitude of AV is */
+/* the magnitude of the instantaneous velocity of the */
+/* rotation, in radians per second. */
+
+/* The angular velocity vector is returned in component */
+/* form */
+
+/* AV = [ AV1 , AV2 , AV3 ] */
+
+/* which is in terms of the base coordinate frame */
+/* specified in the segment descriptor. */
+
+/* CLKOUT is the encoded SCLK associated with the returned */
+/* C-matrix and angular velocity vector. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input record contains an unrecognized subtype code, */
+/* the error SPICE(NOTSUPPORTED) is signaled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The exact format and structure of CK type 5 (MEX/Rosetta Attitude */
+/* file interpolation) CK segments is described in the CK Required */
+/* Reading. */
+
+/* $ Examples */
+
+/* The CKEnn routines are almost always used in conjunction with */
+/* the corresponding CKRnn routines, which read the records from */
+/* CK files. */
+
+/* The following code fragment searches through all of the segments */
+/* in a file applicable to the Mars Express spacecraft bus that */
+/* are of data type 5, for a particular spacecraft clock time. */
+/* It then evaluates the pointing for that epoch and prints the */
+/* result. */
+
+/* CHARACTER*(20) SCLKCH */
+/* CHARACTER*(20) SCTIME */
+/* CHARACTER*(40) IDENT */
+
+/* INTEGER I */
+/* INTEGER SC */
+/* INTEGER INST */
+/* INTEGER HANDLE */
+/* INTEGER DTYPE */
+/* INTEGER ICD ( 6 ) */
+
+/* DOUBLE PRECISION SCLKDP */
+/* DOUBLE PRECISION TOL */
+/* DOUBLE PRECISION CLKOUT */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION RECORD ( 17 ) */
+/* DOUBLE PRECISION CMAT ( 3, 3 ) */
+/* DOUBLE PRECISION AV ( 3 ) */
+
+/* LOGICAL NEEDAV */
+/* LOGICAL FND */
+/* LOGICAL SFND */
+
+
+/* SC = -41 */
+/* INST = -41000 */
+/* DTYPE = 5 */
+/* NEEDAV = .FALSE. */
+
+/* C */
+/* C Load the MEX SCLK kernel and the C-kernel. */
+/* C */
+/* CALL FURNSH ( 'MEX_SCLK.TSC' ) */
+/* CALL DAFOPR ( 'MEX_CK.BC', HANDLE ) */
+/* C */
+/* C Get the spacecraft clock time. Then encode it for use */
+/* C in the C-kernel. */
+/* C */
+/* WRITE (*,*) 'Enter spacecraft clock time string:' */
+/* READ (*,FMT='(A)') SCLKCH */
+
+/* CALL SCENCD ( SC, SCLKCH, SCLKDP ) */
+/* C */
+/* C Use a tolerance of 2 seconds ( half of the nominal */
+/* C separation between MEX pointing instances ). */
+/* C */
+/* CALL SCTIKS ( SC, '0000000002:000', TOL ) */
+
+/* C */
+/* C Search from the beginning of the CK file through all */
+/* C of the segments. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( SFND ) */
+
+/* FND = .FALSE. */
+
+/* DO WHILE ( ( SFND ) .AND. ( .NOT. FND ) ) */
+
+/* C */
+/* C Get the segment identifier and descriptor. */
+/* C */
+/* CALL DAFGN ( IDENT ) */
+/* CALL DAFGS ( DESCR ) */
+/* C */
+/* C Unpack the segment descriptor into its integer and */
+/* C double precision components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* C */
+/* C Determine if this segment should be processed. */
+/* C */
+/* IF ( ( INST .EQ. ICD( 1 ) ) .AND. */
+/* . ( SCLKDP + TOL .GE. DCD( 1 ) ) .AND. */
+/* . ( SCLKDP - TOL .LE. DCD( 2 ) ) .AND. */
+/* . ( DTYPE .EQ. ICD( 3 ) ) ) THEN */
+
+
+/* CALL CKR05 ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
+/* . RECORD, FND ) */
+
+/* IF ( FND ) THEN */
+
+/* CALL CKE05 (NEEDAV,RECORD,CMAT,AV,CLKOUT) */
+
+/* CALL SCDECD ( SC, CLKOUT, SCTIME ) */
+
+/* WRITE (*,*) */
+/* WRITE (*,*) 'Segment identifier: ', IDENT */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'Pointing returned for time: ', */
+/* . SCTIME */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'C-matrix:' */
+/* WRITE (*,*) */
+/* WRITE (*,*) ( CMAT(1,I), I = 1, 3 ) */
+/* WRITE (*,*) ( CMAT(2,I), I = 1, 3 ) */
+/* WRITE (*,*) ( CMAT(3,I), I = 1, 3 ) */
+/* WRITE (*,*) */
+
+/* END IF */
+
+/* END IF */
+
+/* CALL DAFFNA ( SFND ) */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* 1) This routine assumes that the input record is valid. Any */
+/* checking of the input data is assumed to have been performed */
+/* when the source CK file was created. */
+
+/* 2) This routine assumes that the input data are suitable for the */
+/* interpolation method indicated by the subtype code in the */
+/* input record. Since the mapping of rotations to quaternions */
+/* is multiple-valued, this routine assumes that whichever sign */
+/* minimizes the Euclidean distance between one quaternion and */
+/* the next is the correct sign. The same assumption is made */
+/* for quaternion derivatives. */
+
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 20-NOV-2006 (NJB) */
+
+/* Bug fix: this routine now assumes that angular velocity */
+/* and quaternion derivative values stored in the input */
+/* record have units of radians/second. */
+
+/* Bug fix: this routine no longer attempts to determine */
+/* the correct sign of quaternion derivatives. The caller */
+/* must supply quaternion derivatives that are suitable */
+/* for interpolation. */
+
+/* - SPICELIB Version 1.3.0, 23-OCT-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments in */
+/* XPOSEG and VSCL calls. Replaced header reference to LDPOOL */
+/* with reference to FURNSH. */
+
+/* - SPICELIB Version 1.2.0, 14-FEB-2003 (NJB) */
+
+/* Bug fix: angular velocity computation was modified to */
+/* match that used in the corresponding algorithm employed */
+/* by the MEX/Rosetta attitude file reader. The quaternion */
+/* derivative used to derive angular velocity now is the */
+/* derivative of the *unit* quaternion. */
+
+/* - SPICELIB Version 1.1.0, 06-SEP-2002 (NJB) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* evaluate type_5 ck segment */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.3.0, 23-OCT-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments in */
+/* XPOSEG and VSCL calls. Replaced header reference to LDPOOL */
+/* with reference to FURNSH. */
+
+/* - SPICELIB Version 1.2.0, 14-FEB-2003 (NJB) */
+
+/* Bug fix: angular velocity computation was modified to */
+/* match that used in the corresponding algorithm employed */
+/* by the MEX/Rosetta attitude file reader. The quaternion */
+/* derivative used to derive angular velocity now is the */
+/* derivative of the *unit* quaternion. */
+
+/* Letting Q(t) be the quaternion derived by polynomial */
+/* interpolation, and letting UQ(t) be Q(t)/||Q(t)||, */
+/* the quaternion derivative d(UQ)/dt is now used. */
+
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Index of evaluation epoch in record: */
+
+
+/* Index of subtype code in record: */
+
+
+/* Index of packet count in record: */
+
+
+/* Index of SCLK rate in record: */
+
+
+/* Index at which packets start; packet base: */
+
+
+/* Maximum polynomial degree: */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("CKE05", (ftnlen)5);
+
+/* Capture the subtype from the record and set the packet size */
+/* accordingly. */
+
+ subtyp = i_dnnt(&record[1]);
+ if (subtyp == 0) {
+ packsz = 8;
+ } else if (subtyp == 1) {
+ packsz = 4;
+ } else if (subtyp == 2) {
+ packsz = 14;
+ } else if (subtyp == 3) {
+ packsz = 7;
+ } else {
+ setmsg_("Unexpected CK type 5 subtype # found in type 5 segment.", (
+ ftnlen)55);
+ errint_("#", &subtyp, (ftnlen)1);
+ sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
+ chkout_("CKE05", (ftnlen)5);
+ return 0;
+ }
+
+/* Get the packet count and epoch. */
+
+ n = i_dnnt(&record[2]);
+ sclkdp = record[0];
+
+/* Get the nominal clock rate. */
+
+ rate = record[3];
+
+/* Adjust quaternion "signs" as necessary to minimize distance */
+/* between successive quaternions. */
+
+ if (subtyp == 1 || subtyp == 3) {
+
+/* For these types, only the quaternions themselves need be */
+/* adjusted. */
+
+/* PRVPTR is the index of the "previous" quaternion---the */
+/* one to which the successor and its negative will be */
+/* compared. */
+
+ prvptr = 5;
+ i__1 = n;
+ for (i__ = 2; i__ <= i__1; ++i__) {
+
+/* NEWPTR points to the quaternion ahead of the one */
+/* pointed to by PRVPTR. */
+
+ newptr = packsz * (i__ - 1) + 5;
+ vminug_(&record[newptr - 1], &c__4, qneg);
+
+/* Replace the Ith quaternion with QNEG if QNEG is closer */
+/* than the current quaternion to the previous quaternion. */
+
+ if (vdistg_(&record[prvptr - 1], qneg, &c__4) < vdistg_(&record[
+ prvptr - 1], &record[newptr - 1], &c__4)) {
+ moved_(qneg, &c__4, &record[newptr - 1]);
+ }
+ prvptr = newptr;
+ }
+ } else {
+
+/* For the Hermite types, the quaternions may need to be */
+/* adjusted; the derivatives are not adjusted. */
+
+/* PRVPTR is the index of the "previous" quaternion---the */
+/* one to which the successor and its negative will be */
+/* compared. PRVDER points to the corresponding derivative. */
+
+ prvptr = 5;
+ prvder = 9;
+ i__1 = n;
+ for (i__ = 2; i__ <= i__1; ++i__) {
+
+/* NEWPTR points to the quaternion ahead of the one */
+/* pointed to by PRVPTR. */
+
+ newptr = packsz * (i__ - 1) + 5;
+ vminug_(&record[newptr - 1], &c__4, qneg);
+
+/* Replace the Ith quaternion with QNEG if QNEG is closer */
+/* than the current quaternion to the previous quaternion. */
+
+ if (vdistg_(&record[prvptr - 1], qneg, &c__4) < vdistg_(&record[
+ prvptr - 1], &record[newptr - 1], &c__4)) {
+ moved_(qneg, &c__4, &record[newptr - 1]);
+ }
+ }
+ }
+ if (subtyp == 1) {
+
+/* We perform Lagrange interpolation on each quaternion */
+/* component, and obtain quaternion derivatives from the */
+/* interpolating polynomials. The quaternion and derivative */
+/* gives us angular velocity. */
+
+/* We'll transpose the pointing information in the input record so */
+/* that contiguous pieces of it can be shoved directly into the */
+/* interpolation routine LGRINT. We allow LGRINT to overwrite */
+/* the state values in the input record, since this saves local */
+/* storage and does no harm. (See the header of LGRINT for a */
+/* description of its work space usage.) */
+
+ n = i_dnnt(&record[2]);
+ xpsgip_(&packsz, &n, &record[4]);
+
+/* We interpolate each state component in turn. */
+
+ xstart = n * packsz + 5;
+ i__1 = packsz;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ ystart = n * (i__ - 1) + 5;
+ lgrind_(&n, &record[xstart - 1], &record[ystart - 1], work, &
+ sclkdp, &state[(i__2 = i__ - 1) < 8 && 0 <= i__2 ? i__2 :
+ s_rnge("state", i__2, "cke05_", (ftnlen)626)], &state[(
+ i__3 = i__ + 3) < 8 && 0 <= i__3 ? i__3 : s_rnge("state",
+ i__3, "cke05_", (ftnlen)626)]);
+ }
+
+/* The output quaternion is a unitized version of the */
+/* interpolated state. */
+
+ mags = vnormg_(state, &c__4);
+ if (mags == 0.) {
+ setmsg_("Quaternion magnitude at SCLK # was zero.", (ftnlen)40);
+ errdp_("#", &sclkdp, (ftnlen)1);
+ sigerr_("SPICE(DIVIDEBYZERO)", (ftnlen)19);
+ chkout_("CKE05", (ftnlen)5);
+ return 0;
+ }
+ d__1 = 1. / mags;
+ vsclg_(&d__1, state, &c__4, q);
+ if (*needav) {
+
+/* Find the time derivative of the unit quaternion: */
+/* Letting S represent the quaternion portion of STATE, we */
+/* have */
+
+/* Q = S/||S|| */
+
+
+/* Then letting < , > denote the 4-dimensional inner product */
+/* operator, we have */
+
+
+/* d(S)/dt < Q, d(S)/dt > */
+/* d(Q)/dt = ------- - -------------- * Q */
+/* ||S|| ||S|| */
+
+
+ moved_(&state[4], &c__4, ds);
+ d__1 = 1. / mags;
+ vsclg_(&d__1, ds, &c__4, sclddq);
+ d__1 = vdotg_(q, ds, &c__4) / mags;
+ vsclg_(&d__1, q, &c__4, radtrm);
+ vsubg_(sclddq, radtrm, &c__4, dq);
+
+/* Derive angular velocity from Q and dQ/dt: */
+
+ qdq2av_(q, dq, av);
+
+/* Scale the rate from radians/tick to radians/second. */
+
+ d__1 = 1. / rate;
+ vsclip_(&d__1, av);
+ }
+
+/* Q and if required AV have been assigned. */
+
+ } else if (subtyp == 3) {
+
+/* This is the easiest case: we perform Lagrange interpolation */
+/* on each quaternion or angular velocity component. */
+
+/* We'll transpose the pointing information in the input record so */
+/* that contiguous pieces of it can be shoved directly into the */
+/* interpolation routine LGRINT. We allow LGRINT to overwrite */
+/* the state values in the input record, since this saves local */
+/* storage and does no harm. (See the header of LGRINT for a */
+/* description of its work space usage.) */
+
+ n = i_dnnt(&record[2]);
+ xpsgip_(&packsz, &n, &record[4]);
+
+/* We interpolate each state component in turn. */
+
+ xstart = n * packsz + 5;
+ if (*needav) {
+ ub = packsz;
+ } else {
+ ub = 4;
+ }
+ i__1 = ub;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ ystart = n * (i__ - 1) + 5;
+ state[(i__2 = i__ - 1) < 8 && 0 <= i__2 ? i__2 : s_rnge("state",
+ i__2, "cke05_", (ftnlen)727)] = lgrint_(&n, &record[
+ xstart - 1], &record[ystart - 1], locrec, &sclkdp);
+ }
+
+/* The output quaternion is a unitized version of the */
+/* interpolated state. */
+
+ vhatg_(state, &c__4, q);
+ if (*needav) {
+
+/* The angular velocity already is in units of radians/second. */
+
+ vequ_(&state[4], av);
+ }
+
+/* Q and if required AV have been assigned. */
+
+ } else {
+
+/* We have a Hermite-style subtype. Whether it's subtype 0 */
+/* or 2, we perform Hermite interpolation on the quaternions. */
+
+/* We interpolate each quaternion component in turn. Attitude and */
+/* angular velocity are interpolated separately. */
+
+ xstart = packsz * n + 5;
+ for (i__ = 1; i__ <= 4; ++i__) {
+ i__1 = n;
+ for (j = 1; j <= i__1; ++j) {
+
+/* For the Jth input packet, copy the Ith position and */
+/* velocity components into the local record buffer RECORD. */
+
+/* In order to perform Hermite interpolation, the */
+/* quaternions and quaternion derivatives must have a */
+/* common time scale. So prior to interpolation, we scale */
+/* the units of the quaternion derivatives from radians/sec */
+/* to radians/tick. */
+
+ from = packsz * (j - 1) + 4 + i__;
+ to = (j << 1) - 1;
+ locrec[(i__2 = to - 1) < 228 && 0 <= i__2 ? i__2 : s_rnge(
+ "locrec", i__2, "cke05_", (ftnlen)779)] = record[from
+ - 1];
+ locrec[(i__2 = to) < 228 && 0 <= i__2 ? i__2 : s_rnge("locrec"
+ , i__2, "cke05_", (ftnlen)780)] = record[from + 3] *
+ rate;
+ }
+
+/* Interpolate the Ith quaternion and quaternion derivative */
+/* components. */
+
+ hrmint_(&n, &record[xstart - 1], locrec, &sclkdp, work, &state[(
+ i__1 = i__ - 1) < 8 && 0 <= i__1 ? i__1 : s_rnge("state",
+ i__1, "cke05_", (ftnlen)788)], &state[(i__2 = i__ + 3) <
+ 8 && 0 <= i__2 ? i__2 : s_rnge("state", i__2, "cke05_", (
+ ftnlen)788)]);
+ }
+
+/* The output quaternion is a unitized version of the */
+/* interpolated state. */
+
+ mags = vnormg_(state, &c__4);
+ if (mags == 0.) {
+ setmsg_("Quaternion magnitude at SCLK # was zero.", (ftnlen)40);
+ errdp_("#", &sclkdp, (ftnlen)1);
+ sigerr_("SPICE(DIVIDEBYZERO)", (ftnlen)19);
+ chkout_("CKE05", (ftnlen)5);
+ return 0;
+ }
+ d__1 = 1. / mags;
+ vsclg_(&d__1, state, &c__4, q);
+ if (*needav) {
+ if (subtyp == 0) {
+
+/* Find the time derivative of the unit quaternion: */
+/* Letting S represent the quaternion portion of STATE, we */
+/* have */
+
+/* Q = S/||S|| */
+
+
+/* Then letting < , > denote the 4-dimensional inner product */
+/* operator, we have */
+
+
+/* d(S)/dt < Q, d(S)/dt > */
+/* d(Q)/dt = ------- - -------------- * Q */
+/* ||S|| ||S|| */
+
+
+ moved_(&state[4], &c__4, ds);
+ d__1 = 1. / mags;
+ vsclg_(&d__1, ds, &c__4, sclddq);
+ d__1 = vdotg_(q, ds, &c__4) / mags;
+ vsclg_(&d__1, q, &c__4, radtrm);
+ vsubg_(sclddq, radtrm, &c__4, dq);
+
+/* Derive angular velocity from Q and dQ/dt: */
+
+ qdq2av_(q, dq, av);
+
+/* Scale the rate from radians/tick to radians/second. */
+
+ d__1 = 1. / rate;
+ vsclip_(&d__1, av);
+ } else {
+
+/* This is subtype 2; we perform Hermite interpolation on */
+/* the angular velocity and its derivative. */
+
+/* Now interpolate angular velocity, using separate angular */
+/* velocity data and angular acceleration. */
+
+ for (i__ = 1; i__ <= 3; ++i__) {
+ i__1 = n;
+ for (j = 1; j <= i__1; ++j) {
+
+/* For the Jth input packet, copy the Ith position */
+/* and velocity components into the local record */
+/* buffer LOCREC. Note that, as with quaternion */
+/* derivatives, we must scale angular acceleration */
+/* from radians/sec**2 to radians/(sec*tick) before */
+/* interpolating. */
+
+ from = packsz * (j - 1) + 12 + i__;
+ to = (j << 1) - 1;
+ locrec[(i__2 = to - 1) < 228 && 0 <= i__2 ? i__2 :
+ s_rnge("locrec", i__2, "cke05_", (ftnlen)876)]
+ = record[from - 1];
+ locrec[(i__2 = to) < 228 && 0 <= i__2 ? i__2 : s_rnge(
+ "locrec", i__2, "cke05_", (ftnlen)877)] =
+ record[from + 2] * rate;
+ }
+
+/* Interpolate the Ith angular velocity and angular */
+/* acceleration components of the attitude. We'll */
+/* capture the result in a temporary buffer, then */
+/* transfer the velocity to the output argument AV. */
+
+ hrmint_(&n, &record[xstart - 1], locrec, &sclkdp, work, &
+ vbuff[(i__1 = i__ - 1) < 6 && 0 <= i__1 ? i__1 :
+ s_rnge("vbuff", i__1, "cke05_", (ftnlen)887)], &
+ vbuff[(i__2 = i__ + 2) < 6 && 0 <= i__2 ? i__2 :
+ s_rnge("vbuff", i__2, "cke05_", (ftnlen)887)]);
+ }
+
+/* Fill in the angular velocity in the output angular */
+/* velocity vector using the results of interpolating */
+/* velocity and acceleration. */
+
+/* The angular velocity is already in units of */
+/* radians/second. */
+
+ vequ_(vbuff, av);
+ }
+
+/* We've handled the type 0 and type 2 cases. */
+
+ }
+
+/* We've computed the angular velocity AV for the Hermite */
+/* subtypes, if a.v. was requested. */
+
+ }
+
+/* We've handled all four subtypes. */
+
+
+/* Produce a C-matrix from the interpolated quaternion. Set CLKOUT. */
+
+ q2m_(q, cmat);
+ *clkout = record[0];
+ chkout_("CKE05", (ftnlen)5);
+ return 0;
+} /* cke05_ */
+
diff --git a/ext/spice/src/cspice/ckfrot.c b/ext/spice/src/cspice/ckfrot.c
new file mode 100644
index 0000000000..8a9efdd619
--- /dev/null
+++ b/ext/spice/src/cspice/ckfrot.c
@@ -0,0 +1,290 @@
+/* ckfrot.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKFROT ( C-kernel, find rotation ) */
+/* Subroutine */ int ckfrot_(integer *inst, doublereal *et, doublereal *
+ rotate, integer *ref, logical *found)
+{
+ logical have, pfnd, sfnd;
+ doublereal time;
+ extern /* Subroutine */ int sce2c_(integer *, doublereal *, doublereal *);
+ char segid[40];
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ doublereal descr[5];
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *), ckbss_(integer *, doublereal *,
+ doublereal *, logical *), ckpfs_(integer *, doublereal *,
+ doublereal *, doublereal *, logical *, doublereal *, doublereal *,
+ doublereal *, logical *), cksns_(integer *, doublereal *, char *,
+ logical *, ftnlen), xpose_(doublereal *, doublereal *);
+ extern logical failed_(void);
+ doublereal av[3];
+ integer handle;
+ extern /* Subroutine */ int ckhave_(logical *);
+ logical needav;
+ extern /* Subroutine */ int ckmeta_(integer *, char *, integer *, ftnlen);
+ integer sclkid;
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ doublereal clkout;
+ extern logical return_(void), zzsclk_(integer *, integer *);
+ doublereal dcd[2];
+ integer icd[6];
+ doublereal tol, rot[9] /* was [3][3] */;
+
+/* $ Abstract */
+
+/* Find the rotation from a C-kernel Id to the native */
+/* frame at the time requested. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* INST I NAIF instrument ID. */
+/* ET I Epoch measured in seconds past J2000. */
+/* ROTATE O rotation from CK platform to frame REF. */
+/* REF O Reference frame. */
+/* FOUND O True when requested pointing is available. */
+
+/* $ Detailed_Input */
+
+/* INST is the unique NAIF integer ID for the spacecraft */
+/* instrument for which data is being requested. */
+
+/* ET is the epoch for which the state rotation */
+/* is desired. ET should be given in seconds past the */
+/* epoch of J2000. */
+
+
+/* $ Detailed_Output */
+
+/* ROTATE is a rotation matrix that converts */
+/* positions relative to the input frame (given by INST) */
+/* to positions relative to the frame REF. */
+
+/* Thus, if a state S has components x,y,z,dx,dy,dz */
+/* in the frame of INST, frame, then S has components */
+/* x', y', z', dx', dy', dz' in frame REF. */
+
+/* [ x' ] [ ] [ x ] */
+/* | y' | = | ROTATE | | y | */
+/* [ z' ] [ ] [ z ] */
+
+
+/* REF is the id-code reference frame to which ROTATE will */
+/* transform states. */
+
+/* FOUND is true if a record was found to satisfy the pointing */
+/* request. FOUND will be false otherwise. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If a C-kernel file is not loaded using CKLPF prior to calling */
+/* this routine, an error is signalled by a routine that this */
+/* routine calls. */
+
+
+/* $ Files */
+
+/* CKFROT searches through files loaded by CKLPF to locate a segment */
+/* that can satisfy the request for position rotation */
+/* for instrument INST at time ET. You must load a C-kernel */
+/* file using CKLPF before calling this routine. */
+
+/* $ Particulars */
+
+/* CKFROT searches through files loaded by CKLPF to satisfy a */
+/* pointing request. Last-loaded files are searched first, and */
+/* individual files are searched in backwards order, giving */
+/* priority to segments that were added to a file later than the */
+/* others. CKFROT considers only those segments that contain */
+/* angular velocity data. */
+
+/* The search ends when a segment is found that can give pointing */
+/* for the specified instrument at the request time. */
+
+/* $ Examples */
+
+/* None. */
+
+/* $ Restrictions */
+
+/* A C-kernel file should have been loaded by CKLPF. */
+
+/* In addition it is helpful to load a CK-info file into the */
+/* Kernel pool. This file should have the following variables */
+/* defined. */
+
+/* CK__SCLK = SCLK idcode that yields SCLK mapping for INST. */
+/* CK__SPK = SPK idcode that yields ephemeris for INST. */
+
+/* where is the integer string corresponding to INST. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.2.0, 17-FEB-2000 (WLT) */
+
+/* The routine now checks to make sure convert ET to TICKS */
+/* and that at least one C-kernel is loaded before trying */
+/* to look up the transformation. Also the routine now calls */
+/* SCE2C instead of SCE2T. */
+
+/* - SPICELIB Version 1.0.0, 03-MAR-1999 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get instrument frame rotation and reference frame */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel segment descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel segment descriptor. */
+
+/* NC is the number of components in a packed C-kernel */
+/* descriptor. All DAF summaries have this formulaic */
+/* relationship between the number of its integer and */
+/* double precision components and the number of packed */
+/* components. */
+
+/* IDLEN is the length of the C-kernel segment identifier. */
+/* All DAF names have this formulaic relationship */
+/* between the number of summary components and */
+/* the length of the name (You will notice that */
+/* a name and a summary have the same length in bytes.) */
+
+
+/* Local variables */
+
+
+/* Set FOUND to FALSE right now in case we end up */
+/* returning before doing any work. */
+
+ *found = FALSE_;
+ *ref = 0;
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKFROT", (ftnlen)6);
+ }
+
+/* We don't need angular velocity data. */
+/* Assume the segment won't be found until it really is. */
+
+ needav = FALSE_;
+ tol = 0.;
+
+/* Begin a search for this instrument and time, and get the first */
+/* applicable segment. */
+
+ ckhave_(&have);
+ ckmeta_(inst, "SCLK", &sclkid, (ftnlen)4);
+ if (! have) {
+ chkout_("CKFROT", (ftnlen)6);
+ return 0;
+ } else if (! zzsclk_(inst, &sclkid)) {
+ chkout_("CKFROT", (ftnlen)6);
+ return 0;
+ }
+ sce2c_(&sclkid, et, &time);
+ ckbss_(inst, &time, &tol, &needav);
+ cksns_(&handle, descr, segid, &sfnd, (ftnlen)40);
+
+/* Keep trying candidate segments until a segment can produce a */
+/* pointing instance within the specified time tolerance of the */
+/* input time. */
+
+/* Check FAILED to prevent an infinite loop if an error is detected */
+/* by a SPICELIB routine and the error handling is not set to abort. */
+
+ while(sfnd && ! failed_()) {
+ ckpfs_(&handle, descr, &time, &tol, &needav, rot, av, &clkout, &pfnd);
+ if (pfnd) {
+
+/* Found one. Fetch the ID code of the reference frame */
+/* from the descriptor. */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ *ref = icd[1];
+ *found = TRUE_;
+
+/* We now have the rotation matrix from */
+/* REF to INS. We invert ROT to get the rotation */
+/* from INST to REF. */
+
+ xpose_(rot, rotate);
+ chkout_("CKFROT", (ftnlen)6);
+ return 0;
+ }
+ cksns_(&handle, descr, segid, &sfnd, (ftnlen)40);
+ }
+ chkout_("CKFROT", (ftnlen)6);
+ return 0;
+} /* ckfrot_ */
+
diff --git a/ext/spice/src/cspice/ckfxfm.c b/ext/spice/src/cspice/ckfxfm.c
new file mode 100644
index 0000000000..280155baac
--- /dev/null
+++ b/ext/spice/src/cspice/ckfxfm.c
@@ -0,0 +1,351 @@
+/* ckfxfm.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKFXFM ( C-kernel, find transformation ) */
+/* Subroutine */ int ckfxfm_(integer *inst, doublereal *et, doublereal *xform,
+ integer *ref, logical *found)
+{
+ logical have, pfnd, sfnd;
+ doublereal time;
+ extern /* Subroutine */ int sce2c_(integer *, doublereal *, doublereal *);
+ char segid[40];
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ doublereal descr[5];
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *), ckbss_(integer *, doublereal *,
+ doublereal *, logical *), ckpfs_(integer *, doublereal *,
+ doublereal *, doublereal *, logical *, doublereal *, doublereal *,
+ doublereal *, logical *), cksns_(integer *, doublereal *, char *,
+ logical *, ftnlen);
+ doublereal ref2in[36] /* was [6][6] */;
+ extern /* Subroutine */ int rav2xf_(doublereal *, doublereal *,
+ doublereal *);
+ extern logical failed_(void);
+ doublereal av[3];
+ integer handle;
+ extern /* Subroutine */ int ckhave_(logical *);
+ logical needav;
+ extern /* Subroutine */ int ckmeta_(integer *, char *, integer *, ftnlen);
+ integer sclkid;
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ doublereal clkout;
+ extern logical return_(void), zzsclk_(integer *, integer *);
+ extern /* Subroutine */ int invstm_(doublereal *, doublereal *);
+ doublereal dcd[2];
+ integer icd[6];
+ doublereal tol, rot[9] /* was [3][3] */;
+
+/* $ Abstract */
+
+/* Find the transformation from a C-kernel Id to the native */
+/* frame at the time requested. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* INST I NAIF instrument ID. */
+/* ET I Epoch measured in seconds past J2000. */
+/* XFORM O Transformation from CK platform to frame REF. */
+/* REF O Reference frame. */
+/* FOUND O True when requested pointing is available. */
+
+/* $ Detailed_Input */
+
+/* INST is the unique NAIF integer ID for the spacecraft */
+/* instrument for which data is being requested. */
+
+/* ET is the epoch for which the state transformation */
+/* is desired. ET should be given in seconds past the */
+/* epoch of J2000. */
+
+
+/* $ Detailed_Output */
+
+/* XFORM is a state transformation matrix that converts */
+/* states relative to the input frame (given by INST) */
+/* to states relative to the frame REF. */
+
+
+/* Thus, if a state S has components x,y,z,dx,dy,dz */
+/* in the frame of INST, frame, then S has components */
+/* x', y', z', dx', dy', dz' in frame REF. */
+
+/* [ x' ] [ ] [ x ] */
+/* | y' | = | | | y | */
+/* | z' | | | | z | */
+/* | dx' | [ XFORM ] | dx | */
+/* | dy' | = | | | dy | */
+/* [ dz' ] [ ] [ dz ] */
+
+
+/* REF is the id-code reference frame to which XFORM will */
+/* transform states. */
+
+/* FOUND is true if a record was found to satisfy the pointing */
+/* request. FOUND will be false otherwise. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If a C-kernel file is not loaded using CKLPF prior to calling */
+/* this routine, an error is signalled by a routine that this */
+/* routine calls. */
+
+
+/* $ Files */
+
+/* CKFXFM searches through files loaded by CKLPF to locate a segment */
+/* that can satisfy the request for state transformation */
+/* for instrument INST at time ET. You must load a C-kernel */
+/* file using CKLPF before calling this routine. */
+
+/* $ Particulars */
+
+/* CKFXFM searches through files loaded by CKLPF to satisfy a */
+/* pointing request. Last-loaded files are searched first, and */
+/* individual files are searched in backwards order, giving */
+/* priority to segments that were added to a file later than the */
+/* others. CKFXFM considers only those segments that contain */
+/* angular velocity data. */
+
+/* The search ends when a segment is found that can give pointing */
+/* and angular velocity for the specified instrument at the request */
+/* time. */
+
+/* $ Examples */
+
+/* Suppose that you want to determine how fast an instrument */
+/* is rotating with respect to the frame used to store the */
+/* instrument's attitude. First look up the transformation */
+/* from the instrument frame specified by ID to the reference */
+/* frame (returned by CKFXFM). */
+
+/* INST = id_code of the instrument of interest */
+/* ET = epoch of interest in seconds past J2000. */
+
+/* CALL CKFXFM ( INST, ET, XFORM, REF, FOUND ) */
+
+/* Next determine the angular velocity of the transformation from */
+
+/* CALL XF2RAV ( XFORM, ROT, AV ) */
+
+/* The angular rate of change (in radians/second) is just the */
+/* magnitude of AV. */
+
+/* RATE = VNORM ( AV ) */
+
+/* $ Restrictions */
+
+/* A C-kernel file should have been loaded by CKLPF. */
+
+/* In addition is helpful to load a CK-info file into the */
+/* Kernel pool. This file should have the following variables */
+/* defined. */
+
+/* CK__SCLK = SCLK idcode that yields SCLK mapping for INST. */
+/* CK__SPK = SPK idcode that yields ephemeris for INST. */
+
+/* where is the integer string corresponding to INST. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.2.0, 17-FEB-2000 (WLT) */
+
+/* The routine now checks to make sure convert ET to TICKS */
+/* and that at least one C-kernel is loaded before trying */
+/* to look up the transformation. */
+
+/* - SPICELIB Version 2.1.0, 09-MAR-1999 (NJB) */
+
+/* A call to SCE2T has been replaced by a call to SCE2C. */
+
+/* - SPICELIB Version 2.0.0, 28-JUL-1997 (WLT) */
+
+/* The previous edition did not correctly compute the derivative */
+/* block of the state transformation matrix. */
+
+/* The routine incorrectly computed the state transformation */
+/* matrix using the rotation from INST to REF together with */
+/* the angular velocity from REF to INST. Now it computes */
+/* the state transformation matrix from REF to INST and then */
+/* inverts the result to get the correct matrix. */
+
+/* Moved the assignment of FOUND to just before the check */
+/* of the SPICELIB function RETURN. That way if the routine */
+/* exits immediately via a check of the function RETURN(), */
+/* FOUND will have an appropriate value. */
+
+/* - SPICELIB Version 1.0.0, 3-OCT-1994 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get instrument frame transformation and reference frame */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.1.0, 09-MAR-1999 (NJB) */
+
+/* A call to SCE2T has been replaced by a call to SCE2C. This */
+/* routine performs conversion of ET to continuous ticks, */
+/* reducing truncation error in the representation of the input */
+/* time value. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel segment descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel segment descriptor. */
+
+/* NC is the number of components in a packed C-kernel */
+/* descriptor. All DAF summaries have this formulaic */
+/* relationship between the number of its integer and */
+/* double precision components and the number of packed */
+/* components. */
+
+/* IDLEN is the length of the C-kernel segment identifier. */
+/* All DAF names have this formulaic relationship */
+/* between the number of summary components and */
+/* the length of the name (You will notice that */
+/* a name and a summary have the same length in bytes.) */
+
+
+/* Local variables */
+
+
+/* Set FOUND to FALSE right now in case we end up */
+/* returning before doing any work. */
+
+ *found = FALSE_;
+ *ref = 0;
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKFXFM", (ftnlen)6);
+ }
+
+/* Need angular velocity data. */
+/* Assume the segment won't be found until it really is. */
+
+ needav = TRUE_;
+ tol = 0.;
+
+/* Begin a search for this instrument and time, and get the first */
+/* applicable segment. */
+
+ ckmeta_(inst, "SCLK", &sclkid, (ftnlen)4);
+ ckhave_(&have);
+ if (! have) {
+ chkout_("CKFXFM", (ftnlen)6);
+ return 0;
+ } else if (! zzsclk_(inst, &sclkid)) {
+ chkout_("CKFXFM", (ftnlen)6);
+ return 0;
+ }
+ sce2c_(&sclkid, et, &time);
+ ckbss_(inst, &time, &tol, &needav);
+ cksns_(&handle, descr, segid, &sfnd, (ftnlen)40);
+
+/* Keep trying candidate segments until a segment can produce a */
+/* pointing instance within the specified time tolerance of the */
+/* input time. */
+
+/* Check FAILED to prevent an infinite loop if an error is detected */
+/* by a SPICELIB routine and the error handling is not set to abort. */
+
+ while(sfnd && ! failed_()) {
+ ckpfs_(&handle, descr, &time, &tol, &needav, rot, av, &clkout, &pfnd);
+ if (pfnd) {
+
+/* Found one. Fetch the ID code of the reference frame */
+/* from the descriptor. */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ *ref = icd[1];
+ *found = TRUE_;
+
+/* We now have the transformation matrix from */
+/* REF to INST immediately. Using the angular velocity */
+/* we compute the state transformation matrix from REF to INST */
+
+ rav2xf_(rot, av, ref2in);
+
+/* Finally, we invert REF2IN to get the state transformation */
+/* from INST to REF. */
+
+ invstm_(ref2in, xform);
+ chkout_("CKFXFM", (ftnlen)6);
+ return 0;
+ }
+ cksns_(&handle, descr, segid, &sfnd, (ftnlen)40);
+ }
+ chkout_("CKFXFM", (ftnlen)6);
+ return 0;
+} /* ckfxfm_ */
+
diff --git a/ext/spice/src/cspice/ckgp.c b/ext/spice/src/cspice/ckgp.c
new file mode 100644
index 0000000000..a1c684182e
--- /dev/null
+++ b/ext/spice/src/cspice/ckgp.c
@@ -0,0 +1,1026 @@
+/* ckgp.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+static integer c__9 = 9;
+
+/* $Procedure CKGP ( C-kernel, get pointing ) */
+/* Subroutine */ int ckgp_(integer *inst, doublereal *sclkdp, doublereal *tol,
+ char *ref, doublereal *cmat, doublereal *clkout, logical *found,
+ ftnlen ref_len)
+{
+ logical pfnd, sfnd;
+ integer sclk;
+ extern /* Subroutine */ int sct2e_(integer *, doublereal *, doublereal *);
+ integer type1, type2;
+ char segid[40];
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ doublereal descr[5];
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *), ckbss_(integer *, doublereal *,
+ doublereal *, logical *), ckpfs_(integer *, doublereal *,
+ doublereal *, doublereal *, logical *, doublereal *, doublereal *,
+ doublereal *, logical *), moved_(doublereal *, integer *,
+ doublereal *), cksns_(integer *, doublereal *, char *, logical *,
+ ftnlen);
+ logical gotit;
+ extern logical failed_(void);
+ doublereal av[3], et;
+ integer handle;
+ extern /* Subroutine */ int refchg_(integer *, integer *, doublereal *,
+ doublereal *);
+ logical needav;
+ extern /* Subroutine */ int ckmeta_(integer *, char *, integer *, ftnlen);
+ integer refseg, center;
+ extern /* Subroutine */ int namfrm_(char *, integer *, ftnlen), frinfo_(
+ integer *, integer *, integer *, integer *, logical *);
+ integer refreq, typeid;
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ doublereal tmpmat[9] /* was [3][3] */;
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+ extern /* Subroutine */ int mxm_(doublereal *, doublereal *, doublereal *)
+ ;
+ doublereal rot[9] /* was [3][3] */;
+
+/* $ Abstract */
+
+/* Get pointing (attitude) for a specified spacecraft clock time. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* SCLK */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* The parameters below form an enumerated list of the recognized */
+/* frame types. They are: INERTL, PCK, CK, TK, DYN. The meanings */
+/* are outlined below. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Parameters */
+
+/* INERTL an inertial frame that is listed in the routine */
+/* CHGIRF and that requires no external file to */
+/* compute the transformation from or to any other */
+/* inertial frame. */
+
+/* PCK is a frame that is specified relative to some */
+/* INERTL frame and that has an IAU model that */
+/* may be retrieved from the PCK system via a call */
+/* to the routine TISBOD. */
+
+/* CK is a frame defined by a C-kernel. */
+
+/* TK is a "text kernel" frame. These frames are offset */
+/* from their associated "relative" frames by a */
+/* constant rotation. */
+
+/* DYN is a "dynamic" frame. These currently are */
+/* parameterized, built-in frames where the full frame */
+/* definition depends on parameters supplied via a */
+/* frame kernel. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 28-MAY-2004 (NJB) */
+
+/* The parameter DYN was added to support the dynamic frame class. */
+
+/* - SPICELIB Version 2.0.0, 12-DEC-1996 (WLT) */
+
+/* Various unused frames types were removed and the */
+/* frame time TK was added. */
+
+/* - SPICELIB Version 1.0.0, 10-DEC-1995 (WLT) */
+
+/* -& */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* INST I NAIF ID of instrument, spacecraft, or structure. */
+/* SCLKDP I Encoded spacecraft clock time. */
+/* TOL I Time tolerance. */
+/* REF I Reference frame. */
+/* CMAT O C-matrix pointing data. */
+/* CLKOUT O Output encoded spacecraft clock time. */
+/* FOUND O True when requested pointing is available. */
+
+/* $ Detailed_Input */
+
+/* INST is the NAIF integer ID for the instrument, spacecraft, */
+/* or other structure for which pointing is requested. */
+/* For brevity we will refer to this object as the */
+/* "instrument," and the frame fixed to this object as */
+/* the "instrument frame" or "instrument-fixed" frame. */
+
+/* SCLKDP is the encoded spacecraft clock time for which */
+/* pointing is requested. */
+
+/* The SPICELIB routines SCENCD and SCE2C respectively */
+/* convert spacecraft clock strings and ephemeris time to */
+/* encoded spacecraft clock. The inverse conversions are */
+/* performed by SCDECD and SCT2E. */
+
+/* TOL is a time tolerance in ticks, the units of encoded */
+/* spacecraft clock time. */
+
+/* The SPICELIB routine SCTIKS converts a spacecraft */
+/* clock tolerance duration from its character string */
+/* representation to ticks. SCFMT performs the inverse */
+/* conversion. */
+
+/* The C-matrix returned by CKGP is the one whose time */
+/* tag is closest to SCLKDP and within TOL units of */
+/* SCLKDP. (More in Particulars, below.) */
+
+/* In general, because using a non-zero tolerance */
+/* affects selection of the segment from which the */
+/* data is obtained, users are strongly discouraged */
+/* from using a non-zero tolerance when reading CKs */
+/* with continuous data. Using a non-zero tolerance */
+/* should be reserved exclusively to reading CKs with */
+/* discrete data because in practice obtaining data */
+/* from such CKs using a zero tolerance is often not */
+/* possible due to time round off. */
+
+/* REF is the desired reference frame for the returned */
+/* pointing. The returned C-matrix CMAT gives the */
+/* orientation of the instrument designated by INST */
+/* relative to the frame designated by REF. When a */
+/* vector specified relative to frame REF is left- */
+/* multiplied by CMAT, the vector is rotated to the */
+/* frame associated with INST. See the discussion of */
+/* CMAT below for details. */
+
+/* Consult the SPICE document "Frames" for a discussion */
+/* of supported reference frames. */
+
+/* $ Detailed_Output */
+
+/* CMAT is a rotation matrix that transforms the components of */
+/* a vector expressed in the reference frame specified by */
+/* REF to components expressed in the frame tied to the */
+/* instrument, spacecraft, or other structure at time */
+/* CLKOUT (see below). */
+
+/* Thus, if a vector v has components x,y,z in the REF */
+/* reference frame, then v has components x',y',z' in the */
+/* instrument fixed frame at time CLKOUT: */
+
+/* [ x' ] [ ] [ x ] */
+/* | y' | = | CMAT | | y | */
+/* [ z' ] [ ] [ z ] */
+
+/* If you know x', y', z', use the transpose of the */
+/* C-matrix to determine x, y, z as follows: */
+
+/* [ x ] [ ]T [ x' ] */
+/* | y | = | CMAT | | y' | */
+/* [ z ] [ ] [ z' ] */
+/* (Transpose of CMAT) */
+
+
+/* CLKOUT is the encoded spacecraft clock time associated with */
+/* the returned C-matrix. This value may differ from the */
+/* requested time, but never by more than the input */
+/* tolerance TOL. */
+
+/* The particulars section below describes the search */
+/* algorithm used by CKGP to satisfy a pointing */
+/* request. This algorithm determines the pointing */
+/* instance (and therefore the associated time value) */
+/* that is returned. */
+
+/* FOUND is true if a record was found to satisfy the pointing */
+/* request. FOUND will be false otherwise. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If a C-kernel file has not been loaded using FURNSH prior to */
+/* a call to this routine, an error is signaled by a routine in */
+/* the call tree of this routine. */
+
+/* 2) If TOL is negative, found is set to .FALSE. */
+
+/* 3) If REF is not a supported reference frame, an error is */
+/* signaled by a routine in the call tree of this routine and */
+/* FOUND is set to .FALSE. */
+
+/* $ Files */
+
+/* CKGP searches through files loaded by FURNSH to locate a */
+/* segment that can satisfy the request for pointing for instrument */
+/* INST at time SCLKDP. You must load a C-kernel file using FURNSH */
+/* prior to calling this routine. */
+
+/* $ Particulars */
+
+/* How the tolerance argument is used */
+/* ================================== */
+
+
+/* Reading a type 1 CK segment (discrete pointing instances) */
+/* --------------------------------------------------------- */
+
+/* In the diagram below */
+
+/* - "0" is used to represent discrete pointing instances */
+/* (quaternions and associated time tags). */
+
+/* - "( )" are used to represent the end points of the time */
+/* interval covered by a segment in a CK file. */
+
+/* - SCLKDP is the time at which you requested pointing. */
+/* The location of SCLKDP relative to the time tags of the */
+/* pointing instances is indicated by the "+" sign. */
+
+/* - TOL is the time tolerance specified in the pointing */
+/* request. The square brackets "[ ]" represent the */
+/* endpoints of the time interval */
+
+/* SCLKDP-TOL : SCLKDP+TOL */
+
+/* - The quaternions occurring in the segment need not be */
+/* evenly spaced in time. */
+
+
+/* Case 1: pointing is available */
+/* ------------------------------ */
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* Segment (0-----0--0--0--0--0--0---0--0------------0--0--0--0) */
+/* ^ */
+/* | */
+/* CKGP returns this instance. */
+
+
+/* Case 2: pointing is not available */
+/* ---------------------------------- */
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* Segment (0-----0--0--0--0--0--0---0--0--0---------0--0--0--0) */
+
+
+/* CKGP returns no pointing; the output */
+/* FOUND flag is set to .FALSE. */
+
+
+
+/* Reading a type 2, 3, 4, or 5 CK segment (continuous pointing) */
+/* ------------------------------------------------------------- */
+
+/* In the diagrams below */
+
+/* - "==" is used to represent periods of continuous pointing. */
+
+/* - "--" is used to represent gaps in the pointing coverage. */
+
+/* - "( )" are used to represent the end points of the time */
+/* interval covered by a segment in a CK file. */
+
+/* - SCLKDP is the time at which you requested pointing. */
+/* The location of SCLKDP relative to the time tags of the */
+/* pointing instances is indicated by the "+" sign. */
+
+/* - TOL is the time tolerance specified in the pointing */
+/* request. The square brackets "[ ]" represent the */
+/* endpoints of the time interval */
+
+/* SCLKDP-TOL : SCLKDP+TOL */
+
+/* - The quaternions occurring in the periods of continuous */
+/* pointing need not be evenly spaced in time. */
+
+
+/* Case 1: pointing is available at the request time */
+/* -------------------------------------------------- */
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* . . . */
+/* . . . */
+/* Segment (==---===========---=======----------===--) */
+/* ^ */
+/* | */
+
+/* The request time lies within an interval where */
+/* continuous pointing is available. CKGP returns */
+/* pointing at the requested epoch. */
+
+
+/* Case 2: pointing is available "near" the request time */
+/* ------------------------------------------------------ */
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* Segment (==---===========----=======---------===--) */
+/* ^ */
+/* | */
+
+/* The request time lies in a gap: an interval where */
+/* continuous pointing is *not* available. CKGP */
+/* returns pointing for the epoch closest to the */
+/* request time SCLKDP. */
+
+
+/* Case 3: pointing is not available */
+/* ---------------------------------- */
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* Segment (==---===========----=======---------===--) */
+
+/* CKGP returns no pointing; the output */
+/* FOUND flag is set to .FALSE. */
+
+
+
+/* Tolerance and segment priority */
+/* ============================== */
+
+/* CKGP searches through loaded C-kernels to satisfy a pointing */
+/* request. Last-loaded files are searched first. Individual files */
+/* are searched in backwards order, so that between competing */
+/* segments (segments containing data for the same object, for */
+/* overlapping time ranges), the one closest to the end of the file */
+/* has highest priority. */
+
+/* The search ends when a segment is found that can provide pointing */
+/* for the specified instrument at a time falling within the */
+/* specified tolerance on either side of the request time. Within */
+/* that segment, the instance closest to the input time is located */
+/* and returned. */
+
+/* The following four cases illustrate this search procedure. */
+/* Segments A and B are in the same file, with segment A located */
+/* further towards the end of the file than segment B. Both segments */
+/* A and B contain discrete pointing data, indicated by the number */
+/* 0. */
+
+
+/* Case 1: Pointing is available in the first segment searched. */
+/* Because segment A has the highest priority and can */
+/* satisfy the request, segment B is not searched. */
+
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* Segment A (0-----------------0--------0--0-----0) */
+/* ^ */
+/* | */
+/* | */
+/* CKGP returns this instance */
+
+/* Segment B (0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0) */
+
+
+
+/* Case 2: Pointing is not available in the first segment searched. */
+/* Because segment A cannot satisfy the request, segment B */
+/* is searched. */
+
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* Segment A (0-----------------0--------0--0-----0) */
+/* . . . */
+/* Segment B (0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0) */
+/* ^ */
+/* | */
+/* CKGP returns this instance */
+
+
+/* Segments that contain continuous pointing data are searched in */
+/* the same manner as segments containing discrete pointing data. */
+/* For request times that fall within the bounds of continuous */
+/* intervals, CKGP will return pointing at the request time. When */
+/* the request time does not fall within an interval, then a time at */
+/* an endpoint of an interval may be returned if it is the closest */
+/* time in the segment to the user request time and is also within */
+/* the tolerance. */
+
+/* In the following examples, segment A is located further towards */
+/* the end of the file than segment C. Segment A contains discrete */
+/* pointing data and segment C contains continuous data, indicated */
+/* by the "=" character. */
+
+
+/* Case 3: Pointing is not available in the first segment searched. */
+/* Because segment A cannot satisfy the request, segment C */
+/* is searched. */
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* . . . */
+/* Segment A (0-----------------0--------0--0-----0) */
+/* . . . */
+/* . . . */
+/* Segment C (---=============-----====--------==--) */
+/* ^ */
+/* | */
+/* | */
+/* CKGP returns this instance */
+
+
+/* In the next case, assume that the order of segments A and C in the */
+/* file is reversed: A is now closer to the front, so data from */
+/* segment C are considered first. */
+
+
+/* Case 4: Pointing is available in the first segment searched. */
+/* Because segment C has the highest priority and can */
+/* satisfy the request, segment A is not searched. */
+
+/* SCLKDP */
+/* / */
+/* | TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* . . . */
+/* Segment C (---=============-----====--------==--) */
+/* ^ */
+/* | */
+/* CKGP returns this instance */
+
+/* Segment A (0-----------------0--------0--0-----0) */
+/* ^ */
+/* | */
+/* "Best" answer */
+
+
+/* The next case illustrates an unfortunate side effect of using */
+/* a non-zero tolerance when reading multi-segment CKs with */
+/* continuous data. In all cases when the look-up interval */
+/* formed using tolerance overlaps a segment boundary and */
+/* the request time falls within the coverage of the lower */
+/* priority segment, the data at the end of the higher priority */
+/* segment will be picked instead of the data from the lower */
+/* priority segment. */
+
+
+/* Case 5: Pointing is available in the first segment searched. */
+/* Because segment C has the highest priority and can */
+/* satisfy the request, segment A is not searched. */
+
+/* SCLKDP */
+/* / */
+/* | TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* . . . */
+/* Segment C (===============) */
+/* ^ */
+/* | */
+/* CKGP returns this instance */
+
+/* Segment A (=====================) */
+/* ^ */
+/* | */
+/* "Best" answer */
+
+/* $ Examples */
+
+/* Suppose you have two C-kernel files containing data for the */
+/* Voyager 2 narrow angle camera. One file contains predict values, */
+/* and the other contains corrected pointing for a selected group */
+/* of images, that is, for a subset of images from the first file. */
+
+/* The following example program uses CKGP to get C-matrices for a */
+/* set of images whose SCLK counts (un-encoded character string */
+/* versions) are contained in the array SCLKCH. */
+
+/* If available, the program will get the corrected pointing values. */
+/* Otherwise, predict values will be used. */
+
+/* For each C-matrix, a unit pointing vector is constructed */
+/* and printed. */
+
+
+/* C */
+/* C Constants for this program. */
+/* C */
+/* C -- The code for the Voyager 2 spacecraft clock is -32 */
+/* C */
+/* C -- The code for the narrow angle camera on the Voyager 2 */
+/* C spacecraft is -32001. */
+/* C */
+/* C -- Spacecraft clock times for successive Voyager images */
+/* C always differ by more than 0:0:400. This is an */
+/* C acceptable tolerance, and must be converted to "ticks" */
+/* C (units of encoded SCLK) for input to CKGP. */
+/* C */
+/* C -- The reference frame we want is FK4. */
+/* C */
+/* C -- The narrow angle camera boresight defines the third */
+/* C axis of the instrument-fixed coordinate system. */
+/* C Therefore, the vector ( 0, 0, 1 ) represents */
+/* C the boresight direction in the camera-fixed frame. */
+/* C */
+/* IMPLICIT NONE */
+
+/* INTEGER FILEN */
+/* PARAMETER ( FILEN = 255 ) */
+
+/* INTEGER NPICS */
+/* PARAMETER ( NPICS = 2 ) */
+
+/* INTEGER TIMLEN */
+/* PARAMETER ( TIMLEN = 30 ) */
+
+/* INTEGER REFLEN */
+/* PARAMETER ( REFLEN = 32 ) */
+
+/* CHARACTER*(TIMLEN) CLKCH */
+/* CHARACTER*(FILEN) CKPRED */
+/* CHARACTER*(FILEN) CKCORR */
+/* CHARACTER*(REFLEN) REF */
+/* CHARACTER*(FILEN) SCLK */
+/* CHARACTER*(TIMLEN) SCLKCH ( NPICS ) */
+/* CHARACTER*(TIMLEN) TOLVGR */
+
+/* DOUBLE PRECISION CLKOUT */
+/* DOUBLE PRECISION CMAT ( 3, 3 ) */
+/* DOUBLE PRECISION SCLKDP */
+/* DOUBLE PRECISION TOLTIK */
+/* DOUBLE PRECISION VCFIX ( 3 ) */
+/* DOUBLE PRECISION VINERT ( 3 ) */
+
+/* INTEGER SC */
+/* INTEGER I */
+/* INTEGER INST */
+
+/* LOGICAL FOUND */
+
+/* CKPRED = 'voyager2_predict.bc' */
+/* CKCORR = 'voyager2_corrected.bc' */
+/* SCLK = 'voyager2_sclk.tsc' */
+/* SC = -32 */
+/* INST = -32001 */
+/* SCLKCH(1) = '4/08966:30:768' */
+/* SCLKCH(2) = '4/08970:58:768' */
+/* TOLVGR = '0:0:400' */
+/* REF = 'FK4' */
+/* VCFIX( 1 ) = 0.D0 */
+/* VCFIX( 2 ) = 0.D0 */
+/* VCFIX( 3 ) = 1.D0 */
+
+/* C */
+/* C Loading the files in this order ensures that the */
+/* C corrected file will get searched first. */
+/* C */
+/* CALL FURNSH ( CKPRED ) */
+/* CALL FURNSH ( CKCORR ) */
+
+/* C */
+/* C Need to load a Voyager 2 SCLK kernel to convert from */
+/* C clock strings to ticks. */
+/* C */
+/* CALL FURNSH ( SCLK ) */
+
+/* C */
+/* C Convert tolerance from VGR formatted character string */
+/* C SCLK to ticks which are units of encoded SCLK. */
+/* C */
+/* CALL SCTIKS ( SC, TOLVGR, TOLTIK ) */
+
+
+/* DO I = 1, NPICS */
+/* C */
+/* C CKGP requires encoded spacecraft clock. */
+/* C */
+/* CALL SCENCD ( SC, SCLKCH( I ), SCLKDP ) */
+
+/* CALL CKGP ( INST, SCLKDP, TOLTIK, REF, CMAT, */
+/* . CLKOUT, FOUND ) */
+
+/* IF ( FOUND ) THEN */
+
+/* C */
+/* C Use the transpose of the C-matrix to transform the */
+/* C boresight vector from camera-fixed to reference */
+/* C coordinates. */
+/* C */
+/* CALL MTXV ( CMAT, VCFIX, VINERT ) */
+/* CALL SCDECD ( SC, CLKOUT, CLKCH ) */
+
+/* WRITE (*,*) 'VGR 2 SCLK Time: ', CLKCH */
+/* WRITE (*,*) 'VGR 2 NA ISS boresight ' */
+/* . // 'pointing vector: ', VINERT */
+
+/* ELSE */
+
+/* WRITE (*,*) 'Pointing not found for time ', SCLKCH(I) */
+
+/* END IF */
+
+/* END DO */
+
+/* END */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* C.H. Acton (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* J.M. Lynch (JPL) */
+/* B.V. Semenov (JPL) */
+/* M.J. Spencer (JPL) */
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 5.3.1, 09-JUN-2010 (BVS) */
+
+/* Header update: description of the tolerance and Particulars */
+/* section were expanded to address some problems arising from */
+/* using a non-zero tolerance. */
+
+/* - SPICELIB Version 5.3.0, 23-APR-2010 (NJB) */
+
+/* Bug fix: this routine now obtains the rotation */
+/* from the request frame to the applicable CK segment's */
+/* base frame via a call to REFCHG. Formerly the routine */
+/* used FRMCHG, which required that angular velocity data */
+/* be available for this transformation. */
+
+/* - SPICELIB Version 5.2.0, 25-AUG-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in MXM call. */
+
+/* - SPICELIB Version 5.1.2, 29-JAN-2004 (NJB) */
+
+/* Header update: description of input argument REF was */
+/* expanded. */
+
+/* - SPICELIB Version 5.1.1, 27-JUL-2003 (CHA) (NJB) */
+
+/* Various header corrections were made. */
+
+/* - SPICELIB Version 3.2.0, 23-FEB-1999 (WLT) */
+
+/* The previous editions of this routine did not properly handle */
+/* the case when TOL was negative. The routine now returns a */
+/* value of .FALSE. for FOUND as is advertised above. */
+
+/* - SPICELIB Version 3.1.0, 13-APR-1998 (WLT) */
+
+/* The call to CHKOUT in the case when FAILED returned the */
+/* value TRUE used to check out with the name 'CKGPAV'. This */
+/* has been changed to a CKGP. */
+
+/* - SPICELIB Version 3.0.0, 19-SEP-1994 (WLT) */
+
+/* The routine was upgraded to support non-inertial frames. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 30-AUG-1991 (JML) */
+
+/* The Particulars section was updated to show how the */
+/* search algorithm processes segments with continuous */
+/* pointing data. */
+
+/* The example program now loads an SCLK kernel. */
+
+/* FAILED is checked after the call to IRFROT to handle the */
+/* case where the reference frame is invalid and the error */
+/* handling is not set to abort. */
+
+/* FAILED is checked in the DO WHILE loop to handle the case */
+/* where an error is detected by a SPICELIB routine inside the */
+/* loop and the error handling is not set to abort. */
+
+/* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
+
+/* The restriction that a C-kernel file must be loaded */
+/* was explicitly stated. */
+
+
+/* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get ck pointing */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 5.2.0, 25-AUG-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in MXM call. */
+
+/* - SPICELIB Version 3.1.0, 20-DEC-1995 (WLT) */
+
+/* A call to FRINFO did not have enough arguments and */
+/* went undetected until Howard Taylor of ACT. Many */
+/* thanks go out to Howard for tracking down this error. */
+
+/* - SPICELIB Version 3.0.0, 19-SEP-1994 (WLT) */
+
+/* The routine was upgraded to support non-inertial frames. */
+
+/* Calls to NAMIRF and IRFROT were replaced with calls to */
+/* NAMFRM and FRMCHG respectively. */
+
+
+/* - SPICELIB Version 1.0.2, 30-AUG-1991 (JML) */
+
+/* 1) The Particulars section was updated to show how the */
+/* search algorithm processes segments with continuous */
+/* pointing data. */
+
+/* 2) The example program now loads an SCLK kernel. */
+
+/* 3) FAILED is checked after the call to IRFROT to handle the */
+/* case where the reference frame is invalid and the error */
+/* handling is not set to abort. */
+
+/* 4) FAILED is checked in the DO WHILE loop to handle the case */
+/* where an error is detected by a SPICELIB routine inside the */
+/* loop and the error handling is not set to abort. */
+
+/* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
+
+/* 1) The restriction that a C-kernel file must be loaded */
+/* was explicitly stated. */
+/* 2) Minor changes were made to the wording of the header. */
+
+
+/* - Beta Version 1.1.0, 29-AUG-1990 (MJS) */
+
+/* The following changes were made as a result of the */
+/* NAIF CK Code and Documentation Review: */
+
+/* 1) The variable SCLK was changed to SCLKDP. */
+/* 2) The variable INSTR was changed to INST. */
+/* 3) The variable IDENT was changed to SEGID. */
+/* 4) The declarations for the parameters NDC, NIC, NC, and */
+/* IDLEN were moved from the "Declarations" section of the */
+/* header to the "Local parameters" section of the code below */
+/* the header. These parameters are not meant to modified by */
+/* users. */
+/* 5) The header was updated to reflect the changes. */
+
+/* - Beta Version 1.0.0, 04-MAY-1990 (RET) (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel segment descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel segment descriptor. */
+
+/* NC is the number of components in a packed C-kernel */
+/* descriptor. All DAF summaries have this formulaic */
+/* relationship between the number of its integer and */
+/* double precision components and the number of packed */
+/* components. */
+
+/* IDLEN is the length of the C-kernel segment identifier. */
+/* All DAF names have this formulaic relationship */
+/* between the number of summary components and */
+/* the length of the name (You will notice that */
+/* a name and a summary have the same length in bytes.) */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKGP", (ftnlen)4);
+ }
+
+/* Don't need angular velocity data. */
+/* Assume the segment won't be found until it really is. */
+
+ needav = FALSE_;
+ *found = FALSE_;
+
+/* If the tolerance is less than zero, we go no further. */
+
+ if (*tol < 0.) {
+ chkout_("CKGP", (ftnlen)4);
+ return 0;
+ }
+
+/* Begin a search for this instrument and time, and get the first */
+/* applicable segment. */
+
+ ckbss_(inst, sclkdp, tol, &needav);
+ cksns_(&handle, descr, segid, &sfnd, (ftnlen)40);
+
+/* Keep trying candidate segments until a segment can produce a */
+/* pointing instance within the specified time tolerance of the */
+/* input time. */
+
+/* Check FAILED to prevent an infinite loop if an error is detected */
+/* by a SPICELIB routine and the error handling is not set to abort. */
+
+ while(sfnd && ! failed_()) {
+ ckpfs_(&handle, descr, sclkdp, tol, &needav, cmat, av, clkout, &pfnd);
+ if (pfnd) {
+
+/* Found one. If the C-matrix doesn't already rotate from the */
+/* requested frame, convert it to one that does. */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ refseg = icd[1];
+
+/* Look up the id code for the requested reference frame. */
+
+ namfrm_(ref, &refreq, ref_len);
+ if (refreq != refseg) {
+
+/* We may need to convert the output ticks CLKOUT to ET */
+/* so that we can get the needed state transformation */
+/* matrix. This is the case if either of the frames */
+/* is non-inertial. */
+
+ frinfo_(&refreq, ¢er, &type1, &typeid, &gotit);
+ frinfo_(&refseg, ¢er, &type2, &typeid, &gotit);
+ if (type1 == 1 && type2 == 1) {
+
+/* Any old value of ET will do in this case. We'll */
+/* use zero. */
+
+ et = 0.;
+ } else {
+
+/* Look up the spacecraft clock id to use to convert */
+/* the output CLKOUT to ET. */
+
+ ckmeta_(inst, "SCLK", &sclk, (ftnlen)4);
+ sct2e_(&sclk, clkout, &et);
+ }
+
+/* Get the transformation from the requested frame to */
+/* the segment frame at ET. */
+
+ refchg_(&refreq, &refseg, &et, rot);
+
+/* If REFCHG detects that the reference frame is invalid */
+/* then return from this routine with FOUND equal to false. */
+
+ if (failed_()) {
+ chkout_("CKGP", (ftnlen)4);
+ return 0;
+ }
+
+/* Transform the attitude information: convert CMAT so that */
+/* it maps from request frame to C-matrix frame. */
+
+ mxm_(cmat, rot, tmpmat);
+ moved_(tmpmat, &c__9, cmat);
+ }
+ *found = TRUE_;
+ chkout_("CKGP", (ftnlen)4);
+ return 0;
+ }
+ cksns_(&handle, descr, segid, &sfnd, (ftnlen)40);
+ }
+ chkout_("CKGP", (ftnlen)4);
+ return 0;
+} /* ckgp_ */
+
diff --git a/ext/spice/src/cspice/ckgp_c.c b/ext/spice/src/cspice/ckgp_c.c
new file mode 100644
index 0000000000..24f984644f
--- /dev/null
+++ b/ext/spice/src/cspice/ckgp_c.c
@@ -0,0 +1,721 @@
+/*
+
+-Procedure ckgp_c ( C-kernel, get pointing )
+
+-Abstract
+
+ Get pointing (attitude) for a specified spacecraft clock time.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CK
+ SCLK
+
+-Keywords
+
+ POINTING
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+ void ckgp_c ( SpiceInt inst,
+ SpiceDouble sclkdp,
+ SpiceDouble tol,
+ ConstSpiceChar * ref,
+ SpiceDouble cmat[3][3],
+ SpiceDouble * clkout,
+ SpiceBoolean * found )
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ inst I NAIF ID of instrument, spacecraft, or structure.
+ sclkdp I Encoded spacecraft clock time.
+ tol I Time tolerance.
+ ref I Reference frame.
+ cmat O C-matrix pointing data.
+ clkout O Output encoded spacecraft clock time.
+ found O True when requested pointing is available.
+
+-Detailed_Input
+
+ inst is the NAIF integer ID for the instrument, spacecraft, or
+ other structure for which pointing is being requested.
+ For brevity we will refer to this object as the
+ "instrument," and the frame fixed to this object as the
+ "instrument frame" or "instrument-fixed" frame.
+
+ sclkdp is the encoded spacecraft clock time for which
+ pointing is being requested.
+
+ The CSPICE routines scencd_c and sce2c_c respectively
+ convert spacecraft clock strings and ephemeris time
+ to encoded spacecraft clock. The inverse conversions
+ are performed by scdecd_c and sct2e_c.
+
+ tol is a time tolerance in ticks, the units of encoded
+ spacecraft clock time.
+
+ The CSPICE routine sctiks_c converts a spacecraft clock
+ tolerance duration from its character string
+ representation to ticks. scfmt_c performs the inverse
+ conversion.
+
+ The C-matrix returned by ckgp_c is the one whose time tag
+ is closest to `sclkdp' and within `tol' units of
+ `sclkdp'. (More in Particulars, below.)
+
+ In general, because using a non-zero tolerance
+ affects selection of the segment from which the
+ data is obtained, users are strongly discouraged
+ from using a non-zero tolerance when reading CKs
+ with continuous data. Using a non-zero tolerance
+ should be reserved exclusively to reading CKs with
+ discrete data because in practice obtaining data
+ from such CKs using a zero tolerance is often not
+ possible due to time round off.
+
+ ref is the desired reference frame for the returned pointing.
+ The returned C-matrix `cmat' gives the orientation of the
+ instrument designated by `inst' relative to the frame
+ designated by `ref'. When a vector specified relative to
+ frame `ref' is left-multiplied by `cmat', the vector is
+ rotated to the frame associated with `inst'. See the
+ discussion of `cmat' below for details.
+
+ Consult the SPICE document "Frames" for a discussion
+ of supported reference frames.
+
+-Detailed_Output
+
+ cmat is a rotation matrix that transforms the components of a
+ vector expressed in the frame specified by `ref' to
+ components expressed in the frame tied to the instrument,
+ spacecraft, or other structure at time `clkout' (see
+ below).
+
+ Thus, if a vector v has components x,y,z in the `ref'
+ reference frame, then v has components x',y',z' in the
+ instrument fixed frame at time `clkout':
+
+ [ x' ] [ ] [ x ]
+ | y' | = | cmat | | y |
+ [ z' ] [ ] [ z ]
+
+ If you know x', y', z', use the transpose of the
+ C-matrix to determine x, y, z as follows:
+
+ [ x ] [ ]T [ x' ]
+ | y | = | cmat | | y' |
+ [ z ] [ ] [ z' ]
+ (Transpose of cmat)
+
+
+ clkout is the encoded spacecraft clock time associated with
+ the returned C-matrix. This value may differ from the
+ requested time, but never by more than the input
+ tolerance `tol'.
+
+ The particulars section below describes the search
+ algorithm used by ckgp_c to satisfy a pointing request.
+ This algorithm determines the pointing instance
+ (and therefore the associated time value) that is
+ returned.
+
+ found is SPICETRUE if a record was found to satisfy the
+ pointing request. `found' will be SPICEFALSE otherwise.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If a C-kernel file has not been loaded using furnsh_c prior to a
+ call to this routine, an error is signaled by a routine in the
+ call tree of this routine.
+
+ 2) If `tol' is negative, found is set to SPICEFALSE.
+
+ 3) If `ref' is not a supported reference frame, an error is
+ signaled by a routine in the call tree of this routine and
+ `found' is set to SPICEFALSE.
+
+-Files
+
+ ckgp_c searches through files loaded by furnsh_c to locate a segment
+ that satisfies the request for pointing for the instrument `inst' at
+ time `sclkdp'. You must load at least one C-kernel file via furnsh_c
+ prior to calling this routine.
+
+-Particulars
+
+ How the tolerance argument is used
+ ==================================
+
+
+ Reading a type 1 CK segment (discrete pointing instances)
+ ---------------------------------------------------------
+
+ In the diagram below
+
+ - "0" is used to represent discrete pointing instances
+ (quaternions and associated time tags).
+
+ - "( )" are used to represent the end points of the time
+ interval covered by a segment in a CK file.
+
+ - `sclkdp' is the time at which you requested pointing.
+ The location of `sclkdp' relative to the time tags of the
+ pointing instances is indicated by the "+" sign.
+
+ - `tol' is the time tolerance specified in the pointing
+ request. The square brackets "[ ]" represent the
+ endpoints of the time interval
+
+ sclkdp-tol : sclkdp+tol
+
+ - The quaternions occurring in the segment need not be
+ evenly spaced in time.
+
+
+ Case 1: pointing is available
+ ------------------------------
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ Segment (0-----0--0--0--0--0--0---0--0------------0--0--0--0)
+ ^
+ |
+ ckgp_c returns this instance.
+
+
+ Case 2: pointing is not available
+ ----------------------------------
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ Segment (0-----0--0--0--0--0--0---0--0--0---------0--0--0--0)
+
+
+ ckgp_c returns no pointing; the output
+ `found' flag is set to SPICEFALSE.
+
+
+
+ Reading a type 2, 3, 4, or 5 CK segment (continuous pointing)
+ -------------------------------------------------------------
+
+ In the diagrams below
+
+ - "==" is used to represent periods of continuous pointing.
+
+ - "--" is used to represent gaps in the pointing coverage.
+
+ - "( )" are used to represent the end points of the time
+ interval covered by a segment in a CK file.
+
+ - `sclkdp' is the time at which you requested pointing.
+ The location of `sclkdp' relative to the time tags of the
+ pointing instances is indicated by the "+" sign.
+
+ - `tol' is the time tolerance specified in the pointing
+ request. The square brackets "[ ]" represent the
+ endpoints of the time interval
+
+ sclkdp-tol : sclkdp+tol
+
+ - The quaternions occurring in the periods of continuous
+ pointing need not be evenly spaced in time.
+
+
+ Case 1: pointing is available at the request time
+ --------------------------------------------------
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ . . .
+ . . .
+ Segment (==---===========---=======----------===--)
+ ^
+ |
+
+ The request time lies within an interval where
+ continuous pointing is available. ckgp_c returns
+ pointing at the requested epoch.
+
+
+ Case 2: pointing is available "near" the request time
+ ------------------------------------------------------
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ Segment (==---===========----=======---------===--)
+ ^
+ |
+
+ The request time lies in a gap: an interval where
+ continuous pointing is *not* available. ckgp_c
+ returns pointing for the epoch closest to the
+ request time `sclkdp'.
+
+
+ Case 3: pointing is not available
+ ----------------------------------
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ Segment (==---===========----=======---------===--)
+
+ ckgp_c returns no pointing; the output
+ `found' flag is set to SPICEFALSE.
+
+
+
+ Tolerance and segment priority
+ ==============================
+
+ ckgp_c searches through loaded C-kernels to satisfy a pointing
+ request. Last-loaded files are searched first. Individual files are
+ searched in backwards order, so that between competing segments
+ (segments containing data for the same object, for overlapping time
+ ranges), the one closest to the end of the file has highest
+ priority.
+
+ The search ends when a segment is found that can provide pointing
+ for the specified instrument at a time falling within the specified
+ tolerance on either side of the request time. Within that segment,
+ the instance closest to the input time is located and returned.
+
+ The following four cases illustrate this search procedure. Segments
+ A and B are in the same file, with segment A located further
+ towards the end of the file than segment B. Both segments A and B
+ contain discrete pointing data, indicated by the number 0.
+
+
+ Case 1: Pointing is available in the first segment searched.
+ Because segment A has the highest priority and can
+ satisfy the request, segment B is not searched.
+
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ Segment A (0-----------------0--------0--0-----0)
+ ^
+ |
+ |
+ ckgp_c returns this instance
+
+ Segment B (0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0)
+
+
+
+ Case 2: Pointing is not available in the first segment searched.
+ Because segment A cannot satisfy the request, segment B
+ is searched.
+
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ Segment A (0-----------------0--------0--0-----0)
+ . . .
+ Segment B (0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0)
+ ^
+ |
+ ckgp_c returns this instance
+
+
+ Segments that contain continuous pointing data are searched in the
+ same manner as segments containing discrete pointing data. For
+ request times that fall within the bounds of continuous intervals,
+ ckgp_c will return pointing at the request time. When the request
+ time does not fall within an interval, then a time at an endpoint of
+ an interval may be returned if it is the closest time in the segment
+ to the user request time and is also within the tolerance.
+
+ In the following examples, segment A is located further towards the
+ end of the file than segment C. Segment A contains discrete pointing
+ data and segment C contains continuous data, indicated by the "="
+ character.
+
+
+ Case 3: Pointing is not available in the first segment searched.
+ Because segment A cannot satisfy the request, segment C
+ is searched.
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ . . .
+ Segment A (0-----------------0--------0--0-----0)
+ . . .
+ . . .
+ Segment C (---=============-----====--------==--)
+ ^
+ |
+ |
+ ckgp_c returns this instance
+
+
+ In the next case, assume that the order of segments A and C in the
+ file is reversed: A is now closer to the front, so data from
+ segment C are considered first.
+
+
+ Case 4: Pointing is available in the first segment searched.
+ Because segment C has the highest priority and can
+ satisfy the request, segment A is not searched.
+
+ sclkdp
+ /
+ | tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ . . .
+ Segment C (---=============-----====--------==--)
+ ^
+ |
+ ckgp_c returns this instance
+
+ Segment A (0-----------------0--------0--0-----0)
+ ^
+ |
+ "Best" answer
+
+
+ The next case illustrates an unfortunate side effect of using
+ a non-zero tolerance when reading multi-segment CKs with
+ continuous data. In all cases when the look-up interval
+ formed using tolerance overlaps a segment boundary and
+ the request time falls within the coverage of the lower
+ priority segment, the data at the end of the higher priority
+ segment will be picked instead of the data from the lower
+ priority segment.
+
+
+ Case 5: Pointing is available in the first segment searched.
+ Because segment C has the highest priority and can
+ satisfy the request, segment A is not searched.
+
+ sclkdp
+ /
+ | tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ . . .
+ Segment C (===============)
+ ^
+ |
+ ckgp_c returns this instance
+
+ Segment A (=====================)
+ ^
+ |
+ "Best" answer
+
+
+-Examples
+
+
+ Suppose you have two C-kernel files containing pointing for the
+ Voyager 2 narrow angle camera. One file contains predict (planned)
+ values, and the other contains corrected pointing for a selected
+ group of images, that is, for a subset of images from the first
+ file.
+
+ The following example program uses ckgp_c to get C-matrices for a
+ set of images whose SCLK counts (un-encoded character string
+ versions) are contained in the array `sclkch'.
+
+ If available, the program will get the corrected pointing values.
+ Otherwise, predict values will be used.
+
+ For each C-matrix, a unit pointing vector is constructed and
+ printed.
+
+ #include
+ #include "SpiceUsr.h"
+
+ int main ()
+ {
+ /.
+ Constants for this program:
+
+ -- The code for the Voyager 2 spacecraft clock is -32
+
+ -- The code for the narrow angle camera on the Voyager 2
+ spacecraft is -32001.
+
+ -- Spacecraft clock times for successive Voyager images always
+ differ by more than 0:0:400. This is an acceptable
+ tolerance, and must be converted to "ticks" (units of
+ encoded SCLK) for input to ckgp_c.
+
+ -- The reference frame we want is FK4.
+
+ -- The narrow angle camera boresight defines the third
+ axis of the instrument-fixed reference frame.
+ Therefore, the vector ( 0, 0, 1 ) represents
+ the boresight direction in the camera-fixed frame.
+ ./
+
+ #define SC -32
+ #define INST -32001
+ #define REF "FK4"
+ #define TOLVGR "0:0:400"
+ #define NPICS 2
+ #define MAXCLK 30
+ #define CKPRED "voyager2_predict.bc"
+ #define CKCORR "voyager2_corrected.bc"
+ #define SCLK "voyager2_sclk.tsc"
+
+
+ SpiceBoolean found;
+
+ SpiceChar sclkch [NPICS][MAXCLK] =
+
+ { { "4/08966:30:768" },
+ { "4/08970:58:768" } };
+
+ SpiceChar clkch [MAXCLK];
+
+ SpiceDouble cmat [3][3];
+ SpiceDouble clkout;
+ SpiceDouble sclkdp;
+ SpiceDouble toltik;
+ SpiceDouble vinert [3];
+
+ SpiceInt i;
+
+
+ /.
+ Loading the files in this order ensures that the
+ corrected file will get searched first.
+ ./
+ furnsh_c ( CKPRED );
+ furnsh_c ( CKCORR );
+
+ /.
+ Need to load a Voyager 2 SCLK kernel to convert from
+ clock string to ticks. Although not required for
+ the Voyager spacecraft clocks, most modern spacecraft
+ clocks require a leapseconds kernel to be loaded in
+ addition to an SCLK kernel.
+ ./
+ furnsh_c ( SCLK );
+
+ /.
+ Convert tolerance from VGR formatted character string
+ SCLK to ticks, which are units of encoded SCLK.
+ ./
+ sctiks_c ( SC, TOLVGR, &toltik );
+
+ for ( i = 0; i < NPICS; i++ )
+ {
+
+ /.
+ ckgp_c requires encoded spacecraft clock time.
+ ./
+ scencd_c ( SC, sclkch[ i ], &sclkdp );
+
+ ckgp_c ( INST, sclkdp, toltik, REF,
+ cmat, &clkout, &found );
+
+ if ( found )
+ {
+ /.
+ The boresight vector, relative to inertial coordinates,
+ is just the third row of the C-matrix.
+ ./
+ vequ_c ( cmat[2], vinert );
+
+ scdecd_c ( SC, clkout, MAXCLK, clkch );
+
+
+ printf ( "VGR 2 SCLK time: %s\n", clkch );
+
+ printf ( "VGR 2 NA ISS boresight pointing vector: "
+ "%f %f %f\n",
+ vinert[0],
+ vinert[1],
+ vinert[2] );
+ }
+ else
+ {
+ printf ( "Pointing not found for time %s\n", sclkch[i] );
+ }
+
+ }
+
+ return ( 0 );
+ }
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ C.H. Acton (JPL)
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ J.M. Lynch (JPL)
+ B.V. Semenov (JPL)
+ M.J. Spencer (JPL)
+ R.E. Thurman (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.2.3, 03-JUN-2010 (BVS)
+
+ Header update: description of the tolerance and Particulars
+ section were expanded to address some problems arising from
+ using a non-zero tolerance.
+
+ -CSPICE Version 1.2.2, 29-JAN-2004 (NJB)
+
+ Header update: description of input argument `ref' was
+ expanded.
+
+ -CSPICE Version 1.2.1, 27-JUL-2003 (CHA) (NJB)
+
+ Various header corrections were made.
+
+ -CSPICE Version 1.2.0, 02-SEP-1999 (NJB)
+
+ Local type logical variable now used for found flag used in
+ interface of ckgp_.
+
+ -CSPICE Version 1.1.0, 08-FEB-1998 (NJB)
+
+ References to C2F_CreateStr_Sig were removed; code was
+ cleaned up accordingly. String checks are now done using
+ the macro CHKFSTR.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB)
+
+ Based on SPICELIB Version 3.0.0, 19-SEP-1994 (WLT)
+
+-Index_Entries
+
+ get ck pointing
+
+-&
+*/
+
+{ /* Begin ckgp_c */
+
+
+ /*
+ Local variables
+ */
+ logical fnd;
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "ckgp_c");
+
+ /*
+ Check the input string ref to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "ckgp_c", ref );
+
+
+ ckgp_( ( integer * ) &inst,
+ ( doublereal * ) &sclkdp,
+ ( doublereal * ) &tol,
+ ( char * ) ref,
+ ( doublereal * ) cmat,
+ ( doublereal * ) clkout,
+ ( logical * ) &fnd,
+ ( ftnlen ) strlen(ref) );
+
+ /*
+ Assign the SpiceBoolean found flag.
+ */
+
+ *found = fnd;
+
+
+ /*
+ Transpose the C-matrix on output.
+ */
+ xpose_c ( cmat, cmat );
+
+
+ chkout_c ( "ckgp_c" );
+
+} /* End ckgp_c */
diff --git a/ext/spice/src/cspice/ckgpav.c b/ext/spice/src/cspice/ckgpav.c
new file mode 100644
index 0000000000..1ee8790c58
--- /dev/null
+++ b/ext/spice/src/cspice/ckgpav.c
@@ -0,0 +1,1208 @@
+/* ckgpav.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+static integer c__9 = 9;
+
+/* $Procedure CKGPAV ( C-kernel, get pointing and angular velocity ) */
+/* Subroutine */ int ckgpav_(integer *inst, doublereal *sclkdp, doublereal *
+ tol, char *ref, doublereal *cmat, doublereal *av, doublereal *clkout,
+ logical *found, ftnlen ref_len)
+{
+ extern /* Subroutine */ int vadd_(doublereal *, doublereal *, doublereal *
+ );
+ logical pfnd, sfnd;
+ integer sclk;
+ doublereal tmpv[3];
+ extern /* Subroutine */ int mtxv_(doublereal *, doublereal *, doublereal *
+ ), sct2e_(integer *, doublereal *, doublereal *);
+ integer type1, type2;
+ doublereal omega[3];
+ char segid[40];
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ doublereal descr[5];
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *), ckbss_(integer *, doublereal *,
+ doublereal *, logical *), ckpfs_(integer *, doublereal *,
+ doublereal *, doublereal *, logical *, doublereal *, doublereal *,
+ doublereal *, logical *), moved_(doublereal *, integer *,
+ doublereal *), cksns_(integer *, doublereal *, char *, logical *,
+ ftnlen);
+ logical gotit;
+ doublereal xform[36] /* was [6][6] */;
+ extern /* Subroutine */ int xf2rav_(doublereal *, doublereal *,
+ doublereal *);
+ extern logical failed_(void);
+ doublereal et;
+ integer handle;
+ logical needav;
+ extern /* Subroutine */ int ckmeta_(integer *, char *, integer *, ftnlen),
+ frmchg_(integer *, integer *, doublereal *, doublereal *);
+ integer refseg, center;
+ extern /* Subroutine */ int namfrm_(char *, integer *, ftnlen), frinfo_(
+ integer *, integer *, integer *, integer *, logical *);
+ integer refreq, typeid;
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ doublereal tmpmat[9] /* was [3][3] */;
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+ extern /* Subroutine */ int mxm_(doublereal *, doublereal *, doublereal *)
+ ;
+ doublereal rot[9] /* was [3][3] */;
+
+/* $ Abstract */
+
+/* Get pointing (attitude) and angular velocity for a specified */
+/* spacecraft clock time. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* SCLK */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* The parameters below form an enumerated list of the recognized */
+/* frame types. They are: INERTL, PCK, CK, TK, DYN. The meanings */
+/* are outlined below. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Parameters */
+
+/* INERTL an inertial frame that is listed in the routine */
+/* CHGIRF and that requires no external file to */
+/* compute the transformation from or to any other */
+/* inertial frame. */
+
+/* PCK is a frame that is specified relative to some */
+/* INERTL frame and that has an IAU model that */
+/* may be retrieved from the PCK system via a call */
+/* to the routine TISBOD. */
+
+/* CK is a frame defined by a C-kernel. */
+
+/* TK is a "text kernel" frame. These frames are offset */
+/* from their associated "relative" frames by a */
+/* constant rotation. */
+
+/* DYN is a "dynamic" frame. These currently are */
+/* parameterized, built-in frames where the full frame */
+/* definition depends on parameters supplied via a */
+/* frame kernel. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 28-MAY-2004 (NJB) */
+
+/* The parameter DYN was added to support the dynamic frame class. */
+
+/* - SPICELIB Version 2.0.0, 12-DEC-1996 (WLT) */
+
+/* Various unused frames types were removed and the */
+/* frame time TK was added. */
+
+/* - SPICELIB Version 1.0.0, 10-DEC-1995 (WLT) */
+
+/* -& */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* INST I NAIF ID of instrument, spacecraft, or structure. */
+/* SCLKDP I Encoded spacecraft clock time. */
+/* TOL I Time tolerance. */
+/* REF I Reference frame. */
+/* CMAT O C-matrix pointing data. */
+/* AV O Angular velocity vector. */
+/* CLKOUT O Output encoded spacecraft clock time. */
+/* FOUND O True when requested pointing is available. */
+
+/* $ Detailed_Input */
+
+/* INST is the NAIF integer ID for the instrument, spacecraft, */
+/* or other structure for which pointing and angular */
+/* velocity are requested. For brevity we will refer to */
+/* this object as the "instrument," and the frame fixed */
+/* to this object as the "instrument frame" or */
+/* "instrument-fixed" frame. */
+
+/* SCLKDP is the encoded spacecraft clock time for which */
+/* pointing and angular velocity are requested. */
+
+/* The SPICELIB routines SCENCD and SCE2C respectively */
+/* convert spacecraft clock strings and ephemeris time to */
+/* encoded spacecraft clock. The inverse conversions are */
+/* performed by SCDECD and SCT2E. */
+
+/* TOL is a time tolerance in ticks, the units of encoded */
+/* spacecraft clock time. */
+
+/* The SPICELIB routine SCTIKS converts a spacecraft */
+/* clock tolerance duration from its character string */
+/* representation to ticks. SCFMT performs the inverse */
+/* conversion. */
+
+/* The C-matrix - angular velocity vector pair returned by */
+/* CKGPAV is the one whose time tag is closest to SCLKDP */
+/* and within TOL units of SCLKDP. (More in Particulars, */
+/* below.) */
+
+/* In general, because using a non-zero tolerance */
+/* affects selection of the segment from which the */
+/* data is obtained, users are strongly discouraged */
+/* from using a non-zero tolerance when reading CKs */
+/* with continuous data. Using a non-zero tolerance */
+/* should be reserved exclusively to reading CKs with */
+/* discrete data because in practice obtaining data */
+/* from such CKs using a zero tolerance is often not */
+/* possible due to time round off. */
+
+/* REF is the desired reference frame for the returned */
+/* pointing and angular velocity. The returned C-matrix */
+/* CMAT gives the orientation of the instrument */
+/* designated by INST relative to the frame designated by */
+/* REF. When a vector specified relative to frame REF is */
+/* left-multiplied by CMAT, the vector is rotated to the */
+/* frame associated with INST. The returned angular */
+/* velocity vector AV expresses the angular velocity of */
+/* the instrument designated by INST relative to the */
+/* frame designated by REF. See the discussion of CMAT */
+/* and AV below for details. */
+
+/* Consult the SPICE document "Frames" for a discussion */
+/* of supported reference frames. */
+
+/* $ Detailed_Output */
+
+/* CMAT is a rotation matrix that transforms the components of */
+/* a vector expressed in the reference frame specified by */
+/* REF to components expressed in the frame tied to the */
+/* instrument, spacecraft, or other structure at time */
+/* CLKOUT (see below). */
+
+/* Thus, if a vector v has components x,y,z in the REF */
+/* reference frame, then v has components x',y',z' in the */
+/* instrument fixed frame at time CLKOUT: */
+
+/* [ x' ] [ ] [ x ] */
+/* | y' | = | CMAT | | y | */
+/* [ z' ] [ ] [ z ] */
+
+/* If you know x', y', z', use the transpose of the */
+/* C-matrix to determine x, y, z as follows: */
+
+/* [ x ] [ ]T [ x' ] */
+/* | y | = | CMAT | | y' | */
+/* [ z ] [ ] [ z' ] */
+/* (Transpose of CMAT) */
+
+/* AV is the angular velocity vector. This is the axis about */
+/* which the reference frame tied to the instrument is */
+/* rotating in the right-handed sense at time CLKOUT. The */
+/* magnitude of AV is the magnitude of the instantaneous */
+/* velocity of the rotation, in radians per second. AV */
+/* is expressed relative to the frame designated by REF. */
+
+/* CLKOUT is the encoded spacecraft clock time associated with */
+/* the returned C-matrix and the returned angular */
+/* velocity vector. This value may differ from the */
+/* requested time, but never by more than the input */
+/* tolerance TOL. */
+
+/* The particulars section below describes the search */
+/* algorithm used by CKGPAV to satisfy a pointing */
+/* request. This algorithm determines the pointing */
+/* instance (and therefore the associated time value) */
+/* that is returned. */
+
+/* FOUND is true if a record was found to satisfy the pointing */
+/* request. FOUND will be false otherwise. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If a C-kernel file has not been loaded using FURNSH prior to */
+/* a call to this routine, an error is signaled by a routine in */
+/* the call tree of this routine. */
+
+/* 2) If TOL is negative, found is set to .FALSE. */
+
+/* 3) If REF is not a supported reference frame, an error is */
+/* signaled by a routine in the call tree of this routine and */
+/* FOUND is set to .FALSE. */
+
+/* $ Files */
+
+/* CKGPAV searches through files loaded by FURNSH to locate a */
+/* segment that can satisfy the request for pointing and angular */
+/* velocity for instrument INST at time SCLKDP. You must load a */
+/* C-kernel file using FURNSH prior to calling this routine. */
+
+/* $ Particulars */
+
+/* How the tolerance argument is used */
+/* ================================== */
+
+
+/* Reading a type 1 CK segment (discrete pointing instances) */
+/* --------------------------------------------------------- */
+
+/* In the diagram below */
+
+/* - "0" is used to represent discrete pointing instances */
+/* (quaternions, angular velocity vectors, and associated */
+/* time tags). */
+
+/* - "( )" are used to represent the end points of the time */
+/* interval covered by a segment in a CK file. */
+
+/* - SCLKDP is the time at which you requested pointing. */
+/* The location of SCLKDP relative to the time tags of the */
+/* pointing instances is indicated by the "+" sign. */
+
+/* - TOL is the time tolerance specified in the pointing */
+/* request. The square brackets "[ ]" represent the */
+/* endpoints of the time interval */
+
+/* SCLKDP-TOL : SCLKDP+TOL */
+
+/* - The quaternions occurring in the segment need not be */
+/* evenly spaced in time. */
+
+
+/* Case 1: pointing is available */
+/* ------------------------------ */
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* Segment (0-----0--0--0--0--0--0---0--0------------0--0--0--0) */
+/* ^ */
+/* | */
+/* CKGPAV returns this instance. */
+
+
+/* Case 2: pointing is not available */
+/* ---------------------------------- */
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* Segment (0-----0--0--0--0--0--0---0--0--0---------0--0--0--0) */
+
+
+/* CKGPAV returns no pointing; the output */
+/* FOUND flag is set to .FALSE. */
+
+
+
+/* Reading a type 2, 3, 4, or 5 CK segment (continuous pointing) */
+/* ------------------------------------------------------------- */
+
+/* In the diagrams below */
+
+/* - "==" is used to represent periods of continuous pointing. */
+
+/* - "--" is used to represent gaps in the pointing coverage. */
+
+/* - "( )" are used to represent the end points of the time */
+/* interval covered by a segment in a CK file. */
+
+/* - SCLKDP is the time at which you requested pointing. */
+/* The location of SCLKDP relative to the time tags of the */
+/* pointing instances is indicated by the "+" sign. */
+
+/* - TOL is the time tolerance specified in the pointing */
+/* request. The square brackets "[ ]" represent the */
+/* endpoints of the time interval */
+
+/* SCLKDP-TOL : SCLKDP+TOL */
+
+/* - The quaternions occurring in the periods of continuous */
+/* pointing need not be evenly spaced in time. */
+
+
+/* Case 1: pointing is available at the request time */
+/* -------------------------------------------------- */
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* . . . */
+/* . . . */
+/* Segment (==---===========---=======----------===--) */
+/* ^ */
+/* | */
+
+/* The request time lies within an interval where */
+/* continuous pointing is available. CKGPAV returns */
+/* pointing at the requested epoch. */
+
+
+/* Case 2: pointing is available "near" the request time */
+/* ------------------------------------------------------ */
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* Segment (==---===========----=======---------===--) */
+/* ^ */
+/* | */
+
+/* The request time lies in a gap: an interval where */
+/* continuous pointing is *not* available. CKGPAV */
+/* returns pointing for the epoch closest to the */
+/* request time SCLKDP. */
+
+
+/* Case 3: pointing is not available */
+/* ---------------------------------- */
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* Segment (==---===========----=======---------===--) */
+
+/* CKGPAV returns no pointing; the output */
+/* FOUND flag is set to .FALSE. */
+
+
+
+/* Tolerance and segment priority */
+/* ============================== */
+
+/* CKGPAV searches through loaded C-kernels to satisfy a pointing */
+/* request. Last-loaded files are searched first. Individual files */
+/* are searched in backwards order, so that between competing */
+/* segments (segments containing data for the same object, for */
+/* overlapping time ranges), the one closest to the end of the file */
+/* has highest priority. CKGPAV considers only those segments that */
+/* contain both pointing and angular velocity data, as indicated by */
+/* the segment descriptor. */
+
+/* The search ends when a segment is found that can provide pointing */
+/* and angular velocity for the specified instrument at a time */
+/* falling within the specified tolerance on either side of the */
+/* request time. Within that segment, the instance closest to the */
+/* input time is located and returned. */
+
+/* The following four cases illustrate this search procedure. */
+/* Segments A and B are in the same file, with segment A located */
+/* further towards the end of the file than segment B. Both segments */
+/* A and B contain discrete pointing data, indicated by the number */
+/* 0. */
+
+
+/* Case 1: Pointing is available in the first segment searched. */
+/* Because segment A has the highest priority and can */
+/* satisfy the request, segment B is not searched. */
+
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* Segment A (0-----------------0--------0--0-----0) */
+/* ^ */
+/* | */
+/* | */
+/* CKGPAV returns this instance */
+
+/* Segment B (0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0) */
+
+
+
+/* Case 2: Pointing is not available in the first segment searched. */
+/* Because segment A cannot satisfy the request, segment B */
+/* is searched. */
+
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* Segment A (0-----------------0--------0--0-----0) */
+/* . . . */
+/* Segment B (0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0) */
+/* ^ */
+/* | */
+/* CKGPAV returns this instance */
+
+
+/* Segments that contain continuous pointing data are searched in */
+/* the same manner as segments containing discrete pointing data. */
+/* For request times that fall within the bounds of continuous */
+/* intervals, CKGPAV will return pointing at the request time. When */
+/* the request time does not fall within an interval, then a time at */
+/* an endpoint of an interval may be returned if it is the closest */
+/* time in the segment to the user request time and is also within */
+/* the tolerance. */
+
+/* In the following examples, segment A is located further towards */
+/* the end of the file than segment C. Segment A contains discrete */
+/* pointing data and segment C contains continuous data, indicated */
+/* by the "=" character. */
+
+
+/* Case 3: Pointing is not available in the first segment searched. */
+/* Because segment A cannot satisfy the request, segment C */
+/* is searched. */
+
+/* SCLKDP */
+/* \ TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* . . . */
+/* Segment A (0-----------------0--------0--0-----0) */
+/* . . . */
+/* . . . */
+/* Segment C (---=============-----====--------==--) */
+/* ^ */
+/* | */
+/* | */
+/* CKGPAV returns this instance */
+
+
+/* In the next case, assume that the order of segments A and C in the */
+/* file is reversed: A is now closer to the front, so data from */
+/* segment C are considered first. */
+
+
+/* Case 4: Pointing is available in the first segment searched. */
+/* Because segment C has the highest priority and can */
+/* satisfy the request, segment A is not searched. */
+
+/* SCLKDP */
+/* / */
+/* | TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* . . . */
+/* Segment C (---=============-----====--------==--) */
+/* ^ */
+/* | */
+/* CKGPAV returns this instance */
+
+/* Segment A (0-----------------0--------0--0-----0) */
+/* ^ */
+/* | */
+/* "Best" answer */
+
+
+/* The next case illustrates an unfortunate side effect of using */
+/* a non-zero tolerance when reading multi-segment CKs with */
+/* continuous data. In all cases when the look-up interval */
+/* formed using tolerance overlaps a segment boundary and */
+/* the request time falls within the coverage of the lower */
+/* priority segment, the data at the end of the higher priority */
+/* segment will be picked instead of the data from the lower */
+/* priority segment. */
+
+
+/* Case 5: Pointing is available in the first segment searched. */
+/* Because segment C has the highest priority and can */
+/* satisfy the request, segment A is not searched. */
+
+/* SCLKDP */
+/* / */
+/* | TOL */
+/* | / */
+/* |/\ */
+/* Your request [--+--] */
+/* . . . */
+/* . . . */
+/* Segment C (===============) */
+/* ^ */
+/* | */
+/* CKGPAV returns this instance */
+
+/* Segment A (=====================) */
+/* ^ */
+/* | */
+/* "Best" answer */
+
+/* $ Examples */
+
+
+/* Suppose you have two C-kernel files containing data for the */
+/* Voyager 2 narrow angle camera. One file contains predict values, */
+/* and the other contains corrected pointing for a selected group */
+/* of images, that is, for a subset of images from the first file. */
+
+/* The following example program uses CKGPAV to get C-matrices and */
+/* associated angular velocity vectors for a set of images whose */
+/* SCLK counts (un-encoded character string versions) are contained */
+/* in the array SCLKCH. */
+
+/* If available, the program will get the corrected pointing values. */
+/* Otherwise, predict values will be used. */
+
+/* For each C-matrix, a unit pointing vector is constructed */
+/* and printed along with the angular velocity vector. */
+
+/* Note: if the C-kernels of interest do not contain angular */
+/* velocity data, then the SPICELIB routine CKGP should be used to */
+/* read the pointing data. An example program in the header of the */
+/* SPICELIB routine CKGP demonstrates this. */
+
+
+
+/* C */
+/* C Constants for this program. */
+/* C */
+/* C -- The code for the Voyager 2 spacecraft clock is -32 */
+/* C */
+/* C -- The code for the narrow angle camera on the Voyager 2 */
+/* C spacecraft is -32001. */
+/* C */
+/* C -- Spacecraft clock times for successive Voyager images */
+/* C always differ by more than 0:0:400. This is an */
+/* C acceptable tolerance, and must be converted to "ticks" */
+/* C (units of encoded SCLK) for input to CKGPAV. */
+/* C */
+/* C -- The reference frame we want is FK4. */
+/* C */
+/* C -- The narrow angle camera boresight defines the third */
+/* C axis of the instrument-fixed coordinate system. */
+/* C Therefore, the vector ( 0, 0, 1 ) represents */
+/* C the boresight direction in the camera-fixed frame. */
+/* C */
+/* IMPLICIT NONE */
+
+/* INTEGER FILEN */
+/* PARAMETER ( FILEN = 255 ) */
+
+/* INTEGER NPICS */
+/* PARAMETER ( NPICS = 2 ) */
+
+/* INTEGER TIMLEN */
+/* PARAMETER ( TIMLEN = 30 ) */
+
+/* INTEGER REFLEN */
+/* PARAMETER ( REFLEN = 32 ) */
+
+/* CHARACTER*(TIMLEN) CLKCH */
+/* CHARACTER*(FILEN) CKPRED */
+/* CHARACTER*(FILEN) CKCORR */
+/* CHARACTER*(REFLEN) REF */
+/* CHARACTER*(FILEN) SCLK */
+/* CHARACTER*(TIMLEN) SCLKCH ( NPICS ) */
+/* CHARACTER*(TIMLEN) TOLVGR */
+
+/* DOUBLE PRECISION AV ( 3 ) */
+/* DOUBLE PRECISION CLKOUT */
+/* DOUBLE PRECISION CMAT ( 3, 3 ) */
+/* DOUBLE PRECISION SCLKDP */
+/* DOUBLE PRECISION TOLTIK */
+/* DOUBLE PRECISION VCFIX ( 3 ) */
+/* DOUBLE PRECISION VINERT ( 3 ) */
+
+/* INTEGER SC */
+/* INTEGER I */
+/* INTEGER INST */
+
+/* LOGICAL FOUND */
+
+/* CKPRED = 'voyager2_predict.bc' */
+/* CKCORR = 'voyager2_corrected.bc' */
+/* SCLK = 'voyager2_sclk.tsc' */
+/* SC = -32 */
+/* INST = -32001 */
+/* SCLKCH(1) = '4/08966:30:768' */
+/* SCLKCH(2) = '4/08970:58:768' */
+/* TOLVGR = '0:0:400' */
+/* REF = 'FK4' */
+/* VCFIX( 1 ) = 0.D0 */
+/* VCFIX( 2 ) = 0.D0 */
+/* VCFIX( 3 ) = 1.D0 */
+
+/* C */
+/* C Loading the files in this order ensures that the */
+/* C corrected file will get searched first. */
+/* C */
+/* CALL FURNSH ( CKPRED ) */
+/* CALL FURNSH ( CKCORR ) */
+
+/* C */
+/* C Need to load a Voyager 2 SCLK kernel to convert from */
+/* C clock strings to ticks. */
+/* C */
+/* CALL FURNSH ( SCLK ) */
+
+/* C */
+/* C Convert tolerance from VGR formatted character string */
+/* C SCLK to ticks which are units of encoded SCLK. */
+/* C */
+/* CALL SCTIKS ( SC, TOLVGR, TOLTIK ) */
+
+
+/* DO I = 1, NPICS */
+/* C */
+/* C CKGPAV requires encoded spacecraft clock. */
+/* C */
+/* CALL SCENCD ( SC, SCLKCH( I ), SCLKDP ) */
+
+/* CALL CKGPAV ( INST, SCLKDP, TOLTIK, REF, CMAT, AV, */
+/* . CLKOUT, FOUND ) */
+
+/* IF ( FOUND ) THEN */
+
+/* C */
+/* C Use the transpose of the C-matrix to transform the */
+/* C boresight vector from camera-fixed to reference */
+/* C coordinates. */
+/* C */
+/* CALL MTXV ( CMAT, VCFIX, VINERT ) */
+/* CALL SCDECD ( SC, CLKOUT, CLKCH ) */
+
+/* WRITE (*,*) 'VGR 2 SCLK Time: ', CLKCH */
+/* WRITE (*,*) 'VGR 2 NA ISS boresight ' */
+/* . // 'pointing vector: ', VINERT */
+/* WRITE (*,*) 'Angular velocity vector: ', AV */
+
+/* ELSE */
+
+/* WRITE (*,*) 'Pointing not found for time ', SCLKCH(I) */
+
+/* END IF */
+
+/* END DO */
+
+/* END */
+
+
+/* $ Restrictions */
+
+/* Only loaded C-kernel segments containing both pointing and */
+/* angular velocity data will be searched by this reader. Segments */
+/* containing only pointing data will be skipped over. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* C.H. Acton (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* J.M. Lynch (JPL) */
+/* B.V. Semenov (JPL) */
+/* M.J. Spencer (JPL) */
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 5.2.1, 03-JUN-2010 (BVS) */
+
+/* Header update: description of the tolerance and Particulars */
+/* section were expanded to address some problems arising from */
+/* using a non-zero tolerance. */
+
+/* - SPICELIB Version 5.2.0, 25-AUG-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in MTXV, MXM and VADD calls. */
+
+/* - SPICELIB Version 5.1.2, 29-JAN-2004 (NJB) */
+
+/* Header update: descriptions of input arguments REF and */
+/* AV were expanded. */
+
+/* - SPICELIB Version 5.1.1, 27-JUL-2003 (CHA) (NJB) */
+
+/* Various header corrections were made. */
+
+/* - SPICELIB Version 5.1.0, 23-FEB-1999 (WLT) */
+
+/* The previous editions of this routine did not properly handle */
+/* the case when TOL was negative. The routine now returns a */
+/* value of .FALSE. for FOUND as is advertised above. */
+
+/* - SPICELIB Version 5.0.0, 28-JUL-1997 (WLT) */
+
+/* The previous routine incorrectly computed the angular */
+/* velocity of the transformation from the request frame */
+/* to the platform frame of the C-matrix for non-inertial */
+/* reference frames. */
+
+/* - SPICELIB Version 4.0.0, 19-SEP-1995 (WLT) */
+
+/* The routine was upgraded so that the reference frame may */
+/* be non-inertial. */
+
+/* - SPICELIB Version 3.0.0, 5-OCT-1994 (WLT) */
+
+/* The previous versions all computed an incorrect */
+/* value for the angular velocity if the frame specified by */
+/* REF was different from the reference frame of the segment */
+/* from which the angular velocity was extracted. This has */
+/* now been corrected. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 30-AUG-1991 (JML) */
+
+/* 1) The Particulars section was updated to show how the */
+/* search algorithm processes segments with continuous */
+/* pointing data. */
+
+/* 2) It was specified that the angular velocity vector */
+/* gives the right-handed axis about which the instrument */
+/* frame rotates. */
+
+/* 3) The example program now loads an SCLK kernel. */
+
+/* 4) FAILED is checked after the call to IRFROT to handle the */
+/* case where the reference frame is invalid and the error */
+/* handling is not set to abort. */
+
+/* 5) FAILED is checked in the DO WHILE loop to handle the case */
+/* where an error is detected by a SPICELIB routine inside the */
+/* loop and the error handling is not set to abort. */
+
+/* - SPICELIB Version 1.1.0, 02-NOV-1990 (JML) */
+
+/* 1) The variable NEEDAV is no longer being saved. */
+/* 2) In the example program, the calling sequences */
+/* for SCENCD and CKGPAV were corrected. */
+/* 3) The restriction that a C-kernel file must be loaded */
+/* was explicitly stated. */
+
+/* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get ck pointing and angular velocity */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 5.2.0, 25-AUG-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in MTXV, MXM and VADD calls. */
+
+/* - SPICELIB Version 4.1.0, 20-DEC-1995 (WLT) */
+
+/* A call to FRINFO did not have enough arguments and */
+/* went undetected until Howard Taylor of ACT. Many */
+/* thanks go out to Howard for tracking down this error. */
+
+/* - SPICELIB Version 4.0.0, 19-SEP-1995 (WLT) */
+
+/* The routine was upgraded so that the reference frame may */
+/* be non-inertial. */
+
+/* - SPICELIB Version 3.0.0, 5-OCT-1994 (WLT) */
+
+/* The previous versions all computed an incorrect */
+/* value for the angular velocity if the frame specified by */
+/* REF was different from the reference frame of the segment */
+/* from which the angular velocity was extracted. This has */
+/* now been corrected. */
+
+/* Previously we were multiplying by the inverse of the */
+/* rotation that transforms frames. */
+
+/* - SPICELIB Version 2.0.0, 30-AUG-1991 (JML) */
+
+/* 1) The Particulars section was updated to show how the */
+/* search algorithm processes segments with continuous */
+/* pointing data. */
+
+/* 2) It was specified that the angular velocity vector */
+/* gives the right-handed axis about which the instrument */
+/* frame rotates. */
+
+/* 3) The example program now loads an SCLK kernel. */
+
+/* 4) FAILED is checked after the call to IRFROT to handle the */
+/* case where the reference frame is invalid and the error */
+/* handling is not set to abort. */
+
+/* 5) FAILED is checked in the DO WHILE loop to handle the case */
+/* where an error is detected by a SPICELIB routine inside the */
+/* loop and the error handling is not set to abort. */
+
+/* - SPICELIB Version 1.1.0, 02-NOV-1990 (JML) */
+
+/* 1) The variable NEEDAV is no longer being saved. */
+/* 2) In the example program, the calling sequences */
+/* for SCENCD and CKGPAV were corrected. */
+/* 3) The restriction that a C-kernel file must be loaded */
+/* was explicitly stated. */
+
+/* - Beta Version 1.1.0, 30-AUG-1990 (MJS) */
+
+/* The following changes were made as a result of the */
+/* NAIF CK Code and Documentation Review: */
+
+/* 1) The variable SCLK was changed to SCLKDP. */
+/* 2) The variable INSTR was changed to INST. */
+/* 3) The variable IDENT was changed to SEGID. */
+/* 4) The declarations for the parameters NDC, NIC, NC, and */
+/* IDLEN were moved from the "Declarations" section of the */
+/* header to the "Local parameters" section of the code below */
+/* the header. These parameters are not meant to modified by */
+/* users. */
+/* 5) The header was updated to reflect the changes. */
+
+/* - Beta Version 1.0.0, 04-JUN-1990 (RET) (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel segment descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel segment descriptor. */
+
+/* NC is the number of components in a packed C-kernel */
+/* descriptor. All DAF summaries have this formulaic */
+/* relationship between the number of its integer and */
+/* double precision components and the number of packed */
+/* components. */
+
+/* IDLEN is the length of the C-kernel segment identifier. */
+/* All DAF names have this formulaic relationship */
+/* between the number of summary components and */
+/* the length of the name (You will notice that */
+/* a name and a summary have the same length in bytes.) */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKGPAV", (ftnlen)6);
+ }
+
+/* Need angular velocity data. */
+/* Assume the segment won't be found until it really is. */
+
+ needav = TRUE_;
+ *found = FALSE_;
+
+/* If the tolerance is less than zero, we go no further. */
+
+ if (*tol < 0.) {
+ chkout_("CKGPAV", (ftnlen)6);
+ return 0;
+ }
+
+/* Begin a search for this instrument and time, and get the first */
+/* applicable segment. */
+
+ ckbss_(inst, sclkdp, tol, &needav);
+ cksns_(&handle, descr, segid, &sfnd, (ftnlen)40);
+
+/* Keep trying candidate segments until a segment can produce a */
+/* pointing instance within the specified time tolerance of the */
+/* input time. */
+
+/* Check FAILED to prevent an infinite loop if an error is detected */
+/* by a SPICELIB routine and the error handling is not set to abort. */
+
+ while(sfnd && ! failed_()) {
+ ckpfs_(&handle, descr, sclkdp, tol, &needav, cmat, av, clkout, &pfnd);
+ if (pfnd) {
+
+/* Found one. If the data aren't already referenced to the */
+/* requested frame, rotate them. */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ refseg = icd[1];
+
+/* Look up the id code for the requested reference frame. */
+
+ namfrm_(ref, &refreq, ref_len);
+ if (refreq != refseg) {
+
+/* We may need to convert the output ticks CLKOUT to ET */
+/* so that we can get the needed state transformation */
+/* matrix. This is the case if either of the frames */
+/* is non-inertial. */
+
+ frinfo_(&refreq, ¢er, &type1, &typeid, &gotit);
+ frinfo_(&refseg, ¢er, &type2, &typeid, &gotit);
+ if (type1 == 1 && type2 == 1) {
+
+/* Any old value of ET will do in this case. We'll */
+/* use zero. */
+
+ et = 0.;
+ } else {
+
+/* Look up the spacecraft clock id to use to convert */
+/* the output CLKOUT to ET. */
+
+ ckmeta_(inst, "SCLK", &sclk, (ftnlen)4);
+ sct2e_(&sclk, clkout, &et);
+ }
+
+/* Get the transformation from the requested frame to */
+/* the segment frame at ET. */
+
+ frmchg_(&refreq, &refseg, &et, xform);
+
+/* If FRMCHG detects that the reference frame is invalid */
+/* then return from this routine with FOUND equal to false. */
+
+ if (failed_()) {
+ chkout_("CKGPAV", (ftnlen)6);
+ return 0;
+ }
+
+/* First transform the attitude information. Get the */
+/* rotation and angular velocity associated with the */
+/* transformation from request frame to segment frame. */
+/* Then convert CMAT so that it maps from request frame */
+/* to C-matrix frame. */
+
+ xf2rav_(xform, rot, omega);
+ mxm_(cmat, rot, tmpmat);
+ moved_(tmpmat, &c__9, cmat);
+
+/* Now transform the angular velocity information. */
+/* Currently we have OMEGA (the angular velocity of */
+/* the transformation from REF frame to the base */
+/* frame of the C-matrix), and AV the angular velocity */
+/* of the transformation from the C-MATRIX reference */
+/* system to the platform of the C-matrix. */
+
+/* The angular velocity of the C-MATRIX relative to */
+/* requested frame is given by */
+
+/* T */
+/* OMEGA + ROT * AV */
+
+/* Here's why. */
+
+/* The transformation from the request frame to the frame */
+/* of the C-kernel looks like this: */
+
+/* [ ] */
+/* [ ROT : 0 ] */
+/* [................ ] */
+/* [ dROT : ] */
+/* [ ---- : ROT ] */
+/* [ dt : ] */
+
+/* The transformation from the C-kernel reference frame to */
+/* the C-kernel platform frame looks like: */
+
+
+/* [ ] */
+/* [ CMAT : 0 ] */
+/* [ ............... ] */
+/* [ dCMAT : ] */
+/* [ ---- : CMAT ] */
+/* [ dt : ] */
+
+
+/* The transformation from the request frame to the platform */
+/* frame is the product shown below */
+
+
+/* [ ][ ] */
+/* [ CMAT : 0 ][ ROT : 0 ] */
+/* [ ............... ][................ ] */
+/* [ dCMAT : ][ dROT : ] */
+/* [ ---- : CMAT ][ ---- : ROT ] */
+/* [ dt : ][ dt : ] */
+
+
+/* [ : ] */
+/* [ CMAT * ROT : 0 ] */
+/* = [ ........................................ ] */
+/* [ dCMAT dROT : ] */
+/* [ ---- * ROT + CMAT * ---- : CMAT * ROT ] */
+/* [ dt dt : ] */
+
+
+/* In general, the angular velocity matrix of a */
+/* transformation R is given by */
+
+/* T */
+/* dR */
+/* -- * R */
+/* dt */
+
+/* Substituting the appropriate components of the matrix */
+/* in for R we have: */
+
+/* T T */
+/* OMEGA = ROT * dCMAT * CMAT * ROT */
+/* CMAT*ROT ----- */
+/* dt */
+
+/* T */
+/* dROT T */
+/* + ---- * CMAT * CMAT * ROT */
+/* dt */
+
+
+/* T */
+/* = ROT * OMEGA * ROT + OMEGA */
+/* CMAT ROT */
+
+
+/* Consider the first term of the final expression. If we */
+/* let "x" stand for the cross product operation, then by */
+/* definition for any vector V: */
+
+
+/* T */
+/* ROT * OMEGA * ROT * V */
+/* CMAT */
+
+
+/* T */
+/* = ROT * (AV x ROT*V ) */
+/* CMAT */
+
+/* (since rotations distribute across cross */
+/* products) */
+
+/* T T */
+/* = (ROT * AV ) x ( ROT * ROT*V ) */
+/* CMAT */
+
+
+/* T */
+/* = (ROT * AV ) x V */
+/* CMAT */
+
+/* Thus OMEGA is the matrix form of the cross */
+/* CMAT*ROT */
+
+/* T */
+/* product operation {( ROT *AV ) + AV } x . */
+/* CMAT ROT */
+
+
+ mtxv_(rot, av, tmpv);
+ vadd_(omega, tmpv, av);
+ }
+ *found = TRUE_;
+ chkout_("CKGPAV", (ftnlen)6);
+ return 0;
+ }
+ cksns_(&handle, descr, segid, &sfnd, (ftnlen)40);
+ }
+ chkout_("CKGPAV", (ftnlen)6);
+ return 0;
+} /* ckgpav_ */
+
diff --git a/ext/spice/src/cspice/ckgpav_c.c b/ext/spice/src/cspice/ckgpav_c.c
new file mode 100644
index 0000000000..e910b10d30
--- /dev/null
+++ b/ext/spice/src/cspice/ckgpav_c.c
@@ -0,0 +1,759 @@
+/*
+
+-Procedure ckgpav_c ( C-kernel, get pointing and angular velocity )
+
+-Abstract
+
+ Get pointing (attitude) and angular velocity for a specified
+ spacecraft clock time.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CK
+ SCLK
+
+-Keywords
+
+ POINTING
+
+*/
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+ void ckgpav_c ( SpiceInt inst,
+ SpiceDouble sclkdp,
+ SpiceDouble tol,
+ ConstSpiceChar * ref,
+ SpiceDouble cmat[3][3],
+ SpiceDouble av[3],
+ SpiceDouble * clkout,
+ SpiceBoolean * found )
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ inst I NAIF ID of instrument, spacecraft, or structure.
+ sclkdp I Encoded spacecraft clock time.
+ tol I Time tolerance.
+ ref I Reference frame.
+ cmat O C-matrix pointing data.
+ av O Angular velocity vector.
+ clkout O Output encoded spacecraft clock time.
+ found O True when requested pointing is available.
+
+-Detailed_Input
+
+ inst is the NAIF integer ID for the instrument, spacecraft, or
+ other structure for which pointing and angular velocity
+ are requested. For brevity we will refer to this object
+ as the "instrument," and the frame fixed to this object
+ as the "instrument frame" or "instrument-fixed" frame.
+
+ sclkdp is the encoded spacecraft clock time for which
+ pointing and angular velocity are requested.
+
+ The CSPICE routines scencd_c and sce2c_c respectively
+ convert spacecraft clock strings and ephemeris time
+ to encoded spacecraft clock. The inverse conversions
+ are performed by scdecd_c and sct2e_c.
+
+ tol is a time tolerance in ticks, the units of encoded
+ spacecraft clock time.
+
+ The CSPICE routine sctiks_c converts a spacecraft clock
+ tolerance duration from its character string
+ representation to ticks. scfmt_c performs the inverse
+ conversion.
+
+ The C-matrix - angular velocity vector pair returned by
+ ckgpav_c is the one whose time tag is closest to `sclkdp'
+ and within `tol' units of `sclkdp'. (More in
+ Particulars, below.)
+
+ In general, because using a non-zero tolerance
+ affects selection of the segment from which the
+ data is obtained, users are strongly discouraged
+ from using a non-zero tolerance when reading CKs
+ with continuous data. Using a non-zero tolerance
+ should be reserved exclusively to reading CKs with
+ discrete data because in practice obtaining data
+ from such CKs using a zero tolerance is often not
+ possible due to time round off.
+
+ ref is the desired reference frame for the returned pointing
+ and angular velocity. The returned C-matrix `cmat' gives
+ the orientation of the instrument designated by `inst'
+ relative to the frame designated by `ref'. When a vector
+ specified relative to frame `ref' is left-multiplied by
+ `cmat', the vector is rotated to the frame associated
+ with `inst'. The returned angular velocity vector `av'
+ expresses the angular velocity of the instrument
+ designated by `inst' relative to the frame designated by
+ `ref'. See the discussion of `cmat' and `av' below
+ for details.
+
+ Consult the SPICE document "Frames" for a discussion
+ of supported reference frames.
+
+-Detailed_Output
+
+ cmat is a rotation matrix that transforms the components of a
+ vector expressed in the frame specified by `ref' to
+ components expressed in the frame tied to the instrument,
+ spacecraft, or other structure at time `clkout' (see
+ below).
+
+ Thus, if a vector v has components x,y,z in the `ref'
+ reference frame, then v has components x',y',z' in the
+ instrument fixed frame at time `clkout':
+
+ [ x' ] [ ] [ x ]
+ | y' | = | cmat | | y |
+ [ z' ] [ ] [ z ]
+
+ If you know x', y', z', use the transpose of the
+ C-matrix to determine x, y, z as follows:
+
+ [ x ] [ ]T [ x' ]
+ | y | = | cmat | | y' |
+ [ z ] [ ] [ z' ]
+ (Transpose of cmat)
+
+
+ av is the angular velocity vector. This is the axis about
+ which the reference frame tied to the instrument is
+ rotating in the right-handed sense at time `clkout'. The
+ magnitude of `av' is the magnitude of the instantaneous
+ velocity of the rotation, in radians per second.
+ The components of `av' are given relative to the
+ reference frame specified by the input argument `ref'.
+
+ clkout is the encoded spacecraft clock time associated with
+ the returned C-matrix and the returned angular
+ velocity vector. This value may differ from the
+ requested time, but never by more than the input
+ tolerance `tol'.
+
+ The particulars section below describes the search
+ algorithm used by ckgpav_c to satisfy a pointing request.
+ This algorithm determines the pointing instance
+ (and therefore the associated time value) that is
+ returned.
+
+ found is SPICETRUE if a record was found to satisfy the
+ pointing request. `found' will be SPICEFALSE otherwise.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If a C-kernel file has not been loaded using furnsh_c prior to a
+ call to this routine, an error is signaled by a routine in the
+ call tree of this routine.
+
+ 2) If `tol' is negative, found is set to SPICEFALSE.
+
+ 3) If `ref' is not a supported reference frame, an error is
+ signaled by a routine in the call tree of this routine and
+ `found' is set to SPICEFALSE.
+
+-Files
+
+ ckgpav_c searches through files loaded by furnsh_c to locate a
+ segment that satisfies the request for pointing and angular velocity
+ for the instrument `inst' at time `sclkdp'. You must load at least
+ one C-kernel file via furnsh_c prior to calling this routine.
+
+-Particulars
+
+
+ How the tolerance argument is used
+ ==================================
+
+
+ Reading a type 1 CK segment (discrete pointing instances)
+ ---------------------------------------------------------
+
+ In the diagram below
+
+ - "0" is used to represent discrete pointing instances
+ (quaternions, angular velocity vectors, and associated
+ time tags).
+
+ - "( )" are used to represent the end points of the time
+ interval covered by a segment in a CK file.
+
+ - `sclkdp' is the time at which you requested pointing.
+ The location of `sclkdp' relative to the time tags of the
+ pointing instances is indicated by the "+" sign.
+
+ - `tol' is the time tolerance specified in the pointing
+ request. The square brackets "[ ]" represent the
+ endpoints of the time interval
+
+ sclkdp-tol : sclkdp+tol
+
+ - The quaternions occurring in the segment need not be
+ evenly spaced in time.
+
+
+ Case 1: pointing is available
+ ------------------------------
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ Segment (0-----0--0--0--0--0--0---0--0------------0--0--0--0)
+ ^
+ |
+ ckgpav_c returns this instance.
+
+
+ Case 2: pointing is not available
+ ----------------------------------
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ Segment (0-----0--0--0--0--0--0---0--0--0---------0--0--0--0)
+
+
+ ckgpav_c returns no pointing; the output
+ `found' flag is set to SPICEFALSE.
+
+
+
+ Reading a type 2, 3, 4, or 5 CK segment (continuous pointing)
+ -------------------------------------------------------------
+
+ In the diagrams below
+
+ - "==" is used to represent periods of continuous pointing.
+
+ - "--" is used to represent gaps in the pointing coverage.
+
+ - "( )" are used to represent the end points of the time
+ interval covered by a segment in a CK file.
+
+ - `sclkdp' is the time at which you requested pointing.
+ The location of `sclkdp' relative to the time tags of the
+ pointing instances is indicated by the "+" sign.
+
+ - `tol' is the time tolerance specified in the pointing
+ request. The square brackets "[ ]" represent the
+ endpoints of the time interval
+
+ sclkdp-tol : sclkdp+tol
+
+ - The quaternions occurring in the periods of continuous
+ pointing need not be evenly spaced in time.
+
+
+ Case 1: pointing is available at the request time
+ --------------------------------------------------
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ . . .
+ . . .
+ Segment (==---===========---=======----------===--)
+ ^
+ |
+
+ The request time lies within an interval where
+ continuous pointing is available. ckgpav_c returns
+ pointing at the requested epoch.
+
+
+ Case 2: pointing is available "near" the request time
+ ------------------------------------------------------
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ Segment (==---===========----=======---------===--)
+ ^
+ |
+
+ The request time lies in a gap: an interval where
+ continuous pointing is *not* available. ckgpav_c
+ returns pointing for the epoch closest to the
+ request time `sclkdp'.
+
+
+ Case 3: pointing is not available
+ ----------------------------------
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ Segment (==---===========----=======---------===--)
+
+ ckgpav_c returns no pointing; the output
+ `found' flag is set to SPICEFALSE.
+
+
+
+ Tolerance and segment priority
+ ==============================
+
+ ckgpav_c searches through loaded C-kernels to satisfy a pointing
+ request. Last-loaded files are searched first. Individual files are
+ searched in backwards order, so that between competing segments
+ (segments containing data for the same object, for overlapping time
+ ranges), the one closest to the end of the file has highest
+ priority. ckgpav_c considers only those segments that contain both
+ pointing and angular velocity data, as indicated by the segment
+ descriptor.
+
+ The search ends when a segment is found that can provide pointing
+ and angular velocity for the specified instrument at a time
+ falling within the specified tolerance on either side of the
+ request time. Within that segment, the instance closest to the
+ input time is located and returned.
+
+ The following four cases illustrate this search procedure. Segments
+ A and B are in the same file, with segment A located further
+ towards the end of the file than segment B. Both segments A and B
+ contain discrete pointing data, indicated by the number 0.
+
+
+ Case 1: Pointing is available in the first segment searched.
+ Because segment A has the highest priority and can
+ satisfy the request, segment B is not searched.
+
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ Segment A (0-----------------0--------0--0-----0)
+ ^
+ |
+ |
+ ckgpav_c returns this instance
+
+ Segment B (0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0)
+
+
+
+ Case 2: Pointing is not available in the first segment searched.
+ Because segment A cannot satisfy the request, segment B
+ is searched.
+
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ Segment A (0-----------------0--------0--0-----0)
+ . . .
+ Segment B (0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0--0)
+ ^
+ |
+ ckgpav_c returns this instance
+
+
+ Segments that contain continuous pointing data are searched in the
+ same manner as segments containing discrete pointing data. For
+ request times that fall within the bounds of continuous intervals,
+ ckgpav_c will return pointing at the request time. When the request
+ time does not fall within an interval, then a time at an endpoint of
+ an interval may be returned if it is the closest time in the segment
+ to the user request time and is also within the tolerance.
+
+ In the following examples, segment A is located further towards the
+ end of the file than segment C. Segment A contains discrete pointing
+ data and segment C contains continuous data, indicated by the "="
+ character.
+
+
+ Case 3: Pointing is not available in the first segment searched.
+ Because segment A cannot satisfy the request, segment C
+ is searched.
+
+ sclkdp
+ \ tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ . . .
+ Segment A (0-----------------0--------0--0-----0)
+ . . .
+ . . .
+ Segment C (---=============-----====--------==--)
+ ^
+ |
+ |
+ ckgpav_c returns this instance
+
+
+ In the next case, assume that the order of segments A and C in the
+ file is reversed: A is now closer to the front, so data from
+ segment C are considered first.
+
+
+ Case 4: Pointing is available in the first segment searched.
+ Because segment C has the highest priority and can
+ satisfy the request, segment A is not searched.
+
+ sclkdp
+ /
+ | tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ . . .
+ Segment C (---=============-----====--------==--)
+ ^
+ |
+ ckgpav_c returns this instance
+
+ Segment A (0-----------------0--------0--0-----0)
+ ^
+ |
+ "Best" answer
+
+
+ The next case illustrates an unfortunate side effect of using
+ a non-zero tolerance when reading multi-segment CKs with
+ continuous data. In all cases when the look-up interval
+ formed using tolerance overlaps a segment boundary and
+ the request time falls within the coverage of the lower
+ priority segment, the data at the end of the higher priority
+ segment will be picked instead of the data from the lower
+ priority segment.
+
+
+ Case 5: Pointing is available in the first segment searched.
+ Because segment C has the highest priority and can
+ satisfy the request, segment A is not searched.
+
+ sclkdp
+ /
+ | tol
+ | /
+ |/\
+ Your request [--+--]
+ . . .
+ . . .
+ Segment C (===============)
+ ^
+ |
+ ckgpav_c returns this instance
+
+ Segment A (=====================)
+ ^
+ |
+ "Best" answer
+
+
+-Examples
+
+
+ Suppose you have two C-kernel files containing pointing for the
+ Voyager 2 narrow angle camera. One file contains predict (planned)
+ values, and the other contains corrected pointing for a selected
+ group of images, that is, for a subset of images from the first
+ file.
+
+ The following example program uses ckgpav_c to get C-matrices and
+ associated angular velocity vectors for a set of images whose
+ SCLK counts (un-encoded character string versions) are contained
+ in the array `sclkch'.
+
+ If available, the program will get the corrected pointing values.
+ Otherwise, predict values will be used.
+
+ For each C-matrix, a unit pointing vector is constructed and printed
+ along with the angular velocity vector.
+
+ Note: if the C-kernels of interest do not contain angular velocity
+ data, then the CSPICE routine ckgp_c should be used to read the
+ pointing data. An example program in the header of the CSPICE
+ routine ckgp_c demonstrates this.
+
+
+ #include
+ #include "SpiceUsr.h"
+
+ int main ()
+ {
+ /.
+ Constants for this program:
+
+ -- The code for the Voyager 2 spacecraft clock is -32
+
+ -- The code for the narrow angle camera on the Voyager 2
+ spacecraft is -32001.
+
+ -- Spacecraft clock times for successive Voyager images always
+ differ by more than 0:0:400. This is an acceptable
+ tolerance, and must be converted to "ticks" (units of
+ encoded SCLK) for input to ckgpav_c.
+
+ -- The reference frame we want is FK4.
+
+ -- The narrow angle camera boresight defines the third
+ axis of the instrument-fixed reference frame.
+ Therefore, the vector ( 0, 0, 1 ) represents
+ the boresight direction in the camera-fixed frame.
+ ./
+
+ #define SC -32
+ #define INST -32001
+ #define REF "FK4"
+ #define TOLVGR "0:0:400"
+ #define NPICS 2
+ #define MAXCLK 30
+ #define CKPRED "voyager2_predict.bc"
+ #define CKCORR "voyager2_corrected.bc"
+ #define SCLK "voyager2_sclk.tsc"
+
+
+ SpiceBoolean found;
+
+ SpiceChar sclkch [NPICS][MAXCLK] =
+
+ { { "4/08966:30:768" },
+ { "4/08970:58:768" } };
+
+ SpiceChar clkch [MAXCLK];
+
+ SpiceDouble av [3];
+ SpiceDouble cmat [3][3];
+ SpiceDouble clkout;
+ SpiceDouble sclkdp;
+ SpiceDouble toltik;
+ SpiceDouble vinert [3];
+
+ SpiceInt i;
+
+
+ /.
+ Loading the files in this order ensures that the
+ corrected file will get searched first.
+ ./
+ furnsh_c ( CKPRED );
+ furnsh_c ( CKCORR );
+
+ /.
+ Need to load a Voyager 2 SCLK kernel to convert from
+ clock string to ticks. Although not required for
+ the Voyager spacecraft clocks, most modern spacecraft
+ clocks require a leapseconds kernel to be loaded in
+ addition to an SCLK kernel.
+ ./
+ furnsh_c ( SCLK );
+
+ /.
+ Convert tolerance from VGR formatted character string
+ SCLK to ticks, which are units of encoded SCLK.
+ ./
+ sctiks_c ( SC, TOLVGR, &toltik );
+
+ for ( i = 0; i < NPICS; i++ )
+ {
+
+ /.
+ ckgpav_c requires encoded spacecraft clock time.
+ ./
+ scencd_c ( SC, sclkch[ i ], &sclkdp );
+
+ ckgpav_c ( INST, sclkdp, toltik, REF,
+ cmat, av, &clkout, &found );
+
+ if ( found )
+ {
+ /.
+ The boresight vector, relative to inertial coordinates,
+ is just the third row of the C-matrix.
+ ./
+ vequ_c ( cmat[2], vinert );
+
+ scdecd_c ( SC, clkout, MAXCLK, clkch );
+
+
+ printf ( "VGR 2 SCLK time: %s\n", clkch );
+
+ printf ( "VGR 2 NA ISS boresight pointing vector: "
+ "%f %f %f\n",
+ vinert[0],
+ vinert[1],
+ vinert[2] );
+
+ printf ( "Angular velocity vector: %f %f %f\n",
+ av[0],
+ av[1],
+ av[2] );
+ }
+ else
+ {
+ printf ( "Pointing not found for time %s\n", sclkch[i] );
+ }
+
+ }
+
+ return ( 0 );
+ }
+
+
+-Restrictions
+
+ Only loaded C-kernel segments containing both pointing and angular
+ velocity data will be searched by this reader. Segments containing
+ only pointing data will be skipped over.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ C.H. Acton (JPL)
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ J.M. Lynch (JPL)
+ B.V. Semenov (JPL)
+ M.J. Spencer (JPL)
+ R.E. Thurman (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.2.3, 03-JUN-2010 (BVS)
+
+ Header update: description of the tolerance and Particulars
+ section were expanded to address some problems arising from
+ using a non-zero tolerance.
+
+ -CSPICE Version 1.2.2, 29-JAN-2004 (NJB)
+
+ Header update: the description of the input argument `ref'
+ was expanded.
+
+ -CSPICE Version 1.2.1, 27-JUL-2003 (CHA) (NJB)
+
+ Various header corrections were made.
+
+ -CSPICE Version 1.2.0, 02-SEP-1999 (NJB)
+
+ Local type logical variable now used for found flag used in
+ interface of ckgpav_.
+
+ -CSPICE Version 1.1.0, 08-FEB-1998 (NJB)
+
+ References to C2F_CreateStr_Sig were removed; code was
+ cleaned up accordingly. String checks are now done using
+ the macro CHKFSTR.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB)
+
+ Based on SPICELIB Version 5.0.0, 28-JUL-1997 (WLT)
+
+-Index_Entries
+
+ get ck pointing and angular velocity
+
+-&
+*/
+
+{ /* Begin ckgpav_c */
+
+ /*
+ Local variables
+ */
+ logical fnd;
+
+
+ /*
+ Participate in error handling
+ */
+ chkin_c ( "ckgpav_c");
+
+
+ /*
+ Check the input string ref to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "ckgpav_c", ref );
+
+
+ ckgpav_( ( integer * ) &inst,
+ ( doublereal * ) &sclkdp,
+ ( doublereal * ) &tol,
+ ( char * ) ref,
+ ( doublereal * ) cmat,
+ ( doublereal * ) av,
+ ( doublereal * ) clkout,
+ ( logical * ) &fnd,
+ ( ftnlen ) strlen(ref) );
+
+ /*
+ Assign the SpiceBoolean found flag.
+ */
+
+ *found = fnd;
+
+
+ /*
+ Transpose the c-matrix on output.
+ */
+ xpose_c ( cmat, cmat );
+
+
+ chkout_c ( "ckgpav_c");
+
+} /* End ckgpav_c */
diff --git a/ext/spice/src/cspice/ckgr01.c b/ext/spice/src/cspice/ckgr01.c
new file mode 100644
index 0000000000..955b7bb7f4
--- /dev/null
+++ b/ext/spice/src/cspice/ckgr01.c
@@ -0,0 +1,403 @@
+/* ckgr01.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKGR01 ( C-kernel, get record, type 01 ) */
+/* Subroutine */ int ckgr01_(integer *handle, doublereal *descr, integer *
+ recno, doublereal *record)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Local variables */
+ integer addr__, nrec, psiz;
+ doublereal n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *), dafgda_(integer *,
+ integer *, integer *, doublereal *), sigerr_(char *, ftnlen),
+ chkout_(char *, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer beg, icd[6];
+
+/* $ Abstract */
+
+/* Given the handle and descriptor of a data type 1 segment in a */
+/* CK file, return a specified pointing record from that segment. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of the file containing the segment. */
+/* DESCR I The segment descriptor. */
+/* RECNO I The number of the pointing record to be returned. */
+/* RECORD O The pointing record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the binary CK file containing the */
+/* desired segment. The file should have been opened */
+/* for read access, either by CKLPF or DAFOPR. */
+
+/* DESCR is the packed descriptor of the data type 1 segment. */
+
+/* RECNO is the number of the individual pointing record to be */
+/* returned from the data type 1 segment. */
+
+/* $ Detailed_Output */
+
+/* RECORD is the pointing record indexed by RECNO in the segment. */
+/* The contents are as follows: */
+
+/* RECORD( 1 ) = CLKOUT */
+
+/* RECORD( 2 ) = q0 */
+/* RECORD( 3 ) = q1 */
+/* RECORD( 4 ) = q2 */
+/* RECORD( 5 ) = q3 */
+
+/* RECORD( 6 ) = Av1 ] */
+/* RECORD( 7 ) = Av2 |-- Returned optionally */
+/* RECORD( 8 ) = Av3 ] */
+
+/* CLKOUT is the encoded spacecraft clock time associated */
+/* with the returned pointing values. */
+
+/* The quantities q0 - q3 represent a quaternion. */
+/* The quantities Av1, Av2, and Av3 represent the */
+/* angular velocity vector, and are returned only if the */
+/* segment contains angular velocity data. The */
+/* components of the angular velocity vector are */
+/* specified relative to the inertial reference */
+/* frame of the segment. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the segment is not of data type 1, the error */
+/* SPICE(CKWRONGDATATYPE) is signalled. */
+
+/* 2) If RECNO is less than one or greater than the number of */
+/* records in the specified segment, the error */
+/* SPICE(CKNONEXISTREC) is signalled. */
+
+/* 3) If the specified handle does not belong to any file that is */
+/* currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 4) If DESCR is not a valid, packed descriptor of a segment in */
+/* the CK file specified by HANDLE, the results of this routine */
+/* are unpredictable. */
+
+/* $ Files */
+
+/* The file specified by HANDLE should be open for read access. */
+
+/* $ Particulars */
+
+/* For a detailed description of the structure of a type 1 segment, */
+/* see the CK required reading. */
+
+/* This is a utility routine that performs as follows. It finds out */
+/* how many records are in the segment, checks to see if the request */
+/* fits the bounds of the segment, and then moves directly to get */
+/* the requested data. */
+
+/* $ Examples */
+
+/* The following code fragment prints the records of the first */
+/* segment in a CK file. Suppose MOC.CK is valid CK file that */
+/* contains segments of data type 1. */
+
+/* INTEGER ICD ( 6 ) */
+/* INTEGER HANDLE */
+/* INTEGER NREC */
+/* INTEGER I */
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION RECORD ( 8 ) */
+/* LOGICAL FOUND */
+
+/* C */
+/* C First load the file. (The file may also be opened by using */
+/* C CKLPF.) */
+/* C */
+/* CALL DAFOPR ( 'MOC.CK', HANDLE ) */
+
+/* C */
+/* C Begin forward search. Find first array. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* C */
+/* C Get segment descriptor. */
+/* C */
+/* CALL DAFGS ( DESCR ) */
+
+/* C */
+/* C Unpack the segment descriptor into its double precision */
+/* C and integer components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* C */
+/* C The data type for a segment is located in the third integer */
+/* C component of the descriptor. */
+/* C */
+/* IF ( ICD( 3 ) .EQ. 1 ) THEN */
+
+/* C */
+/* C How many records does this segment contain? */
+/* C */
+/* CALL CKNR01 ( HANDLE, DESCR, NREC ) */
+
+/* DO I = 1, NREC */
+
+/* C */
+/* C Get the record associated with record number I. */
+/* C */
+/* CALL CKGR01 ( HANDLE, DESCR, I, RECORD ) */
+/* WRITE (*,*) 'Record ', I, ':' */
+/* WRITE (*,*) RECORD */
+/* END DO */
+
+/* END IF */
+
+/* $ Restrictions */
+
+/* The binay CK file containing the segment whose descriptor was */
+/* passed to this routine must be opened for read access by either */
+/* CKLPF or DAFOPR. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.E. McLean (JPL) */
+/* M.J. Spencer (JPL) */
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 07-SEP-2001 (EDW) */
+
+/* Replaced DAFRDA call with DAFGDA. */
+/* Added IMPLICIT NONE. */
+
+/* - SPICELIB Version 1.0.3, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.2, 06-MAR-1991 (JML) */
+
+/* A correction was made to the example program in the */
+/* header. The array of double precision components of */
+/* the descriptor ( DCD ) had originally been declared */
+/* as an integer. */
+
+/* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
+
+/* The restriction that a C-kernel file must be loaded */
+/* was explicitly stated. */
+
+/* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get ck type_1 record */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 07-SEP-2000 (EDW) */
+
+/* Replaced DAFRDA call with DAFGDA. */
+
+/* - SPICELIB Version 1.0.2, 06-MAR-1991 (JML) */
+
+/* A correction was made to the example program in the */
+/* header. The array of double precision components of */
+/* the descriptor ( DCD ) had originally been declared */
+/* as an integer. */
+
+/* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
+
+/* 1) The restriction that a C-kernel file must be loaded */
+/* was explicitly stated. */
+/* 2) ROTATIONS was removed from the required reading section. */
+/* 3) Minor changes were made to the wording of the header. */
+
+
+/* - Beta Version 1.1.0, 28-AUG-1990 (MJS) (JEM) */
+
+/* The following changes were made as a result of the */
+/* NAIF CK Code and Documentation Review: */
+
+/* 1) The name of this routine was changed from CK01GR to */
+/* CKGR01 in order to be consistent with the SPICELIB */
+/* naming convention. */
+/* 2) The declarations for the parameters QSIZ, QAVSIZ, NDC, and */
+/* NIC were moved from the "Declarations" section of the */
+/* header to the "Local parameters" section of the code below */
+/* the header. These parameters are not meant to modified by */
+/* users. */
+/* 3) The header was corrected, improved, and updated to reflect */
+/* the changes. */
+/* 4) The in-code comments were improved. */
+
+/* - Beta Version 1.0.0, 23-MAY-1990 (RET) (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel segment descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel segment descriptor. */
+
+/* QSIZ is the number of double precision numbers making up */
+/* the quaternion portion of a pointing record. */
+
+/* QAVSIZ is the number of double precision numbers making up */
+/* the quaternion and angular velocity portion of a */
+/* pointing record. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKGR01", (ftnlen)6);
+ }
+
+/* The unpacked descriptor contains the following information */
+/* about the segment: */
+
+/* DCD(1) Initial encoded SCLK */
+/* DCD(2) Final encoded SCLK */
+/* ICD(1) Instrument */
+/* ICD(2) Inertial reference frame */
+/* ICD(3) Data type */
+/* ICD(4) Angular velocity flag */
+/* ICD(5) Initial address of segment data */
+/* ICD(6) Final address of segment data */
+
+/* From the descriptor, determine */
+
+/* 1 - Is this really a type 1 segment? */
+/* 2 - The beginning address of the segment. */
+/* 3 - The number of records in the segment (it's the last number */
+/* in the segment). */
+/* 4 - The existence of angular velocity data, which determines how */
+/* big the pointing portion of the returned record will be. */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ if (icd[2] != 1) {
+ setmsg_("Data type of the segment should be 1: Passed descriptor sho"
+ "ws type = #.", (ftnlen)71);
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
+ chkout_("CKGR01", (ftnlen)6);
+ return 0;
+ }
+ beg = icd[4];
+ dafgda_(handle, &icd[5], &icd[5], &n);
+ nrec = (integer) n;
+ if (icd[3] == 1) {
+ psiz = 7;
+ } else {
+ psiz = 4;
+ }
+
+/* If a request was made for a record which doesn't exist, then */
+/* signal an error and leave. */
+
+ if (*recno < 1 || *recno > nrec) {
+ setmsg_("Requested record number (#) does not exist. There are # rec"
+ "ords in the segment.", (ftnlen)79);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", &nrec, (ftnlen)1);
+ sigerr_("SPICE(CKNONEXISTREC)", (ftnlen)20);
+ chkout_("CKGR01", (ftnlen)6);
+ return 0;
+ }
+
+/* Get the pointing record indexed by RECNO. */
+
+ addr__ = beg + psiz * (*recno - 1);
+ i__1 = addr__ + (psiz - 1);
+ dafgda_(handle, &addr__, &i__1, &record[1]);
+
+/* Next get the SCLK time. Need to go past all of the NREC pointing */
+/* records (PSIZ * NREC numbers), and then to the RECNOth SCLK */
+/* time. */
+
+ addr__ = beg + psiz * nrec + *recno - 1;
+ dafgda_(handle, &addr__, &addr__, record);
+ chkout_("CKGR01", (ftnlen)6);
+ return 0;
+} /* ckgr01_ */
+
diff --git a/ext/spice/src/cspice/ckgr02.c b/ext/spice/src/cspice/ckgr02.c
new file mode 100644
index 0000000000..13c1a4f01d
--- /dev/null
+++ b/ext/spice/src/cspice/ckgr02.c
@@ -0,0 +1,359 @@
+/* ckgr02.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+static integer c__7 = 7;
+
+/* $Procedure CKGR02 ( C-kernel, get record, type 02 ) */
+/* Subroutine */ int ckgr02_(integer *handle, doublereal *descr, integer *
+ recno, doublereal *record)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Local variables */
+ integer addr__, nrec;
+ doublereal prec[8];
+ extern /* Subroutine */ int chkin_(char *, ftnlen), cknr02_(integer *,
+ doublereal *, integer *), dafus_(doublereal *, integer *, integer
+ *, doublereal *, integer *), moved_(doublereal *, integer *,
+ doublereal *), dafgda_(integer *, integer *, integer *,
+ doublereal *), sigerr_(char *, ftnlen), chkout_(char *, ftnlen),
+ setmsg_(char *, ftnlen), errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer beg, icd[6];
+
+/* $ Abstract */
+
+/* Given the handle and descriptor of a type 2 segment in a CK file, */
+/* return a specified pointing record from that segment. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of the file containing the segment. */
+/* DESCR I The segment descriptor. */
+/* RECNO I The number of the pointing record to be returned. */
+/* RECORD O The pointing record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the binary CK file containing the */
+/* desired segment. The file should have been opened */
+/* for read or write access, either by CKLPF, DAFOPR, */
+/* or DAFOPW. */
+
+/* DESCR is the packed descriptor of the data type 2 segment. */
+
+/* RECNO is the number of the individual pointing record to be */
+/* returned from the data type 2 segment. */
+
+/* $ Detailed_Output */
+
+/* RECORD is the pointing record indexed by RECNO in the segment. */
+/* The contents are as follows: */
+
+/* RECORD( 1 ) = start SCLK time of interval */
+/* RECORD( 2 ) = end SCLK time of interval */
+/* RECORD( 3 ) = seconds per tick rate */
+
+/* RECORD( 4 ) = q0 */
+/* RECORD( 5 ) = q1 */
+/* RECORD( 6 ) = q2 */
+/* RECORD( 7 ) = q3 */
+
+/* RECORD( 8 ) = av1 */
+/* RECORD( 9 ) = av2 */
+/* RECORD( 10 ) = av3 */
+
+
+/* See the section on data type 2 in the CK Required */
+/* Reading for a complete description on how pointing */
+/* is obtained from a type 2 record. */
+
+/* Note that the RECORD returned by this routine is */
+/* slightly different from that returned by CKR02. */
+/* The second element of the record returned by CKR02 */
+/* contains the SCLK time at which pointing was */
+/* requested, whereas this routine returns the SCLK */
+/* time of the right endpoint of the interval for which */
+/* the constant angular velocity model is valid. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the segment is not of data type 2, the error */
+/* SPICE(CKWRONGDATATYPE) is signalled. */
+
+/* 2) If RECNO is less than one or greater than the number of */
+/* records in the specified segment, the error */
+/* SPICE(CKNONEXISTREC) is signalled. */
+
+/* 3) If the specified handle does not belong to any file that is */
+/* currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 4) If DESCR is not a valid descriptor of a segment in the CK */
+/* file specified by HANDLE, the results of this routine are */
+/* unpredictable. */
+
+/* $ Files */
+
+/* The file specified by HANDLE should be open for read or write */
+/* access. */
+
+/* $ Particulars */
+
+/* For a detailed description of the structure of a type 2 segment, */
+/* see the CK Required Reading. */
+
+/* This is a utility routine that may be used to read the individual */
+/* pointing records that make up a data type 2 segment. It is */
+/* normally used in combination with CKNR02, which gives the number */
+/* of pointing instances stored in a segment. */
+
+/* $ Examples */
+
+/* Suppose GLL_PLT.BC is a CK file that contains segments of data */
+/* type 2. Then the following code fragment uses CKNR02 and CKGR02 */
+/* to extract each pointing record in the first segment in the file. */
+
+
+/* INTEGER ICD ( 6 ) */
+/* INTEGER HANDLE */
+/* INTEGER NREC */
+/* INTEGER I */
+
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION RECORD ( 10 ) */
+
+/* LOGICAL FOUND */
+
+/* C */
+/* C First load the file. (The file may also be opened by using */
+/* C CKLPF.) */
+/* C */
+/* CALL DAFOPR ( 'GLL_PLT.BC', HANDLE ) */
+
+/* C */
+/* C Begin forward search. Find the first array. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* C */
+/* C Get segment descriptor. */
+/* C */
+/* CALL DAFGS ( DESCR ) */
+
+/* C */
+/* C Unpack the segment descriptor into its double precision */
+/* C and integer components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* C */
+/* C The data type for a segment is located in the third integer */
+/* C component of the descriptor. */
+/* C */
+/* IF ( ICD( 3 ) .EQ. 2 ) THEN */
+
+/* C */
+/* C How many records does this segment contain? */
+/* C */
+/* CALL CKNR02 ( HANDLE, DESCR, NREC ) */
+
+/* DO I = 1, NREC */
+
+/* C */
+/* C Get the Ith record in the segment. */
+/* C */
+/* CALL CKGR02 ( HANDLE, DESCR, I, RECORD ) */
+/* C */
+/* C Process the pointing data. */
+/* C */
+/* . */
+/* . */
+/* . */
+
+/* END DO */
+
+/* END IF */
+
+/* $ Restrictions */
+
+/* 1) The binary CK file containing the segment whose descriptor was */
+/* passed to this routine must be opened for read or write access */
+/* by either CKLPF, DAFOPR, or DAFOPW. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.M. Lynch (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 07-SEP-2001 (EDW) */
+
+/* Replaced DAFRDA call with DAFGDA. */
+/* Added IMPLICIT NONE. */
+
+/* - SPICELIB Version 1.0.0, 25-NOV-1992 (JML) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get ck type_2 record */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel segment descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel segment descriptor. */
+
+/* PSIZ is the number of double precision numbers making up */
+/* the quaternion, angular velocity, and seconds per */
+/* tick rate portion of a pointing record. */
+
+/* DTYPE is the data type. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKGR02", (ftnlen)6);
+ }
+
+
+/* The unpacked descriptor contains the following information */
+/* about the segment: */
+
+/* DCD(1) Initial encoded SCLK */
+/* DCD(2) Final encoded SCLK */
+/* ICD(1) Instrument */
+/* ICD(2) Inertial reference frame */
+/* ICD(3) Data type */
+/* ICD(4) Angular velocity flag */
+/* ICD(5) Initial address of segment data */
+/* ICD(6) Final address of segment data */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ if (icd[2] != 2) {
+ setmsg_("Data type of the segment should be 2: Passed descriptor sho"
+ "ws type = #.", (ftnlen)71);
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
+ chkout_("CKGR02", (ftnlen)6);
+ return 0;
+ }
+
+/* Find out how many pointing instances there are in the segment. */
+
+ cknr02_(handle, descr, &nrec);
+
+/* If a request was made for a record which doesn't exist, then */
+/* signal an error and leave. */
+
+ if (*recno < 1 || *recno > nrec) {
+ setmsg_("Requested record number (#) does not exist. There are # rec"
+ "ords in the segment.", (ftnlen)79);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", &nrec, (ftnlen)1);
+ sigerr_("SPICE(CKNONEXISTREC)", (ftnlen)20);
+ chkout_("CKGR02", (ftnlen)6);
+ return 0;
+ }
+
+/* The address of the first double precision number in the array */
+/* is stored in the fifth integer component of the descriptor. */
+
+ beg = icd[4];
+
+/* Get the pointing record indexed by RECNO. */
+
+ addr__ = beg + (*recno - 1 << 3);
+ i__1 = addr__ + 7;
+ dafgda_(handle, &addr__, &i__1, prec);
+ record[2] = prec[7];
+ moved_(prec, &c__7, &record[3]);
+
+/* Next get the interval start time. Need to go past all of the */
+/* NREC pointing records (PSIZ * NREC numbers), and then to the */
+/* RECNOth SCLK start time. */
+
+ addr__ = beg + (nrec << 3) + *recno - 1;
+ dafgda_(handle, &addr__, &addr__, record);
+
+/* Next get the interval stop time. Need to go past all of the */
+/* NREC pointing records and start times ( (PSIZ+1)*NREC numbers ), */
+/* and then to the RECNOth SCLK stop time. */
+
+ addr__ = beg + nrec * 9 + *recno - 1;
+ dafgda_(handle, &addr__, &addr__, &record[1]);
+ chkout_("CKGR02", (ftnlen)6);
+ return 0;
+} /* ckgr02_ */
+
diff --git a/ext/spice/src/cspice/ckgr03.c b/ext/spice/src/cspice/ckgr03.c
new file mode 100644
index 0000000000..3dec38db8c
--- /dev/null
+++ b/ext/spice/src/cspice/ckgr03.c
@@ -0,0 +1,396 @@
+/* ckgr03.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKGR03 ( C-kernel, get record, type 03 ) */
+/* Subroutine */ int ckgr03_(integer *handle, doublereal *descr, integer *
+ recno, doublereal *record)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Builtin functions */
+ integer i_dnnt(doublereal *);
+
+ /* Local variables */
+ integer addr__, nrec, psiz;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *), dafgda_(integer *,
+ integer *, integer *, doublereal *), sigerr_(char *, ftnlen),
+ chkout_(char *, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ doublereal npoint;
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer beg, icd[6], end;
+
+/* $ Abstract */
+
+/* Given the handle and descriptor of a type 3 segment in a CK file, */
+/* return a specified pointing instance from that segment. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of the file containing the segment. */
+/* DESCR I The segment descriptor. */
+/* RECNO I The number of the pointing instance to be returned. */
+/* RECORD O The pointing record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the binary CK file containing the */
+/* desired segment. The file should have been opened */
+/* for read or write access, either by CKLPF, DAFOPR, */
+/* or DAFOPW. */
+
+/* DESCR is the packed descriptor of the data type 3 segment. */
+
+/* RECNO is the number of the discrete pointing instance to be */
+/* returned from the data type 3 segment. */
+
+/* $ Detailed_Output */
+
+/* RECORD is the pointing instance indexed by RECNO in the */
+/* segment. The contents are as follows: */
+
+/* RECORD( 1 ) = CLKOUT */
+
+/* RECORD( 2 ) = q0 */
+/* RECORD( 3 ) = q1 */
+/* RECORD( 4 ) = q2 */
+/* RECORD( 5 ) = q3 */
+
+/* RECORD( 6 ) = av1 ] */
+/* RECORD( 7 ) = av2 |-- Returned optionally */
+/* RECORD( 8 ) = av3 ] */
+
+/* CLKOUT is the encoded spacecraft clock time associated */
+/* with the returned pointing values. */
+
+/* The quantities q0 - q3 are the components of the */
+/* quaternion that represents the C-matrix that transforms */
+/* vectors from the inertial reference frame of the */
+/* segment to the instrument frame at time CLKOUT. */
+
+/* The quantities av1, av2, and av3 represent the */
+/* angular velocity vector, and are returned only if */
+/* the segment contains angular velocity data. The */
+/* components of the angular velocity vector are */
+/* specified relative to the inertial reference */
+/* frame of the segment. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the segment is not of data type 3, the error */
+/* SPICE(CKWRONGDATATYPE) is signalled. */
+
+/* 2) If RECNO is less than one or greater than the number of */
+/* records in the specified segment, the error */
+/* SPICE(CKNONEXISTREC) is signalled. */
+
+/* 3) If the specified handle does not belong to any DAF file that */
+/* is currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 4) If DESCR is not a valid descriptor of a segment in the CK */
+/* file specified by HANDLE, the results of this routine are */
+/* unpredictable. */
+
+/* $ Files */
+
+/* The file specified by HANDLE should be open for read or */
+/* write access. */
+
+/* $ Particulars */
+
+/* For a detailed description of the structure of a type 3 segment, */
+/* see the CK required reading. */
+
+/* This is a utility routine that may be used to read the individual */
+/* pointing instances that make up a type 3 segment. It is normally */
+/* used in conjunction with CKNR03, which gives the number of */
+/* pointing instances stored in a segment. */
+
+/* $ Examples */
+
+/* Suppose that MOC.BC is a CK file that contains segments of */
+/* data type 3. Then the following code fragment extracts the */
+/* SCLK time, boresight vector, and angular velocity vector for */
+/* each pointing instance in the first segment in the file. */
+
+
+/* INTEGER ICD ( 6 ) */
+/* INTEGER HANDLE */
+/* INTEGER NREC */
+/* INTEGER I */
+
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION RECORD ( 8 ) */
+/* DOUBLE PRECISION QUAT ( 4 ) */
+/* DOUBLE PRECISION AV ( 3 ) */
+/* DOUBLE PRECISION BORE ( 3 ) */
+/* DOUBLE PRECISION CMAT ( 3, 3 ) */
+/* DOUBLE PRECISION SCLKDP */
+
+/* LOGICAL FOUND */
+/* LOGICAL AVSEG */
+
+/* C */
+/* C First load the file. (The file may also be opened by using */
+/* C CKLPF.) */
+/* C */
+/* CALL DAFOPR ( 'MOC.BC', HANDLE ) */
+/* C */
+/* C Begin forward search. Find the first array. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+/* C */
+/* C Get segment descriptor. */
+/* C */
+/* CALL DAFGS ( DESCR ) */
+/* C */
+/* C Unpack the segment descriptor into its double precision */
+/* C and integer components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+/* C */
+/* C The data type for a segment is located in the third integer */
+/* C component of the descriptor. */
+/* C */
+/* IF ( ICD( 3 ) .EQ. 3 ) THEN */
+/* C */
+/* C Does the segment contain AV data? */
+/* C */
+/* AVSEG = ( ICD(4) .EQ. 1 ) */
+/* C */
+/* C How many records does this segment contain? */
+/* C */
+/* CALL CKNR03 ( HANDLE, DESCR, NREC ) */
+
+/* DO I = 1, NREC */
+/* C */
+/* C Get the Ith pointing instance in the segment. */
+/* C */
+/* CALL CKGR03 ( HANDLE, DESCR, I, RECORD ) */
+
+/* C */
+/* C Unpack RECORD into the time, quaternion, and av. */
+/* C */
+/* SCLKDP = RECORD ( 1 ) */
+
+/* CALL MOVED ( RECORD(2), 4, QUAT ) */
+
+/* IF ( AVSEG ) THEN */
+/* CALL MOVED ( RECORD(6), 3, AV ) */
+/* END IF */
+
+/* C */
+/* C The boresight vector is the third row of the C-matrix. */
+/* C */
+/* CALL Q2M ( QUAT, CMAT ) */
+
+/* BORE(1) = CMAT(3,1) */
+/* BORE(2) = CMAT(3,2) */
+/* BORE(3) = CMAT(3,3) */
+/* C */
+/* C Write out the results. */
+/* C */
+/* WRITE (*,*) 'Record: ', I */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'SCLK time = ', SCLKDP */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'boresight: ', BORE */
+
+/* IF ( AVSEG ) THEN */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'angular velocity: ', AV */
+/* END IF */
+
+/* END DO */
+
+/* END IF */
+
+/* $ Restrictions */
+
+/* 1) The binary CK file containing the segment whose descriptor was */
+/* passed to this routine must be opened for read or write access */
+/* by either CKLPF, DAFOPR, DAFOPW. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.M. Lynch (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 07-SEP-2001 (EDW) */
+
+/* Replaced DAFRDA call with DAFGDA. */
+/* Added IMPLICIT NONE. */
+
+/* - SPICELIB Version 1.0.0, 25-NOV-1992 (JML) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get ck type_3 record */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel segment descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel segment descriptor. */
+
+/* QSIZ is the number of double precision numbers making up */
+/* the quaternion portion of a pointing record. */
+
+/* QAVSIZ is the number of double precision numbers making up */
+/* the quaternion and angular velocity portion of a */
+/* pointing record. */
+
+/* DTYPE is the data type of the segment that this routine */
+/* operates on. */
+
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKGR03", (ftnlen)6);
+ }
+
+/* The unpacked descriptor contains the following information */
+/* about the segment: */
+
+/* DCD(1) Initial encoded SCLK */
+/* DCD(2) Final encoded SCLK */
+/* ICD(1) Instrument */
+/* ICD(2) Inertial reference frame */
+/* ICD(3) Data type */
+/* ICD(4) Angular velocity flag */
+/* ICD(5) Initial address of segment data */
+/* ICD(6) Final address of segment data */
+
+/* From the descriptor, determine */
+
+/* 1 - Is this really a type 3 segment? */
+/* 2 - The beginning address of the segment. */
+/* 3 - The number of pointing instances in the segment (it's the */
+/* last word in the segment). */
+/* 4 - The existence of angular velocity data, which determines how */
+/* big the pointing portion of the returned record will be. */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ if (icd[2] != 3) {
+ setmsg_("Data type of the segment should be 3: Passed descriptor sho"
+ "ws type = #.", (ftnlen)71);
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
+ chkout_("CKGR03", (ftnlen)6);
+ return 0;
+ }
+ if (icd[3] == 1) {
+ psiz = 7;
+ } else {
+ psiz = 4;
+ }
+ beg = icd[4];
+ end = icd[5];
+ dafgda_(handle, &end, &end, &npoint);
+ nrec = i_dnnt(&npoint);
+
+/* If a request was made for a record which doesn't exist, then */
+/* signal an error and leave. */
+
+ if (*recno < 1 || *recno > nrec) {
+ setmsg_("Requested record number (#) does not exist. There are # rec"
+ "ords in the segment.", (ftnlen)79);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", &nrec, (ftnlen)1);
+ sigerr_("SPICE(CKNONEXISTREC)", (ftnlen)20);
+ chkout_("CKGR03", (ftnlen)6);
+ return 0;
+ }
+
+/* Get the pointing record indexed by RECNO. */
+
+ addr__ = beg + psiz * (*recno - 1);
+ i__1 = addr__ + psiz - 1;
+ dafgda_(handle, &addr__, &i__1, &record[1]);
+
+/* Next get the SCLK time. Need to go past all of the NREC pointing */
+/* records (PSIZ * NREC numbers), and then to the RECNOth SCLK */
+/* time. */
+
+ addr__ = beg + psiz * nrec + *recno - 1;
+ dafgda_(handle, &addr__, &addr__, record);
+ chkout_("CKGR03", (ftnlen)6);
+ return 0;
+} /* ckgr03_ */
+
diff --git a/ext/spice/src/cspice/ckgr04.c b/ext/spice/src/cspice/ckgr04.c
new file mode 100644
index 0000000000..2c3941cd79
--- /dev/null
+++ b/ext/spice/src/cspice/ckgr04.c
@@ -0,0 +1,534 @@
+/* ckgr04.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+static integer c__7 = 7;
+static doublereal c_b15 = 128.;
+
+/* $Procedure CKGR04 ( C-kernel, get record, type 04 ) */
+/* Subroutine */ int ckgr04_(integer *handle, doublereal *descr, integer *
+ recno, doublereal *record)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer nrec, ends[1], k;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), cknr04_(integer *,
+ doublereal *, integer *), dafus_(doublereal *, integer *, integer
+ *, doublereal *, integer *);
+ integer numall;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ integer numcft[7];
+ extern /* Subroutine */ int chkout_(char *, ftnlen), sgfpkt_(integer *,
+ doublereal *, integer *, integer *, doublereal *, integer *),
+ setmsg_(char *, ftnlen), errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+ extern /* Subroutine */ int zzck4d2i_(doublereal *, integer *, doublereal
+ *, integer *);
+
+/* $ Abstract */
+
+/* Given the handle and descriptor of a type 4 segment in */
+/* a CK file, return a specified pointing record from that */
+/* segment. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+/* DAF.REQ */
+/* GS.REQ */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* Declarations of the CK data type specific and general CK low */
+/* level routine parameters. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* 1) If new CK types are added, the size of the record passed */
+/* between CKRxx and CKExx must be registered as separate */
+/* parameter. If this size will be greater than current value */
+/* of the CKMRSZ parameter (which specifies the maximum record */
+/* size for the record buffer used inside CKPFS) then it should */
+/* be assigned to CKMRSZ as a new value. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Literature_References */
+
+/* CK Required Reading. */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 19-AUG-2002 (NJB) */
+
+/* Updated to support CK type 5. */
+
+/* - SPICELIB Version 1.0.0, 05-APR-1999 (BVS) */
+
+/* -& */
+
+/* Number of quaternion components and number of quaternion and */
+/* angular rate components together. */
+
+
+/* CK Type 1 parameters: */
+
+/* CK1DTP CK data type 1 ID; */
+
+/* CK1RSZ maximum size of a record passed between CKR01 */
+/* and CKE01. */
+
+
+/* CK Type 2 parameters: */
+
+/* CK2DTP CK data type 2 ID; */
+
+/* CK2RSZ maximum size of a record passed between CKR02 */
+/* and CKE02. */
+
+
+/* CK Type 3 parameters: */
+
+/* CK3DTP CK data type 3 ID; */
+
+/* CK3RSZ maximum size of a record passed between CKR03 */
+/* and CKE03. */
+
+
+/* CK Type 4 parameters: */
+
+/* CK4DTP CK data type 4 ID; */
+
+/* CK4PCD parameter defining integer to DP packing schema that */
+/* is applied when seven number integer array containing */
+/* polynomial degrees for quaternion and angular rate */
+/* components packed into a single DP number stored in */
+/* actual CK records in a file; the value of must not be */
+/* changed or compatibility with existing type 4 CK files */
+/* will be lost. */
+
+/* CK4MXD maximum Chebychev polynomial degree allowed in type 4 */
+/* records; the value of this parameter must never exceed */
+/* value of the CK4PCD; */
+
+/* CK4SFT number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 4 */
+/* CK record that passed between routines CKR04 and CKE04; */
+
+/* CK4RSZ maximum size of type 4 CK record passed between CKR04 */
+/* and CKE04; CK4RSZ is computed as follows: */
+
+/* CK4RSZ = ( CK4MXD + 1 ) * QAVSIZ + CK4SFT */
+
+
+/* CK Type 5 parameters: */
+
+
+/* CK5DTP CK data type 5 ID; */
+
+/* CK5MXD maximum polynomial degree allowed in type 5 */
+/* records. */
+
+/* CK5MET number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 5 */
+/* CK record that passed between routines CKR05 and CKE05; */
+
+/* CK5MXP maximum packet size for any subtype. Subtype 2 */
+/* has the greatest packet size, since these packets */
+/* contain a quaternion, its derivative, an angular */
+/* velocity vector, and its derivative. See ck05.inc */
+/* for a description of the subtypes. */
+
+/* CK5RSZ maximum size of type 5 CK record passed between CKR05 */
+/* and CKE05; CK5RSZ is computed as follows: */
+
+/* CK5RSZ = ( CK5MXD + 1 ) * CK5MXP + CK5MET */
+
+
+
+/* Maximum record size that can be handled by CKPFS. This value */
+/* must be set to the maximum of all CKxRSZ parameters (currently */
+/* CK4RSZ.) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of the file containing the segment. */
+/* DESCR I The segment descriptor. */
+/* RECNO I The number of the pointing record to be returned. */
+/* RECORD O The pointing record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the binary CK file containing the */
+/* desired segment. The file should have been opened */
+/* for read or write access, either by CKLPF, DAFOPR, */
+/* or DAFOPW. */
+
+/* DESCR is the packed descriptor of the data type 4 segment. */
+
+/* RECNO is the number of the pointing record to be returned */
+/* from the data type 4 segment. */
+
+/* $ Detailed_Output */
+
+/* RECORD is the pointing record indexed by RECNO in the */
+/* segment. The contents of the record are as follows: */
+
+/* --------------------------------------------------- */
+/* | The midpoint of the approximation interval | */
+/* --------------------------------------------------- */
+/* | The radius of the approximation interval | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for q0 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for q1 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for q2 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for q3 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for AV1 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for AV2 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for AV3 | */
+/* --------------------------------------------------- */
+/* | q0 Cheby coefficients | */
+/* --------------------------------------------------- */
+/* | q1 Cheby coefficients | */
+/* --------------------------------------------------- */
+/* | q2 Cheby coefficients | */
+/* --------------------------------------------------- */
+/* | q3 Cheby coefficients | */
+/* --------------------------------------------------- */
+/* | AV1 Cheby coefficients (optional) | */
+/* --------------------------------------------------- */
+/* | AV2 Cheby coefficients (optional) | */
+/* --------------------------------------------------- */
+/* | AV3 Cheby coefficients (optional) | */
+/* --------------------------------------------------- */
+
+/* $ Parameters */
+
+/* See 'ckparam.inc'. */
+
+/* $ Files */
+
+/* The file specified by HANDLE should be open for read or */
+/* write access. */
+
+/* $ Exceptions */
+
+/* 1) If the segment is not of data type 4, the error */
+/* SPICE(CKWRONGDATATYPE) is signalled. */
+
+/* 2) If RECNO is less than one or greater than the number of */
+/* records in the specified segment, the error */
+/* SPICE(CKNONEXISTREC) is signalled. */
+
+/* 3) If the specified handle does not belong to any DAF file that */
+/* is currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 4) If DESCR is not a valid descriptor of a segment in the CK */
+/* file specified by HANDLE, the results of this routine are */
+/* unpredictable. */
+
+/* $ Particulars */
+
+/* For a detailed description of the structure of a type 4 segment, */
+/* see the CK required reading. */
+
+/* This is a utility routine that may be used to read the individual */
+/* pointing records that make up a type 4 segment. It is normally */
+/* used in conjunction with CKNR04, which gives the number of */
+/* pointing records stored in a segment. */
+
+/* $ Examples */
+
+/* Suppose that DATA.BC is a CK file that contains segments of */
+/* data type 4. Then the following code fragment extracts the */
+/* data packets contained in the segment. */
+
+/* C */
+/* C CK parameters include file. */
+/* C */
+/* INCLUDE 'ckparam.inc' */
+/* C */
+/* C Declarations. */
+/* C */
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION PKTDAT ( CK4RSZ ) */
+
+/* INTEGER AVFLAG */
+/* INTEGER HANDLE */
+/* INTEGER I */
+/* INTEGER ICD ( 6 ) */
+/* INTEGER K */
+/* INTEGER LASTAD */
+/* INTEGER NCOEF ( QAVSIZ ) */
+/* INTEGER NREC */
+
+/* LOGICAL FOUND */
+/* C */
+/* C First load the file. (The file may also be opened by using */
+/* C CKLPF.) */
+/* C */
+/* CALL DAFOPR ( 'DATA.BC', HANDLE ) */
+/* C */
+/* C Begin forward search. Find the first array. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+/* C */
+/* C Get segment descriptor. */
+/* C */
+/* CALL DAFGS ( DESCR ) */
+/* C */
+/* C Unpack the segment descriptor into its double precision */
+/* C and integer components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* IF ( ICD( 3 ) .EQ. 4 ) THEN */
+/* C */
+/* C How many records does this segment contain? */
+/* C */
+/* CALL CKNR04 ( HANDLE, DESCR, NREC ) */
+
+/* DO I = 1, NREC */
+/* C */
+/* C Get the data records stored in the segment. */
+/* C */
+/* CALL CKGR04 ( HANDLE, DESCR, I, PKTDAT ) */
+/* C */
+/* C Print data packet contents. Print coverage interval */
+/* C midpoint & radii first. */
+/* C */
+/* WRITE (2,*) PKTDAT (1) */
+/* WRITE (2,*) PKTDAT (2) */
+/* C */
+/* C Decode numbers of coefficients. */
+/* C */
+/* CALL ZZCK4D2I ( PKTDAT(3), QAVSIZ, CK4PCD, NCOEF ) */
+/* C */
+/* C Print number of coefficients for Q0, Q1, Q2 and Q3. */
+/* C */
+/* WRITE (2,FMT='(I2,6X,I2)') NCOEF( 1 ), NCOEF( 2 ) */
+/* WRITE (2,FMT='(I2,6X,I2)') NCOEF( 3 ), NCOEF( 4 ) */
+/* C */
+/* C Print number coefficients for AV1, AV2 and AV3. */
+/* C */
+/* WRITE (2,FMT='(I2,6X,I2)') NCOEF( 5 ), NCOEF( 6 ) */
+/* WRITE (2,FMT='(I2,6X,I2)') NCOEF( 7 ) */
+/* C */
+/* C Print Cheby coefficients. */
+/* C */
+/* LASTAD = 0 */
+
+/* DO K = 1, QAVSIZ */
+/* LASTAD = LASTAD + NCOEF( K ) */
+/* END DO */
+
+/* DO K = 4, LASTAD + 4 */
+/* WRITE (2,*) PKTDAT (K) */
+/* END DO */
+
+/* END DO */
+
+/* END IF */
+
+/* $ Restrictions */
+
+/* 1) The binary CK file containing the segment whose descriptor */
+/* was passed to this routine must be opened for read or write */
+/* access by either CKLPF, DAFOPR, or DAFOPW. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* Y.K. Zaiko (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 05-MAY-1999 (YKZ) (BVS) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get CK type_4 record */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Length (in DPs) of non-coefficient front part of RECORD when */
+/* it contains decoded numbers of coefficients. It is one less */
+/* than the length of the same part in a record exchanged between */
+/* CKR04 and CKE04 because it doesn't contain time at which */
+/* pointing has to be evaluated. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKGR04", (ftnlen)6);
+ }
+
+/* Unpack descriptor and check segment data type. Signal an error */
+/* if it's not 4. */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ if (icd[2] != 4) {
+ setmsg_("Data type of the segment should be 4: Passed descriptor sh"
+ "ows type = #.", (ftnlen)72);
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
+ chkout_("CKGR04", (ftnlen)6);
+ return 0;
+ }
+
+/* If a request was made for a data record which doesn't */
+/* exist, then signal an error and leave. */
+
+ cknr04_(handle, descr, &nrec);
+ if (*recno < 1 || *recno > nrec) {
+ setmsg_("Requested record number (#) does not exist. There are # rec"
+ "ords in the segment.", (ftnlen)79);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", &nrec, (ftnlen)1);
+ sigerr_("SPICE(CKNONEXISTREC)", (ftnlen)20);
+ chkout_("CKGR04", (ftnlen)6);
+ return 0;
+ }
+
+/* Get the data record indexed by RECNO. */
+
+ sgfpkt_(handle, descr, recno, recno, record, ends);
+
+/* Decode 7 numbers of coefficients from double precision value. */
+
+ zzck4d2i_(&record[2], &c__7, &c_b15, numcft);
+
+/* Compute total number of coefficients in the fetched packet. */
+
+ numall = 0;
+ for (k = 1; k <= 7; ++k) {
+ numall += numcft[(i__1 = k - 1) < 7 && 0 <= i__1 ? i__1 : s_rnge(
+ "numcft", i__1, "ckgr04_", (ftnlen)366)];
+ }
+
+/* Move polynomial coefficients to the right to free space for */
+/* decoded numbers of coefficients and insert these numbers */
+/* starting from the third position. */
+
+ for (k = numall; k >= 1; --k) {
+ record[k + 8] = record[k + 2];
+ }
+ for (k = 1; k <= 7; ++k) {
+ record[k + 1] = (doublereal) numcft[(i__1 = k - 1) < 7 && 0 <= i__1 ?
+ i__1 : s_rnge("numcft", i__1, "ckgr04_", (ftnlen)379)];
+ }
+
+/* All done. */
+
+ chkout_("CKGR04", (ftnlen)6);
+ return 0;
+} /* ckgr04_ */
+
diff --git a/ext/spice/src/cspice/ckgr05.c b/ext/spice/src/cspice/ckgr05.c
new file mode 100644
index 0000000000..f9109130ae
--- /dev/null
+++ b/ext/spice/src/cspice/ckgr05.c
@@ -0,0 +1,521 @@
+/* ckgr05.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKGR05 ( C-kernel, get record, type 05 ) */
+/* Subroutine */ int ckgr05_(integer *handle, doublereal *descr, integer *
+ recno, doublereal *record)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer i_dnnt(doublereal *);
+
+ /* Local variables */
+ integer addr__, nrec;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *), dafgda_(integer *,
+ integer *, integer *, doublereal *);
+ integer packsz;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ doublereal npoint;
+ extern logical return_(void);
+ integer subtyp;
+ doublereal dcd[2];
+ integer beg, icd[6], end;
+
+/* $ Abstract */
+
+/* Given the handle and descriptor of a type 5 segment in a CK file, */
+/* return a specified pointing instance from that segment. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* Declare parameters specific to CK type 05. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 20-AUG-2002 (NJB) */
+
+/* -& */
+
+/* CK type 5 subtype codes: */
+
+
+/* Subtype 0: Hermite interpolation, 8-element packets. Quaternion */
+/* and quaternion derivatives only, no angular velocity */
+/* vector provided. Quaternion elements are listed */
+/* first, followed by derivatives. Angular velocity is */
+/* derived from the quaternions and quaternion */
+/* derivatives. */
+
+
+/* Subtype 1: Lagrange interpolation, 4-element packets. Quaternion */
+/* only. Angular velocity is derived by differentiating */
+/* the interpolating polynomials. */
+
+
+/* Subtype 2: Hermite interpolation, 14-element packets. */
+/* Quaternion and angular angular velocity vector, as */
+/* well as derivatives of each, are provided. The */
+/* quaternion comes first, then quaternion derivatives, */
+/* then angular velocity and its derivatives. */
+
+
+/* Subtype 3: Lagrange interpolation, 7-element packets. Quaternion */
+/* and angular velocity vector provided. The quaternion */
+/* comes first. */
+
+
+/* Packet sizes associated with the various subtypes: */
+
+
+/* End of file ck05.inc. */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of the file containing the segment. */
+/* DESCR I The segment descriptor. */
+/* RECNO I The number of the pointing instance to be returned. */
+/* RECORD O The pointing record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the binary CK file containing the */
+/* desired segment. */
+
+/* DESCR is the packed descriptor of the data type 5 segment. */
+
+/* RECNO is the number of the discrete pointing instance to be */
+/* returned from the data type 5 segment. */
+
+/* $ Detailed_Output */
+
+/* RECORD is the pointing instance indexed by RECNO in the */
+/* segment. The contents are as follows: */
+
+/* RECORD( 1 ) = CLKOUT */
+
+/* CLKOUT is the encoded spacecraft clock time associated */
+/* with the returned pointing values. */
+
+/* RECORD( 2 ) = SUBTYP */
+
+/* SUBTYP is the CK type 5 subtype code. This code */
+/* identifies the structure and meaning of the rest */
+/* of the record. However, all subtypes have a */
+/* quaternion stored in elements 3-6. */
+
+/* RECORD( 3 ) = q0 */
+/* RECORD( 4 ) = q1 */
+/* RECORD( 5 ) = q2 */
+/* RECORD( 6 ) = q3 */
+
+/* Subtype 1 ends here; there are no angular velocity */
+/* data. Angular velocity is derived by differentiating */
+/* Lagrange interpolating polynomials. */
+
+/* RECORD( 7 ) = ] */
+/* RECORD( 8 ) = ] --- For subtypes 0 and 2, these */
+/* RECORD( 9 ) = ] elements contain a quaternion */
+/* RECORD( 10 ) = ] derivative. For subtype 3, */
+/* elements 7-9 contain an */
+/* angular velocity vector; */
+/* element 10 is unassigned. */
+
+/* All subtypes except subtype */
+/* 2 stop here. */
+
+/* RECORD( 11 ) = ] */
+/* RECORD( 12 ) = ] --- For subtype 2, these */
+/* RECORD( 13 ) = ] elements contain an angular */
+/* velocity vector. */
+
+
+/* RECORD( 14 ) = ] */
+/* RECORD( 15 ) = ] --- For subtype 2, these */
+/* RECORD( 16 ) = ] elements contain the */
+/* derivative of an angular */
+/* velocity vector. */
+
+/* The quantities q0 - q3 are the components of the */
+/* quaternion that represents the C-matrix that transforms */
+/* vectors from the inertial reference frame of the */
+/* segment to the instrument frame at time CLKOUT. */
+
+/* Quaternion derivatives, angular velocity, or the */
+/* derivative of angular velocity are returned only */
+/* these are supported by the segment subtype and */
+/* if the segment descriptor indicates that angular */
+/* velocity is present. */
+
+/* The components of the angular velocity vector are */
+/* specified relative to the inertial reference frame of */
+/* the segment. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the segment is not of data type 5, the error */
+/* SPICE(CKWRONGDATATYPE) is signaled. */
+
+/* 2) If RECNO is less than one or greater than the number of */
+/* records in the specified segment, the error */
+/* SPICE(CKNONEXISTREC) is signaled. */
+
+/* 3) If the specified handle does not belong to any DAF file that */
+/* is currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 4) If DESCR is not a valid descriptor of a segment in the CK */
+/* file specified by HANDLE, the results of this routine are */
+/* unpredictable. */
+
+/* 5) If the segment subtype is not recognized, the error */
+/* SPICE(NOTSUPPORTED) is signaled. */
+
+/* $ Files */
+
+/* The file specified by HANDLE should be open for read or */
+/* write access. */
+
+/* $ Particulars */
+
+/* For a detailed description of the structure of a type 5 segment, */
+/* see the CK required reading. */
+
+/* This is a utility routine that may be used to read the individual */
+/* pointing instances that make up a type 5 segment. It is normally */
+/* used in conjunction with CKNR05, which gives the number of */
+/* pointing instances stored in a segment. */
+
+/* $ Examples */
+
+/* Suppose that MOC.BC is a CK file that contains segments of */
+/* data type 5. Then the following code fragment extracts the */
+/* SCLK time and boresight vector for each pointing instance */
+/* in the first segment in the file. */
+
+
+/* INTEGER ICD ( 6 ) */
+/* INTEGER HANDLE */
+/* INTEGER NREC */
+/* INTEGER I */
+
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION RECORD ( 16 ) */
+/* DOUBLE PRECISION QUAT ( 4 ) */
+/* DOUBLE PRECISION BORE ( 3 ) */
+/* DOUBLE PRECISION CMAT ( 3, 3 ) */
+/* DOUBLE PRECISION SCLKDP */
+
+/* LOGICAL FOUND */
+
+/* C */
+/* C First load the file. (The file may also be opened by using */
+/* C CKLPF.) */
+/* C */
+/* CALL DAFOPR ( 'MOC.BC', HANDLE ) */
+
+/* C */
+/* C Begin forward search. Find the first array. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* C */
+/* C Get segment descriptor. */
+/* C */
+/* CALL DAFGS ( DESCR ) */
+
+/* C */
+/* C Unpack the segment descriptor into its double precision */
+/* C and integer components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* C */
+/* C The data type for a segment is located in the third integer */
+/* C component of the descriptor. */
+/* C */
+/* IF ( ICD( 3 ) .EQ. 5 ) THEN */
+/* C */
+/* C How many records does this segment contain? */
+/* C */
+/* CALL CKNR05 ( HANDLE, DESCR, NREC ) */
+
+/* DO I = 1, NREC */
+/* C */
+/* C Get the Ith pointing instance in the segment. */
+/* C */
+/* CALL CKGR05 ( HANDLE, DESCR, I, RECORD ) */
+
+/* C */
+/* C Unpack from RECORD the time tag and quaternion. */
+/* C The locations of these items in the record are */
+/* C independent of the subtype. */
+/* C */
+/* SCLKDP = RECORD ( 1 ) */
+
+/* CALL MOVED ( RECORD(3), 4, QUAT ) */
+
+/* C */
+/* C The boresight vector is the third row of the C-matrix. */
+/* C */
+/* CALL Q2M ( QUAT, CMAT ) */
+
+/* BORE(1) = CMAT(3,1) */
+/* BORE(2) = CMAT(3,2) */
+/* BORE(3) = CMAT(3,3) */
+/* C */
+/* C Write out the results. */
+/* C */
+/* WRITE (*,*) 'Record: ', I */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'SCLK time = ', SCLKDP */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'boresight: ', BORE */
+
+/* END DO */
+
+/* END IF */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* J.M. Lynch (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 27-AUG-2002 (NJB) (JML) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get ck type_5 record */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel segment descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel segment descriptor. */
+
+/* DTYPE is the data type of the segment that this routine */
+/* operates on. */
+
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKGR05", (ftnlen)6);
+ }
+
+/* The unpacked descriptor contains the following information */
+/* about the segment: */
+
+/* DCD(1) Initial encoded SCLK */
+/* DCD(2) Final encoded SCLK */
+/* ICD(1) Instrument */
+/* ICD(2) Inertial reference frame */
+/* ICD(3) Data type */
+/* ICD(4) Angular velocity flag */
+/* ICD(5) Initial address of segment data */
+/* ICD(6) Final address of segment data */
+
+/* From the descriptor, determine */
+
+/* 1 - Is this really a type 5 segment? */
+/* 2 - The beginning address of the segment. */
+/* 3 - The number of pointing instances in the segment (it's the */
+/* last word in the segment). */
+/* 4 - The existence of angular velocity data, which determines how */
+/* big the pointing portion of the returned record will be. */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ if (icd[2] != 5) {
+ setmsg_("Data type of the segment should be 5: Passed descriptor sho"
+ "ws type = #.", (ftnlen)71);
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
+ chkout_("CKGR05", (ftnlen)6);
+ return 0;
+ }
+
+/* Capture the segment's address range. */
+
+ beg = icd[4];
+ end = icd[5];
+
+/* Read the subtype from the segment. */
+
+ i__1 = end - 3;
+ i__2 = end - 3;
+ dafgda_(handle, &i__1, &i__2, &record[1]);
+ subtyp = (integer) record[1];
+ if (subtyp == 0) {
+ packsz = 8;
+ } else if (subtyp == 1) {
+ packsz = 4;
+ } else if (subtyp == 2) {
+ packsz = 14;
+ } else if (subtyp == 3) {
+ packsz = 7;
+ } else {
+ setmsg_("Unexpected CK type 5 subtype # found in type 5 segment.", (
+ ftnlen)55);
+ errint_("#", &subtyp, (ftnlen)1);
+ sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
+ chkout_("CKGR05", (ftnlen)6);
+ return 0;
+ }
+ dafgda_(handle, &end, &end, &npoint);
+ nrec = i_dnnt(&npoint);
+
+/* If a request was made for a record which doesn't exist, then */
+/* signal an error and leave. */
+
+ if (*recno < 1 || *recno > nrec) {
+ setmsg_("Requested record number (#) does not exist. There are # rec"
+ "ords in the segment.", (ftnlen)79);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", &nrec, (ftnlen)1);
+ sigerr_("SPICE(CKNONEXISTREC)", (ftnlen)20);
+ chkout_("CKGR05", (ftnlen)6);
+ return 0;
+ }
+
+/* Get the pointing record indexed by RECNO. */
+
+ addr__ = beg + packsz * (*recno - 1);
+ i__1 = addr__ + packsz - 1;
+ dafgda_(handle, &addr__, &i__1, &record[2]);
+
+/* Next get the SCLK time. Need to go past all of the NREC pointing */
+/* records (PACKSZ * NREC numbers), and then to the RECNOth SCLK */
+/* time. */
+
+ addr__ = beg + packsz * nrec + *recno - 1;
+ dafgda_(handle, &addr__, &addr__, record);
+ chkout_("CKGR05", (ftnlen)6);
+ return 0;
+} /* ckgr05_ */
+
diff --git a/ext/spice/src/cspice/cklpf_c.c b/ext/spice/src/cspice/cklpf_c.c
new file mode 100644
index 0000000000..136aa36826
--- /dev/null
+++ b/ext/spice/src/cspice/cklpf_c.c
@@ -0,0 +1,190 @@
+/*
+
+-Procedure cklpf_c ( C-kernel, load pointing file )
+
+-Abstract
+
+ Load a CK pointing file for use by the CK readers. Return that
+ file's handle, to be used by other CK routines to refer to the
+ file.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CK
+ DAF
+
+-Keywords
+
+ POINTING
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ void cklpf_c ( ConstSpiceChar * filename,
+ SpiceInt * handle )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ filename I Name of the CK file to be loaded.
+ handle O Loaded file's handle.
+
+-Detailed_Input
+
+ filename is the name of a C-kernel file to be loaded.
+
+-Detailed_Output
+
+ handle is an integer handle assigned to the file upon loading.
+ Almost every other CK routine will subsequently use
+ this number to refer to the file.
+
+-Parameters
+
+ ftsize is the maximum number of pointing files that can
+ be loaded by CKLPF at any given time for use by the
+ readers.
+
+-Exceptions
+
+ 1) If an attempt is made to load more files than is specified
+ by the parameter ftsize, the error "SPICE(CKTOOMANYFILES)"
+ is signalled.
+
+ 2) If an attempt is made to open more DAF files than is specified
+ by the parameter ftsize in DAFAH, an error is signalled by a
+ routine that this routine calls.
+
+ 3) If the file specified by filename can not be opened, an error
+ is signalled by a routine that this routine calls.
+
+ 4) If the file specified by filename has already been loaded,
+ it will become the "last-loaded" file. (The readers
+ search the last-loaded file first.)
+
+-Files
+
+ The C-kernel file specified by filename is loaded. The file is
+ assigned an integer handle by CKLPF. Other CK routines will refer
+ to this file by its handle.
+
+-Particulars
+
+ See Particulars in ckbsr.
+
+ If there is room for a new file, CKLPF opens the file for
+ reading. This routine must be called prior to a call to CKGP or
+ CKGPAV.
+
+ CK readers search files loaded with CKLPF in the reverse order
+ in which they were loaded. That is, last-loaded files are
+ searched first.
+
+-Examples
+
+ ck_kern = "/kernels/mpf/ck/lander_nominal.bck";
+ cklpf_c ( ck_kern, &hand );
+
+ Also see the Example in ckbsr.for.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ J.M. Lynch (JPL)
+ J.E. McLean (JPL)
+ M.J. Spencer (JPL)
+ R.E. Thurman (JPL)
+ I.M. Underwood (JPL)
+ E.D. Wright (JPL)
+ B.V. Semenov (JPL)
+
+-Version
+
+ -CSPICE Version 2.0.1, 31-JAN-2008 (BVS)
+
+ Removed '-Revisions' from the header.
+
+ -CSPICE Version 2.0.0, 08-FEB-1998 (NJB)
+
+ Input argument filename changed to type ConstSpiceChar *;
+ name was changed to "filename" from "fname."
+
+ References to C2F_CreateStr_Sig were removed; code was
+ cleaned up accordingly. String checks are now done using
+ the macro CHKFSTR.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (EDW)
+
+-Index_Entries
+
+ load ck pointing file
+
+-&
+*/
+
+{ /* Begin spklef_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "cklpf_c" );
+
+
+ /*
+ Check the input string filename to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "cklpf_c", filename );
+
+
+ /*
+ Call the f2c'd Fortran routine.
+ */
+ cklpf_ ( ( char * ) filename,
+ ( integer * ) handle,
+ ( ftnlen ) strlen(filename) );
+
+
+ chkout_c ( "cklpf_c" );
+
+} /* end cklpf_c */
diff --git a/ext/spice/src/cspice/ckmeta.c b/ext/spice/src/cspice/ckmeta.c
new file mode 100644
index 0000000000..b9fd3c6018
--- /dev/null
+++ b/ext/spice/src/cspice/ckmeta.c
@@ -0,0 +1,419 @@
+/* ckmeta.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static integer c__0 = 0;
+static integer c__2 = 2;
+
+/* $Procedure CKMETA ( CK ID to associated SCLK ) */
+/* Subroutine */ int ckmeta_(integer *ckid, char *meta, integer *idcode,
+ ftnlen meta_len)
+{
+ /* Initialized data */
+
+ static char base[7] = "CKMETA.";
+ static integer currnt = 0;
+ static integer last = 0;
+ static logical nodata = TRUE_;
+
+ /* System generated locals */
+ address a__1[2];
+ integer i__1, i__2, i__3[2];
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+ /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen),
+ s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_cmp(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ static integer this__, spks[30], n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ static char agent[32*30];
+ extern /* Subroutine */ int ucase_(char *, char *, ftnlen, ftnlen),
+ errch_(char *, char *, ftnlen, ftnlen);
+ static logical found[2];
+ static integer sclks[30];
+ extern /* Subroutine */ int ljust_(char *, char *, ftnlen, ftnlen);
+ extern logical failed_(void);
+ extern integer bschoi_(integer *, integer *, integer *, integer *);
+ static logical update;
+ extern /* Subroutine */ int orderi_(integer *, integer *, integer *);
+ static integer cksord[30];
+ extern /* Subroutine */ int gipool_(char *, integer *, integer *, integer
+ *, integer *, logical *, ftnlen), sigerr_(char *, ftnlen);
+ static char mymeta[7];
+ extern /* Subroutine */ int chkout_(char *, ftnlen), prefix_(char *,
+ integer *, char *, ftnlen, ftnlen), cvpool_(char *, logical *,
+ ftnlen), setmsg_(char *, ftnlen), suffix_(char *, integer *, char
+ *, ftnlen, ftnlen), cmprss_(char *, integer *, char *, char *,
+ ftnlen, ftnlen, ftnlen);
+ static char lookup[32*2*30];
+ extern logical return_(void);
+ extern /* Subroutine */ int intstr_(integer *, char *, ftnlen), swpool_(
+ char *, integer *, char *, ftnlen, ftnlen);
+ static integer cks[30];
+
+/* $ Abstract */
+
+/* This routine returns (depending upon the users' request) */
+/* the ID code of either the spacecraft or spacecraft clock */
+/* associated with a C-Kernel ID code. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* CKID I The ID code for some C kernel object. */
+/* META I The kind of meta data requested 'SPK' or 'SCLK' */
+/* IDCODE O The ID code for the clock of the C kernel. */
+
+/* $ Detailed_Input */
+
+/* CKID is the ID code for some object whose attitude */
+/* and possibly angular velocity are stored in */
+/* some C-kernel. */
+
+/* META is a character string that indicates which piece */
+/* of meta data to fetch. Acceptable values are */
+/* 'SCLK' and 'SPK'. The routine is case insensitive. */
+/* Leading and trailing blanks are insignificant. */
+/* However, blanks between characters are regarded */
+/* as being significant and will result in the error */
+/* 'SPICE(UNKNOWNCKMETA)' being signalled. */
+
+/* $ Detailed_Output */
+
+/* IDCODE if META is 'SCLK' then the value returned in IDCODE */
+/* is the "ID code" of the spacecraft clock used for */
+/* converting ET to TICKS and TICKS to ET for the */
+/* C-kernel used to represent the attitude of the */
+/* object with ID code CKID. */
+
+/* if META is 'SPK' then the value returned in IDCODE */
+/* is the "ID code" of the spacecraft on which the */
+/* platform indicated by CKID is mounted. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the variable META is not recognized to be one of the */
+/* inputs 'SPK' or 'SCLK' then the error 'SPICE(UNKNOWNCKMETA)' */
+/* will be signalled. */
+
+/* 2) If CKID is greater than -1000, the associated SCLK and SPK */
+/* ID's must be in the kernel pool. If they are not present */
+/* a value of zero is returned for the requested item. Zero */
+/* is never the valid ID of a spacecraft clock or ephemeris */
+/* object. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This is a utility routine for mapping C-kernels to associated */
+/* spacecraft clocks. This is needed to facilitate the writing */
+/* of routines such as CKEZ and CKEZAV. */
+
+/* $ Examples */
+
+/* Suppose you would like to look up the attitude of */
+/* an object in a C-kernel but have ET and seconds as your */
+/* input time and tolerance. */
+
+/* This routine can be used in conjunction with SCE2C and */
+/* CKGPAV to perform this task. */
+
+/* CALL CKMETA ( CKID, 'SCLK' IDCODE ) */
+
+/* CALL SCE2C ( IDCODE, ET, TICKS ) */
+/* CALL SCE2C ( IDCODE, ET+SECTOL, TICK2 ) */
+
+/* TOL = TICK2 - TICKS */
+
+/* CALL CKGPAV ( CKID, TICKS, TOL, REF, CMAT, AV, CLKOUT, FOUND ) */
+
+/* IF ( FOUND ) THEN */
+
+/* CALL SCT2E ( IDCODE, CLKOUT, ETOUT ) */
+
+/* END IF */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 05-MAR-2009 (NJB) */
+
+/* This routine now keeps track of whether its kernel pool */
+/* look-up failed. If so, a kernel pool lookup is attempted on */
+/* the next call to this routine. This change is an enhancement, */
+/* not a bug fix (unlike similar modifications in SCLK routines). */
+
+/* Header sections were put in correct order. */
+
+/* - SPICELIB Version 1.0.1, 09-MAR-1999 (NJB) */
+
+/* Comments referring to SCE2T have been updated to refer to */
+/* SCE2C. Occurrences of "id" replaced by "ID." */
+
+/* - SPICELIB Version 1.0.0, 4-OCT-1994 (WLT) */
+
+
+/* -& */
+/* $ Index_Entries */
+
+/* Map C-kernel ID to SCLK and SPK ID */
+
+/* -& */
+
+/* SPICELIB Functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("CKMETA", (ftnlen)6);
+
+/* Get an upper-case, left-justified copy of the metadata */
+/* type ('SCLK' or 'SPK'). */
+
+ cmprss_(" ", &c__1, meta, mymeta, (ftnlen)1, meta_len, (ftnlen)7);
+ ljust_(mymeta, mymeta, (ftnlen)7, (ftnlen)7);
+ ucase_(mymeta, mymeta, (ftnlen)7, (ftnlen)7);
+
+/* See if we already have this CK ID in hand. */
+
+ this__ = bschoi_(ckid, &currnt, cks, cksord);
+ if (this__ > 0) {
+
+/* We've got it. Check to see if its value has been updated. */
+/* (Note that every CK ID has its own agent.) */
+
+ cvpool_(agent + (((i__1 = this__ - 1) < 30 && 0 <= i__1 ? i__1 :
+ s_rnge("agent", i__1, "ckmeta_", (ftnlen)264)) << 5), &update,
+ (ftnlen)32);
+ if (update || nodata) {
+ gipool_(lookup + (((i__1 = (this__ << 1) - 2) < 60 && 0 <= i__1 ?
+ i__1 : s_rnge("lookup", i__1, "ckmeta_", (ftnlen)268)) <<
+ 5), &c__1, &c__1, &n, &sclks[(i__2 = this__ - 1) < 30 &&
+ 0 <= i__2 ? i__2 : s_rnge("sclks", i__2, "ckmeta_", (
+ ftnlen)268)], found, (ftnlen)32);
+ gipool_(lookup + (((i__1 = (this__ << 1) - 1) < 60 && 0 <= i__1 ?
+ i__1 : s_rnge("lookup", i__1, "ckmeta_", (ftnlen)271)) <<
+ 5), &c__1, &c__1, &n, &spks[(i__2 = this__ - 1) < 30 && 0
+ <= i__2 ? i__2 : s_rnge("spks", i__2, "ckmeta_", (ftnlen)
+ 271)], &found[1], (ftnlen)32);
+ if (failed_()) {
+ nodata = TRUE_;
+ chkout_("CKMETA", (ftnlen)6);
+ return 0;
+ }
+
+/* Note that failure to find data is not an error in this */
+/* routine; it's just SPICE errors that are a problem. */
+
+ nodata = FALSE_;
+ }
+ } else {
+
+/* We don't have this on our handy list. Find a place to put it. */
+
+ if (currnt < 30) {
+ ++currnt;
+ last = currnt;
+ } else {
+ ++last;
+ if (last > 30) {
+ last = 1;
+ }
+ }
+ this__ = last;
+ cks[(i__1 = this__ - 1) < 30 && 0 <= i__1 ? i__1 : s_rnge("cks", i__1,
+ "ckmeta_", (ftnlen)314)] = *ckid;
+
+/* Recompute the order vector for the CKS; construct the */
+/* kernel pool variable names and the agent name. */
+
+ orderi_(cks, &currnt, cksord);
+ intstr_(ckid, lookup + (((i__1 = (this__ << 1) - 2) < 60 && 0 <= i__1
+ ? i__1 : s_rnge("lookup", i__1, "ckmeta_", (ftnlen)321)) << 5)
+ , (ftnlen)32);
+ prefix_("CK_", &c__0, lookup + (((i__1 = (this__ << 1) - 2) < 60 && 0
+ <= i__1 ? i__1 : s_rnge("lookup", i__1, "ckmeta_", (ftnlen)
+ 322)) << 5), (ftnlen)3, (ftnlen)32);
+/* Writing concatenation */
+ i__3[0] = 7, a__1[0] = base;
+ i__3[1] = 32, a__1[1] = lookup + (((i__2 = (this__ << 1) - 2) < 60 &&
+ 0 <= i__2 ? i__2 : s_rnge("lookup", i__2, "ckmeta_", (ftnlen)
+ 324)) << 5);
+ s_cat(agent + (((i__1 = this__ - 1) < 30 && 0 <= i__1 ? i__1 : s_rnge(
+ "agent", i__1, "ckmeta_", (ftnlen)324)) << 5), a__1, i__3, &
+ c__2, (ftnlen)32);
+ s_copy(lookup + (((i__1 = (this__ << 1) - 1) < 60 && 0 <= i__1 ? i__1
+ : s_rnge("lookup", i__1, "ckmeta_", (ftnlen)325)) << 5),
+ lookup + (((i__2 = (this__ << 1) - 2) < 60 && 0 <= i__2 ?
+ i__2 : s_rnge("lookup", i__2, "ckmeta_", (ftnlen)325)) << 5),
+ (ftnlen)32, (ftnlen)32);
+ suffix_("_SCLK", &c__0, lookup + (((i__1 = (this__ << 1) - 2) < 60 &&
+ 0 <= i__1 ? i__1 : s_rnge("lookup", i__1, "ckmeta_", (ftnlen)
+ 327)) << 5), (ftnlen)5, (ftnlen)32);
+ suffix_("_SPK", &c__0, lookup + (((i__1 = (this__ << 1) - 1) < 60 &&
+ 0 <= i__1 ? i__1 : s_rnge("lookup", i__1, "ckmeta_", (ftnlen)
+ 328)) << 5), (ftnlen)4, (ftnlen)32);
+
+/* Set a watch for this item and fetch the current value */
+/* from the kernel pool (if there is a value there). */
+
+ swpool_(agent + (((i__1 = this__ - 1) < 30 && 0 <= i__1 ? i__1 :
+ s_rnge("agent", i__1, "ckmeta_", (ftnlen)334)) << 5), &c__1,
+ lookup + (((i__2 = (this__ << 1) - 2) < 60 && 0 <= i__2 ?
+ i__2 : s_rnge("lookup", i__2, "ckmeta_", (ftnlen)334)) << 5),
+ (ftnlen)32, (ftnlen)32);
+ cvpool_(agent + (((i__1 = this__ - 1) < 30 && 0 <= i__1 ? i__1 :
+ s_rnge("agent", i__1, "ckmeta_", (ftnlen)335)) << 5), &update,
+ (ftnlen)32);
+ gipool_(lookup + (((i__1 = (this__ << 1) - 2) < 60 && 0 <= i__1 ?
+ i__1 : s_rnge("lookup", i__1, "ckmeta_", (ftnlen)337)) << 5),
+ &c__1, &c__1, &n, &sclks[(i__2 = this__ - 1) < 30 && 0 <=
+ i__2 ? i__2 : s_rnge("sclks", i__2, "ckmeta_", (ftnlen)337)],
+ found, (ftnlen)32);
+ gipool_(lookup + (((i__1 = (this__ << 1) - 1) < 60 && 0 <= i__1 ?
+ i__1 : s_rnge("lookup", i__1, "ckmeta_", (ftnlen)340)) << 5),
+ &c__1, &c__1, &n, &spks[(i__2 = this__ - 1) < 30 && 0 <= i__2
+ ? i__2 : s_rnge("spks", i__2, "ckmeta_", (ftnlen)340)], &
+ found[1], (ftnlen)32);
+ if (failed_()) {
+ nodata = TRUE_;
+ chkout_("CKMETA", (ftnlen)6);
+ return 0;
+ }
+
+/* Note that failure to find data is not an error in this */
+/* routine; it's just SPICE errors that are a problem. */
+
+/* At this point, kernel data checks are done. */
+
+ nodata = FALSE_;
+
+/* If we didn't find it, we manufacture an ID code based upon */
+/* the "convention" used for all CKS so far. However, the */
+/* convention assumes that the CK ID will be less than -1000 */
+/* if it's not there is no sensible ID to return. We return */
+/* zero in that case. */
+
+ if (cks[(i__1 = this__ - 1) < 30 && 0 <= i__1 ? i__1 : s_rnge("cks",
+ i__1, "ckmeta_", (ftnlen)368)] <= -1000) {
+ if (! found[0]) {
+ sclks[(i__1 = this__ - 1) < 30 && 0 <= i__1 ? i__1 : s_rnge(
+ "sclks", i__1, "ckmeta_", (ftnlen)371)] = cks[(i__2 =
+ this__ - 1) < 30 && 0 <= i__2 ? i__2 : s_rnge("cks",
+ i__2, "ckmeta_", (ftnlen)371)] / 1000;
+ }
+ if (! found[1]) {
+ spks[(i__1 = this__ - 1) < 30 && 0 <= i__1 ? i__1 : s_rnge(
+ "spks", i__1, "ckmeta_", (ftnlen)375)] = cks[(i__2 =
+ this__ - 1) < 30 && 0 <= i__2 ? i__2 : s_rnge("cks",
+ i__2, "ckmeta_", (ftnlen)375)] / 1000;
+ }
+ } else {
+ if (! found[0]) {
+ sclks[(i__1 = this__ - 1) < 30 && 0 <= i__1 ? i__1 : s_rnge(
+ "sclks", i__1, "ckmeta_", (ftnlen)381)] = 0;
+ }
+ if (! found[1]) {
+ spks[(i__1 = this__ - 1) < 30 && 0 <= i__1 ? i__1 : s_rnge(
+ "spks", i__1, "ckmeta_", (ftnlen)385)] = 0;
+ }
+ }
+ }
+ if (s_cmp(mymeta, "SPK", (ftnlen)7, (ftnlen)3) == 0) {
+ *idcode = spks[(i__1 = this__ - 1) < 30 && 0 <= i__1 ? i__1 : s_rnge(
+ "spks", i__1, "ckmeta_", (ftnlen)395)];
+ } else if (s_cmp(mymeta, "SCLK", (ftnlen)7, (ftnlen)4) == 0) {
+ *idcode = sclks[(i__1 = this__ - 1) < 30 && 0 <= i__1 ? i__1 : s_rnge(
+ "sclks", i__1, "ckmeta_", (ftnlen)399)];
+ } else {
+ *idcode = 0;
+ setmsg_("The CK meta data item \"#\" is not a recognized meta data i"
+ "tem for the routine CKMETA. The recognized value are \"SP"
+ "K\" and \"SCLK\". ", (ftnlen)129);
+ errch_("#", meta, (ftnlen)1, meta_len);
+ sigerr_("SPICE(UNKNOWNCKMETA)", (ftnlen)20);
+ chkout_("CKMETA", (ftnlen)6);
+ return 0;
+ }
+ chkout_("CKMETA", (ftnlen)6);
+ return 0;
+} /* ckmeta_ */
+
diff --git a/ext/spice/src/cspice/cknr01.c b/ext/spice/src/cspice/cknr01.c
new file mode 100644
index 0000000000..ca5e41af04
--- /dev/null
+++ b/ext/spice/src/cspice/cknr01.c
@@ -0,0 +1,325 @@
+/* cknr01.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKNR01 ( C-kernel, number of records, type 01 ) */
+/* Subroutine */ int cknr01_(integer *handle, doublereal *descr, integer *
+ nrec)
+{
+ doublereal n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *), dafgda_(integer *,
+ integer *, integer *, doublereal *), sigerr_(char *, ftnlen),
+ chkout_(char *, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+
+/* $ Abstract */
+
+/* Given the handle of a CK file and the descriptor of a data */
+/* type 1 segment in that file, return the number of pointing */
+/* records in that segment. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of the file containing the segment. */
+/* DESCR I The descriptor of the type 1 segment. */
+/* NREC O The number of records in the segment. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the binary CK file containing the */
+/* segment whose descriptor was also passed. The file */
+/* should have been opened for read access, either by */
+/* CKLPF or DAFOPR. */
+
+/* DESCR The packed descriptor of a data type 1 segment. */
+
+/* $ Detailed_Output */
+
+/* NREC The number of pointing records in the type 1 segment. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the segment indicated by DESCR is not a type 1 segment, */
+/* the error 'SPICE(CKWRONGDATATYPE)' is signalled. */
+
+/* 2) If the specified handle does not belong to any file that is */
+/* currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 3) If DESCR is not a valid, packed descriptor of a segment in */
+/* the CK file specified by HANDLE, the results of this routine */
+/* are unpredictable. */
+
+/* $ Files */
+
+/* The file specified by HANDLE should be open for read access. */
+
+/* $ Particulars */
+
+/* For a complete description of the internal structure of a type 1 */
+/* segment, see the CK required reading. */
+
+/* $ Examples */
+
+/* The following code fragment prints the records of the first */
+/* segment in a CK file. Suppose MOC.CK is binary CK file that */
+/* contains segments of data type 1. */
+
+/* INTEGER ICD ( 6 ) */
+/* INTEGER HANDLE */
+/* INTEGER NREC */
+/* INTEGER I */
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION RECORD ( 8 ) */
+/* LOGICAL FOUND */
+
+/* C */
+/* C First load the file. (The file may also be opened by using */
+/* C CKLPF.) */
+/* C */
+/* CALL DAFOPR ( 'MOC.CK', HANDLE ) */
+
+/* C */
+/* C Begin forward search. Find first array. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* C */
+/* C Get segment descriptor. */
+/* C */
+/* CALL DAFGS ( DESCR ) */
+
+/* C */
+/* C Unpack the segment descriptor into its double precision */
+/* C and integer components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* C */
+/* C The data type for a segment is located in the third integer */
+/* C component of the descriptor. */
+/* C */
+/* IF ( ICD( 3 ) .EQ. 1 ) THEN */
+
+/* C */
+/* C How many records does this segment contain? */
+/* C */
+/* CALL CKNR01 ( HANDLE, DESCR, NREC ) */
+
+/* DO I = 1, NREC */
+
+/* C */
+/* C Get the record associated with record number I. */
+/* C */
+/* CALL CKGR01 ( HANDLE, DESCR, I, RECORD ) */
+/* WRITE (*,*) 'Record ', I, ':' */
+/* WRITE (*,*) RECORD */
+/* END DO */
+
+/* END IF */
+
+/* $ Restrictions */
+
+/* The binay CK file containing the segment whose descriptor was */
+/* passed to this routine must be opened for read access by either */
+/* CKLPF or DAFOPR. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.E. McLean (JPL) */
+/* M.J. Spencer (JPL) */
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 07-SEP-2001 (EDW) */
+
+/* Replaced DAFRDA call with DAFGDA. */
+/* Added IMPLICIT NONE. */
+
+/* - SPICELIB Version 1.0.3, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.2, 06-MAR-1991 (JML) */
+
+/* A correction was made to the example program in the */
+/* header. The array of double precision components of */
+/* the descriptor ( DCD ) had originally been declared */
+/* as an integer. */
+
+/* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
+
+/* The restriction that a C-kernel file must be loaded */
+/* was explicitly stated. */
+
+/* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* number of ck type_1 records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.2, 06-MAR-1991 (JML) */
+
+/* A correction was made to the example program in the */
+/* header. The array of double precision components of */
+/* the descriptor ( DCD ) had originally been declared */
+/* as an integer. */
+
+/* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
+
+/* 1) The restriction that a C-kernel file must be loaded */
+/* was explicitly stated. */
+/* 2) Minor changes were made to the wording of the header. */
+
+/* - Beta Version 1.1.0, 28-AUG-1990 (MJS) (JEM) */
+
+/* The following changes were made as a result of the */
+/* NAIF CK Code and Documentation Review: */
+
+/* 1) The name of this routine was changed from CK01NR to */
+/* CKNR01 in order to be consistent with the SPICELIB */
+/* naming convention. */
+/* 2) The declarations for the parameters NDC and NIC were */
+/* moved from the "Declarations" section of the header to */
+/* the "Local parameters" section of the code below the */
+/* header. These parameters are not meant to modified by */
+/* users. */
+/* 3) The variables INTDES and DPDES were changed to ICD and */
+/* DCD. */
+/* 4) The header was corrected, improved, and updated to reflect */
+/* the changes. */
+/* 5) The in-code comments were improved. */
+
+/* - Beta Version 1.0.0, 22-MAY-1990 (RET) (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel descriptor. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKNR01", (ftnlen)6);
+ }
+
+/* The number of pointing records contained in a data type 1 */
+/* segment is stored in the final double precision word of the */
+/* segment. Since the address of this very word is stored in the */
+/* sixth integer component of the segment descriptor, it is a trivial */
+/* matter to extract the count. */
+
+/* The unpacked descriptor contains the following information */
+/* about the segment: */
+
+/* DCD(1) Initial encoded SCLK */
+/* DCD(2) Final encoded SCLK */
+/* ICD(1) Instrument */
+/* ICD(2) Inertial reference frame */
+/* ICD(3) Data type */
+/* ICD(4) Angular velocity flag */
+/* ICD(5) Initial address of segment data */
+/* ICD(6) Final address of segment data */
+
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+
+/* If this segment is not of data type 1, then signal an error. */
+
+ if (icd[2] != 1) {
+ setmsg_("Data type of the segment should be 1: Passed descriptor sho"
+ "ws type = #.", (ftnlen)71);
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
+ chkout_("CKNR01", (ftnlen)6);
+ return 0;
+ }
+
+/* The number of records is the final word in the segment. */
+
+ dafgda_(handle, &icd[5], &icd[5], &n);
+ *nrec = (integer) n;
+ chkout_("CKNR01", (ftnlen)6);
+ return 0;
+} /* cknr01_ */
+
diff --git a/ext/spice/src/cspice/cknr02.c b/ext/spice/src/cspice/cknr02.c
new file mode 100644
index 0000000000..3bb6b025db
--- /dev/null
+++ b/ext/spice/src/cspice/cknr02.c
@@ -0,0 +1,318 @@
+/* cknr02.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKNR02 ( C-kernel, number of records, type 02 ) */
+/* Subroutine */ int cknr02_(integer *handle, doublereal *descr, integer *
+ nrec)
+{
+ /* System generated locals */
+ doublereal d__1;
+
+ /* Builtin functions */
+ integer i_dnnt(doublereal *);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *), sigerr_(char *,
+ ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen),
+ errint_(char *, integer *, ftnlen);
+ integer arrsiz;
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer beg, icd[6], end;
+
+/* $ Abstract */
+
+/* Given the handle of a CK file and the descriptor of a type 2 */
+/* segment in that file, return the number of pointing records */
+/* in that segment. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of the file containing the segment. */
+/* DESCR I The descriptor of the type 2 segment. */
+/* NREC O The number of records in the segment. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the binary CK file containing the */
+/* segment. The file should have been opened for read */
+/* or write access, either by CKLPF, DAFOPR, or DAFOPW. */
+
+/* DESCR The packed descriptor of a data type 2 segment. */
+
+/* $ Detailed_Output */
+
+/* NREC The number of pointing records in the type 2 segment */
+/* associated with HANDLE and DESCR. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the segment indicated by DESCR is not a type 2 segment, */
+/* the error 'SPICE(CKWRONGDATATYPE)' is signalled. */
+
+/* 2) If the specified handle does not belong to any file that is */
+/* currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 3) If DESCR is not a valid descriptor of a segment in the CK */
+/* file specified by HANDLE, the results of this routine are */
+/* unpredictable. */
+
+/* $ Files */
+
+/* The file specified by HANDLE should be open for read or write */
+/* access. */
+
+/* $ Particulars */
+
+/* For a complete description of the internal structure of a type 2 */
+/* segment, see the CK required reading. */
+
+/* This routine returns the number of pointing records contained */
+/* in the specified segment. It is normally used in conjunction */
+/* with CKGR02, which returns the Ith record in the segment. */
+
+/* $ Examples */
+
+/* Suppose GLL_PLT.BC is a CK file that contains segments of data */
+/* type 2. Then the following code fragment uses CKNR02 and CKGR02 */
+/* to extract each pointing record in the first segment in the file. */
+
+/* INTEGER ICD ( 6 ) */
+/* INTEGER HANDLE */
+/* INTEGER NREC */
+/* INTEGER I */
+
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION RECORD ( 10 ) */
+
+/* LOGICAL FOUND */
+
+/* C */
+/* C First load the file. ( The file may also be opened by using */
+/* C CKLPF. ) */
+/* C */
+/* CALL DAFOPR ( 'GLL_PLT.BC', HANDLE ) */
+
+/* C */
+/* C Begin forward search. Find the first array. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* C */
+/* C Get segment descriptor. */
+/* C */
+/* CALL DAFGS ( DESCR ) */
+
+/* C */
+/* C Unpack the segment descriptor into its double precision */
+/* C and integer components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* C */
+/* C The data type for a segment is located in the third integer */
+/* C component of the descriptor. */
+/* C */
+/* IF ( ICD( 3 ) .EQ. 2 ) THEN */
+
+/* C */
+/* C How many records does this segment contain? */
+/* C */
+/* CALL CKNR02 ( HANDLE, DESCR, NREC ) */
+
+/* DO I = 1, NREC */
+
+/* C */
+/* C Get the Ith record in the segment. */
+/* C */
+/* CALL CKGR02 ( HANDLE, DESCR, I, RECORD ) */
+/* C */
+/* C Process the pointing data. */
+/* C */
+/* . */
+/* . */
+/* . */
+
+/* END DO */
+
+/* END IF */
+
+/* $ Restrictions */
+
+/* 1) The binary CK file containing the segment whose descriptor was */
+/* passed to this routine must be opened for read or write access */
+/* by either CKLPF, DAFOPR, DAFOPW. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.M. Lynch (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 25-NOV-1992 (JML) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* number of ck type_2 records */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel descriptor. */
+
+/* DTYPE is the data type. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKNR02", (ftnlen)6);
+ }
+
+/* The unpacked descriptor contains the following information */
+/* about the segment: */
+
+/* DCD(1) Initial encoded SCLK */
+/* DCD(2) Final encoded SCLK */
+/* ICD(1) Instrument */
+/* ICD(2) Inertial reference frame */
+/* ICD(3) Data type */
+/* ICD(4) Angular velocity flag */
+/* ICD(5) Initial address of segment data */
+/* ICD(6) Final address of segment data */
+
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+
+/* If this segment is not of data type 2, then signal an error. */
+
+ if (icd[2] != 2) {
+ setmsg_("Data type of the segment should be 2: Passed descriptor sho"
+ "ws type = #.", (ftnlen)71);
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
+ chkout_("CKNR02", (ftnlen)6);
+ return 0;
+ }
+
+/* The beginning and ending addresses of the segment are in the */
+/* descriptor. */
+
+ beg = icd[4];
+ end = icd[5];
+
+/* Calculate the number of pointing records in the segment from */
+/* the physical size of the segment and knowledge of its structure. */
+
+/* Based on the structure of a type 2 segment, the size of a */
+/* segment with N pointing intervals is given as follows: */
+
+/* ARRSIZ = PSIZ * N + 2 * N + ( N-1 ) / 100 (1) */
+
+/* In the above equation PSIZ is eight and integer arithmetic is */
+/* used. This equation is equivalent to: */
+
+
+/* 100 * ARRSIZ = 1000 * N + ( N-1 ) * 100 (2) */
+/* ------- */
+/* 100 */
+
+/* If we can eliminate the integer division then, since all of */
+/* the other values represent whole numbers, we can solve the */
+/* equation for N in terms of ARRSIZ by using double precision */
+/* arithmetic and then rounding the result to the nearest integer. */
+
+/* This next equation uses double precision arithmetic and is */
+/* equivalent to (2): */
+
+/* 100 * ARRSIZ = 1000 * N + ( N-1 ) - ( N-1 ) MOD 100 (3) */
+
+/* Which means: */
+
+/* 100 * ARRSIZ + 1 ( N-1 ) MOD 100 */
+/* ---------------- + --------------- = N (4) */
+/* 1001 1001 */
+
+/* Since the second term on the left side of (4) is always less */
+/* than 0.1, the first term will always round to the correct */
+/* value of N. */
+
+ arrsiz = end - beg + 1;
+ d__1 = ((doublereal) arrsiz * 100. + 1.) / 1001.;
+ *nrec = i_dnnt(&d__1);
+ chkout_("CKNR02", (ftnlen)6);
+ return 0;
+} /* cknr02_ */
+
diff --git a/ext/spice/src/cspice/cknr03.c b/ext/spice/src/cspice/cknr03.c
new file mode 100644
index 0000000000..e0b9854d8e
--- /dev/null
+++ b/ext/spice/src/cspice/cknr03.c
@@ -0,0 +1,324 @@
+/* cknr03.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKNR03 ( C-kernel, number of records, type 03 ) */
+/* Subroutine */ int cknr03_(integer *handle, doublereal *descr, integer *
+ nrec)
+{
+ /* Builtin functions */
+ integer i_dnnt(doublereal *);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *), dafgda_(integer *,
+ integer *, integer *, doublereal *), sigerr_(char *, ftnlen),
+ chkout_(char *, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ doublereal npoint;
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+
+/* $ Abstract */
+
+/* Given the handle of a CK file and the descriptor of a type 3 */
+/* segment in that file, return the number of pointing instances */
+/* in that segment. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of the file containing the segment. */
+/* DESCR I The descriptor of the type 3 segment. */
+/* NREC O The number of pointing instances in the segment. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the binary CK file containing the */
+/* segment. The file should have been opened for read */
+/* or write access, either by CKLPF, DAFOPR, or DAFOPW. */
+
+/* DESCR The packed descriptor of a data type 3 segment. */
+
+/* $ Detailed_Output */
+
+/* NREC The number of pointing instances in the type 3 segment. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the segment indicated by DESCR is not a type 3 segment, */
+/* the error 'SPICE(CKWRONGDATATYPE)' is signalled. */
+
+/* 2) If the specified handle does not belong to any DAF file that */
+/* is currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 3) If DESCR is not a valid descriptor of a segment in the CK */
+/* file specified by HANDLE, the results of this routine are */
+/* unpredictable. */
+
+/* $ Files */
+
+/* The file specified by HANDLE should be open for read or */
+/* write access. */
+
+/* $ Particulars */
+
+/* For a complete description of the internal structure of a type 3 */
+/* segment, see the CK required reading. */
+
+/* This routine returns the number of discrete pointing instances */
+/* contained in the specified segment. It is normally used in */
+/* conjunction with CKGR03 which returns the Ith pointing instance */
+/* in the segment. */
+
+/* $ Examples */
+
+/* Suppose that MOC.BC is a CK file that contains segments of */
+/* data type 3. Then the following code fragment extracts the */
+/* SCLK time, boresight vector, and angular velocity vector for */
+/* each pointing instance in the first segment in the file. */
+
+
+/* INTEGER ICD ( 6 ) */
+/* INTEGER HANDLE */
+/* INTEGER NREC */
+/* INTEGER I */
+
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION RECORD ( 8 ) */
+/* DOUBLE PRECISION QUAT ( 4 ) */
+/* DOUBLE PRECISION AV ( 3 ) */
+/* DOUBLE PRECISION BORE ( 3 ) */
+/* DOUBLE PRECISION CMAT ( 3, 3 ) */
+/* DOUBLE PRECISION SCLKDP */
+
+/* LOGICAL FOUND */
+/* LOGICAL AVSEG */
+
+/* C */
+/* C First load the file. (The file may also be opened by using */
+/* C CKLPF.) */
+/* C */
+/* CALL DAFOPR ( 'MOC.BC', HANDLE ) */
+
+/* C */
+/* C Begin forward search. Find the first array. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* C */
+/* C Get segment descriptor. */
+/* C */
+/* CALL DAFGS ( DESCR ) */
+
+/* C */
+/* C Unpack the segment descriptor into its double precision */
+/* C and integer components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* C */
+/* C The data type for a segment is located in the third integer */
+/* C component of the descriptor. */
+/* C */
+/* IF ( ICD( 3 ) .EQ. 3 ) THEN */
+/* C */
+/* C Does the segment contain AV data? */
+/* C */
+/* AVSEG = ( ICD(4) .EQ. 1 ) */
+/* C */
+/* C How many records does this segment contain? */
+/* C */
+/* CALL CKNR03 ( HANDLE, DESCR, NREC ) */
+
+/* DO I = 1, NREC */
+
+/* C */
+/* C Get the Ith pointing instance in the segment. */
+/* C */
+/* CALL CKGR03 ( HANDLE, DESCR, I, RECORD ) */
+
+/* C */
+/* C Unpack RECORD into the time, quaternion, and av. */
+/* C */
+/* SCLKDP = RECORD ( 1 ) */
+
+/* CALL MOVED ( RECORD(2), 4, QUAT ) */
+
+/* IF ( AVSEG ) THEN */
+/* CALL MOVED ( RECORD(6), 3, AV ) */
+/* END IF */
+/* C */
+/* C The boresight vector is the third row of the C-matrix. */
+/* C */
+/* CALL Q2M ( QUAT, CMAT ) */
+
+/* BORE(1) = CMAT(3,1) */
+/* BORE(2) = CMAT(3,2) */
+/* BORE(3) = CMAT(3,3) */
+/* C */
+/* C Write out the results. */
+/* C */
+/* WRITE (*,*) 'Record: ', I */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'SCLK time = ', SCLKDP */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'boresight: ', BORE */
+
+/* IF ( AVSEG ) THEN */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'angular velocity: ', AV */
+/* END IF */
+
+/* END DO */
+
+/* END IF */
+
+/* $ Restrictions */
+
+/* 1) The binary CK file containing the segment whose descriptor was */
+/* passed to this routine must be opened for read or write access */
+/* by either CKLPF, DAFOPR, or DAFOPW. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.M. Lynch (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 07-SEP-2001 (EDW) */
+
+/* Replaced DAFRDA call with DAFGDA. */
+/* Added IMPLICIT NONE. */
+
+/* - SPICELIB Version 1.0.0, 25-NOV-1992 (JML) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* number of ck type_3 records */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel descriptor. */
+
+/* DTYPE is the data type of the segment that this routine */
+/* operates on. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKNR03", (ftnlen)6);
+ }
+
+/* The number of discrete pointing instances contained in a data */
+/* type 3 segment is stored in the last double precision word of */
+/* the segment. Since the address of the last word is stored in */
+/* the sixth integer component of the segment descriptor, it is */
+/* a trivial matter to extract the count. */
+
+/* The unpacked descriptor contains the following information */
+/* about the segment: */
+
+/* DCD(1) Initial encoded SCLK */
+/* DCD(2) Final encoded SCLK */
+/* ICD(1) Instrument */
+/* ICD(2) Inertial reference frame */
+/* ICD(3) Data type */
+/* ICD(4) Angular velocity flag */
+/* ICD(5) Initial address of segment data */
+/* ICD(6) Final address of segment data */
+
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+
+/* If this segment is not of data type 3, then signal an error. */
+
+ if (icd[2] != 3) {
+ setmsg_("Data type of the segment should be 3: Passed descriptor sho"
+ "ws type = #.", (ftnlen)71);
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
+ chkout_("CKNR03", (ftnlen)6);
+ return 0;
+ }
+
+/* The number of records is the final word in the segment. */
+
+ dafgda_(handle, &icd[5], &icd[5], &npoint);
+ *nrec = i_dnnt(&npoint);
+ chkout_("CKNR03", (ftnlen)6);
+ return 0;
+} /* cknr03_ */
+
diff --git a/ext/spice/src/cspice/cknr04.c b/ext/spice/src/cspice/cknr04.c
new file mode 100644
index 0000000000..e302f0b187
--- /dev/null
+++ b/ext/spice/src/cspice/cknr04.c
@@ -0,0 +1,433 @@
+/* cknr04.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+static integer c__12 = 12;
+
+/* $Procedure CKNR04 ( C-kernel, number of records, data type 4 ) */
+/* Subroutine */ int cknr04_(integer *handle, doublereal *descr, integer *
+ nrec)
+{
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *), sgmeta_(integer *,
+ doublereal *, integer *, integer *), sigerr_(char *, ftnlen),
+ chkout_(char *, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+
+/* $ Abstract */
+
+/* Given the handle of a CK file and the descriptor of a type 4 */
+/* segment in that file, return the number of pointing instances */
+/* in that segment. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+/* DAF.REQ */
+/* GS.REQ */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* Declarations of the CK data type specific and general CK low */
+/* level routine parameters. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* 1) If new CK types are added, the size of the record passed */
+/* between CKRxx and CKExx must be registered as separate */
+/* parameter. If this size will be greater than current value */
+/* of the CKMRSZ parameter (which specifies the maximum record */
+/* size for the record buffer used inside CKPFS) then it should */
+/* be assigned to CKMRSZ as a new value. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Literature_References */
+
+/* CK Required Reading. */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 19-AUG-2002 (NJB) */
+
+/* Updated to support CK type 5. */
+
+/* - SPICELIB Version 1.0.0, 05-APR-1999 (BVS) */
+
+/* -& */
+
+/* Number of quaternion components and number of quaternion and */
+/* angular rate components together. */
+
+
+/* CK Type 1 parameters: */
+
+/* CK1DTP CK data type 1 ID; */
+
+/* CK1RSZ maximum size of a record passed between CKR01 */
+/* and CKE01. */
+
+
+/* CK Type 2 parameters: */
+
+/* CK2DTP CK data type 2 ID; */
+
+/* CK2RSZ maximum size of a record passed between CKR02 */
+/* and CKE02. */
+
+
+/* CK Type 3 parameters: */
+
+/* CK3DTP CK data type 3 ID; */
+
+/* CK3RSZ maximum size of a record passed between CKR03 */
+/* and CKE03. */
+
+
+/* CK Type 4 parameters: */
+
+/* CK4DTP CK data type 4 ID; */
+
+/* CK4PCD parameter defining integer to DP packing schema that */
+/* is applied when seven number integer array containing */
+/* polynomial degrees for quaternion and angular rate */
+/* components packed into a single DP number stored in */
+/* actual CK records in a file; the value of must not be */
+/* changed or compatibility with existing type 4 CK files */
+/* will be lost. */
+
+/* CK4MXD maximum Chebychev polynomial degree allowed in type 4 */
+/* records; the value of this parameter must never exceed */
+/* value of the CK4PCD; */
+
+/* CK4SFT number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 4 */
+/* CK record that passed between routines CKR04 and CKE04; */
+
+/* CK4RSZ maximum size of type 4 CK record passed between CKR04 */
+/* and CKE04; CK4RSZ is computed as follows: */
+
+/* CK4RSZ = ( CK4MXD + 1 ) * QAVSIZ + CK4SFT */
+
+
+/* CK Type 5 parameters: */
+
+
+/* CK5DTP CK data type 5 ID; */
+
+/* CK5MXD maximum polynomial degree allowed in type 5 */
+/* records. */
+
+/* CK5MET number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 5 */
+/* CK record that passed between routines CKR05 and CKE05; */
+
+/* CK5MXP maximum packet size for any subtype. Subtype 2 */
+/* has the greatest packet size, since these packets */
+/* contain a quaternion, its derivative, an angular */
+/* velocity vector, and its derivative. See ck05.inc */
+/* for a description of the subtypes. */
+
+/* CK5RSZ maximum size of type 5 CK record passed between CKR05 */
+/* and CKE05; CK5RSZ is computed as follows: */
+
+/* CK5RSZ = ( CK5MXD + 1 ) * CK5MXP + CK5MET */
+
+
+
+/* Maximum record size that can be handled by CKPFS. This value */
+/* must be set to the maximum of all CKxRSZ parameters (currently */
+/* CK4RSZ.) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of the file containing the segment. */
+/* DESCR I The descriptor of the type 4 segment. */
+/* NREC O The number of pointing records in the segment. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the binary CK file containing the */
+/* segment. The file should have been opened for read */
+/* or write access, either by CKLPF, DAFOPR, or DAFOPW. */
+
+/* DESCR The packed descriptor of a data type 4 segment. */
+
+/* $ Detailed_Output */
+
+/* NREC The number of pointing records in the type 4 */
+/* segment. */
+
+/* $ Parameters */
+
+/* See 'ckparam.inc'. */
+
+/* $ Files */
+
+/* The file specified by HANDLE should be open for read or */
+/* write access. */
+
+/* $ Exceptions */
+
+/* 1) If the segment indicated by DESCR is not a type 4 segment, */
+/* the error 'SPICE(CKWRONGDATATYPE)' is signalled. */
+
+/* 2) If the specified handle does not belong to any DAF file that */
+/* is currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 3) If DESCR is not a valid descriptor of a segment in the CK */
+/* file specified by HANDLE, the results of this routine are */
+/* unpredictable. */
+
+/* $ Particulars */
+
+/* For a complete description of the internal structure of a type 4 */
+/* segment, see the CK required reading. */
+
+/* This routine returns the number of pointing records contained */
+/* in the specified segment. It is normally used in conjunction */
+/* with CKGR04 which returns the Ith pointing record in the */
+/* segment. */
+
+/* $ Examples */
+
+/* Suppose that DATA.BC is a CK file that contains segments of */
+/* data type 4. Then the following code fragment extracts the */
+/* data packets contained in the segment. */
+
+/* C */
+/* C CK parameters include file. */
+/* C */
+/* INCLUDE 'ckparam.inc' */
+/* C */
+/* C Declarations. */
+/* C */
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION PKTDAT ( CK4RSZ ) */
+
+/* INTEGER AVFLAG */
+/* INTEGER HANDLE */
+/* INTEGER I */
+/* INTEGER ICD ( 6 ) */
+/* INTEGER K */
+/* INTEGER LASTAD */
+/* INTEGER NCOEF ( QAVSIZ ) */
+/* INTEGER NREC */
+
+/* LOGICAL FOUND */
+/* C */
+/* C First load the file. (The file may also be opened by using */
+/* C CKLPF.) */
+/* C */
+/* CALL DAFOPR ( 'DATA.BC', HANDLE ) */
+/* C */
+/* C Begin forward search. Find the first array. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+/* C */
+/* C Get segment descriptor. */
+/* C */
+/* CALL DAFGS ( DESCR ) */
+/* C */
+/* C Unpack the segment descriptor into its double precision */
+/* C and integer components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* IF ( ICD( 3 ) .EQ. 4 ) THEN */
+/* C */
+/* C How many records does this segment contain? */
+/* C */
+/* CALL CKNR04 ( HANDLE, DESCR, NREC ) */
+
+/* DO I = 1, NREC */
+/* C */
+/* C Get the data records stored in the segment. */
+/* C */
+/* CALL CKGR04 ( HANDLE, DESCR, I, PKTDAT ) */
+/* C */
+/* C Print data packet contents. Print coverage interval */
+/* C midpoint & radii first. */
+/* C */
+/* WRITE (2,*) PKTDAT (1) */
+/* WRITE (2,*) PKTDAT (2) */
+/* C */
+/* C Decode numbers of coefficients. */
+/* C */
+/* CALL ZZCK4D2I ( PKTDAT(3), QAVSIZ, CK4PCD, NCOEF ) */
+/* C */
+/* C Print number of coefficients for Q0, Q1, Q2 and Q3. */
+/* C */
+/* WRITE (2,FMT='(I2,6X,I2)') NCOEF( 1 ), NCOEF( 2 ) */
+/* WRITE (2,FMT='(I2,6X,I2)') NCOEF( 3 ), NCOEF( 4 ) */
+/* C */
+/* C Print number coefficients for AV1, AV2 and AV3. */
+/* C */
+/* WRITE (2,FMT='(I2,6X,I2)') NCOEF( 5 ), NCOEF( 6 ) */
+/* WRITE (2,FMT='(I2,6X,I2)') NCOEF( 7 ) */
+/* C */
+/* C Print Cheby coefficients. */
+/* C */
+/* LASTAD = 0 */
+
+/* DO K = 1, QAVSIZ */
+/* LASTAD = LASTAD + NCOEF( K ) */
+/* END DO */
+
+/* DO K = 4, LASTAD + 4 */
+/* WRITE (2,*) PKTDAT (K) */
+/* END DO */
+
+/* END DO */
+
+/* END IF */
+
+/* $ Restrictions */
+
+/* 1) The binary CK file containing the segment whose descriptor */
+/* was passed to this routine must be opened for read or write */
+/* access by either CKLPF, DAFOPR, or DAFOPW. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* Y.K. Zaiko (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 05-MAY-1999 (YKZ) (BVS) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* number of CK type_4 records */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKNR04", (ftnlen)6);
+ }
+
+/* Check whether our segment is of the type 4 by unpacking */
+/* descriptor and checking value of its third integer component. */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ if (icd[2] != 4) {
+ setmsg_("Data type of the segment should be 4: Passed descriptor sho"
+ "ws type = #.", (ftnlen)71);
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
+ chkout_("CKNR04", (ftnlen)6);
+ return 0;
+ }
+
+/* The number of records (packets) can be obtained by a call to */
+/* SGMETA. This number is a meta item 12 (see sgparam.inc for */
+/* details.) */
+
+ sgmeta_(handle, descr, &c__12, nrec);
+
+/* All done. */
+
+ chkout_("CKNR04", (ftnlen)6);
+ return 0;
+} /* cknr04_ */
+
diff --git a/ext/spice/src/cspice/cknr05.c b/ext/spice/src/cspice/cknr05.c
new file mode 100644
index 0000000000..1f948c88fe
--- /dev/null
+++ b/ext/spice/src/cspice/cknr05.c
@@ -0,0 +1,304 @@
+/* cknr05.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKNR05 ( C-kernel, number of records, type 05 ) */
+/* Subroutine */ int cknr05_(integer *handle, doublereal *descr, integer *
+ nrec)
+{
+ /* Builtin functions */
+ integer i_dnnt(doublereal *);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *), dafgda_(integer *,
+ integer *, integer *, doublereal *), sigerr_(char *, ftnlen),
+ chkout_(char *, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ doublereal npoint;
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+
+/* $ Abstract */
+
+/* Given the handle of a CK file and the descriptor of a type 5 */
+/* segment in that file, return the number of pointing instances */
+/* in that segment. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of the file containing the segment. */
+/* DESCR I The descriptor of the type 5 segment. */
+/* NREC O The number of pointing instances in the segment. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the binary CK file containing the */
+/* segment. */
+
+/* DESCR The packed descriptor of a data type 5 segment. */
+
+/* $ Detailed_Output */
+
+/* NREC The number of pointing instances in the type 5 segment. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the segment indicated by DESCR is not a type 5 segment, */
+/* the error 'SPICE(CKWRONGDATATYPE)' is signaled. */
+
+/* 2) If the specified handle does not belong to any DAF file that */
+/* is currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 3) If DESCR is not a valid descriptor of a segment in the CK */
+/* file specified by HANDLE, the results of this routine are */
+/* unpredictable. */
+
+/* $ Files */
+
+/* The file specified by HANDLE should be open for read or */
+/* write access. */
+
+/* $ Particulars */
+
+/* For a complete description of the internal structure of a type 5 */
+/* segment, see the CK required reading. */
+
+/* This routine returns the number of discrete pointing instances */
+/* contained in the specified segment. It is normally used in */
+/* conjunction with CKGR05 which returns the Ith pointing instance */
+/* in the segment. */
+
+/* $ Examples */
+
+/* Suppose that MOC.BC is a CK file that contains segments of */
+/* data type 5. Then the following code fragment extracts the */
+/* SCLK time and boresight vector for each pointing instance */
+/* in the first segment in the file. */
+
+
+/* INTEGER ICD ( 6 ) */
+/* INTEGER HANDLE */
+/* INTEGER NREC */
+/* INTEGER I */
+
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION RECORD ( 16 ) */
+/* DOUBLE PRECISION QUAT ( 4 ) */
+/* DOUBLE PRECISION BORE ( 3 ) */
+/* DOUBLE PRECISION CMAT ( 3, 3 ) */
+/* DOUBLE PRECISION SCLKDP */
+
+/* LOGICAL FOUND */
+
+/* C */
+/* C First load the file. (The file may also be opened by using */
+/* C CKLPF.) */
+/* C */
+/* CALL DAFOPR ( 'MOC.BC', HANDLE ) */
+
+/* C */
+/* C Begin forward search. Find the first array. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* C */
+/* C Get segment descriptor. */
+/* C */
+/* CALL DAFGS ( DESCR ) */
+
+/* C */
+/* C Unpack the segment descriptor into its double precision */
+/* C and integer components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* C */
+/* C The data type for a segment is located in the third integer */
+/* C component of the descriptor. */
+/* C */
+/* IF ( ICD( 3 ) .EQ. 5 ) THEN */
+/* C */
+/* C How many records does this segment contain? */
+/* C */
+/* CALL CKNR05 ( HANDLE, DESCR, NREC ) */
+
+/* DO I = 1, NREC */
+/* C */
+/* C Get the Ith pointing instance in the segment. */
+/* C */
+/* CALL CKGR05 ( HANDLE, DESCR, I, RECORD ) */
+
+/* C */
+/* C Unpack from RECORD the time tag and quaternion. */
+/* C The locations of these items in the record are */
+/* C independent of the subtype. */
+/* C */
+/* SCLKDP = RECORD ( 1 ) */
+
+/* CALL MOVED ( RECORD(3), 4, QUAT ) */
+
+/* C */
+/* C The boresight vector is the third row of the C-matrix. */
+/* C */
+/* CALL Q2M ( QUAT, CMAT ) */
+
+/* BORE(1) = CMAT(3,1) */
+/* BORE(2) = CMAT(3,2) */
+/* BORE(3) = CMAT(3,3) */
+/* C */
+/* C Write out the results. */
+/* C */
+/* WRITE (*,*) 'Record: ', I */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'SCLK time = ', SCLKDP */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'boresight: ', BORE */
+
+/* END DO */
+
+/* END IF */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* J.M. Lynch (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 18-AUG-2002 (NJB) (JML) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* number of ck type_5 records */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel descriptor. */
+
+/* DTYPE is the data type of the segment that this routine */
+/* operates on. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKNR05", (ftnlen)6);
+ }
+
+/* The number of discrete pointing instances contained in a data */
+/* type 5 segment is stored in the last double precision word of */
+/* the segment. Since the address of the last word is stored in */
+/* the sixth integer component of the segment descriptor, it is */
+/* a trivial matter to extract the count. */
+
+/* The unpacked descriptor contains the following information */
+/* about the segment: */
+
+/* DCD(1) Initial encoded SCLK */
+/* DCD(2) Final encoded SCLK */
+/* ICD(1) Instrument */
+/* ICD(2) Inertial reference frame */
+/* ICD(3) Data type */
+/* ICD(4) Angular velocity flag */
+/* ICD(5) Initial address of segment data */
+/* ICD(6) Final address of segment data */
+
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+
+/* If this segment is not of data type 5, then signal an error. */
+
+ if (icd[2] != 5) {
+ setmsg_("Data type of the segment should be 5: Passed descriptor sho"
+ "ws type = #.", (ftnlen)71);
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
+ chkout_("CKNR05", (ftnlen)6);
+ return 0;
+ }
+
+/* The number of records is the final word in the segment. */
+
+ dafgda_(handle, &icd[5], &icd[5], &npoint);
+ *nrec = i_dnnt(&npoint);
+ chkout_("CKNR05", (ftnlen)6);
+ return 0;
+} /* cknr05_ */
+
diff --git a/ext/spice/src/cspice/ckobj.c b/ext/spice/src/cspice/ckobj.c
new file mode 100644
index 0000000000..6e8a7d1794
--- /dev/null
+++ b/ext/spice/src/cspice/ckobj.c
@@ -0,0 +1,433 @@
+/* ckobj.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKOBJ ( CK objects ) */
+/* Subroutine */ int ckobj_(char *ck, integer *ids, ftnlen ck_len)
+{
+ /* Builtin functions */
+ integer s_cmp(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ char arch[80];
+ extern /* Subroutine */ int dafgs_(doublereal *), chkin_(char *, ftnlen);
+ doublereal descr[5];
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *), errch_(char *, char *, ftnlen, ftnlen);
+ logical found;
+ doublereal dc[2];
+ integer ic[6];
+ extern /* Subroutine */ int daffna_(logical *);
+ extern logical failed_(void);
+ extern /* Subroutine */ int dafbfs_(integer *);
+ integer handle;
+ extern /* Subroutine */ int dafcls_(integer *), getfat_(char *, char *,
+ char *, ftnlen, ftnlen, ftnlen), dafopr_(char *, integer *,
+ ftnlen), sigerr_(char *, ftnlen), chkout_(char *, ftnlen),
+ setmsg_(char *, ftnlen), insrti_(integer *, integer *);
+ char kertyp[80];
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Find the set of ID codes of all objects in a specified CK file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CELLS */
+/* CK */
+/* DAF */
+/* NAIF_IDS */
+/* SETS */
+
+/* $ Keywords */
+
+/* POINTING */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* CK I Name of CK file. */
+/* IDS I/O Set of ID codes of objects in CK file. */
+
+/* $ Detailed_Input */
+
+/* CK is the name of a C-kernel. */
+
+/* IDS is an initialized SPICELIB set data structure. */
+/* IDS optionally may contain a set of ID codes on */
+/* input; on output, the data already present in */
+/* IDS will be combined with ID code set found for the */
+/* file CK. */
+
+/* If IDS contains no data on input, its size and */
+/* cardinality still must be initialized. */
+
+/* $ Detailed_Output */
+
+/* IDS is a SPICELIB set data structure which contains */
+/* the union of its contents upon input with the set */
+/* of ID codes of each object for which pointing data */
+/* are present in the indicated CK file. The elements */
+/* of SPICELIB sets are unique; hence each ID code in */
+/* IDS appears only once, even if the CK file */
+/* contains multiple segments for that ID code. */
+
+/* See the Examples section below for a complete */
+/* example program showing how to retrieve the ID */
+/* codes from IDS. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file has transfer format, the error */
+/* SPICE(INVALIDFORMAT) is signaled. */
+
+/* 2) If the input file is not a transfer file but has architecture */
+/* other than DAF, the error SPICE(BADARCHTYPE) is signaled. */
+
+/* 3) If the input file is a binary DAF file of type other than */
+/* CK, the error SPICE(BADFILETYPE) is signaled. */
+
+/* 4) If the CK file cannot be opened or read, the error will */
+/* be diagnosed by routines called by this routine. */
+
+/* 5) If the size of the output set argument IDS is insufficient to */
+/* contain the actual number of ID codes of objects covered by */
+/* the indicated CK file, the error will be diagnosed by */
+/* routines called by this routine. */
+
+/* $ Files */
+
+/* This routine reads a C-kernel. */
+
+/* $ Particulars */
+
+/* This routine provides an API via which applications can determine */
+/* the set of objects for which there are pointing data in a */
+/* specified CK file. */
+
+/* $ Examples */
+
+/* 1) Display the interval-level coverage for each object in a */
+/* specified CK file. Use tolerance of zero ticks. Do not */
+/* request angular velocity. Express the results in the TDB time */
+/* system. */
+
+/* Find the set of objects in the file. Loop over the contents */
+/* of the ID code set: find the coverage for each item in the */
+/* set and display the coverage. */
+
+
+/* PROGRAM CKCVR */
+/* IMPLICIT NONE */
+
+/* C */
+/* C SPICELIB functions */
+/* C */
+/* INTEGER WNCARD */
+/* INTEGER CARDI */
+/* C */
+/* C Local parameters */
+/* C */
+/* C */
+/* C Declare the coverage window. Make enough room */
+/* C for MAXIV intervals. */
+/* C */
+/* INTEGER FILSIZ */
+/* PARAMETER ( FILSIZ = 255 ) */
+
+/* INTEGER LBCELL */
+/* PARAMETER ( LBCELL = -5 ) */
+
+/* INTEGER MAXIV */
+/* PARAMETER ( MAXIV = 100000 ) */
+
+/* INTEGER WINSIZ */
+/* PARAMETER ( WINSIZ = 2 * MAXIV ) */
+
+/* INTEGER TIMLEN */
+/* PARAMETER ( TIMLEN = 50 ) */
+
+/* INTEGER MAXOBJ */
+/* PARAMETER ( MAXOBJ = 1000 ) */
+
+/* C */
+/* C Local variables */
+/* C */
+/* CHARACTER*(FILSIZ) CK */
+/* CHARACTER*(FILSIZ) LSK */
+/* CHARACTER*(FILSIZ) SCLK */
+/* CHARACTER*(TIMLEN) TIMSTR */
+
+/* DOUBLE PRECISION B */
+/* DOUBLE PRECISION COVER ( LBCELL : WINSIZ ) */
+/* DOUBLE PRECISION E */
+
+/* INTEGER I */
+/* INTEGER IDS ( LBCELL : MAXOBJ ) */
+/* INTEGER J */
+/* INTEGER NIV */
+
+/* C */
+/* C Load a leapseconds kernel and SCLK kernel for output */
+/* C time conversion. Note that we assume a single spacecraft */
+/* C clock is associated with all of the objects in the CK. */
+/* C */
+/* CALL PROMPT ( 'Name of leapseconds kernel > ', LSK ) */
+/* CALL FURNSH ( LSK ) */
+
+/* CALL PROMPT ( 'Name of SCLK kernel > ', SCLK ) */
+/* CALL FURNSH ( SCLK ) */
+
+/* C */
+/* C Get name of CK file. */
+/* C */
+/* CALL PROMPT ( 'Name of CK file > ', CK ) */
+
+/* C */
+/* C Initialize the set IDS. */
+/* C */
+/* CALL SSIZEI ( MAXOBJ, IDS ) */
+
+/* C */
+/* C Initialize the window COVER. */
+/* C */
+/* CALL SSIZED ( WINSIZ, COVER ) */
+
+/* C */
+/* C Find the set of objects in the CK file. */
+/* C */
+/* CALL CKOBJ ( CK, IDS ) */
+
+/* C */
+/* C We want to display the coverage for each object. Loop */
+/* C over the contents of the ID code set, find the coverage */
+/* C for each item in the set, and display the coverage. */
+/* C */
+/* DO I = 1, CARDI( IDS ) */
+/* C */
+/* C Find the coverage window for the current */
+/* C object. Empty the coverage window each time */
+/* C so we don't include data for the previous object. */
+/* C */
+/* CALL SCARDD ( 0, COVER ) */
+/* CALL CKCOV ( CK, IDS(I), .FALSE., */
+/* . 'INTERVAL', 0.D0, 'TDB', COVER ) */
+
+/* C */
+/* C Get the number of intervals in the coverage */
+/* C window. */
+/* C */
+/* NIV = WNCARD( COVER ) */
+
+/* C */
+/* C Display a simple banner. */
+/* C */
+/* WRITE (*,*) '========================================' */
+/* WRITE (*,*) 'Coverage for object ', IDS(I) */
+
+/* C */
+/* C Convert the coverage interval start and stop */
+/* C times to TDB calendar strings. */
+/* C */
+/* DO J = 1, NIV */
+/* C */
+/* C Get the endpoints of the Jth interval. */
+/* C */
+/* CALL WNFETD ( COVER, J, B, E ) */
+/* C */
+/* C Convert the endpoints to TDB calendar */
+/* C format time strings and display them. */
+/* C */
+/* CALL TIMOUT ( B, */
+/* . 'YYYY MON DD HR:MN:SC.###### ' // */
+/* . '(TDB) ::TDB', */
+/* . TIMSTR ) */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) 'Interval: ', J */
+/* WRITE (*,*) 'Start: ', TIMSTR */
+
+/* CALL TIMOUT ( E, */
+/* . 'YYYY MON DD HR:MN:SC.###### ' // */
+/* . '(TDB) ::TDB', */
+/* . TIMSTR ) */
+/* WRITE (*,*) 'Stop: ', TIMSTR */
+/* WRITE (*,*) ' ' */
+
+/* END DO */
+
+/* WRITE (*,*) '========================================' */
+
+/* END DO */
+
+/* END */
+
+
+/* $ Restrictions */
+
+/* 1) If an error occurs while this routine is updating the set */
+/* IDS, the set may be corrupted. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 30-NOV-2007 (NJB) */
+
+/* Corrected bug in program in header Examples section: program */
+/* now empties the coverage window prior to collecting data for */
+/* the current object. Deleted declaration of unused parameter */
+/* NAMLEN in example program. Updated example to use WNCARD */
+/* rather than CARDD. */
+
+/* - SPICELIB Version 1.0.0, 30-DEC-2004 (NJB) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* find id codes of objects in ck file */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("CKOBJ", (ftnlen)5);
+
+/* See whether GETFAT thinks we've got a CK file. */
+
+ getfat_(ck, arch, kertyp, ck_len, (ftnlen)80, (ftnlen)80);
+ if (s_cmp(arch, "XFR", (ftnlen)80, (ftnlen)3) == 0) {
+ setmsg_("Input file # has architecture #. The file must be a binary "
+ "CK file to be readable by this routine. If the input file i"
+ "s an CK file in transfer format, run TOBIN on the file to co"
+ "nvert it to binary format.", (ftnlen)205);
+ errch_("#", ck, (ftnlen)1, ck_len);
+ errch_("#", arch, (ftnlen)1, (ftnlen)80);
+ sigerr_("SPICE(INVALIDFORMAT)", (ftnlen)20);
+ chkout_("CKOBJ", (ftnlen)5);
+ return 0;
+ } else if (s_cmp(arch, "DAF", (ftnlen)80, (ftnlen)3) != 0) {
+ setmsg_("Input file # has architecture #. The file must be a binary "
+ "CK file to be readable by this routine. Binary CK files hav"
+ "e DAF architecture. If you expected the file to be a binary"
+ " CK file, the problem may be due to the file being an old no"
+ "n-native file lacking binary file format information. It's a"
+ "lso possible the file has been corrupted.", (ftnlen)340);
+ errch_("#", ck, (ftnlen)1, ck_len);
+ errch_("#", arch, (ftnlen)1, (ftnlen)80);
+ sigerr_("SPICE(INVALIDARCHTYPE)", (ftnlen)22);
+ chkout_("CKOBJ", (ftnlen)5);
+ return 0;
+ } else if (s_cmp(kertyp, "CK", (ftnlen)80, (ftnlen)2) != 0) {
+ setmsg_("Input file # has file type #. The file must be a binary CK "
+ "file to be readable by this routine. If you expected the fil"
+ "e to be a binary CK file, the problem may be due to the file"
+ " being an old non-native file lacking binary file format inf"
+ "ormation. It's also possible the file has been corrupted.", (
+ ftnlen)296);
+ errch_("#", ck, (ftnlen)1, ck_len);
+ errch_("#", kertyp, (ftnlen)1, (ftnlen)80);
+ sigerr_("SPICE(INVALIDFILETYPE)", (ftnlen)22);
+ chkout_("CKOBJ", (ftnlen)5);
+ return 0;
+ }
+
+/* Open the file for reading. */
+
+ dafopr_(ck, &handle, ck_len);
+ if (failed_()) {
+ chkout_("CKOBJ", (ftnlen)5);
+ return 0;
+ }
+
+/* We will examine each segment descriptor in the file, and */
+/* we'll update our ID code set according to the data found */
+/* in these descriptors. */
+
+/* Start a forward search. */
+
+ dafbfs_(&handle);
+
+/* Find the next DAF array. */
+
+ daffna_(&found);
+ while(found && ! failed_()) {
+
+/* Fetch and unpack the segment descriptor. */
+
+ dafgs_(descr);
+ dafus_(descr, &c__2, &c__6, dc, ic);
+
+/* Insert the current ID code into the output set. */
+/* The insertion algorithm will handle duplicates; no special */
+/* action is required here. */
+
+ insrti_(ic, ids);
+ daffna_(&found);
+ }
+
+/* Release the file. */
+
+ dafcls_(&handle);
+ chkout_("CKOBJ", (ftnlen)5);
+ return 0;
+} /* ckobj_ */
+
diff --git a/ext/spice/src/cspice/ckobj_c.c b/ext/spice/src/cspice/ckobj_c.c
new file mode 100644
index 0000000000..6f27bc9fa8
--- /dev/null
+++ b/ext/spice/src/cspice/ckobj_c.c
@@ -0,0 +1,348 @@
+/*
+
+-Procedure ckobj_c ( CK objects )
+
+-Abstract
+
+ Find the set of ID codes of all objects in a specified CK file.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CELLS
+ CK
+ DAF
+ NAIF_IDS
+ SETS
+
+-Keywords
+
+ POINTING
+ UTILITY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ void ckobj_c ( ConstSpiceChar * ck,
+ SpiceCell * ids )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ ck I Name of CK file.
+ ids I/O Set of ID codes of objects in CK file.
+
+-Detailed_Input
+
+ ck is the name of a C-kernel.
+
+ ids is an initialized CSPICE set data structure.
+ `ids' optionally may contain a set of ID codes on
+ input; on output, the data already present in
+ `ids' will be combined with ID code set found for the
+ file `ck'.
+
+ If `ids' contains no data on input, its size and
+ cardinality still must be initialized.
+
+-Detailed_Output
+
+ ids is a CSPICE set data structure which contains
+ the union of its contents upon input with the set
+ of ID codes of each object for which pointing data
+ are present in the indicated CK file. The elements
+ of CSPICE sets are unique; hence each ID code in
+ `ids' appears only once, even if the CK file
+ contains multiple segments for that ID code.
+
+ See the Examples section below for a complete
+ example program showing how to retrieve the ID
+ codes from `ids'.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the input file has transfer format, the error
+ SPICE(INVALIDFORMAT) is signaled.
+
+ 2) If the input file is not a transfer file but has architecture
+ other than DAF, the error SPICE(BADARCHTYPE) is signaled.
+
+ 3) If the input file is a binary DAF file of type other than
+ CK, the error SPICE(BADFILETYPE) is signaled.
+
+ 4) If the CK file cannot be opened or read, the error will
+ be diagnosed by routines called by this routine.
+
+ 5) If the size of the output set argument `ids' is insufficient to
+ contain the actual number of ID codes of objects covered by
+ the indicated CK file, the error will be diagnosed by
+ routines called by this routine.
+
+ 6) The error SPICE(EMPTYSTRING) is signaled if the input
+ string `ck' does not contain at least one character, since the
+ input string cannot be converted to a Fortran-style string in
+ this case.
+
+ 7) The error SPICE(NULLPOINTER) is signaled if the input string
+ pointer `ck' is null.
+
+-Files
+
+ This routine reads a C-kernel.
+
+-Particulars
+
+ This routine provides an API via which applications can determine
+ the set of objects for which there are pointing data in a
+ specified CK file.
+
+-Examples
+
+ 1) Display the interval-level coverage for each object in a
+ specified CK file. Use tolerance of zero ticks. Do not request
+ angular velocity. Express the results in the TDB time system.
+
+ Find the set of objects in the file. Loop over the contents of
+ the ID code set: find the coverage for each item in the set and
+ display the coverage.
+
+
+ #include
+ #include "SpiceUsr.h"
+
+ int main()
+ {
+
+ /.
+ Local parameters
+ ./
+ #define FILSIZ 256
+ #define MAXIV 100000
+ #define WINSIZ ( 2 * MAXIV )
+ #define TIMLEN 51
+ #define MAXOBJ 1000
+
+ /.
+ Local variables
+ ./
+ SPICEDOUBLE_CELL ( cover, WINSIZ );
+ SPICEINT_CELL ( ids, MAXOBJ );
+
+ SpiceChar ck [ FILSIZ ];
+ SpiceChar lsk [ FILSIZ ];
+ SpiceChar sclk [ FILSIZ ];
+ SpiceChar timstr [ TIMLEN ];
+
+ SpiceDouble b;
+ SpiceDouble e;
+
+ SpiceInt i;
+ SpiceInt j;
+ SpiceInt niv;
+ SpiceInt obj;
+
+
+ /.
+ Load a leapseconds kernel and SCLK kernel for output time
+ conversion. Note that we assume a single spacecraft clock is
+ associated with all of the objects in the CK.
+ ./
+ prompt_c ( "Name of leapseconds kernel > ", FILSIZ, lsk );
+ furnsh_c ( lsk );
+
+ prompt_c ( "Name of SCLK kernel > ", FILSIZ, sclk );
+ furnsh_c ( sclk );
+
+ /.
+ Get name of CK file.
+ ./
+ prompt_c ( "Name of CK file > ", FILSIZ, ck );
+
+ /.
+ Find the set of objects in the CK file.
+ ./
+ ckobj_c ( ck, &ids );
+
+ /.
+ We want to display the coverage for each object. Loop over
+ the contents of the ID code set, find the coverage for
+ each item in the set, and display the coverage.
+ ./
+ for ( i = 0; i < card_c( &ids ); i++ )
+ {
+ /.
+ Find the coverage window for the current object.
+ Empty the coverage window each time so we don't
+ include data for the previous object.
+ ./
+ obj = SPICE_CELL_ELEM_I( &ids, i );
+
+ scard_c ( 0, &cover );
+ ckcov_c ( ck, obj, SPICEFALSE,
+ "INTERVAL", 0.0, "TDB", &cover );
+
+ /.
+ Get the number of intervals in the coverage window.
+ ./
+ niv = wncard_c( &cover );
+
+ /.
+ Display a simple banner.
+ ./
+ printf ( "%s\n", "========================================" );
+
+ printf ( "Coverage for object %ld\n", obj );
+
+ /.
+ Convert the coverage interval start and stop times to TDB
+ calendar strings.
+ ./
+ for ( j = 0; j < niv; j++ )
+ {
+ /.
+ Get the endpoints of the jth interval.
+ ./
+ wnfetd_c ( &cover, j, &b, &e );
+
+ /.
+ Convert the endpoints to TDB calendar
+ format time strings and display them.
+ ./
+ timout_c ( b,
+ "YYYY MON DD HR:MN:SC.###### (TDB) ::TDB",
+ TIMLEN,
+ timstr );
+
+ printf ( "\n"
+ "Interval: %ld\n"
+ "Start: %s\n",
+ j,
+ timstr );
+
+ timout_c ( e,
+ "YYYY MON DD HR:MN:SC.###### (TDB) ::TDB",
+ TIMLEN,
+ timstr );
+ printf ( "Stop: %s\n", timstr );
+
+ }
+ printf ( "%s\n", "========================================" );
+
+ }
+ return ( 0 );
+ }
+
+
+-Restrictions
+
+ 1) If an error occurs while this routine is updating the set
+ `ids', the set may be corrupted.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.1, 30-NOV-2007 (NJB)
+
+ Corrected bug in example program in header:
+ program now empties result window prior to collecting
+ data for each object. Updated example to use wncard_c
+ rather than card_c.
+
+ -CSPICE Version 1.0.0, 30-DEC-2004 (NJB)
+
+-Index_Entries
+
+ find id codes in ck file
+
+-&
+*/
+
+{ /* Begin ckobj_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+ chkin_c ( "ckobj_c" );
+
+ /*
+ Check the input string `ck' to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "ckobj_c", ck );
+
+ /*
+ Make sure cell data type is SpiceInt.
+ */
+ CELLTYPECHK ( CHK_STANDARD, "ckobj_c", SPICE_INT, ids );
+
+ /*
+ Initialize the cell if necessary.
+ */
+ CELLINIT ( ids );
+
+ /*
+ Call the f2c'd Fortran routine.
+ */
+ ckobj_ ( ( char * ) ck,
+ ( integer * ) (ids->base),
+ ( ftnlen ) strlen(ck) );
+
+ /*
+ Sync the output cell.
+ */
+ if ( !failed_c() )
+ {
+ zzsynccl_c ( F2C, ids );
+ }
+
+
+ chkout_c ( "ckobj_c" );
+
+} /* End ckobj_c */
diff --git a/ext/spice/src/cspice/ckopn.c b/ext/spice/src/cspice/ckopn.c
new file mode 100644
index 0000000000..bcc23e7f41
--- /dev/null
+++ b/ext/spice/src/cspice/ckopn.c
@@ -0,0 +1,212 @@
+/* ckopn.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKOPN ( CK, open new file. ) */
+/* Subroutine */ int ckopn_(char *name__, char *ifname, integer *ncomch,
+ integer *handle, ftnlen name_len, ftnlen ifname_len)
+{
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomr;
+ extern logical failed_(void);
+ extern /* Subroutine */ int dafonw_(char *, char *, integer *, integer *,
+ char *, integer *, integer *, ftnlen, ftnlen, ftnlen), chkout_(
+ char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Open a new CK file, returning the handle of the opened file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* NAME I The name of the CK file to be opened. */
+/* IFNAME I The internal filename for the CK. */
+/* NCOMCH I The number of characters to reserve for comments. */
+/* HANDLE O The handle of the opened CK file. */
+
+/* $ Detailed_Input */
+
+/* NAME The name of the CK file to be opened. */
+
+/* IFNAME The internal filename for the CK file that is being */
+/* created. The internal filename may be up to 60 characters */
+/* long. If you do not have any conventions for tagging your */
+/* files, an internal filename of 'CK_file' is perfectly */
+/* acceptable. You may also leave it blank if you like. */
+
+/* NCOMCH This is the space, measured in characters, to be */
+/* initially set aside for the comment area when a new CK */
+/* file is opened. The amount of space actually set aside */
+/* may be greater than the amount requested, due to the */
+/* manner in which comment records are allocated in an CK */
+/* file. However, the amount of space set aside for comments */
+/* will always be at least the amount that was requested. */
+
+/* The value of NCOMCH should be greater than or equal to */
+/* zero, i.e., 0 <= NCOMCH. A negative value, should one */
+/* occur, will be assumed to be zero. */
+
+/* $ Detailed_Output */
+
+/* HANDLE The handle of the opened CK file. If an error occurs the */
+/* value of this variable will not represent a valid handle. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the value of NCOMCH is negative, a value of zero (0) will */
+/* be used for the number of comment characters to be set aside */
+/* for comments. */
+
+/* 2) If an error occurs while attempting to open a CK file the */
+/* value of HANDLE will not represent a valid file handle. */
+
+/* $ Files */
+
+/* See NAME and HANDLE. */
+
+/* $ Particulars */
+
+/* Open a new CK file, reserving room for comments if requested. */
+
+/* $ Examples */
+
+/* Suppose that you want to create a new CK file called 'new.ck' */
+/* that contains a single type 3 CK segment and has room for at */
+/* least 5000 comment characters. The following code fragment should */
+/* take care of this for you, assuming that all of the variables */
+/* passed to the CK type 3 segment writer have appropriate values. */
+
+/* NAME = 'new.ck' */
+/* IFNAME = 'Test CK file' */
+
+/* CALL CKOPN ( NAME, IFNAME, 5000, HANDLE ) */
+/* CALL CKW03 ( HANDLE, BEGTIM, ENDTIM, INST, REF, AVFLAG, */
+/* . SEGID, NREC, SCLKDP, QUATS, AVVS, NINTS, */
+/* . STARTS ) */
+/* CALL CKCLS ( HANDLE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 09-NOV-2006 (NJB) */
+
+/* Routine has been upgraded to support comment */
+/* area allocation using NCOMCH. */
+
+/* - SPICELIB Version 1.0.0, 26-JAN-1995 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* open a new ck file */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* DAF ND and NI values for CK files. */
+
+
+/* Length of a DAF comment record, in characters. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("CKOPN", (ftnlen)5);
+
+/* Compute the number of comment records that we want to allocate, if */
+/* the number of comment characters requested is greater than zero, */
+/* we always allocate an extra record to account for the end of line */
+/* marks in the comment area. */
+
+ if (*ncomch > 0) {
+ ncomr = (*ncomch - 1) / 1000 + 1;
+ } else {
+ ncomr = 0;
+ }
+
+/* Just do it. All of the error handling is taken care of for us. */
+
+ dafonw_(name__, "CK", &c__2, &c__6, ifname, &ncomr, handle, name_len, (
+ ftnlen)2, ifname_len);
+ if (failed_()) {
+
+/* If we failed, make sure that HANDLE does not contain a value */
+/* that represents a valid DAF file handle. */
+
+ *handle = 0;
+ }
+ chkout_("CKOPN", (ftnlen)5);
+ return 0;
+} /* ckopn_ */
+
diff --git a/ext/spice/src/cspice/ckopn_c.c b/ext/spice/src/cspice/ckopn_c.c
new file mode 100644
index 0000000000..177eaab68b
--- /dev/null
+++ b/ext/spice/src/cspice/ckopn_c.c
@@ -0,0 +1,194 @@
+/*
+
+-Procedure ckopn_c ( CK, open new file. )
+
+-Abstract
+
+ Open a new CK file, returning the handle of the opened file.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ CK
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+ void ckopn_c ( ConstSpiceChar * fname,
+ ConstSpiceChar * ifname,
+ SpiceInt ncomch,
+ SpiceInt * handle )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ fname I The name of the CK file to be opened.
+ ifname I The internal filename for the CK.
+ ncomch I The number of characters to reserve for comments.
+ handle O The handle of the opened CK file.
+
+-Detailed_Input
+
+ fname The name of the CK file to be opened.
+
+ ifname The internal filename for the CK file that is being
+ created. The internal filename may be up to 60 characters
+ long. If you do not have any conventions for tagging your
+ files, an internal filename of "CK_file" is perfectly
+ acceptable. You may also leave it blank if you like.
+
+ ncomch This is the space, measured in characters, to be
+ initially set aside for the comment area when a new CK
+ file is opened. The amount of space actually set aside
+ may be greater than the amount requested, due to the
+ manner in which comment records are allocated in an CK
+ file. However, the amount of space set aside for comments
+ will always be at least the amount that was requested.
+
+ The value of ncomch should be greater than or equal to
+ zero, i.e., 0 <= ncomch. A negative value, should one
+ occur, will be assumed to be zero.
+
+-Detailed_Output
+
+ handle The handle of the opened CK file. If an error occurs the
+ value of this variable will not represent a valid handle.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the value of ncomch is negative, a value of zero will
+ be used for the number of comment characters to be set aside
+ for comments.
+
+ 2) If an error occurs while attempting to open a CK file the
+ value of handle will not represent a valid file handle.
+
+-Files
+
+ See fname and handle.
+
+-Particulars
+
+ Open a new CK file, reserving room for comments if requested.
+
+-Examples
+
+ Suppose that you want to create a new CK file called "new.ck"
+ that contains a single type 3 CK segment and has room for at
+ least 5000 comment characters. The following code fragment should
+ take care of this for you, assuming that all of the variables
+ passed to the CK type 3 segment writer have appropriate values.
+
+ fname = "new.ck";
+ ifname = "Test CK file";
+
+ ckopn_c ( fname, ifname, 5000, &handle );
+
+ ckw03_c ( handle, begtim, endtim, inst,
+ ref, avflag, segid, nrec,
+ sclkdp, quats, avvs, nints, starts );
+
+ ckcls_c ( handle );
+
+
+-Restrictions
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.1.1, 09-NOV-2006 (NJB)
+
+ Header comments indicating that `ncomch' is ignored have
+ been deleted.
+
+ -CSPICE Version 1.1.0, 08-FEB-1998 (NJB)
+
+ References to C2F_CreateStr_Sig were removed; code was
+ cleaned up accordingly. String checks are now done using
+ the macro CHKFSTR.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB)
+
+ Based on SPICELIB Version 1.0.0, 26-JAN-1995 (KRG)
+
+-Index_Entries
+
+ open a new ck file
+
+-&
+*/
+
+{ /* Begin ckopn_c */
+
+ /*
+ Participate in error handling.
+ */
+ chkin_c ( "ckopn_c" );
+
+ /*
+ Check the input strings fname and ifname to make sure the pointers
+ are non-null and the string lengths are non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "ckopn_c", fname );
+ CHKFSTR ( CHK_STANDARD, "ckopn_c", ifname );
+
+
+ ckopn_ ( ( char * ) fname,
+ ( char * ) ifname,
+ ( integer * ) &ncomch,
+ ( integer * ) handle,
+ ( ftnlen ) strlen(fname),
+ ( ftnlen ) strlen(ifname) );
+
+
+ chkout_c ( "ckopn_c" );
+
+} /* End ckopn_c */
diff --git a/ext/spice/src/cspice/ckpfs.c b/ext/spice/src/cspice/ckpfs.c
new file mode 100644
index 0000000000..24cf5c9242
--- /dev/null
+++ b/ext/spice/src/cspice/ckpfs.c
@@ -0,0 +1,622 @@
+/* ckpfs.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKPFS ( C-kernel, get pointing from segment ) */
+/* Subroutine */ int ckpfs_(integer *handle, doublereal *descr, doublereal *
+ sclkdp, doublereal *tol, logical *needav, doublereal *cmat,
+ doublereal *av, doublereal *clkout, logical *found)
+{
+ extern /* Subroutine */ int cke01_(logical *, doublereal *, doublereal *,
+ doublereal *, doublereal *), cke02_(logical *, doublereal *,
+ doublereal *, doublereal *, doublereal *), cke03_(logical *,
+ doublereal *, doublereal *, doublereal *, doublereal *), cke04_(
+ logical *, doublereal *, doublereal *, doublereal *, doublereal *)
+ , cke05_(logical *, doublereal *, doublereal *, doublereal *,
+ doublereal *), ckr01_(integer *, doublereal *, doublereal *,
+ doublereal *, logical *, doublereal *, logical *), ckr02_(integer
+ *, doublereal *, doublereal *, doublereal *, doublereal *,
+ logical *), ckr03_(integer *, doublereal *, doublereal *,
+ doublereal *, logical *, doublereal *, logical *), ckr04_(integer
+ *, doublereal *, doublereal *, doublereal *, logical *,
+ doublereal *, logical *), ckr05_(integer *, doublereal *,
+ doublereal *, doublereal *, logical *, doublereal *, logical *);
+ integer type__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *);
+ doublereal record[228];
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+
+/* $ Abstract */
+
+/* Evaluate pointing data from a segment for a given time. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* Declarations of the CK data type specific and general CK low */
+/* level routine parameters. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* 1) If new CK types are added, the size of the record passed */
+/* between CKRxx and CKExx must be registered as separate */
+/* parameter. If this size will be greater than current value */
+/* of the CKMRSZ parameter (which specifies the maximum record */
+/* size for the record buffer used inside CKPFS) then it should */
+/* be assigned to CKMRSZ as a new value. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Literature_References */
+
+/* CK Required Reading. */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 19-AUG-2002 (NJB) */
+
+/* Updated to support CK type 5. */
+
+/* - SPICELIB Version 1.0.0, 05-APR-1999 (BVS) */
+
+/* -& */
+
+/* Number of quaternion components and number of quaternion and */
+/* angular rate components together. */
+
+
+/* CK Type 1 parameters: */
+
+/* CK1DTP CK data type 1 ID; */
+
+/* CK1RSZ maximum size of a record passed between CKR01 */
+/* and CKE01. */
+
+
+/* CK Type 2 parameters: */
+
+/* CK2DTP CK data type 2 ID; */
+
+/* CK2RSZ maximum size of a record passed between CKR02 */
+/* and CKE02. */
+
+
+/* CK Type 3 parameters: */
+
+/* CK3DTP CK data type 3 ID; */
+
+/* CK3RSZ maximum size of a record passed between CKR03 */
+/* and CKE03. */
+
+
+/* CK Type 4 parameters: */
+
+/* CK4DTP CK data type 4 ID; */
+
+/* CK4PCD parameter defining integer to DP packing schema that */
+/* is applied when seven number integer array containing */
+/* polynomial degrees for quaternion and angular rate */
+/* components packed into a single DP number stored in */
+/* actual CK records in a file; the value of must not be */
+/* changed or compatibility with existing type 4 CK files */
+/* will be lost. */
+
+/* CK4MXD maximum Chebychev polynomial degree allowed in type 4 */
+/* records; the value of this parameter must never exceed */
+/* value of the CK4PCD; */
+
+/* CK4SFT number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 4 */
+/* CK record that passed between routines CKR04 and CKE04; */
+
+/* CK4RSZ maximum size of type 4 CK record passed between CKR04 */
+/* and CKE04; CK4RSZ is computed as follows: */
+
+/* CK4RSZ = ( CK4MXD + 1 ) * QAVSIZ + CK4SFT */
+
+
+/* CK Type 5 parameters: */
+
+
+/* CK5DTP CK data type 5 ID; */
+
+/* CK5MXD maximum polynomial degree allowed in type 5 */
+/* records. */
+
+/* CK5MET number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 5 */
+/* CK record that passed between routines CKR05 and CKE05; */
+
+/* CK5MXP maximum packet size for any subtype. Subtype 2 */
+/* has the greatest packet size, since these packets */
+/* contain a quaternion, its derivative, an angular */
+/* velocity vector, and its derivative. See ck05.inc */
+/* for a description of the subtypes. */
+
+/* CK5RSZ maximum size of type 5 CK record passed between CKR05 */
+/* and CKE05; CK5RSZ is computed as follows: */
+
+/* CK5RSZ = ( CK5MXD + 1 ) * CK5MXP + CK5MET */
+
+
+
+/* Maximum record size that can be handled by CKPFS. This value */
+/* must be set to the maximum of all CKxRSZ parameters (currently */
+/* CK4RSZ.) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I CK file handle. */
+/* DESCR I Segment descriptor. */
+/* SCLKDP I Spacecraft clock time. */
+/* TOL I Time tolerance. */
+/* NEEDAV I True when angular velocity data is requested. */
+/* CMAT O C-matrix. */
+/* AV O Angular velocity vector. */
+/* CLKOUT O Output spacecraft clock time. */
+/* FOUND O True when requested pointing is available. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the binary CK file containing the */
+/* desired segment. The file should have been opened */
+/* for read access, either by CKLPF or DAFOPR. */
+
+/* DESCR is the packed descriptor of the segment. */
+
+/* SCLKDP is the encoded spacecraft clock time for which */
+/* pointing is desired. */
+
+/* TOL is a time tolerance, measured in the same units as */
+/* encoded spacecraft clock. The C-matrix returned by */
+/* CKPFS is the one whose time is closest to SCLKDP and */
+/* within TOL units of SCLKDP. */
+
+/* NEEDAV is true when angular velocity data is requested. */
+
+
+/* $ Detailed_Output */
+
+/* CMAT is a rotation matrix that transforms the components of */
+/* of a vector expressed in the inertial frame given in */
+/* the segment to components expressed in the instrument */
+/* fixed frame at time CLKOUT. */
+
+/* Thus, if a vector v has components x, y, z in the */
+/* inertial frame, then v has components x', y', z' in */
+/* the instrument fixed frame at time CLKOUT: */
+
+/* [ x' ] [ ] [ x ] */
+/* | y' | = | CMAT | | y | */
+/* [ z' ] [ ] [ z ] */
+
+/* If the x', y', z' components are known, use the */
+/* transpose of the C-matrix to determine x, y, z as */
+/* follows. */
+
+/* [ x ] [ ]T [ x' ] */
+/* | y | = | CMAT | | y' | */
+/* [ z ] [ ] [ z' ] */
+/* (Transpose of CMAT) */
+
+/* AV is the angular velocity vector. This is returned only */
+/* if it has been requested, as indicated by NEEDAV. In */
+/* other words, if NEEDAV is true, then the pointing */
+/* records in the segment must contain AV data. */
+
+/* The angular velocity vector is the right-handed axis */
+/* about which the reference frame tied to the instrument */
+/* is instantaneously rotating at time CLKOUT. The */
+/* magnitude of AV is the magnitude of the instantaneous */
+/* velocity of the rotation, in radians per second. */
+
+/* The components of AV are given relative to the */
+/* reference frame specified in the segment descriptor. */
+
+/* CLKOUT is the encoded spacecraft clock time associated with */
+/* the returned C-matrix and, optionally, the returned */
+/* angular velocity vector. */
+
+/* FOUND is true if a C-matrix and an angular velocity vector */
+/* (if requested) were found to satisfy the pointing */
+/* request. FOUND will be false otherwise. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the data type of the segment is not one of those supported */
+/* by this routine, the error SPICE(CKUNKNOWNDATATYPE) is */
+/* signalled. */
+
+/* 2) If the specified handle does not belong to any file that is */
+/* currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 3) If DESCR is not a valid, packed descriptor of a segment in */
+/* the CK file specified by HANDLE, the results of this routine */
+/* are unpredictable. */
+
+/* 4) If TOL is negative, FOUND is false. */
+
+/* 5) If NEEDAV is true, but the segment doesn't contain AV data, */
+/* an error is signalled by a routine that this routine calls. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The structure of this routine is just a big case statement. Each */
+/* segment data type is supported by two routines: */
+
+/* CKRnn which reads a single logical pointing record from a */
+/* segment of type nn. (A logical record is defined as */
+/* a collection of numbers sufficient to determine the */
+/* C-matrix, and optionally the angular velocity vector, */
+/* at the input time.) */
+
+/* CKEnn which evaluates the pointing record returned by CKRnn */
+/* to give the C-matrix and optionally the angular */
+/* velocity vector at the input time. */
+
+/* The data type is determined from the segment descriptor, and the */
+/* appropriate routines are called. */
+
+/* $ Examples */
+
+/* CKPFS allows you to be more selective than CKGP or CKGPAV about */
+/* choosing segments to satisfy CK pointing requests. */
+
+/* Suppose MOC.BC is a CK file consisting of several segments */
+/* containing Mars Observer Camera pointing data. Each segment */
+/* covers the same time period, but produces different pointing */
+/* values (one segment may contain predict values, another may */
+/* contain telemetry-based values, and others may contain different */
+/* corrected versions). */
+
+/* The following code fragment shows how different the results are */
+/* for each segment. The program steps through the file segment by */
+/* segment and requests pointing for the same time from each */
+/* segment. The results are printed to the screen. */
+
+/* GETIME is an imaginary routine used to get an encoded SCLK time */
+/* (SCLKDP) and time tolerance from the user. */
+
+/* SC = -94 */
+/* INST = -94001 */
+/* NEEDAV = .TRUE. */
+
+/* CALL CKLPF ( 'MOC.BC', HANDLE ) */
+
+/* CALL GETIME ( SCLKDP, TOL, QUIT ) */
+
+/* C */
+/* C For each time, begin a forward search through the file, and */
+/* C for each segment found, get its descriptor, identifier, and */
+/* C evaluate the pointing. */
+/* C */
+/* DO WHILE ( .NOT. QUIT ) */
+
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+
+/* CALL DAFGS ( DESCR ) */
+/* CALL DAFGN ( IDENT ) */
+
+/* CALL CKPFS ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
+/* . CMAT, AV, CLKOUT, PFOUND ) */
+
+/* IF ( PFOUND ) THEN */
+/* WRITE (*,*) 'Segment: ', IDENT */
+/* WRITE (*,*) 'C-Matrix: ', CMAT */
+/* WRITE (*,*) 'Angular velocity: ', AV */
+
+/* ELSE */
+/* CALL SCDECD ( SC, SCLKDP, SCLKCH ) */
+/* WRITE (*,*) 'Data not found at time ', SCLKCH */
+
+/* END IF */
+
+/* CALL DAFFNA ( FOUND ) */
+
+/* END DO */
+
+/* CALL GETIME ( SCLKDP, TOL, QUIT ) */
+
+/* END DO */
+
+
+/* $ Restrictions */
+
+/* A C-kernel file should have been loaded by either CKLPF */
+/* or DAFOPR. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.M. Lynch (JPL) */
+/* B.V. Semenov (JPL) */
+/* M.J. Spencer (JPL) */
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 5.0.0, 19-AUG-2002 (NJB) */
+
+/* The routine was updated to handle data type 5 segments. */
+
+/* - SPICELIB Version 4.0.0, 02-MAY-1999 (BVS) */
+
+/* The routine was updated to handle data type 4 segments. */
+/* The RECSIZ size parameter was eliminated. The dimension */
+/* of the RECORD buffer is now defined by the CKMRSZ parameter */
+/* specified in the 'ckparam.inc' include file. */
+
+/* - SPICELIB Version 3.0.0, 11-SEP-1992 (JML) */
+
+/* The routine was updated to handle data type 3 segments. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 30-AUG-1991 (JML) */
+
+/* The routine was updated to handle data type 2 segments. */
+
+/* FOUND is now initialized to false. */
+
+/* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
+
+/* The restriction that a C-kernel file must be loaded */
+/* was explicitly stated. */
+
+
+/* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get pointing from ck segment */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 5.0.0, 19-AUG-2002 (NJB) */
+
+/* The routine was updated to handle data type 5 segments. */
+
+/* - SPICELIB Version 4.0.0, 02-MAY-1999 (BVS) */
+
+/* The routine was updated to handle data type 4 segments. */
+
+/* a) 'ckparam.inc' include file was included. */
+
+/* b) RECSIZ size parameter was eliminated. */
+
+/* c) Size of the RECORD was reset to CKMRSZ, parameter */
+/* defined in the 'ckparam.inc' include file. */
+
+/* d) Calls to CKR04 and CKE04 were added to the case */
+/* statement. */
+
+/* - SPICELIB Version 3.0.0, 11-SEP-1992 (JML) */
+
+/* The routine was updated to handle data type 3 segments. */
+
+/* a) RECSIZ was increased to 17. */
+
+/* b) Calls to CKR03 and CKE03 were added to the case */
+/* statement. */
+
+/* - SPICELIB Version 2.0.0, 30-AUG-1991 (JML) */
+
+/* 1) The routine was updated to handle data type 2 segments. */
+
+/* 2) FOUND is initialized to false to guard against it being */
+/* left unchanged from its previous value when an error is */
+/* detected. */
+
+/* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
+
+/* 1) The restriction that a C-kernel file must be loaded */
+/* was explicitly stated. */
+
+/* - Beta Version 1.1.0, 30-AUG-1990 (MJS) */
+
+/* The following changes were made as a result of the */
+/* NAIF CK Code and Documentation Review: */
+
+/* 1) The variable SCLK was changed to SCLKDP. */
+/* 2) The declarations for the parameters RECSIZ, NDC, and NIC */
+/* were moved from the "Declarations" section of the header */
+/* to the "Local parameters" section of the code below the */
+/* header. These parameters are not meant to modified by */
+/* users. */
+/* 3) The header was updated. */
+/* 4) The comments in the code were improved. */
+
+/* - Beta Version 1.0.0, 07-MAY-1990 (RET) (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel segment descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel segment descriptor. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKPFS", (ftnlen)5);
+ }
+
+/* Start off with FOUND set to false. This guards against FOUND */
+/* being left unchanged from a previous call if any errors are */
+/* detected. */
+
+ *found = FALSE_;
+
+/* Upgrading CKPFS to accommodate new data types involves following */
+/* these steps: */
+
+/* 1) Write the two new routines CKRnn and CKEnn. (You may need to */
+/* add or subtract from the arguments used in the existing CKRnn */
+/* and CKEnn calling sequences, but should not have to change */
+/* the inputs or outputs to CKPFS.) */
+
+/* 2) Insert a new case into the code of CKPFS. */
+
+/* 3) Depending on the size of RECORD returned from CKRnn, modify */
+/* the parameter RECSIZ. (You will only need to change it if */
+/* RECSIZ is not large enough for the new CKRnn's RECORD.) */
+
+
+/* Unpack the descriptor to see what the data type of the segment is, */
+/* and call the appropriate read-and-evaluate routines. */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ type__ = icd[2];
+ if (type__ == 1) {
+ ckr01_(handle, descr, sclkdp, tol, needav, record, found);
+ if (*found) {
+ cke01_(needav, record, cmat, av, clkout);
+ }
+ } else if (type__ == 2) {
+ ckr02_(handle, descr, sclkdp, tol, record, found);
+ if (*found) {
+ cke02_(needav, record, cmat, av, clkout);
+ }
+ } else if (type__ == 3) {
+ ckr03_(handle, descr, sclkdp, tol, needav, record, found);
+ if (*found) {
+ cke03_(needav, record, cmat, av, clkout);
+ }
+ } else if (type__ == 4) {
+ ckr04_(handle, descr, sclkdp, tol, needav, record, found);
+ if (*found) {
+ cke04_(needav, record, cmat, av, clkout);
+ }
+ } else if (type__ == 5) {
+ ckr05_(handle, descr, sclkdp, tol, needav, record, found);
+ if (*found) {
+ cke05_(needav, record, cmat, av, clkout);
+ }
+ } else {
+ setmsg_("The data type # is not currently supported.", (ftnlen)43);
+ errint_("#", &type__, (ftnlen)1);
+ sigerr_("SPICE(CKUNKNOWNDATATYPE)", (ftnlen)24);
+ }
+ chkout_("CKPFS", (ftnlen)5);
+ return 0;
+} /* ckpfs_ */
+
diff --git a/ext/spice/src/cspice/ckr01.c b/ext/spice/src/cspice/ckr01.c
new file mode 100644
index 0000000000..fc54944c82
--- /dev/null
+++ b/ext/spice/src/cspice/ckr01.c
@@ -0,0 +1,602 @@
+/* ckr01.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKR01 ( C-kernel, read pointing record, data type 1 ) */
+/* Subroutine */ int ckr01_(integer *handle, doublereal *descr, doublereal *
+ sclkdp, doublereal *tol, logical *needav, doublereal *record, logical
+ *found)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+ doublereal d__1;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer nrec, ndir, skip, psiz, i__, n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *);
+ integer group;
+ extern /* Subroutine */ int dafgda_(integer *, integer *, integer *,
+ doublereal *);
+ doublereal buffer[100];
+ integer remain, dirloc;
+ extern integer lstcld_(doublereal *, integer *, doublereal *), lstled_(
+ doublereal *, integer *, doublereal *);
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen);
+ integer grpndx;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer beg, icd[6], end;
+ logical fnd;
+
+/* $ Abstract */
+
+/* Read a pointing record from a CK segment, data type 1. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I File handle. */
+/* DESCR I Segment descriptor. */
+/* SCLKDP I Spacecraft clock time. */
+/* TOL I Time tolerance. */
+/* NEEDAV I True when angular velocity data is requested. */
+/* RECORD O Pointing data record. */
+/* FOUND O True when data is found. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the integer handle of the CK file containing the */
+/* segment. */
+
+/* DESCR is the descriptor of the segment. */
+
+/* SCLKDP is an encoded spacecraft clock time for which */
+/* pointing is being requested. The SPICELIB routines */
+/* SCENCD and SCDECD are used to encode and decode SCLK */
+/* times. */
+
+/* TOL is a time tolerance, measured in the same units as */
+/* encoded spacecraft clock. */
+
+/* The record returned by CKR01 is the one whose time is */
+/* closest to SCLKDP and within TOL units of SCLKDP. */
+
+/* NEEDAV is true when angular velocity data is requested. */
+
+
+/* $ Detailed_Output */
+
+/* RECORD is the pointing record. Contents are as follows: */
+
+/* RECORD( 1 ) = CLKOUT */
+
+/* RECORD( 2 ) = q0 */
+/* RECORD( 3 ) = q1 */
+/* RECORD( 4 ) = q2 */
+/* RECORD( 5 ) = q3 */
+
+/* RECORD( 6 ) = Av1 ] */
+/* RECORD( 7 ) = Av2 |-- Returned optionally */
+/* RECORD( 8 ) = Av3 ] */
+
+/* CLKOUT is the encoded spacecraft clock time for the */
+/* returned pointing values. CLKOUT will be the closest */
+/* time in the segment to the input time as long as it is */
+/* within the input tolerance (see FOUND below). If SCLKDP */
+/* falls at the exact midpoint of two times, the record */
+/* for the greater of the two will be returned. */
+
+/* The quantities q0 - q3 represent a quaternion. */
+/* The quantities Av1, Av2, and Av3 represent the angular */
+/* velocity vector, and are returned if the segment */
+/* contains angular velocity data and NEEDAV is true. */
+/* The components of the angular velocity vector are */
+/* specified relative to the inertial reference frame */
+/* for the segment. */
+
+/* FOUND is true if a record was found to satisfy the pointing */
+/* request. FOUND will be false when there is no pointing */
+/* instance within the segment whose time falls within */
+/* the requested time tolerance on either side of the */
+/* input time. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified handle does not belong to any file that is */
+/* currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 2) If DESCR is not a valid, packed descriptor of a segment in */
+/* the CK file specified by HANDLE, the results of this routine */
+/* are unpredictable. */
+
+/* 3) If the segment is not of data type 1, as specified in the */
+/* third integer component of the segment descriptor, then */
+/* the error SPICE(WRONGDATATYPE) is signalled. */
+
+/* 4) If there is a need for angular velocity data and the segment */
+/* contains no such data, the error SPICE(NOAVDATA) is signalled. */
+
+/* $ Files */
+
+/* The file containing the segment is specified by its handle, and */
+/* should be opened for read, either by CKLPF or DAFOPR. */
+
+/* $ Particulars */
+
+/* See the CK Required Reading file for a detailed description of */
+/* the structure of a type 1 pointing segment. */
+
+/* This routine searches a type 1 segment for the pointing instance */
+/* whose associated time is closest to the time that pointing was */
+/* requested for. If this time is within the tolerance specified by */
+/* the user, it sets FOUND equal to true and returns information in */
+/* the array RECORD that CKE01 uses to evaluate the pointing at the */
+/* time CLKOUT. */
+
+/* $ Examples */
+
+/* The CKRnn routines are usually used in tandem with the CKEnn */
+/* routines, which evaluate the record returned by CKRnn to give */
+/* the pointing information and output time. */
+
+/* The following code fragment searches through a file (represented */
+/* by HANDLE) for all segments applicable to the Voyager 2 wide angle */
+/* camera, for a particular spacecraft clock time, which have data */
+/* type 1. It then evaluates the pointing for that epoch and prints */
+/* the result. */
+
+/* C */
+/* C - Get the spacecraft clock time. Must encode it for use */
+/* C in the C-kernel. */
+/* C */
+/* C - Set the time tolerance high to catch anything close to */
+/* C the input time. */
+/* C */
+/* C - We don't need angular velocity data. */
+/* C */
+/* SC = -32 */
+/* INST = -32002 */
+/* TOL = 1000.D0 */
+/* NEEDAV = .FALSE. */
+/* DTYPE = 1 */
+/* C */
+/* C Load the Voyager 2 spacecraft clock kernel and the C-kernel. */
+/* C */
+/* CALL FURNSH ( 'VGR_SCLK.TSC' ) */
+/* CALL DAFOPR ( 'VGR2_CK.BC', HANDLE ) */
+/* C */
+/* C Convert the input request time to ticks. */
+/* C */
+/* WRITE (*,*) 'Enter spacecraft clock time string:' */
+/* READ (*,FMT='(A)') SCLKCH */
+/* CALL SCENCD ( SC, SCLKCH, SCLKDP ) */
+
+/* C */
+/* C Search from the beginning through all segments. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( SFND ) */
+
+/* DO WHILE ( SFND ) */
+
+/* CALL DAFGN ( IDENT ) */
+/* CALL DAFGS ( DESCR ) */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* IF ( INST .EQ. ICD( 1 ) .AND. */
+/* . DTYPE .EQ. ICD( 3 ) .AND. */
+/* . SCLKDP + TOL .GE. DCD( 1 ) .AND. */
+/* . SCLKDP - TOL .LE. DCD( 2 ) ) THEN */
+
+/* CALL CKR01 ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
+/* . RECORD, FOUND ) */
+
+/* IF ( FOUND ) THEN */
+
+/* CALL CKE01 ( NEEDAV, RECORD, CMAT, AV, CLKOUT ) */
+
+/* WRITE (*,*) 'Segment descriptor and identifier:' */
+/* WRITE (*,*) DCD, ICD */
+/* WRITE (*,*) IDENT */
+
+/* WRITE (*,*) 'C-matrix:' */
+/* WRITE (*,*) CMAT */
+
+/* END IF */
+
+/* END IF */
+
+/* CALL DAFFNA ( SFND ) */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* 1) The file containing the segment should be opened for read, */
+/* either by CKLPF or DAFOPR. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.M. Lynch (JPL) */
+/* J.E. McLean (JPL) */
+/* M.J. Spencer (JPL) */
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.2.1, 22-AUG-2006 (EDW) */
+
+/* Replaced references to LDPOOL with references */
+/* to FURNSH. */
+
+/* - SPICELIB Version 1.2.0, 07-SEP-2001 (EDW) */
+
+/* Replaced DAFRDA call with DAFGDA. */
+/* Added IMPLICIT NONE. */
+
+/* - SPICELIB Version 1.1.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.1.0, 30-AUG-1991 (JML) */
+
+/* This routine now checks the segment descriptor to */
+/* determine if it has been given a type 1 segment. */
+
+/* The FOUND flag is set to FALSE at the beginning of */
+/* the routine. */
+
+/* The particulars section was changed to provide a more */
+/* general description of the function of this routine. The */
+/* information that was originally in Particulars was moved */
+/* to the body of the code. */
+
+/* The example program was changed so that the tolerance */
+/* and data type are used in selecting which segments to read. */
+
+/* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
+
+/* The example program was corrected so that the input */
+/* instrument code was tested against ICD(1) instead of */
+/* ICD(3). */
+
+/* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read ck type_1 pointing data record */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 30-AUG-1991 (JML) */
+
+/* 1) This routine now checks the segment descriptor, ICD(3), */
+/* to determine if it has been given a type 1 segment. */
+
+/* 2) The FOUND flag is set to FALSE at the beginning of */
+/* the routine. This is done so that if a SPICE error */
+/* is signalled, the FOUND flag will definitely be false. */
+
+/* 3) The particulars section was changed to provide a more */
+/* general description of the function of this routine. The */
+/* information that was originally in Particulars was moved */
+/* to the body of the code. */
+
+/* 4) The example program was changed so that the tolerance */
+/* and data type are used in selecting which segments to read. */
+
+/* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
+
+/* 1) The example program was corrected so that the input */
+/* instrument code was tested against ICD(1) instead of */
+/* ICD(3). */
+/* 2) ROTATIONS was removed from the Required Reading section. */
+
+/* - Beta Version 1.1.0, 29-AUG-1990 (MJS) (JEM) */
+
+/* The following changes were made as a result of the */
+/* NAIF CK Code and Documentation Review: */
+
+/* 1) The variable SCLK was changed to SCLKDP. */
+/* 2) The declarations for the parameters QSIZ, QAVSIZ, NDC, and */
+/* NIC were moved from the "Declarations" section of the */
+/* header to the "Local parameters" section of the code below */
+/* the header. These parameters are not meant to modified by */
+/* users. */
+/* 3) The variable DIRSIZ has been parameterized in the code */
+/* following the header. DIRSIZ is still 100. */
+/* 5) The header was improved and updated to reflect the changes. */
+/* 6) The in-code comments were improved. */
+
+/* - Beta Version 1.0.0, 17-MAY-1990 (RET) (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* DIRSIZ is the directory size. */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel segment descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel segment descriptor. */
+
+/* QSIZ is the number of double precision numbers making up */
+/* the quaternion portion of a pointing record. */
+
+/* QAVSIZ is the number of double precision numbers making up */
+/* the quaternion and angular velocity portion of a */
+/* pointing record. */
+
+/* DTYPE is the data type of the segment that this routine */
+/* operates on. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKR01", (ftnlen)5);
+ }
+
+/* To minimize the number of file reads performed during the search, */
+/* a buffer of 100 double precision numbers is used to read the SCLK */
+/* times from the C-kernel. If there are 10,001 or fewer pointing */
+/* records, at most four reads will be needed to satisfy the request: */
+/* one to read NREC, one to read in 100 or fewer directory times, */
+/* one to read 100 or fewer actual times, and then after the */
+/* appropriate record has been located, one to read the quaternion */
+/* and angular velocity data. */
+
+/* One more read would be required for every other group of 10,000 */
+/* records in the segment. */
+
+
+/* Start off with FOUND set to FALSE. */
+
+ *found = FALSE_;
+
+/* We need to look at a few of the descriptor components. */
+
+/* The unpacked descriptor contains the following information */
+/* about the segment: */
+
+/* DCD(1) Initial encoded SCLK */
+/* DCD(2) Final encoded SCLK */
+/* ICD(1) Instrument */
+/* ICD(2) Inertial reference frame */
+/* ICD(3) Data type */
+/* ICD(4) Angular velocity flag */
+/* ICD(5) Initial address of segment data */
+/* ICD(6) Final address of segment data */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+
+/* Check to make sure that the segment is type 1. */
+
+ if (icd[2] != 1) {
+ setmsg_("The segment is not a type 1 segment. Type is #", (ftnlen)47)
+ ;
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(WRONGDATATYPE)", (ftnlen)20);
+ chkout_("CKR01", (ftnlen)5);
+ return 0;
+ }
+
+/* The size of the record returned depends on whether or not the */
+/* segment contains angular velocity data. */
+
+/* This is a convenient place to check if the need for angular */
+/* velocity data matches the availability. */
+
+ if (icd[3] == 1) {
+ psiz = 7;
+ } else {
+ psiz = 4;
+ if (*needav) {
+ setmsg_("Segment does not contain angular velocity data.", (
+ ftnlen)47);
+ sigerr_("SPICE(NOAVDATA)", (ftnlen)15);
+ chkout_("CKR01", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* The beginning and ending addresses of the segment are in the */
+/* descriptor. */
+
+ beg = icd[4];
+ end = icd[5];
+
+/* Get the number of records in this segment, and from that determine */
+/* the number of directory epochs. */
+
+ dafgda_(handle, &end, &end, buffer);
+ nrec = (integer) buffer[0];
+ ndir = (nrec - 1) / 100;
+
+/* The directory epochs narrow down the search to a group of DIRSIZ */
+/* or fewer records. The way the directory is constructed guarantees */
+/* that we will definitely find the closest time in the segment to */
+/* SCLKDP in the indicated group. */
+
+/* There is only one group if there are no directory epochs. */
+
+ if (ndir == 0) {
+ group = 1;
+ } else {
+
+/* Compute the location of the first directory epoch. From the */
+/* beginning of the segment, need to go through all of the */
+/* pointing numbers (PSIZ*NREC of them), then through all of */
+/* the SCLKDP times (NREC more) to get to the first SCLK */
+/* directory. */
+
+ dirloc = beg + (psiz + 1) * nrec;
+
+/* Locate the first directory epoch greater than SCLKDP. Read in */
+/* as many as DIRSIZ directory epochs at a time for comparison. */
+
+ fnd = FALSE_;
+ remain = ndir;
+ group = 0;
+ while(! fnd) {
+
+/* The number of records to read in the buffer. */
+
+ n = min(remain,100);
+ i__1 = dirloc + n - 1;
+ dafgda_(handle, &dirloc, &i__1, buffer);
+ remain -= n;
+
+/* If we find the first directory time greater than or equal */
+/* to the epoch, we're done. */
+
+/* If we reach the end of the directories, and still haven't */
+/* found one bigger than the epoch, the group is the last group */
+/* in the segment. */
+
+/* Otherwise keep looking. */
+
+ i__ = lstled_(sclkdp, &n, buffer);
+ if (i__ < n) {
+ group = group + i__ + 1;
+ fnd = TRUE_;
+ } else if (remain == 0) {
+ group = ndir + 1;
+ fnd = TRUE_;
+ } else {
+ dirloc += n;
+ group += n;
+ }
+ }
+ }
+
+/* Now we know which group of DIRSIZ (or less) times to look at. */
+/* Out of the NREC SCLKDP times, the number that we should skip over */
+/* to get to the proper group is DIRSIZ*( GROUP - 1 ). */
+
+ skip = (group - 1) * 100;
+
+/* From this we can compute the index into the segment of the group */
+/* of times we want. From the beginning, need to pass through */
+/* PSIZ*NREC pointing numbers to get to the first SCLKDP time. */
+/* Then we skip over the number just computed above. */
+
+ grpndx = beg + nrec * psiz + skip;
+
+/* The number of times that we have to look at may be less than */
+/* DIRSIZ. However many there are, go ahead and read them into the */
+/* buffer. */
+
+/* Computing MIN */
+ i__1 = 100, i__2 = nrec - skip;
+ n = min(i__1,i__2);
+ i__1 = grpndx + n - 1;
+ dafgda_(handle, &grpndx, &i__1, buffer);
+
+/* Find the time in the group closest to the input time, and see */
+/* if it's within tolerance. */
+
+ i__ = lstcld_(sclkdp, &n, buffer);
+ if ((d__1 = *sclkdp - buffer[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("buffer", i__1, "ckr01_", (ftnlen)625)], abs(d__1)) > *tol)
+ {
+ chkout_("CKR01", (ftnlen)5);
+ return 0;
+ }
+
+/* Now we know the exact record that we want. */
+
+/* RECORD( 1 ) holds CLKOUT. */
+
+ *found = TRUE_;
+ record[0] = buffer[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "buffer", i__1, "ckr01_", (ftnlen)638)];
+
+/* We need the Ith pointing record out of this group of DIRSIZ. */
+/* This group of DIRSIZ is SKIP records into the beginning */
+/* of the segment. And each record is PSIZ big. */
+
+ n = beg + psiz * (skip + i__ - 1);
+ i__1 = n + psiz - 1;
+ dafgda_(handle, &n, &i__1, &record[1]);
+
+/* That is all. */
+
+ chkout_("CKR01", (ftnlen)5);
+ return 0;
+} /* ckr01_ */
+
diff --git a/ext/spice/src/cspice/ckr02.c b/ext/spice/src/cspice/ckr02.c
new file mode 100644
index 0000000000..9884f41f10
--- /dev/null
+++ b/ext/spice/src/cspice/ckr02.c
@@ -0,0 +1,659 @@
+/* ckr02.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+static integer c__7 = 7;
+
+/* $Procedure CKR02 ( C-kernel, read pointing record, data type 2 ) */
+/* Subroutine */ int ckr02_(integer *handle, doublereal *descr, doublereal *
+ sclkdp, doublereal *tol, doublereal *record, logical *found)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+ doublereal d__1;
+
+ /* Builtin functions */
+ integer i_dnnt(doublereal *), s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer nrec;
+ doublereal prec[8];
+ integer ndir, skip;
+ doublereal diff1, diff2;
+ integer i__, n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *);
+ integer index;
+ extern /* Subroutine */ int vequg_(doublereal *, integer *, doublereal *);
+ integer group;
+ doublereal start, stopi;
+ extern /* Subroutine */ int dafgda_(integer *, integer *, integer *,
+ doublereal *);
+ doublereal buffer[100];
+ integer remain, dirloc;
+ extern integer lstled_(doublereal *, integer *, doublereal *);
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen);
+ doublereal clkout;
+ integer grpndx;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen);
+ integer stploc;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ integer arrsiz;
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer beg, icd[6], end;
+ logical fnd;
+
+/* $ Abstract */
+
+/* Read a pointing record from a CK segment, data type 2. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I File handle. */
+/* DESCR I Segment descriptor. */
+/* SCLKDP I Spacecraft clock time. */
+/* TOL I Time tolerance */
+/* RECORD O Pointing data record. */
+/* FOUND O True when data is found. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the integer handle of the CK file containing the */
+/* segment. */
+
+/* DESCR is the descriptor of the segment. */
+
+/* SCLKDP is the encoded spacecraft clock time for which */
+/* pointing is being requested. */
+
+/* TOL is a time tolerance, measured in the same units as */
+/* encoded spacecraft clock. */
+
+/* When SCLKDP falls within the bounds of one of the */
+/* intervals then the tolerance has no effect. However, */
+/* if the request time is not in one of the intervals */
+/* then the tolerance is used to determine if pointing */
+/* at one of the interval endpoints should be returned. */
+
+/* $ Detailed_Output */
+
+/* RECORD is the pointing record. Contents are as follows: */
+
+/* RECORD( 1 ) = Start time of interval. */
+/* RECORD( 2 ) = Time for which pointing was found. */
+/* RECORD( 3 ) = Seconds per tick rate. */
+
+/* RECORD( 4 ) = q0 */
+/* RECORD( 5 ) = q1 */
+/* RECORD( 6 ) = q2 */
+/* RECORD( 7 ) = q3 */
+
+/* RECORD( 8 ) = av1 */
+/* RECORD( 9 ) = av2 */
+/* RECORD( 10 ) = av3 */
+
+/* The quantities q0 - q3 are the components of the */
+/* quaternion that represents the C-matrix associated with */
+/* the start time of the interval. The quantities av1, */
+/* av2, and av3 represent the angular velocity vector of */
+/* the interval. The components of the angular velocity */
+/* vector are specified relative to the inertial reference */
+/* frame of the segment. */
+
+/* FOUND is true if a record was found to satisfy the pointing */
+/* request. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified handle does not belong to any file that is */
+/* currently known to be open, an error is diagnosed by a */
+/* routine that this routine calls. */
+
+/* 2) If DESCR is not a valid, packed descriptor of a segment in */
+/* the CK file specified by HANDLE, the results of this routine */
+/* are unpredictable. */
+
+/* 3) If the segment is not of data type 2, as specified in the */
+/* third integer component of the segment descriptor, then */
+/* the error SPICE(WRONGDATATYPE) is signalled. */
+
+/* $ Files */
+
+/* The file containing the segment is specified by its handle, and */
+/* should be opened for read, either by CKLPF or DAFOPR. */
+
+/* $ Particulars */
+
+/* See the CK Required Reading file for a detailed description of */
+/* the structure of a type 2 pointing segment. */
+
+/* This routine searches a type 2 segment and determines if the */
+/* request for pointing can be satisfied by the segment. If so, */
+/* then it returns information in the array RECORD that CKE02 uses */
+/* to evaluate the pointing at the time for which pointing was found. */
+
+/* When the time for which pointing was requested falls within one */
+/* of the intervals then the returned time is the same as the */
+/* requested time. However, when the request time is not within any */
+/* of the intervals then the returned time will be the interval */
+/* endpoint closest to the request time, provided that endpoint is */
+/* within the tolerance specified by the user. */
+
+
+/* $ Examples */
+
+/* The CKRnn routines are usually used in tandem with the CKEnn */
+/* routines, which evaluate the record returned by CKRnn to give */
+/* the pointing information and output time. */
+
+/* The following code fragment searches through a file (attached to */
+/* HANDLE) for all segments applicable to the Voyager 2 wide angle */
+/* camera, for a particular spacecraft clock time, that are of data */
+/* types 1 or 2. It then evaluates the pointing for that epoch and */
+/* prints the result. */
+
+
+/* SC = -32 */
+/* INST = -32002 */
+/* C */
+/* C Load the Voyager 2 spacecraft clock kernel and the C-kernel. */
+/* C */
+/* CALL FURNSH ( 'VGR_SCLK.TSC' ) */
+/* CALL DAFOPR ( 'VGR2_CK.BC', HANDLE ) */
+/* C */
+/* C Get the spacecraft clock time. Must encode it for use */
+/* C in the C-kernel. */
+/* C */
+/* WRITE (*,*) 'Enter spacecraft clock time string:' */
+/* READ (*,FMT='(A)') SCLKCH */
+/* CALL SCENCD ( SC, SCLKCH, SCLKDP ) */
+
+/* C */
+/* C Search from the beginning through all segments. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( SFND ) */
+
+/* DO WHILE ( SFND ) */
+
+/* CALL DAFGN ( IDENT ) */
+/* CALL DAFGS ( DESCR ) */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* IF ( INST .EQ. ICD( 1 ) .AND. */
+/* . SCLKDP + TOL .GE. DCD( 1 ) .AND. */
+/* . SCLKDP - TOL .LE. DCD( 2 ) ) THEN */
+
+/* DTYPE = ICD ( 3 ) */
+
+/* IF ( DTYPE .EQ. 1 ) THEN */
+
+/* CALL CKR01 ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
+/* . RECORD, FOUND ) */
+
+/* IF ( FOUND ) THEN */
+/* CALL CKE01 ( NEEDAV, RECORD, CMAT, AV, CLKOUT ) */
+/* END IF */
+
+/* ELSE IF ( DTYPE .EQ. 2 ) THEN */
+
+/* CALL CKR02 ( HANDLE, DESCR, SCLKDP, TOL, */
+/* . RECORD, FOUND ) */
+
+/* IF ( FOUND ) THEN */
+/* CALL CKE02 ( NEEDAV, RECORD, CMAT, AV, CLKOUT ) */
+/* END IF */
+
+/* END IF */
+
+/* IF ( FOUND ) THEN */
+
+/* WRITE (*,*) 'Segment descriptor and identifier:' */
+/* WRITE (*,*) DCD, ICD */
+/* WRITE (*,*) IDENT */
+
+/* WRITE (*,*) 'C-matrix:' */
+/* WRITE (*,*) CMAT */
+
+/* END IF */
+
+/* END IF */
+
+/* CALL DAFFNA ( SFND ) */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* 1) The file containing the segment should be opened for read, */
+/* either by CKLPF or DAFOPR. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.M. Lynch (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1, 22-AUG-2006 (EDW) */
+
+/* Replaced references to LDPOOL with references */
+/* to FURNSH. */
+
+/* - SPICELIB Version 1.1.0, 07-SEP-2001 (EDW) */
+
+/* Replaced DAFRDA call with DAFGDA. */
+/* Added IMPLICIT NONE. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 30-AUG-1991 (JML) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read ck type_2 pointing data record */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* DIRSIZ is the directory size. */
+
+/* NDC is the number of double precision components in an */
+/* unpacked C-kernel segment descriptor. */
+
+/* NIC is the number of integer components in an unpacked */
+/* C-kernel segment descriptor. */
+
+/* PSIZ is the number of double precision numbers making up */
+/* the record containing the quaternion, angular */
+/* velocity vector, and seconds per tick rate. */
+
+/* DTYPE is the data type of the segment that this routine */
+/* operates on. */
+
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKR02", (ftnlen)5);
+ }
+
+/* To minimize the number of file reads performed during the search, */
+/* a buffer of 100 double precision numbers is used to read the SCLK */
+/* times from the C-kernel. If there are 10,001 or fewer pointing */
+/* records, at most four reads will be needed to satisfy the request: */
+/* one to read in 100 or fewer directory times, one to read 100 or */
+/* fewer interval start times, one to read from the stop times, and */
+/* then, after the appropriate record has been located, one to read */
+/* the pointing record. */
+
+/* One more read would be required for every other group of 10,000 */
+/* records in the segment. */
+
+
+/* Start off with FOUND equal to false. */
+
+ *found = FALSE_;
+
+/* We need to look at a few of the descriptor components. */
+
+/* The unpacked descriptor contains the following information */
+/* about the segment: */
+
+/* DCD(1) Initial encoded SCLK */
+/* DCD(2) Final encoded SCLK */
+/* ICD(1) Instrument */
+/* ICD(2) Inertial reference frame */
+/* ICD(3) Data type */
+/* ICD(4) Angular velocity flag */
+/* ICD(5) Initial address of segment data */
+/* ICD(6) Final address of segment data */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+
+/* Check to make sure that the segment is type 2. */
+
+ if (icd[2] != 2) {
+ setmsg_("The segment is not a type 2 segment. Type is #", (ftnlen)47)
+ ;
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(WRONGDATATYPE)", (ftnlen)20);
+ chkout_("CKR02", (ftnlen)5);
+ return 0;
+ }
+
+/* The beginning and ending addresses of the segment are in the */
+/* descriptor. */
+
+ beg = icd[4];
+ end = icd[5];
+
+/* Get the number of records in this segment, and from that determine */
+/* the number of directory epochs. */
+
+
+/* Based on the structure of a type 2 segment, the size of a */
+/* segment with N pointing intervals is given as follows: */
+
+/* ARRSIZ = PSIZ * N + 2 * N + ( N-1 ) / 100 (1) */
+
+/* In the above equation PSIZ is eight and integer arithmetic is */
+/* used. This equation is equivalent to: */
+
+
+/* 100 * ARRSIZ = 1000 * N + ( N-1 ) * 100 (2) */
+/* ------- */
+/* 100 */
+
+/* If we can eliminate the integer division then, since all of */
+/* the other values represent whole numbers, we can solve the */
+/* equation for N in terms of ARRSIZ by using double precision */
+/* arithmetic and then rounding the result to the nearest integer. */
+
+/* This next equation uses double precision arithmetic and is */
+/* equivalent to (2): */
+
+/* 100 * ARRSIZ = 1000 * N + ( N-1 ) - ( N-1 ) MOD 100 (3) */
+
+/* Which means: */
+
+/* 100 * ARRSIZ + 1 ( N-1 ) MOD 100 */
+/* ---------------- + --------------- = N (4) */
+/* 1001 1001 */
+
+/* Since the second term on the left side of (4) is always less */
+/* than 0.1, the first term will always round to the correct */
+/* value of N. */
+
+ arrsiz = end - beg + 1;
+ d__1 = ((doublereal) arrsiz * 100. + 1.) / 1001.;
+ nrec = i_dnnt(&d__1);
+ ndir = (nrec - 1) / 100;
+
+/* The directory epochs narrow down the search to a group of DIRSIZ */
+/* or fewer records. */
+
+/* There is only one group if there are no directory epochs. */
+
+ if (ndir == 0) {
+ group = 1;
+ } else {
+
+/* Compute the location of the first directory epoch. From the */
+/* beginning of the segment, we need to go through all of the */
+/* pointing numbers (PSIZ*NREC of them), then through all of */
+/* the SCLK start and stop times (2*NREC more) to get to the */
+/* first SCLK directory. */
+
+ dirloc = beg + nrec * 10;
+
+/* Locate the last directory epoch less than or equal to SCLKDP. */
+
+/* Read in as many as DIRSIZ directory epochs at a time for */
+/* comparison. */
+
+ fnd = FALSE_;
+ remain = ndir;
+ group = 0;
+ while(! fnd) {
+
+/* The number of records to read in the buffer. */
+
+ n = min(remain,100);
+ i__1 = dirloc + n - 1;
+ dafgda_(handle, &dirloc, &i__1, buffer);
+ remain -= n;
+
+/* Determine the last directory element in BUFFER that's less */
+/* than or equal to SCLKDP. */
+
+/* If we reach the end of the directories, and still haven't */
+/* found one bigger than the epoch, the group is the last group */
+/* in the segment. */
+
+/* Otherwise keep looking. */
+
+ i__ = lstled_(sclkdp, &n, buffer);
+ if (i__ < n) {
+ group = group + i__ + 1;
+ fnd = TRUE_;
+ } else if (remain == 0) {
+ group = ndir + 1;
+ fnd = TRUE_;
+ } else {
+ dirloc += n;
+ group += n;
+ }
+ }
+ }
+
+/* Now we know which group of DIRSIZ (or less) times to look at. */
+/* Out of the NREC START times, the number that we should skip over */
+/* to get to the proper group is DIRSIZ*( GROUP - 1 ). */
+
+ skip = (group - 1) * 100;
+
+/* From this we can compute the index into the segment of the group */
+/* of times we want. From the beginning, we need to pass through */
+/* PSIZ*NREC pointing numbers to get to the first START time. */
+/* Then we skip over the number just computed above. */
+
+ grpndx = beg + (nrec << 3) + skip;
+
+/* The number of times that we have to look at may be less than */
+/* DIRSIZ. However many there are, go ahead and read them into the */
+/* buffer. */
+
+/* Computing MIN */
+ i__1 = 100, i__2 = nrec - skip;
+ n = min(i__1,i__2);
+ i__1 = grpndx + n - 1;
+ dafgda_(handle, &grpndx, &i__1, buffer);
+
+/* Find the largest time in the group less than or equal to the input */
+/* time. */
+
+ i__ = lstled_(sclkdp, &n, buffer);
+
+/* If the request time does not fall into one of the intervals, then */
+/* there are several cases in which this routine can return an */
+/* endpoint of an interval. */
+
+/* 1) If I = 0 then the request time falls before the first START */
+/* time in the group. Because of the way that the directory */
+/* is constructed we already know that the preceding STOP */
+/* time is not the right one so all we have to check is if */
+/* SCLKDP + TOL is greater than or equal to the first START */
+/* time of the group. */
+
+/* 2) If I = N and the request time is not in the Nth interval */
+/* then we know that the request time is after the last STOP */
+/* time in the group. Because of the way that the directory */
+/* is constructed we already know that the following START */
+/* time is not the right one so all we have to check is if */
+/* SCLKDP - TOL is less than or equal to the last STOP time */
+/* of the group. */
+
+/* 3) Finally, if I is between 1 and N-1 and the request time */
+/* does not fall in any of the intervals then we need to */
+/* return the closer of STOP(I) or START(I+1) if it is */
+/* within TOL of SCLKDP. */
+
+
+/* If SCLKDP is less than the first time in BUFFER then check to see */
+/* if we want the first START time in the group. */
+
+ if (i__ == 0) {
+ if (*sclkdp + *tol >= buffer[0]) {
+ *found = TRUE_;
+ start = buffer[0];
+ clkout = buffer[0];
+ index = 1;
+ } else {
+ chkout_("CKR02", (ftnlen)5);
+ return 0;
+ }
+ } else {
+
+/* I is not equal to zero. Determine if the request time falls */
+/* within the Ith interval. */
+
+ stploc = beg + nrec * 9 + skip + i__ - 1;
+ dafgda_(handle, &stploc, &stploc, &stopi);
+ if (*sclkdp <= stopi) {
+ *found = TRUE_;
+ start = buffer[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("buffer", i__1, "ckr02_", (ftnlen)619)];
+ clkout = *sclkdp;
+ index = i__;
+ } else {
+
+/* The request time does not fall within the interval. Check */
+/* to see if the Ith STOP time or the (I+1)th START time */
+/* satisfy the request. */
+
+/* If I = N then we need to consider only the STOP time */
+/* because of the way that the directory is constructed. */
+
+ if (i__ == n) {
+ if (*sclkdp - *tol <= stopi) {
+ *found = TRUE_;
+ start = buffer[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1
+ : s_rnge("buffer", i__1, "ckr02_", (ftnlen)638)];
+ clkout = stopi;
+ index = i__;
+ } else {
+ chkout_("CKR02", (ftnlen)5);
+ return 0;
+ }
+ } else {
+
+/* Find which time SCLKDP is closest to and then see if */
+/* it is within the tolerance. */
+
+ diff1 = *sclkdp - stopi;
+ diff2 = buffer[(i__1 = i__) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("buffer", i__1, "ckr02_", (ftnlen)656)] - *
+ sclkdp;
+ if (min(diff1,diff2) <= *tol) {
+ *found = TRUE_;
+
+/* Notice that if the request time is equidistant from */
+/* the STOP and START time the START time will be chosen. */
+
+ if (diff2 <= diff1) {
+ start = buffer[(i__1 = i__) < 100 && 0 <= i__1 ? i__1
+ : s_rnge("buffer", i__1, "ckr02_", (ftnlen)
+ 667)];
+ clkout = buffer[(i__1 = i__) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("buffer", i__1, "ckr02_", (
+ ftnlen)668)];
+ index = i__ + 1;
+ } else {
+ start = buffer[(i__1 = i__ - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("buffer", i__1, "ckr02_", (
+ ftnlen)673)];
+ clkout = stopi;
+ index = i__;
+ }
+ } else {
+ chkout_("CKR02", (ftnlen)5);
+ return 0;
+ }
+ }
+ }
+ }
+
+
+/* Now we know the exact record that we want and can begin */
+/* constructing the output record. */
+
+/* RECORD( 1 ) holds the interval start time. */
+/* RECORD( 2 ) holds the time for which pointing was found (CLKOUT). */
+
+ record[0] = start;
+ record[1] = clkout;
+
+/* We need the pointing record out of GROUP indexed by INDEX. */
+/* This group of size DIRSIZ is SKIP records into the beginning */
+/* of the segment. And each record is PSIZ big. */
+
+ n = beg + (skip + index - 1 << 3);
+ i__1 = n + 7;
+ dafgda_(handle, &n, &i__1, prec);
+ record[2] = prec[7];
+ vequg_(prec, &c__7, &record[3]);
+
+/* That is all. */
+
+ chkout_("CKR02", (ftnlen)5);
+ return 0;
+} /* ckr02_ */
+
diff --git a/ext/spice/src/cspice/ckr03.c b/ext/spice/src/cspice/ckr03.c
new file mode 100644
index 0000000000..6b8a4c3cb7
--- /dev/null
+++ b/ext/spice/src/cspice/ckr03.c
@@ -0,0 +1,995 @@
+/* ckr03.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKR03 ( C-kernel, read pointing record, data type 3 ) */
+/* Subroutine */ int ckr03_(integer *handle, doublereal *descr, doublereal *
+ sclkdp, doublereal *tol, logical *needav, doublereal *record, logical
+ *found)
+{
+ /* Initialized data */
+
+ static doublereal prevs = -1.;
+ static doublereal prevn = -1.;
+ static integer lhand = 0;
+ static integer lbeg = -1;
+ static integer lend = -1;
+
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer i_dnnt(doublereal *), s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer addr__, skip, psiz, i__, n;
+ doublereal ldiff;
+ integer laddr;
+ doublereal rdiff;
+ integer raddr;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *);
+ integer nidir;
+ doublereal lsclk;
+ extern doublereal dpmax_(void);
+ extern /* Subroutine */ int moved_(doublereal *, integer *, doublereal *);
+ integer nrdir;
+ doublereal rsclk;
+ integer group;
+ doublereal start;
+ extern /* Subroutine */ int dafgda_(integer *, integer *, integer *,
+ doublereal *);
+ extern logical failed_(void);
+ integer grpadd;
+ doublereal buffer[100];
+ integer remain, dirloc;
+ extern integer lstled_(doublereal *, integer *, doublereal *);
+ integer numrec;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern integer lstltd_(doublereal *, integer *, doublereal *);
+ integer numint;
+ doublereal nstart;
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer beg, icd[6], end;
+ logical fnd;
+
+/* $ Abstract */
+
+/* Read a pointing record from a CK segment, data type 3. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I File handle. */
+/* DESCR I Segment descriptor. */
+/* SCLKDP I Pointing request time. */
+/* TOL I Time tolerance. */
+/* NEEDAV I Angular velocity request flag. */
+/* RECORD O Pointing data record. */
+/* FOUND O True when data is found. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the integer handle of the CK file containing the */
+/* segment. */
+
+/* DESCR is the descriptor of the segment. */
+
+/* SCLKDP is the encoded spacecraft clock time for which */
+/* pointing is being requested. */
+
+/* TOL is a time tolerance, measured in the same units as */
+/* encoded spacecraft clock. */
+
+/* When SCLKDP falls within the bounds of one of the */
+/* interpolation intervals then the tolerance has no */
+/* effect because pointing will be returned at the */
+/* request time. */
+
+/* However, if the request time is not in one of the */
+/* intervals, then the tolerance is used to determine */
+/* if pointing at one of the interval endpoints should */
+/* be returned. */
+
+/* NEEDAV is true if angular velocity is requested. */
+
+/* $ Detailed_Output */
+
+/* RECORD is the record that CKE03 will evaluate to determine */
+/* the pointing. */
+
+/* When the request time falls within an interval for */
+/* which linear interpolation is valid, the values of */
+/* the two pointing instances that bracket the request */
+/* time are returned in RECORD as follows: */
+
+/* RECORD( 1 ) = Left bracketing SCLK time. */
+
+/* RECORD( 2 ) = lq0 \ */
+/* RECORD( 3 ) = lq1 \ Left bracketing */
+/* RECORD( 4 ) = lq2 / quaternion. */
+/* RECORD( 5 ) = lq3 / */
+
+/* RECORD( 6 ) = lav1 \ Left bracketing */
+/* RECORD( 7 ) = lav2 angular velocity */
+/* RECORD( 8 ) = lav3 / ( optional ) */
+
+/* RECORD( 9 ) = Right bracketing SCLK time. */
+
+/* RECORD( 10 ) = rq0 \ */
+/* RECORD( 11 ) = rq1 \ Right bracketing */
+/* RECORD( 12 ) = rq2 / quaternion. */
+/* RECORD( 13 ) = rq3 / */
+
+/* RECORD( 14 ) = rav1 \ Right bracketing */
+/* RECORD( 15 ) = rav2 angular velocity */
+/* RECORD( 16 ) = rav3 / ( optional ) */
+
+/* RECORD( 17 ) = pointing request time, SCLKDP. */
+
+/* The quantities lq0 - lq3 and rq0 - rq3 are the */
+/* components of the quaternions that represent the */
+/* C-matrices associated with the times that bracket */
+/* the requested time. */
+
+/* The quantities lav1, lav2, lav3 and rav1, rav2, rav3 */
+/* are the components of the angular velocity vectors at */
+/* the respective bracketing times. The components of the */
+/* angular velocity vectors are specified relative to */
+/* the inertial reference frame of the segment. */
+
+/* If the request time does not fall within an */
+/* interpolation interval, but is within TOL of an */
+/* interval endpoint, the values of that pointing */
+/* instance are returned in both parts of RECORD */
+/* ( i.e. RECORD(1-9) and RECORD(10-16) ). */
+
+/* FOUND is true if a record was found to satisfy the pointing */
+/* request. This occurs when the time for which pointing */
+/* is requested falls inside one of the interpolation */
+/* intervals, or when the request time is within the */
+/* tolerance of an interval endpoint. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified handle does not belong to an open DAF file, */
+/* an error is diagnosed by a routine that this routine calls. */
+
+/* 2) If DESCR is not a valid descriptor of a segment in the CK */
+/* file specified by HANDLE, the results of this routine are */
+/* unpredictable. */
+
+/* 3) If the segment is not of data type 3, as specified in the */
+/* third integer component of the segment descriptor, then */
+/* the error SPICE(WRONGDATATYPE) is signalled. */
+
+/* 4) If angular velocity data was requested but the segment */
+/* contains no such data, the error SPICE(NOAVDATA) is signalled. */
+
+/* $ Files */
+
+/* The file containing the segment is specified by its handle and */
+/* should be opened for read or write access, either by CKLPF, */
+/* DAFOPR, or DAFOPW. */
+
+/* $ Particulars */
+
+/* See the CK Required Reading file for a detailed description of */
+/* the structure of a type 3 pointing segment. */
+
+/* When the time for which pointing was requested falls within an */
+/* interpolation interval, then FOUND will be true and RECORD will */
+/* contain the pointing instances in the segment that bracket the */
+/* request time. CKE03 will evaluate RECORD to give pointing at */
+/* the request time. */
+
+/* However, when the request time is not within any of the */
+/* interpolation intervals, then FOUND will be true only if the */
+/* interval endpoint closest to the request time is within the */
+/* tolerance specified by the user. In this case both parts of */
+/* RECORD will contain this closest pointing instance, and CKE03 */
+/* will evaluate RECORD to give pointing at the time associated */
+/* with the returned pointing instance. */
+
+/* $ Examples */
+
+/* The CKRnn routines are usually used in tandem with the CKEnn */
+/* routines, which evaluate the record returned by CKRnn to give */
+/* the pointing information and output time. */
+
+/* The following code fragment searches through all of the segments */
+/* in a file applicable to the Mars Observer spacecraft bus that */
+/* are of data type 3, for a particular spacecraft clock time. */
+/* It then evaluates the pointing for that epoch and prints the */
+/* result. */
+
+/* CHARACTER*(20) SCLKCH */
+/* CHARACTER*(20) SCTIME */
+/* CHARACTER*(40) IDENT */
+
+/* INTEGER I */
+/* INTEGER SC */
+/* INTEGER INST */
+/* INTEGER HANDLE */
+/* INTEGER DTYPE */
+/* INTEGER ICD ( 6 ) */
+
+/* DOUBLE PRECISION SCLKDP */
+/* DOUBLE PRECISION TOL */
+/* DOUBLE PRECISION CLKOUT */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION RECORD ( 17 ) */
+/* DOUBLE PRECISION CMAT ( 3, 3 ) */
+/* DOUBLE PRECISION AV ( 3 ) */
+
+/* LOGICAL NEEDAV */
+/* LOGICAL FND */
+/* LOGICAL SFND */
+
+
+/* SC = -94 */
+/* INST = -94000 */
+/* DTYPE = 3 */
+/* NEEDAV = .FALSE. */
+
+/* C */
+/* C Load the MO SCLK kernel and the C-kernel. */
+/* C */
+/* CALL FURNSH ( 'MO_SCLK.TSC' ) */
+/* CALL DAFOPR ( 'MO_CK.BC', HANDLE ) */
+/* C */
+/* C Get the spacecraft clock time. Then encode it for use */
+/* C in the C-kernel. */
+/* C */
+/* WRITE (*,*) 'Enter spacecraft clock time string:' */
+/* READ (*,FMT='(A)') SCLKCH */
+
+/* CALL SCENCD ( SC, SCLKCH, SCLKDP ) */
+/* C */
+/* C Use a tolerance of 2 seconds ( half of the nominal */
+/* C separation between MO pointing instances ). */
+/* C */
+/* CALL SCTIKS ( SC, '0000000002:000', TOL ) */
+
+/* C */
+/* C Search from the beginning of the CK file through all */
+/* C of the segments. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( SFND ) */
+
+/* FND = .FALSE. */
+
+/* DO WHILE ( ( SFND ) .AND. ( .NOT. FND ) ) */
+
+/* C */
+/* C Get the segment identifier and descriptor. */
+/* C */
+
+/* CALL DAFGN ( IDENT ) */
+/* CALL DAFGS ( DESCR ) */
+/* C */
+/* C Unpack the segment descriptor into its integer and */
+/* C double precision components. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+
+/* C */
+/* C Determine if this segment should be processed. */
+/* C */
+/* IF ( ( INST .EQ. ICD( 1 ) ) .AND. */
+/* . ( SCLKDP + TOL .GE. DCD( 1 ) ) .AND. */
+/* . ( SCLKDP - TOL .LE. DCD( 2 ) ) .AND. */
+/* . ( DTYPE .EQ. ICD( 3 ) ) ) THEN */
+
+
+/* CALL CKR03 ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
+/* . RECORD, FND ) */
+
+/* IF ( FND ) THEN */
+
+/* CALL CKE03 (NEEDAV,RECORD,CMAT,AV,CLKOUT) */
+
+/* CALL SCDECD ( SC, CLKOUT, SCTIME ) */
+
+/* WRITE (*,*) */
+/* WRITE (*,*) 'Segment identifier: ', IDENT */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'Pointing returned for time: ', */
+/* . SCTIME */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'C-matrix:' */
+/* WRITE (*,*) */
+/* WRITE (*,*) ( CMAT(1,I), I = 1, 3 ) */
+/* WRITE (*,*) ( CMAT(2,I), I = 1, 3 ) */
+/* WRITE (*,*) ( CMAT(3,I), I = 1, 3 ) */
+/* WRITE (*,*) */
+
+/* END IF */
+
+/* END IF */
+
+/* CALL DAFFNA ( SFND ) */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* 1) The file containing the segment should be opened for read */
+/* or write access either by CKLPF, DAFOPR, or DAFOPW. */
+
+/* 2) The record returned by this routine is intended to be */
+/* evaluated by CKE03. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.M. Lynch (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1, 22-AUG-2006 (EDW) */
+
+/* Replaced references to LDPOOL with references */
+/* to FURNSH. */
+
+/* - SPICELIB Version 1.1.0, 07-SEP-2001 (EDW) */
+
+/* Replaced DAFRDA call with DAFGDA. */
+/* Added IMPLICIT NONE. */
+
+/* - SPICELIB Version 1.0.0, 25-NOV-1992 (JML) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read ck type_3 pointing data record */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* DIRSIZ is the directory size. */
+
+/* BUFSIZ is the maximum number of double precision numbers */
+/* that we will read from the DAF file at one time. */
+/* BUFSIZ is normally set equal to DIRSIZ. */
+
+/* ND is the number of double precision components in an */
+/* unpacked C-kernel segment descriptor. */
+
+/* NI is the number of integer components in an unpacked */
+/* C-kernel segment descriptor. */
+
+/* QSIZ is the number of double precision numbers making up */
+/* the quaternion portion of a pointing record. */
+
+/* QAVSIZ is the number of double precision numbers making up */
+/* the quaternion and angular velocity portion of a */
+/* pointing record. */
+
+/* DTYPE is the data type of the segment that this routine */
+/* operates on. */
+
+
+
+/* Local variables */
+
+
+/* Saved variables. */
+
+
+/* Initial values. */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKR03", (ftnlen)5);
+ }
+
+/* Start off with FOUND equal to false just in case a SPICELIB error */
+/* is signalled and the return mode is not set to ABORT. */
+
+ *found = FALSE_;
+
+/* We need to look at a few of the descriptor components. */
+
+/* The unpacked descriptor contains the following information */
+/* about the segment: */
+
+/* DCD(1) Initial encoded SCLK */
+/* DCD(2) Final encoded SCLK */
+/* ICD(1) Instrument */
+/* ICD(2) Inertial reference frame */
+/* ICD(3) Data type */
+/* ICD(4) Angular velocity flag */
+/* ICD(5) Initial address of segment data */
+/* ICD(6) Final address of segment data */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+
+/* Check to make sure that the segment is type 3. */
+
+ if (icd[2] != 3) {
+ setmsg_("The segment is not a type 3 segment. Type is #", (ftnlen)47)
+ ;
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(WRONGDATATYPE)", (ftnlen)20);
+ chkout_("CKR03", (ftnlen)5);
+ return 0;
+ }
+
+/* Does this segment contain angular velocity? */
+
+ if (icd[3] == 1) {
+ psiz = 7;
+ } else {
+ psiz = 4;
+ if (*needav) {
+ setmsg_("Segment does not contain angular velocity data.", (
+ ftnlen)47);
+ sigerr_("SPICE(NOAVDATA)", (ftnlen)15);
+ chkout_("CKR03", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* The beginning and ending addresses of the segment are in the */
+/* descriptor. */
+
+ beg = icd[4];
+ end = icd[5];
+
+/* The procedure used in finding a record to satisfy the request */
+/* for pointing is as follows: */
+
+/* 1) Find the two pointing instances in the segment that bracket */
+/* the request time. */
+
+/* The pointing instance that brackets the request time on the */
+/* left is defined to be the one associated with the largest */
+/* time in the segment that is less than or equal to SCLKDP. */
+
+/* The pointing instance that brackets the request time on the */
+/* right is defined to be the one associated with the first */
+/* time in the segment greater than SCLKDP. */
+
+/* Since the times in the segment are strictly increasing the */
+/* left and right bracketing pointing instances are always */
+/* adjacent. */
+
+/* 2) Determine if the bracketing times are in the same */
+/* interpolation interval. */
+
+/* 3) If they are, then pointing at the request time may be */
+/* linearly interpolated from the bracketing times. */
+
+/* 4) If the times that bracket the request time are not in the */
+/* same interval then, since they are adjacent in the segment */
+/* and since intervals begin and end at actual times, they must */
+/* both be interval endpoints. Return the pointing instance */
+/* associated with the endpoint closest to the request time, */
+/* provided that it is within the tolerance. */
+
+
+/* Get the number of intervals and pointing instances ( records ) */
+/* in this segment, and from that determine the number of respective */
+/* directory epochs. */
+
+ i__1 = end - 1;
+ dafgda_(handle, &i__1, &end, buffer);
+ numint = i_dnnt(buffer);
+ numrec = i_dnnt(&buffer[1]);
+ nidir = (numint - 1) / 100;
+ nrdir = (numrec - 1) / 100;
+
+/* Check the FAILED flag just in case HANDLE is not attached to */
+/* any DAF file and the error action is not set to ABORT. You need */
+/* need to do this only after the first call to DAFGDA. */
+
+ if (failed_()) {
+ chkout_("CKR03", (ftnlen)5);
+ return 0;
+ }
+
+/* To find the times that bracket the request time we will first */
+/* find the greatest directory time less than the request time. */
+/* This will narrow down the search to a group of DIRSIZ or fewer */
+/* times where the Jth group is defined to contain SCLK times */
+/* ((J-1)*DIRSIZ + 1) through (J*DIRSIZ). */
+
+/* For example if DIRSIZ = 100 then: */
+
+/* group first time # last time # */
+/* ----- --------------- ------------ */
+/* 1 1 100 */
+/* 2 101 200 */
+/* . . . */
+/* . . . */
+/* 10 901 1000 */
+/* . . . */
+/* . . . */
+/* NRDIR+1 (NRDIR)*100+1 NUMREC */
+
+
+/* Thus if the Ith directory time is the largest one less than */
+/* our request time SCLKDP, then we know that: */
+
+/* SCLKS ( DIRSIZ * I ) < SCLKDP <= SCLKS ( DIRSIZ * (I+1) ) */
+
+/* where SCLKS is taken to be the array of NUMREC times associated */
+/* with the pointing instances. */
+
+/* Therefore, at least one of the bracketing times will come from */
+/* the (I+1)th group. */
+
+
+/* There is only one group if there are no directory epochs. */
+
+ if (nrdir == 0) {
+ group = 1;
+ } else {
+
+/* Compute the location of the first directory epoch. From the */
+/* beginning of the segment, we need to go through all of the */
+/* pointing numbers (PSIZ*NUMREC of them) and then through all of */
+/* the NUMREC SCLK times. */
+
+ dirloc = beg + (psiz + 1) * numrec;
+
+/* Search through the directory times. Read in as many as BUFSIZ */
+/* directory epochs at a time for comparison. */
+
+ fnd = FALSE_;
+ remain = nrdir;
+ group = 0;
+ while(! fnd) {
+
+/* The number of records to read into the buffer. */
+
+ n = min(remain,100);
+ i__1 = dirloc + n - 1;
+ dafgda_(handle, &dirloc, &i__1, buffer);
+ remain -= n;
+
+/* Determine the last directory element in BUFFER that's less */
+/* than SCLKDP. */
+
+ i__ = lstltd_(sclkdp, &n, buffer);
+ if (i__ < n) {
+ group = group + i__ + 1;
+ fnd = TRUE_;
+ } else if (remain == 0) {
+
+/* The request time is greater than the last directory time */
+/* so we want the last group in the segment. */
+
+ group = nrdir + 1;
+ fnd = TRUE_;
+ } else {
+
+/* Need to read another block of directory times. */
+
+ dirloc += n;
+ group += n;
+ }
+ }
+ }
+
+/* Now we know which group of DIRSIZ (or less) times to look at. */
+/* Out of the NUMREC SCLK times, the number that we should skip over */
+/* to get to the proper group is DIRSIZ * ( GROUP - 1 ). */
+
+ skip = (group - 1) * 100;
+
+/* From this we can compute the address in the segment of the group */
+/* of times we want. From the beginning, we need to pass through */
+/* PSIZ * NUMREC pointing numbers to get to the first SCLK time. */
+/* Then we skip over the number just computed above. */
+
+ grpadd = beg + numrec * psiz + skip;
+
+/* The number of times that we have to look at may be less than */
+/* DIRSIZ. However many there are, go ahead and read them into the */
+/* buffer. */
+
+/* Computing MIN */
+ i__1 = 100, i__2 = numrec - skip;
+ n = min(i__1,i__2);
+ i__1 = grpadd + n - 1;
+ dafgda_(handle, &grpadd, &i__1, buffer);
+
+/* Find the largest time in the group less than or equal to the input */
+/* time. */
+
+ i__ = lstled_(sclkdp, &n, buffer);
+
+/* Find the pointing instances in the segment that bracket the */
+/* request time and calculate the addresses for the pointing data */
+/* associated with these times. For cases in which the request time */
+/* is equal to one of the times in the segment, that time will be */
+/* the left bracketing time of the returned pair. */
+
+/* Need to handle the cases when the request time is greater than */
+/* the last or less than the first time in the segment separately. */
+
+ if (i__ == 0) {
+ if (group == 1) {
+
+/* The time occurs before the first time in the segment. Since */
+/* this time cannot possibly be in any of the intervals, the */
+/* first time can satisfy the request for pointing only if it */
+/* is within the tolerance of the request time. */
+
+ if (buffer[0] - *sclkdp <= *tol) {
+ record[0] = buffer[0];
+ record[8] = buffer[0];
+
+/* Calculate the address of the quaternion and angular */
+/* velocity data. Then read it from the file. */
+
+ i__1 = beg + psiz - 1;
+ dafgda_(handle, &beg, &i__1, buffer);
+ moved_(buffer, &psiz, &record[1]);
+ moved_(buffer, &psiz, &record[9]);
+ record[16] = *sclkdp;
+ *found = TRUE_;
+ }
+ chkout_("CKR03", (ftnlen)5);
+ return 0;
+ } else {
+
+/* The first time in the current group brackets the request */
+/* time on the right and the last time from the preceding */
+/* group brackets on the left. */
+
+ rsclk = buffer[0];
+ raddr = beg + skip * psiz;
+ i__1 = grpadd - 1;
+ i__2 = grpadd - 1;
+ dafgda_(handle, &i__1, &i__2, &lsclk);
+ laddr = raddr - psiz;
+ }
+ } else if (i__ == n) {
+
+/* There are two possible cases, but the same action can handle */
+/* both. */
+
+/* 1) If this is the last group ( NRDIR + 1 ) then the request */
+/* time occurs on or after the last time in the segment. */
+/* In either case this last time can satisfy the request for */
+/* pointing only if it is within the tolerance of the request */
+/* time. */
+
+/* 2) The request time is greater than or equal to the last time */
+/* in this group. Since this time is the same as the (I+1)th */
+/* directory time, and since the search on the directory times */
+/* used a strictly less than test, we know that the request */
+/* time must be equal to this time. Just return the pointing */
+/* instance associated with the request time. ( Note that */
+/* SCLKDP - BUFFER(N) will be zero in this case. ) */
+
+ if (*sclkdp - buffer[(i__1 = n - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("buffer", i__1, "ckr03_", (ftnlen)826)] <= *tol) {
+ record[0] = buffer[(i__1 = n - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("buffer", i__1, "ckr03_", (ftnlen)828)];
+ record[8] = buffer[(i__1 = n - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("buffer", i__1, "ckr03_", (ftnlen)829)];
+
+/* Calculate the address of the quaternion and angular */
+/* velocity data. Then read it from the file. */
+
+ addr__ = beg + psiz * (skip + n - 1);
+ i__1 = addr__ + psiz - 1;
+ dafgda_(handle, &addr__, &i__1, buffer);
+ moved_(buffer, &psiz, &record[1]);
+ moved_(buffer, &psiz, &record[9]);
+ record[16] = *sclkdp;
+ *found = TRUE_;
+ }
+ chkout_("CKR03", (ftnlen)5);
+ return 0;
+ } else {
+
+/* The bracketing times are contained in this group. */
+
+ lsclk = buffer[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "buffer", i__1, "ckr03_", (ftnlen)855)];
+ rsclk = buffer[(i__1 = i__) < 100 && 0 <= i__1 ? i__1 : s_rnge("buff"
+ "er", i__1, "ckr03_", (ftnlen)856)];
+ laddr = beg + (skip + i__ - 1) * psiz;
+ raddr = laddr + psiz;
+ }
+
+/* At this point we have the two times in the segment that bracket */
+/* the request time. We also have the addresses of the pointing */
+/* data associated with those times. The task now is to determine */
+/* if the bracketing times fall in the same interval. If so then */
+/* we can interpolate between them. If they don't then return */
+/* pointing for whichever of the two times is closest to the */
+/* request time, provided that it is within the tolerance. */
+
+
+/* Find the interpolation interval that the request time is in and */
+/* determine if the bracketing SCLK's are both in it. */
+
+/* First check if the request time falls in the same interval as */
+/* it did last time. We need to make sure that we are dealing */
+/* with the same segment as well as the same time range. */
+
+
+/* PREVS is the start time of the interval that satisfied */
+/* the previous request for pointing. */
+
+/* PREVN is the start time of the interval that followed */
+/* the interval specified above. */
+
+/* LHAND is the handle of the file that PREVS and PREVN */
+/* were found in. */
+
+/* LBEG, are the beginning and ending addresses of the */
+/* LEND segment in the file LHAND that PREVS and PREVN */
+/* were found in. */
+
+ if (*handle == lhand && beg == lbeg && end == lend && *sclkdp >= prevs &&
+ *sclkdp < prevn) {
+ start = prevs;
+ nstart = prevn;
+ } else {
+
+/* The START times of all of the intervals are stored in the */
+/* segment and a directory of every hundredth START is also */
+/* stored. The procedure to find the bracketing interval start */
+/* times is identical to the one used above for finding the */
+/* bracketing times. */
+
+/* The directory epochs narrow down the search for the times that */
+/* bracket the request time to a group of DIRSIZ or fewer records. */
+
+
+/* There is only one group if there are no directory epochs. */
+
+ if (nidir == 0) {
+ group = 1;
+ } else {
+
+/* Compute the location of the first directory epoch. From the */
+/* beginning of the segment, we need to go through all of the */
+/* pointing numbers (PSIZ*NUMREC of them), then through all of */
+/* the NUMREC SCLK times and NRDIR directory times, and then */
+/* finally through the NUMINT interval start times. */
+
+ dirloc = beg + (psiz + 1) * numrec + nrdir + numint;
+
+/* Locate the largest directory time less than the */
+/* request time SCLKDP. */
+
+/* Read in as many as BUFSIZ directory epochs at a time for */
+/* comparison. */
+
+ fnd = FALSE_;
+ remain = nidir;
+ group = 0;
+ while(! fnd) {
+
+/* The number of records to read into the buffer. */
+
+ n = min(remain,100);
+ i__1 = dirloc + n - 1;
+ dafgda_(handle, &dirloc, &i__1, buffer);
+ remain -= n;
+
+/* Determine the last directory element in BUFFER that's */
+/* less than SCLKDP. */
+
+ i__ = lstltd_(sclkdp, &n, buffer);
+ if (i__ < n) {
+ group = group + i__ + 1;
+ fnd = TRUE_;
+ } else if (remain == 0) {
+
+/* The request time is greater than the last directory */
+/* time so we want the last group in the segment. */
+
+ group = nidir + 1;
+ fnd = TRUE_;
+ } else {
+
+/* Need to read another block of directory times. */
+
+ dirloc += n;
+ group += n;
+ }
+ }
+ }
+
+/* Now we know which group of DIRSIZ (or less) times to look at. */
+/* Out of the NUMINT SCLK START times, the number that we should */
+/* skip over to get to the proper group is DIRSIZ * ( GROUP - 1 ). */
+
+ skip = (group - 1) * 100;
+
+/* From this we can compute the address in the segment of the */
+/* group of times we want. To get to the first interval start */
+/* time we must pass over PSIZ * NUMREC pointing numbers, NUMREC */
+/* SCLK times, and NRDIR SCLK directory times. Then we skip */
+/* over the number just computed above. */
+
+ grpadd = beg + (psiz + 1) * numrec + nrdir + skip;
+
+/* The number of times that we have to look at may be less than */
+/* DIRSIZ. However many there are, go ahead and read them into */
+/* the buffer. */
+
+/* Computing MIN */
+ i__1 = 100, i__2 = numint - skip;
+ n = min(i__1,i__2);
+ i__1 = grpadd + n - 1;
+ dafgda_(handle, &grpadd, &i__1, buffer);
+
+/* Find the index of the largest time in the group that is less */
+/* than or equal to the input time. */
+
+ i__ = lstled_(sclkdp, &n, buffer);
+ if (i__ == 0) {
+
+/* The first start time in the buffer is the start of the */
+/* interval following the one containing the request time. */
+
+/* We don't need to check if GROUP = 1 because the case of */
+/* the request time occurring before the first time in the */
+/* segment has already been handled. */
+
+ nstart = buffer[0];
+ addr__ = grpadd - 1;
+ dafgda_(handle, &addr__, &addr__, &start);
+ } else if (i__ == n) {
+ if (group == nidir + 1) {
+
+/* This is the last interval in the segment. */
+
+ start = buffer[(i__1 = n - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("buffer", i__1, "ckr03_", (ftnlen)1040)];
+ nstart = dpmax_();
+ } else {
+
+/* The last START time in this group is equal to the */
+/* request time. */
+
+ start = buffer[(i__1 = n - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("buffer", i__1, "ckr03_", (ftnlen)1049)];
+ addr__ = grpadd + n;
+ dafgda_(handle, &addr__, &addr__, &nstart);
+ }
+ } else {
+
+/* The bracketing START times are contained in this group. */
+
+ start = buffer[(i__1 = i__ - 1) < 100 && 0 <= i__1 ? i__1 :
+ s_rnge("buffer", i__1, "ckr03_", (ftnlen)1061)];
+ nstart = buffer[(i__1 = i__) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "buffer", i__1, "ckr03_", (ftnlen)1062)];
+ }
+
+/* Save the information about the interval and segment. */
+
+ lhand = *handle;
+ lbeg = beg;
+ lend = end;
+ prevs = start;
+ prevn = nstart;
+ }
+
+/* Check and see if the bracketing pointing instances belong */
+/* to the same interval. If they do then we can interpolate */
+/* between them, if not then check to see if the closer of */
+/* the two to the request time lies within the tolerance. */
+
+/* The left bracketing time will always belong to the same */
+/* interval as the request time, therefore we need to check */
+/* only that the right bracketing time is less than the start */
+/* time of the next interval. */
+
+ if (rsclk < nstart) {
+ record[0] = lsclk;
+ i__1 = laddr + psiz - 1;
+ dafgda_(handle, &laddr, &i__1, &record[1]);
+ record[8] = rsclk;
+ i__1 = raddr + psiz - 1;
+ dafgda_(handle, &raddr, &i__1, &record[9]);
+ record[16] = *sclkdp;
+ *found = TRUE_;
+ } else {
+ ldiff = *sclkdp - lsclk;
+ rdiff = rsclk - *sclkdp;
+ if (ldiff <= *tol || rdiff <= *tol) {
+
+/* Return the pointing instance closest to the request time. */
+
+/* If the request time is midway between LSCLK and RSCLK then */
+/* grab the pointing instance associated with the greater time. */
+
+ if (ldiff < rdiff) {
+ record[0] = lsclk;
+ record[8] = lsclk;
+ i__1 = laddr + psiz - 1;
+ dafgda_(handle, &laddr, &i__1, buffer);
+ moved_(buffer, &psiz, &record[1]);
+ moved_(buffer, &psiz, &record[9]);
+ } else {
+ record[0] = rsclk;
+ record[8] = rsclk;
+ i__1 = raddr + psiz - 1;
+ dafgda_(handle, &raddr, &i__1, buffer);
+ moved_(buffer, &psiz, &record[1]);
+ moved_(buffer, &psiz, &record[9]);
+ }
+ record[16] = *sclkdp;
+ *found = TRUE_;
+ }
+ }
+ chkout_("CKR03", (ftnlen)5);
+ return 0;
+} /* ckr03_ */
+
diff --git a/ext/spice/src/cspice/ckr04.c b/ext/spice/src/cspice/ckr04.c
new file mode 100644
index 0000000000..9093a2f8b3
--- /dev/null
+++ b/ext/spice/src/cspice/ckr04.c
@@ -0,0 +1,783 @@
+/* ckr04.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+static integer c__7 = 7;
+static doublereal c_b18 = 128.;
+
+/* $Procedure CKR04 ( C-kernel, read pointing record, data type 4 ) */
+/* Subroutine */ int ckr04_(integer *handle, doublereal *descr, doublereal *
+ sclkdp, doublereal *tol, logical *needav, doublereal *record, logical
+ *found)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer nrec, ends, indx;
+ doublereal lbnd1, lbnd2, rbnd1;
+ integer k;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), cknr04_(integer *,
+ doublereal *, integer *), dafus_(doublereal *, integer *, integer
+ *, doublereal *, integer *);
+ doublereal value;
+ logical exist;
+ doublereal midpt1, midpt2;
+ extern logical failed_(void);
+ integer numall;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ integer numcft[7];
+ extern /* Subroutine */ int chkout_(char *, ftnlen), sgfpkt_(integer *,
+ doublereal *, integer *, integer *, doublereal *, integer *),
+ sgfrvi_(integer *, doublereal *, doublereal *, doublereal *,
+ integer *, logical *);
+ doublereal clkout;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+ extern /* Subroutine */ int zzck4d2i_(doublereal *, integer *, doublereal
+ *, integer *);
+ doublereal rad1, rad2;
+
+/* $ Abstract */
+
+/* Read a single data record from a type 4 CK segment. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+/* DAF.REQ */
+/* GS.REQ */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* Declarations of the CK data type specific and general CK low */
+/* level routine parameters. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* 1) If new CK types are added, the size of the record passed */
+/* between CKRxx and CKExx must be registered as separate */
+/* parameter. If this size will be greater than current value */
+/* of the CKMRSZ parameter (which specifies the maximum record */
+/* size for the record buffer used inside CKPFS) then it should */
+/* be assigned to CKMRSZ as a new value. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Literature_References */
+
+/* CK Required Reading. */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 19-AUG-2002 (NJB) */
+
+/* Updated to support CK type 5. */
+
+/* - SPICELIB Version 1.0.0, 05-APR-1999 (BVS) */
+
+/* -& */
+
+/* Number of quaternion components and number of quaternion and */
+/* angular rate components together. */
+
+
+/* CK Type 1 parameters: */
+
+/* CK1DTP CK data type 1 ID; */
+
+/* CK1RSZ maximum size of a record passed between CKR01 */
+/* and CKE01. */
+
+
+/* CK Type 2 parameters: */
+
+/* CK2DTP CK data type 2 ID; */
+
+/* CK2RSZ maximum size of a record passed between CKR02 */
+/* and CKE02. */
+
+
+/* CK Type 3 parameters: */
+
+/* CK3DTP CK data type 3 ID; */
+
+/* CK3RSZ maximum size of a record passed between CKR03 */
+/* and CKE03. */
+
+
+/* CK Type 4 parameters: */
+
+/* CK4DTP CK data type 4 ID; */
+
+/* CK4PCD parameter defining integer to DP packing schema that */
+/* is applied when seven number integer array containing */
+/* polynomial degrees for quaternion and angular rate */
+/* components packed into a single DP number stored in */
+/* actual CK records in a file; the value of must not be */
+/* changed or compatibility with existing type 4 CK files */
+/* will be lost. */
+
+/* CK4MXD maximum Chebychev polynomial degree allowed in type 4 */
+/* records; the value of this parameter must never exceed */
+/* value of the CK4PCD; */
+
+/* CK4SFT number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 4 */
+/* CK record that passed between routines CKR04 and CKE04; */
+
+/* CK4RSZ maximum size of type 4 CK record passed between CKR04 */
+/* and CKE04; CK4RSZ is computed as follows: */
+
+/* CK4RSZ = ( CK4MXD + 1 ) * QAVSIZ + CK4SFT */
+
+
+/* CK Type 5 parameters: */
+
+
+/* CK5DTP CK data type 5 ID; */
+
+/* CK5MXD maximum polynomial degree allowed in type 5 */
+/* records. */
+
+/* CK5MET number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 5 */
+/* CK record that passed between routines CKR05 and CKE05; */
+
+/* CK5MXP maximum packet size for any subtype. Subtype 2 */
+/* has the greatest packet size, since these packets */
+/* contain a quaternion, its derivative, an angular */
+/* velocity vector, and its derivative. See ck05.inc */
+/* for a description of the subtypes. */
+
+/* CK5RSZ maximum size of type 5 CK record passed between CKR05 */
+/* and CKE05; CK5RSZ is computed as follows: */
+
+/* CK5RSZ = ( CK5MXD + 1 ) * CK5MXP + CK5MET */
+
+
+
+/* Maximum record size that can be handled by CKPFS. This value */
+/* must be set to the maximum of all CKxRSZ parameters (currently */
+/* CK4RSZ.) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I File handle. */
+/* DESCR I Segment descriptor. */
+/* SCLKDP I Pointing request time. */
+/* TOL I Time tolerance. */
+/* NEEDAV I Angular velocity request flag. */
+/* RECORD O Pointing data record. */
+/* FOUND O True when a record covering SCLKDP is found. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the integer handle of the CK file containing the */
+/* segment. */
+
+/* DESCR is the descriptor of the segment. */
+
+/* SCLKDP is the encoded spacecraft clock time for which */
+/* pointing is being requested. */
+
+/* TOL is a time tolerance, measured in the same units as */
+/* encoded spacecraft clock. */
+
+/* When SCLKDP falls within the bounds of one of the */
+/* interpolation intervals then the tolerance has no */
+/* effect because pointing will be returned at the */
+/* request time. */
+
+/* However, if the request time is not in one of the */
+/* intervals, then the tolerance is used to determine */
+/* if pointing at one of the interval endpoints should */
+/* be returned. */
+
+/* NEEDAV is true if angular velocity is requested. */
+
+/* $ Detailed_Output */
+
+/* RECORD is the record that CKE04 will evaluate to determine */
+/* the pointing and it includes parameters: */
+
+/* --------------------------------------------------- */
+/* | Encoded onboard time which is the closest | */
+/* | to SCLKDP and belongs to one of approximation | */
+/* | intervals | */
+/* --------------------------------------------------- */
+/* | encoded SCLK time of the midpoint of | */
+/* | interpolation interval | */
+/* --------------------------------------------------- */
+/* | radii of interpolation interval | */
+/* | expressed as double precision SCLK ticks | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for q0 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for q1 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for q2 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for q3 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for AV1 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for AV2 | */
+/* --------------------------------------------------- */
+/* | Number of coefficients for AV3 | */
+/* --------------------------------------------------- */
+/* | q0 Cheby coefficients | */
+/* --------------------------------------------------- */
+/* | q1 Cheby coefficients | */
+/* --------------------------------------------------- */
+/* | q2 Cheby coefficients | */
+/* --------------------------------------------------- */
+/* | q3 Cheby coefficients | */
+/* --------------------------------------------------- */
+/* | AV1 Cheby coefficients (optional) | */
+/* --------------------------------------------------- */
+/* | AV2 Cheby coefficients (optional) | */
+/* --------------------------------------------------- */
+/* | AV3 Cheby coefficients (optional) | */
+/* --------------------------------------------------- */
+
+/* FOUND is true if a record was found to satisfy the pointing */
+/* request. This occurs when the time for which pointing */
+/* is requested falls inside one of the interpolation */
+/* intervals, or when the request time is within the */
+/* tolerance of an interval endpoint. */
+
+/* $ Parameters */
+
+/* See 'ckparam.inc'. */
+
+/* $ Files */
+
+/* See argument HANDLE. */
+
+/* $ Exceptions */
+
+/* 1) If the specified handle does not belong to an open DAF file, */
+/* an error is diagnosed by a routine that this routine calls. */
+
+/* 2) If the specified descriptor does not belong a segment */
+/* data in which are organized in accordance with generic */
+/* segment architecture, an error is diagnosed by DAF generic */
+/* segment routines that this routine calls. */
+
+/* 3) If DESCR is not a valid descriptor of a segment in the CK */
+/* file specified by HANDLE, the results of this routine are */
+/* unpredictable. */
+
+/* 4) If the segment is not of data type 4, as specified in the */
+/* third integer component of the segment descriptor, then */
+/* the error SPICE(WRONGDATATYPE) is signalled. */
+
+/* 5) If angular velocity data was requested but the segment */
+/* contains no such data, the error SPICE(NOAVDATA) is */
+/* signalled. */
+
+/* $ Particulars */
+
+/* See the CK Required Reading file for a detailed description of */
+/* the structure of a type 4 pointing segment. */
+
+/* When the time for which pointing was requested falls within an */
+/* interpolation interval, then FOUND will be true and RECORD will */
+/* contain the set of Chebychev polynomial coefficients for the */
+/* time interval that brackets the request time. CKE04 will */
+/* evaluate RECORD to give pointing at the request time. */
+
+/* However, when the request time is not within any of the */
+/* interpolation intervals, then FOUND will be true only if the */
+/* interval endpoint closest to the request time is within the */
+/* tolerance specified by the user. In this case RECORD will */
+/* contain the set of Chebychev polynomial coefficients for the */
+/* time interval one of the ends of which was within tolerance */
+/* from the request time, and CKE04 will evaluate RECORD to give */
+/* pointing at the time associated with that interval end time. */
+
+
+/* $ Examples */
+
+/* The CKRnn routines are usually used in tandem with the CKEnn */
+/* routines, which evaluate the record returned by CKRnn to give */
+/* the pointing information and output time. */
+
+/* The following code fragment searches through all of the segments */
+/* in a file applicable to the Mars Global Surveyor spacecraft bus */
+/* that are of data type 4, for a particular spacecraft clock time. */
+/* It then evaluates the pointing for that epoch and prints the */
+/* result. */
+
+/* C */
+/* C CK parameters include file. */
+/* C */
+/* INCLUDE 'ckparam.inc' */
+/* C */
+/* C Declarations */
+/* C */
+/* CHARACTER*(20) SCLKCH */
+/* CHARACTER*(20) SCTIME */
+/* CHARACTER*(40) IDENT */
+
+/* DOUBLE PRECISION AV ( 3 ) */
+/* DOUBLE PRECISION CLKOUT */
+/* DOUBLE PRECISION CMAT ( 3, 3 ) */
+/* DOUBLE PRECISION DCD ( 2 ) */
+/* DOUBLE PRECISION DESCR ( 5 ) */
+/* DOUBLE PRECISION RECORD ( CK4RSZ ) */
+/* DOUBLE PRECISION SCLKDP */
+/* DOUBLE PRECISION TOL */
+
+/* INTEGER HANDLE */
+/* INTEGER I */
+/* INTEGER ICD ( 6 ) */
+/* INTEGER INST */
+/* INTEGER SC */
+
+/* LOGICAL FND */
+/* LOGICAL NEEDAV */
+/* LOGICAL SFND */
+/* C */
+/* C Initial values. */
+/* C */
+/* SC = -94 */
+/* INST = -94000 */
+/* NEEDAV = .FALSE. */
+/* C */
+/* C Load the MGS SCLK kernel and the C-kernel. */
+/* C */
+/* CALL FURNSH( 'MGS_SCLK.TSC' ) */
+/* CALL DAFOPR( 'MGS_CK4.BC', HANDLE ) */
+/* C */
+/* C Get the spacecraft clock time. Then encode it for use */
+/* C in the C-kernel. */
+/* C */
+/* CALL PROMPT( 'Enter SCLK string: ', SCLKCH ) */
+/* CALL SCENCD( SC, SCLKCH, SCLKDP ) */
+/* C */
+/* C Use a tolerance of 2 seconds (half of the nominal */
+/* C separation between MGS pointing instances ). */
+/* C */
+/* CALL SCTIKS ( SC, '0000000002:000', TOL ) */
+/* C */
+/* C Search from the beginning of the CK file through all */
+/* C of the segments. */
+/* C */
+/* CALL DAFBFS( HANDLE ) */
+/* CALL DAFFNA( SFND ) */
+
+/* FND = .FALSE. */
+
+/* DO WHILE ( ( SFND ) .AND. ( .NOT. FND ) ) */
+/* C */
+/* C Get the segment identifier and descriptor. */
+/* C */
+/* CALL DAFGN( IDENT ) */
+/* CALL DAFGS( DESCR ) */
+/* C */
+/* C Unpack the segment descriptor into its integer and */
+/* C double precision components. */
+/* C */
+/* CALL DAFUS( DESCR, 2, 6, DCD, ICD ) */
+/* C */
+/* C Determine if this segment should be processed. */
+/* C */
+/* IF ( ( INST .EQ. ICD( 1 ) ) .AND. */
+/* . ( SCLKDP + TOL .GE. DCD( 1 ) ) .AND. */
+/* . ( SCLKDP - TOL .LE. DCD( 2 ) ) .AND. */
+/* . ( CK4DTP .EQ. ICD( 3 ) ) ) THEN */
+/* C */
+/* C Find CK 4 record covering requested time. */
+/* C */
+/* CALL CKR04( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
+/* . RECORD, FND ) */
+
+/* IF ( FND ) THEN */
+/* C */
+/* C Compute pointing using found CK 4 record. */
+/* C */
+/* CALL CKE04( NEEDAV, RECORD, CMAT, AV, CLKOUT) */
+
+/* CALL SCDECD( SC, CLKOUT, SCTIME ) */
+
+/* WRITE (*,*) */
+/* WRITE (*,*) 'Segment identifier: ', IDENT */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'Pointing returned for time: ', */
+/* . SCTIME */
+/* WRITE (*,*) */
+/* WRITE (*,*) 'C-matrix:' */
+/* WRITE (*,*) */
+/* WRITE (*,*) ( CMAT(1,I), I = 1, 3 ) */
+/* WRITE (*,*) ( CMAT(2,I), I = 1, 3 ) */
+/* WRITE (*,*) ( CMAT(3,I), I = 1, 3 ) */
+/* WRITE (*,*) */
+
+/* END IF */
+
+/* END IF */
+
+/* CALL DAFFNA ( SFND ) */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* 1) The file containing the segment should be opened for read */
+/* or write access either by CKLPF, DAFOPR, or DAFOPW. */
+
+/* 2) The record returned by this routine is intended to be */
+/* evaluated by CKE04. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* Y.K. Zaiko (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 22-AUG-2006 (EDW) */
+
+/* Replaced references to LDPOOL with references */
+/* to FURNSH. */
+
+/* - SPICELIB Version 1.0.0, 05-MAY-1999 (YKZ) (BVS) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read record from type_4 CK segment */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKR04", (ftnlen)5);
+ }
+
+/* Set initial value of the found flag to "NOT FOUND". */
+
+ *found = FALSE_;
+
+/* We need to unpack and analyze descriptor components. The */
+/* unpacked descriptor contains the following information */
+/* about the segment: */
+
+/* DCD(1) Initial encoded SCLK */
+/* DCD(2) Final encoded SCLK */
+/* ICD(1) Instrument */
+/* ICD(2) Inertial reference frame */
+/* ICD(3) Data type */
+/* ICD(4) Angular velocity flag */
+/* ICD(5) Initial address of segment data */
+/* ICD(6) Final address of segment data */
+
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+
+/* Check if the segment is type 4. Signal an error if it's not. */
+
+ if (icd[2] != 4) {
+ setmsg_("The segment is not a type 4 segment. Type is #", (ftnlen)47)
+ ;
+ errint_("#", &icd[2], (ftnlen)1);
+ sigerr_("SPICE(WRONGDATATYPE)", (ftnlen)20);
+ chkout_("CKR04", (ftnlen)5);
+ return 0;
+ }
+ if (*needav) {
+
+/* Signal an error if angular velocities are required but */
+/* they are not present in the segment. */
+
+ if (icd[3] != 1) {
+ setmsg_("Segment does not contain angular velocity data.", (
+ ftnlen)47);
+ sigerr_("SPICE(NOAVDATA)", (ftnlen)15);
+ chkout_("CKR04", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Get number of records (packets) in the segment. */
+
+ cknr04_(handle, descr, &nrec);
+
+/* Locate the last time in the set of reference epochs less than or */
+/* equal to the input SCLKDP. */
+
+ sgfrvi_(handle, descr, sclkdp, &value, &indx, &exist);
+ if (failed_()) {
+ chkout_("CKR04", (ftnlen)5);
+ return 0;
+ }
+ if (! exist) {
+
+/* We didn't find reference value with means that SCLKDP is */
+/* less than the left bound of the first interpolation interval. */
+/* Fetch the first record. */
+
+ indx = 1;
+ sgfpkt_(handle, descr, &indx, &indx, record, &ends);
+ if (failed_()) {
+ chkout_("CKR04", (ftnlen)5);
+ return 0;
+ }
+ midpt1 = record[0];
+ rad1 = record[1];
+
+/* Check whether SCLKDP is within TOL of the left bound of the */
+/* first interval. */
+
+ lbnd1 = midpt1 - rad1 - *tol;
+ if (*sclkdp >= lbnd1) {
+ *found = TRUE_;
+ clkout = midpt1 - rad1;
+ }
+ } else {
+
+/* We found reference value. */
+
+ if (indx >= nrec) {
+
+/* The SCLKDP is greater than the left bound of the last */
+/* interpolation interval. Fetch the last record. */
+
+ indx = nrec;
+ sgfpkt_(handle, descr, &indx, &indx, record, &ends);
+ if (failed_()) {
+ chkout_("CKR04", (ftnlen)5);
+ return 0;
+ }
+ midpt1 = record[0];
+ rad1 = record[1];
+
+/* Check whether SCLKDP is within TOL of the right bound of */
+/* the last interval. */
+
+ rbnd1 = midpt1 + rad1 + *tol;
+ if (*sclkdp <= rbnd1) {
+ *found = TRUE_;
+
+/* Check whether SCLKDP falls between right bound of the */
+/* last interval and right bound + TOL. */
+
+ rbnd1 = midpt1 + rad1;
+ if (*sclkdp >= rbnd1) {
+ clkout = midpt1 + rad1;
+ } else {
+
+/* SCLKDP belongs to the last interval */
+
+ clkout = *sclkdp;
+ }
+ }
+ } else if (indx >= 1 && indx < nrec) {
+
+/* The SCLKDP lies between left bound of the first interval */
+/* and the right bound of the interval before the last */
+/* interval. Fetch the found record. */
+
+ sgfpkt_(handle, descr, &indx, &indx, record, &ends);
+ if (failed_()) {
+ chkout_("CKR04", (ftnlen)5);
+ return 0;
+ }
+ midpt1 = record[0];
+ rad1 = record[1];
+
+/* Check whether SCLKDP belongs to current interval. */
+
+ rbnd1 = midpt1 + rad1;
+ if (*sclkdp <= rbnd1) {
+ *found = TRUE_;
+ clkout = *sclkdp;
+ } else {
+
+/* SCLKDP doesn't belong to current interval. Fetch the */
+/* next packet. */
+
+ i__1 = indx + 1;
+ i__2 = indx + 1;
+ sgfpkt_(handle, descr, &i__1, &i__2, record, &ends);
+ if (failed_()) {
+ chkout_("CKR04", (ftnlen)5);
+ return 0;
+ }
+ midpt2 = record[0];
+ rad2 = record[1];
+
+/* Find the closest interval bound for SCLKDP. */
+
+ rbnd1 = midpt1 + rad1;
+ lbnd2 = midpt2 - rad2;
+ if (*sclkdp - rbnd1 <= lbnd2 - *sclkdp) {
+
+/* SCLKDP is closer to the right bound of current */
+/* interval. Check whether it's within TOL of it. */
+
+ rbnd1 = midpt1 + rad1 + *tol;
+ if (*sclkdp <= rbnd1) {
+ *found = TRUE_;
+ clkout = midpt1 + rad1;
+
+/* At this point we need to re-read our current */
+/* record because it was overwritten by the next */
+/* record. No FAILED() check here -- we already */
+/* fetched this packet successfully one call to */
+/* SGFPKT ago. */
+
+ sgfpkt_(handle, descr, &indx, &indx, record, &ends);
+ }
+ } else {
+
+/* SCLKDP is closer to the left bound of the next */
+/* interval. Check whether it's within TOL of it. */
+
+ lbnd2 = midpt2 - rad2 - *tol;
+ if (*sclkdp >= lbnd2) {
+ *found = TRUE_;
+ ++indx;
+ clkout = midpt2 - rad2;
+ }
+ }
+ }
+ }
+ }
+
+/* If we found the interval on segment the SCLKDP belongs to, then */
+
+ if (*found) {
+
+/* Decode numbers of polynomial coefficients. */
+
+ zzck4d2i_(&record[2], &c__7, &c_b18, numcft);
+
+/* Count total number of coefficients. */
+
+ numall = 0;
+ for (k = 1; k <= 7; ++k) {
+ numall += numcft[(i__1 = k - 1) < 7 && 0 <= i__1 ? i__1 : s_rnge(
+ "numcft", i__1, "ckr04_", (ftnlen)665)];
+ }
+
+/* Move coefficients to the right and insert numbers of */
+/* coefficients into output RECORD. */
+
+ for (k = numall; k >= 1; --k) {
+ record[k + 9] = record[k + 2];
+ }
+ for (k = 1; k <= 7; ++k) {
+ record[k + 2] = (doublereal) numcft[(i__1 = k - 1) < 7 && 0 <=
+ i__1 ? i__1 : s_rnge("numcft", i__1, "ckr04_", (ftnlen)
+ 677)];
+ }
+ record[2] = record[1];
+ record[1] = record[0];
+
+/* Insert CLKOUT into output RECORD */
+
+ record[0] = clkout;
+ }
+
+/* All done. */
+
+ chkout_("CKR04", (ftnlen)5);
+ return 0;
+} /* ckr04_ */
+
diff --git a/ext/spice/src/cspice/ckr05.c b/ext/spice/src/cspice/ckr05.c
new file mode 100644
index 0000000000..e0213a6c76
--- /dev/null
+++ b/ext/spice/src/cspice/ckr05.c
@@ -0,0 +1,1251 @@
+/* ckr05.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKR05 ( Read CK record from segment, type 05 ) */
+/* Subroutine */ int ckr05_(integer *handle, doublereal *descr, doublereal *
+ sclkdp, doublereal *tol, logical *needav, doublereal *record, logical
+ *found)
+{
+ /* Initialized data */
+
+ static integer lbeg = -1;
+ static integer lend = -1;
+ static integer lhand = 0;
+ static doublereal prevn = -1.;
+ static doublereal prevnn = -1.;
+ static doublereal prevs = -1.;
+
+ /* System generated locals */
+ integer i__1, i__2;
+ doublereal d__1, d__2;
+
+ /* Builtin functions */
+ integer i_dnnt(doublereal *), s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer high;
+ doublereal rate;
+ integer last, type__, i__, j, n;
+ doublereal t;
+ integer begin;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
+ integer *, integer *, doublereal *, integer *);
+ integer nidir;
+ extern doublereal dpmax_(void);
+ extern /* Subroutine */ int moved_(doublereal *, integer *, doublereal *);
+ integer npdir, nsrch;
+ extern /* Subroutine */ int errdp_(char *, doublereal *, ftnlen);
+ integer lsize, first, nints, rsize;
+ doublereal start;
+ extern /* Subroutine */ int dafgda_(integer *, integer *, integer *,
+ doublereal *);
+ doublereal dc[2];
+ integer ic[6];
+ extern logical failed_(void);
+ integer bufbas, dirbas;
+ doublereal hepoch;
+ extern doublereal brcktd_(doublereal *, doublereal *, doublereal *);
+ doublereal lepoch;
+ integer npread, nsread, remain, pbegix, sbegix, timbas;
+ doublereal pbuffr[101];
+ extern integer lstled_(doublereal *, integer *, doublereal *);
+ doublereal sbuffr[103];
+ integer pendix, sendix, packsz;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen);
+ integer maxwnd;
+ doublereal contrl[5];
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ extern integer lstltd_(doublereal *, integer *, doublereal *);
+ doublereal nstart;
+ extern logical return_(void);
+ integer pgroup, sgroup, wndsiz, wstart, subtyp;
+ doublereal nnstrt;
+ extern logical odd_(integer *);
+ integer end, low;
+
+/* $ Abstract */
+
+/* Read a single CK data record from a segment of type 05 */
+/* (MEX/Rosetta Attitude file interpolation). */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* Declare parameters specific to CK type 05. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 20-AUG-2002 (NJB) */
+
+/* -& */
+
+/* CK type 5 subtype codes: */
+
+
+/* Subtype 0: Hermite interpolation, 8-element packets. Quaternion */
+/* and quaternion derivatives only, no angular velocity */
+/* vector provided. Quaternion elements are listed */
+/* first, followed by derivatives. Angular velocity is */
+/* derived from the quaternions and quaternion */
+/* derivatives. */
+
+
+/* Subtype 1: Lagrange interpolation, 4-element packets. Quaternion */
+/* only. Angular velocity is derived by differentiating */
+/* the interpolating polynomials. */
+
+
+/* Subtype 2: Hermite interpolation, 14-element packets. */
+/* Quaternion and angular angular velocity vector, as */
+/* well as derivatives of each, are provided. The */
+/* quaternion comes first, then quaternion derivatives, */
+/* then angular velocity and its derivatives. */
+
+
+/* Subtype 3: Lagrange interpolation, 7-element packets. Quaternion */
+/* and angular velocity vector provided. The quaternion */
+/* comes first. */
+
+
+/* Packet sizes associated with the various subtypes: */
+
+
+/* End of file ck05.inc. */
+
+/* $ Abstract */
+
+/* Declarations of the CK data type specific and general CK low */
+/* level routine parameters. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* 1) If new CK types are added, the size of the record passed */
+/* between CKRxx and CKExx must be registered as separate */
+/* parameter. If this size will be greater than current value */
+/* of the CKMRSZ parameter (which specifies the maximum record */
+/* size for the record buffer used inside CKPFS) then it should */
+/* be assigned to CKMRSZ as a new value. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Literature_References */
+
+/* CK Required Reading. */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 19-AUG-2002 (NJB) */
+
+/* Updated to support CK type 5. */
+
+/* - SPICELIB Version 1.0.0, 05-APR-1999 (BVS) */
+
+/* -& */
+
+/* Number of quaternion components and number of quaternion and */
+/* angular rate components together. */
+
+
+/* CK Type 1 parameters: */
+
+/* CK1DTP CK data type 1 ID; */
+
+/* CK1RSZ maximum size of a record passed between CKR01 */
+/* and CKE01. */
+
+
+/* CK Type 2 parameters: */
+
+/* CK2DTP CK data type 2 ID; */
+
+/* CK2RSZ maximum size of a record passed between CKR02 */
+/* and CKE02. */
+
+
+/* CK Type 3 parameters: */
+
+/* CK3DTP CK data type 3 ID; */
+
+/* CK3RSZ maximum size of a record passed between CKR03 */
+/* and CKE03. */
+
+
+/* CK Type 4 parameters: */
+
+/* CK4DTP CK data type 4 ID; */
+
+/* CK4PCD parameter defining integer to DP packing schema that */
+/* is applied when seven number integer array containing */
+/* polynomial degrees for quaternion and angular rate */
+/* components packed into a single DP number stored in */
+/* actual CK records in a file; the value of must not be */
+/* changed or compatibility with existing type 4 CK files */
+/* will be lost. */
+
+/* CK4MXD maximum Chebychev polynomial degree allowed in type 4 */
+/* records; the value of this parameter must never exceed */
+/* value of the CK4PCD; */
+
+/* CK4SFT number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 4 */
+/* CK record that passed between routines CKR04 and CKE04; */
+
+/* CK4RSZ maximum size of type 4 CK record passed between CKR04 */
+/* and CKE04; CK4RSZ is computed as follows: */
+
+/* CK4RSZ = ( CK4MXD + 1 ) * QAVSIZ + CK4SFT */
+
+
+/* CK Type 5 parameters: */
+
+
+/* CK5DTP CK data type 5 ID; */
+
+/* CK5MXD maximum polynomial degree allowed in type 5 */
+/* records. */
+
+/* CK5MET number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 5 */
+/* CK record that passed between routines CKR05 and CKE05; */
+
+/* CK5MXP maximum packet size for any subtype. Subtype 2 */
+/* has the greatest packet size, since these packets */
+/* contain a quaternion, its derivative, an angular */
+/* velocity vector, and its derivative. See ck05.inc */
+/* for a description of the subtypes. */
+
+/* CK5RSZ maximum size of type 5 CK record passed between CKR05 */
+/* and CKE05; CK5RSZ is computed as follows: */
+
+/* CK5RSZ = ( CK5MXD + 1 ) * CK5MXP + CK5MET */
+
+
+
+/* Maximum record size that can be handled by CKPFS. This value */
+/* must be set to the maximum of all CKxRSZ parameters (currently */
+/* CK4RSZ.) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I File handle. */
+/* DESCR I Segment descriptor. */
+/* SCLKDP I Pointing request time. */
+/* TOL I Lookup tolerance. */
+/* NEEDAV I Angular velocity flag. */
+/* RECORD O Data record. */
+/* FOUND O Flag indicating whether record was found. */
+
+/* $ Detailed_Input */
+
+/* HANDLE, */
+/* DESCR are the file handle and segment descriptor for */
+/* a CK segment of type 05. */
+
+/* SCLKDP is an encoded spacecraft clock time indicating */
+/* the epoch for which pointing is desired. */
+
+/* TOL is a time tolerance, measured in the same units as */
+/* encoded spacecraft clock. */
+
+/* When SCLKDP falls within the bounds of one of the */
+/* interpolation intervals then the tolerance has no */
+/* effect because pointing will be returned at the */
+/* request time. */
+
+/* However, if the request time is not in one of the */
+/* intervals, then the tolerance is used to determine */
+/* if pointing at one of the interval endpoints should */
+/* be returned. */
+
+/* NEEDAV is true if angular velocity is requested. */
+
+/* $ Detailed_Output */
+
+/* RECORD is a set of data from the specified segment which, */
+/* when evaluated at epoch SCLKDP, will give the */
+/* attitude and angular velocity of some body, relative */
+/* to the reference frame indicated by DESCR. */
+
+/* The structure of the record is as follows: */
+
+/* +----------------------+ */
+/* | evaluation epoch | */
+/* +----------------------+ */
+/* | subtype code | */
+/* +----------------------+ */
+/* | number of packets (n)| */
+/* +----------------------+ */
+/* | nominal SCLK rate | */
+/* +----------------------+ */
+/* | packet 1 | */
+/* +----------------------+ */
+/* | packet 2 | */
+/* +----------------------+ */
+/* . */
+/* . */
+/* . */
+/* +----------------------+ */
+/* | packet n | */
+/* +----------------------+ */
+/* | epochs 1--n | */
+/* +----------------------+ */
+
+/* The packet size is a function of the subtype code. */
+/* All packets in a record have the same size. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* This routine follows the pattern established in the lower-numbered */
+/* CK data type readers of not explicitly performing error */
+/* diagnoses. Exceptions are listed below nonetheless. */
+
+/* 1) If the input HANDLE does not designate a loaded CK file, the */
+/* error will be diagnosed by routines called by this routine. */
+
+/* 2) If the segment specified by DESCR is not of data type 05, */
+/* the error 'SPICE(WRONGCKTYPE)' is signaled. */
+
+/* 3) If the input SCLK value is not within the range specified */
+/* in the segment descriptor, the error SPICE(TIMEOUTOFBOUNDS) */
+/* is signaled. */
+
+/* 4) If the window size is non-positive or greater than the */
+/* maximum allowed value, the error SPICE(INVALIDVALUE) is */
+/* signaled. */
+
+/* 5) If the window size is not compatible with the segment */
+/* subtype, the error SPICE(INVALIDVALUE) is signaled. */
+
+/* 6) If the segment subtype is not recognized, the error */
+/* SPICE(NOTSUPPORTED) is signaled. */
+
+/* 7) If the tolerance is negative, the error SPICE(VALUEOUTOFRANGE) */
+/* is signaled. */
+
+/* $ Files */
+
+/* See argument HANDLE. */
+
+/* $ Particulars */
+
+/* See the CK Required Reading file for a description of the */
+/* structure of a data type 05 segment. */
+
+/* $ Examples */
+
+/* The data returned by the CKRnn routine is in its rawest form, */
+/* taken directly from the segment. As such, it will be meaningless */
+/* to a user unless he/she understands the structure of the data type */
+/* completely. Given that understanding, however, the CKRxx */
+/* routines might be used to "dump" and check segment data for a */
+/* particular epoch. */
+
+
+/* C */
+/* C Get a segment applicable to a specified body and epoch. */
+/* C */
+/* C CALL CKBSS ( INST, SCLKDP, TOL, NEEDAV ) */
+/* CALL CKSNS ( HANDLE, DESCR, SEGID, SFND ) */
+
+/* IF ( .NOT. SFND ) THEN */
+/* [Handle case of pointing not being found] */
+/* END IF */
+
+/* C */
+/* C Look at parts of the descriptor. */
+/* C */
+/* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
+/* CENTER = ICD( 2 ) */
+/* REF = ICD( 3 ) */
+/* TYPE = ICD( 4 ) */
+
+/* IF ( TYPE .EQ. 05 ) THEN */
+
+/* CALL CKR05 ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
+/* . RECORD, FOUND ) */
+
+/* IF ( .NOT. FOUND ) THEN */
+/* [Handle case of pointing not being found] */
+/* END IF */
+
+/* [Look at the RECORD data] */
+/* . */
+/* . */
+/* . */
+/* END IF */
+
+/* $ Restrictions */
+
+/* 1) Correctness of inputs must be ensured by the caller of */
+/* this routine. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 06-SEP-2002 (NJB) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read record from type_5 ck segment */
+
+/* -& */
+/* $ Revisions */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Maximum polynomial degree: */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("CKR05", (ftnlen)5);
+
+/* No pointing found so far. */
+
+ *found = FALSE_;
+
+/* Unpack the segment descriptor, and get the start and end addresses */
+/* of the segment. */
+
+ dafus_(descr, &c__2, &c__6, dc, ic);
+ type__ = ic[2];
+ begin = ic[4];
+ end = ic[5];
+
+/* Make sure that this really is a type 05 data segment. */
+
+ if (type__ != 5) {
+ setmsg_("You are attempting to locate type * data in a type 5 data s"
+ "egment.", (ftnlen)66);
+ errint_("*", &type__, (ftnlen)1);
+ sigerr_("SPICE(WRONGCKTYPE)", (ftnlen)18);
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+
+/* Check the tolerance value. */
+
+ if (*tol < 0.) {
+ setmsg_("Tolerance must be non-negative but was actually *.", (ftnlen)
+ 50);
+ errdp_("*", tol, (ftnlen)1);
+ sigerr_("SPICE(VALUEOUTOFRANGE)", (ftnlen)22);
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+
+/* Check the request time and tolerance against the bounds in */
+/* the segment descriptor. */
+
+ if (*sclkdp + *tol < dc[0] || *sclkdp - *tol > dc[1]) {
+
+/* The request time is too far outside the segment's coverage */
+/* interval for any pointing to satisfy the request. */
+
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+
+/* Set the request time to use for searching. */
+
+ t = brcktd_(sclkdp, dc, &dc[1]);
+
+/* From this point onward, we assume the segment was constructed */
+/* correctly. In particular, we assume: */
+
+/* 1) The segment descriptor's time bounds are in order and are */
+/* distinct. */
+
+/* 2) The epochs in the segment are in strictly increasing */
+/* order. */
+
+
+/* 3) The interpolation interval start times in the segment are */
+/* in strictly increasing order. */
+
+
+/* 4) The degree of the interpolating polynomial specified by */
+/* the segment is at least 1 and is no larger than MAXDEG. */
+
+
+ i__1 = end - 4;
+ dafgda_(handle, &i__1, &end, contrl);
+
+/* Check the FAILED flag just in case HANDLE is not attached to */
+/* any DAF file and the error action is not set to ABORT. We */
+/* do this only after the first call to DAFGDA, as in CKR03. */
+
+ if (failed_()) {
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+ rate = contrl[0];
+ subtyp = i_dnnt(&contrl[1]);
+ wndsiz = i_dnnt(&contrl[2]);
+ nints = i_dnnt(&contrl[3]);
+ n = i_dnnt(&contrl[4]);
+
+/* Set the packet size, which is a function of the subtype. */
+
+ if (subtyp == 0) {
+ packsz = 8;
+ } else if (subtyp == 1) {
+ packsz = 4;
+ } else if (subtyp == 2) {
+ packsz = 14;
+ } else if (subtyp == 3) {
+ packsz = 7;
+ } else {
+ setmsg_("Unexpected CK type 5 subtype # found in type 5 segment.", (
+ ftnlen)55);
+ errint_("#", &subtyp, (ftnlen)1);
+ sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+
+/* Check the window size. */
+
+ if (wndsiz <= 0) {
+ setmsg_("Window size in type 05 segment was #; must be positive.", (
+ ftnlen)55);
+ errint_("#", &wndsiz, (ftnlen)1);
+ sigerr_("SPICE(INVALIDVALUE)", (ftnlen)19);
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+ if (subtyp == 0 || subtyp == 2) {
+
+/* These are the Hermite subtypes. */
+
+ maxwnd = 8;
+ if (wndsiz > maxwnd) {
+ setmsg_("Window size in type 05 segment was #; max allowed value"
+ " is # for subtypes 0 and 2 (Hermite, 8 or 14-element pac"
+ "kets).", (ftnlen)117);
+ errint_("#", &wndsiz, (ftnlen)1);
+ errint_("#", &maxwnd, (ftnlen)1);
+ sigerr_("SPICE(INVALIDVALUE)", (ftnlen)19);
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+ if (odd_(&wndsiz)) {
+ setmsg_("Window size in type 05 segment was #; must be even for "
+ "subtypes 0 and 2 (Hermite, 8 or 14-element packets).", (
+ ftnlen)107);
+ errint_("#", &wndsiz, (ftnlen)1);
+ sigerr_("SPICE(INVALIDVALUE)", (ftnlen)19);
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+ } else if (subtyp == 1 || subtyp == 3) {
+
+/* These are the Lagrange subtypes. */
+
+ maxwnd = 16;
+ if (wndsiz > maxwnd) {
+ setmsg_("Window size in type 05 segment was #; max allowed value"
+ " is # for subtypes 1 and 3 (Lagrange, 4 or 7-element pac"
+ "kets).", (ftnlen)117);
+ errint_("#", &wndsiz, (ftnlen)1);
+ errint_("#", &maxwnd, (ftnlen)1);
+ sigerr_("SPICE(INVALIDVALUE)", (ftnlen)19);
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+ if (odd_(&wndsiz)) {
+ setmsg_("Window size in type 05 segment was #; must be even for "
+ "subtypes 1 and 3 (Lagrange, 4 or 7-element packets).", (
+ ftnlen)107);
+ errint_("#", &wndsiz, (ftnlen)1);
+ sigerr_("SPICE(INVALIDVALUE)", (ftnlen)19);
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+ } else {
+ setmsg_("This point should not be reached. Getting here may indicate"
+ " that the code needs to updated to handle the new subtype #",
+ (ftnlen)118);
+ errint_("#", &subtyp, (ftnlen)1);
+ sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+
+/* We now need to select the pointing values to interpolate */
+/* in order to satisfy the pointing request. The first step */
+/* is to use the pointing directories (if any) to locate a set of */
+/* epochs bracketing the request time. Note that the request */
+/* time might not be bracketed: it could precede the first */
+/* epoch or follow the last epoch. */
+
+/* We'll use the variable PGROUP to refer to the set of epochs */
+/* to search. The first group consists of the epochs prior to */
+/* and including the first pointing directory entry. The last */
+/* group consists of the epochs following the last pointing */
+/* directory entry. Other groups consist of epochs following */
+/* one pointing directory entry up to and including the next */
+/* pointing directory entry. */
+
+ npdir = (n - 1) / 100;
+ dirbas = begin + n * packsz + n - 1;
+ if (npdir == 0) {
+
+/* There's no mystery about which group of epochs to search. */
+
+ pgroup = 1;
+ } else {
+
+/* There's at least one directory. Find the first directory */
+/* whose time is greater than or equal to the request time, if */
+/* there is such a directory. We'll search linearly through the */
+/* directory entries, reading up to DIRSIZ of them at a time. */
+/* Having found the correct set of directory entries, we'll */
+/* perform a binary search within that set for the desired entry. */
+
+ bufbas = dirbas;
+ npread = min(npdir,100);
+ i__1 = bufbas + 1;
+ i__2 = bufbas + npread;
+ dafgda_(handle, &i__1, &i__2, pbuffr);
+ remain = npdir - npread;
+ while(pbuffr[(i__1 = npread - 1) < 101 && 0 <= i__1 ? i__1 : s_rnge(
+ "pbuffr", i__1, "ckr05_", (ftnlen)633)] < t && remain > 0) {
+ bufbas += npread;
+ npread = min(remain,100);
+
+/* Note: NPREAD is always > 0 here. */
+
+ i__1 = bufbas + 1;
+ i__2 = bufbas + npread;
+ dafgda_(handle, &i__1, &i__2, pbuffr);
+ remain -= npread;
+ }
+
+/* At this point, BUFBAS - DIRBAS is the number of directory */
+/* entries preceding the one contained in PBUFFR(1). */
+
+/* PGROUP is one more than the number of directories we've */
+/* passed by. */
+
+ pgroup = bufbas - dirbas + lstltd_(&t, &npread, pbuffr) + 1;
+ }
+
+/* PGROUP now indicates the set of epochs in which to search for the */
+/* request epoch. The following cases can occur: */
+
+/* PGROUP = 1 */
+/* ========== */
+
+/* NPDIR = 0 */
+/* -------- */
+/* The request time may precede the first time tag */
+/* of the segment, exceed the last time tag, or lie */
+/* in the closed interval bounded by these time tags. */
+
+/* NPDIR >= 1 */
+/* --------- */
+/* The request time may precede the first time tag */
+/* of the group but does not exceed the last epoch */
+/* of the group. */
+
+
+/* 1 < PGROUP <= NPDIR */
+/* =================== */
+
+/* The request time follows the last time of the */
+/* previous group and is less than or equal to */
+/* the pointing directory entry at index PGROUP. */
+
+/* 1 < PGROUP = NPDIR + 1 */
+/* ====================== */
+
+/* The request time follows the last time of the */
+/* last pointing directory entry. The request time */
+/* may exceed the last time tag. */
+
+
+/* Now we'll look up the time tags in the group of epochs */
+/* we've identified. */
+
+/* We'll use the variable names PBEGIX and PENDIX to refer to */
+/* the indices, relative to the set of time tags, of the first */
+/* and last time tags in the set we're going to look up. */
+
+ if (pgroup == 1) {
+ pbegix = 1;
+ pendix = min(n,100);
+ } else {
+
+/* If the group index is greater than 1, we'll include the last */
+/* time tag of the previous group in the set of time tags we look */
+/* up. That way, the request time is strictly bracketed on the */
+/* low side by the time tag set we look up. */
+
+ pbegix = (pgroup - 1) * 100;
+/* Computing MIN */
+ i__1 = pbegix + 100;
+ pendix = min(i__1,n);
+ }
+ timbas = dirbas - n;
+ i__1 = timbas + pbegix;
+ i__2 = timbas + pendix;
+ dafgda_(handle, &i__1, &i__2, pbuffr);
+ npread = pendix - pbegix + 1;
+
+/* At this point, we'll deal with the cases where T lies outside */
+/* of the range of epochs we've buffered. */
+
+ if (t < pbuffr[0]) {
+
+/* This can happen only if PGROUP = 1 and T precedes all epochs. */
+/* If the input request time is too far from PBUFFR(1) on */
+/* the low side, we're done. */
+
+ if (*sclkdp + *tol < pbuffr[0]) {
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+
+/* Bracket T to move it within the range of buffered epochs. */
+
+ t = pbuffr[0];
+ } else if (t > pbuffr[(i__1 = npread - 1) < 101 && 0 <= i__1 ? i__1 :
+ s_rnge("pbuffr", i__1, "ckr05_", (ftnlen)748)]) {
+
+/* This can happen only if T follows all epochs. */
+
+ if (*sclkdp - *tol > pbuffr[(i__1 = npread - 1) < 101 && 0 <= i__1 ?
+ i__1 : s_rnge("pbuffr", i__1, "ckr05_", (ftnlen)752)]) {
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+
+/* Bracket T to move it within the range of buffered epochs. */
+
+ t = pbuffr[(i__1 = npread - 1) < 101 && 0 <= i__1 ? i__1 : s_rnge(
+ "pbuffr", i__1, "ckr05_", (ftnlen)762)];
+ }
+
+/* At this point, */
+
+/* | T - SCLKDP | <= TOL */
+
+/* Also, one of the following is true: */
+
+/* T is the first time of the segment */
+
+/* T is the last time of the segment */
+
+/* T equals SCLKDP */
+
+
+
+/* Find two adjacent time tags bounding the request epoch. The */
+/* request time cannot be greater than all of time tags in the */
+/* group, and it cannot precede the first element of the group. */
+
+ i__ = lstltd_(&t, &npread, pbuffr);
+
+/* The variables LOW and HIGH are the indices of a pair of time */
+/* tags that bracket the request time. Remember that NPREAD could */
+/* be equal to 1, in which case we would have LOW = HIGH. */
+
+ if (i__ == 0) {
+
+/* This can happen only if PGROUP = 1 and T = PBUFFR(1). */
+
+ low = 1;
+ lepoch = pbuffr[0];
+ if (n == 1) {
+ high = 1;
+ } else {
+ high = 2;
+ }
+ hepoch = pbuffr[(i__1 = high - 1) < 101 && 0 <= i__1 ? i__1 : s_rnge(
+ "pbuffr", i__1, "ckr05_", (ftnlen)805)];
+ } else {
+ low = pbegix + i__ - 1;
+ lepoch = pbuffr[(i__1 = i__ - 1) < 101 && 0 <= i__1 ? i__1 : s_rnge(
+ "pbuffr", i__1, "ckr05_", (ftnlen)810)];
+ high = low + 1;
+ hepoch = pbuffr[(i__1 = i__) < 101 && 0 <= i__1 ? i__1 : s_rnge("pbu"
+ "ffr", i__1, "ckr05_", (ftnlen)813)];
+ }
+
+/* We now need to find the interpolation interval containing */
+/* T, if any. We may be able to use the interpolation */
+/* interval found on the previous call to this routine. If */
+/* this is the first call or if the previous interval is not */
+/* applicable, we'll search for the interval. */
+
+/* First check if the request time falls in the same interval as */
+/* it did last time. We need to make sure that we are dealing */
+/* with the same segment as well as the same time range. */
+
+
+/* PREVS is the start time of the interval that satisfied */
+/* the previous request for pointing. */
+
+/* PREVN is the start time of the interval that followed */
+/* the interval specified above. */
+
+/* PREVNN is the start time of the interval that followed */
+/* the interval starting at PREVN. */
+
+/* LHAND is the handle of the file that PREVS and PREVN */
+/* were found in. */
+
+/* LBEG, are the beginning and ending addresses of the */
+/* LEND segment in the file LHAND that PREVS and PREVN */
+/* were found in. */
+
+ if (*handle == lhand && begin == lbeg && end == lend && t >= prevs && t <
+ prevn) {
+ start = prevs;
+ nstart = prevn;
+ nnstrt = prevnn;
+ } else {
+
+/* Search for the interpolation interval. */
+
+ nidir = (nints - 1) / 100;
+ dirbas = end - 5 - nidir;
+ if (nidir == 0) {
+
+/* There's no mystery about which group of epochs to search. */
+
+ sgroup = 1;
+ } else {
+
+/* There's at least one directory. Find the first directory */
+/* whose time is greater than or equal to the request time, if */
+/* there is such a directory. We'll search linearly through */
+/* the directory entries, reading up to DIRSIZ of them at a */
+/* time. Having found the correct set of directory entries, */
+/* we'll perform a binary search within that set for the */
+/* desired entry. */
+
+ bufbas = dirbas;
+ nsread = min(nidir,100);
+ remain = nidir - nsread;
+ i__1 = bufbas + 1;
+ i__2 = bufbas + nsread;
+ dafgda_(handle, &i__1, &i__2, sbuffr);
+ while(sbuffr[(i__1 = nsread - 1) < 103 && 0 <= i__1 ? i__1 :
+ s_rnge("sbuffr", i__1, "ckr05_", (ftnlen)885)] < t &&
+ remain > 0) {
+ bufbas += nsread;
+ nsread = min(remain,100);
+ remain -= nsread;
+
+/* Note: NSREAD is always > 0 here. */
+
+ i__1 = bufbas + 1;
+ i__2 = bufbas + nsread;
+ dafgda_(handle, &i__1, &i__2, sbuffr);
+ }
+
+/* At this point, BUFBAS - DIRBAS is the number of directory */
+/* entries preceding the one contained in SBUFFR(1). */
+
+/* SGROUP is one more than the number of directories we've */
+/* passed by. */
+
+ sgroup = bufbas - dirbas + lstltd_(&t, &nsread, sbuffr) + 1;
+ }
+
+/* SGROUP now indicates the set of interval start times in which */
+/* to search for the request epoch. */
+
+/* Now we'll look up the time tags in the group of epochs we've */
+/* identified. */
+
+/* We'll use the variable names SBEGIX and SENDIX to refer to the */
+/* indices, relative to the set of start times, of the first and */
+/* last start times in the set we're going to look up. */
+
+ if (sgroup == 1) {
+ sbegix = 1;
+ sendix = min(nints,102);
+ } else {
+
+/* Look up the start times for the group of interest. Also */
+/* buffer last start time from the previous group. Also, it */
+/* turns out to be useful to pick up two extra start */
+/* times---the first two start times of the next group---if */
+/* they exist. */
+
+ sbegix = (sgroup - 1) * 100;
+/* Computing MIN */
+ i__1 = sbegix + 102;
+ sendix = min(i__1,nints);
+ }
+ timbas = dirbas - nints;
+ i__1 = timbas + sbegix;
+ i__2 = timbas + sendix;
+ dafgda_(handle, &i__1, &i__2, sbuffr);
+ nsread = sendix - sbegix + 1;
+
+/* Find the last interval start time less than or equal to the */
+/* request time. We know T is greater than or equal to the */
+/* first start time, so I will be > 0. */
+
+ nsrch = min(101,nsread);
+ i__ = lstled_(&t, &nsrch, sbuffr);
+ start = sbuffr[(i__1 = i__ - 1) < 103 && 0 <= i__1 ? i__1 : s_rnge(
+ "sbuffr", i__1, "ckr05_", (ftnlen)956)];
+
+/* Let NSTART ("next start") be the start time that follows */
+/* START, if START is not the last start time. If NSTART */
+/* has a successor, let NNSTRT be that start time. */
+
+ if (i__ < nsread) {
+ nstart = sbuffr[(i__1 = i__) < 103 && 0 <= i__1 ? i__1 : s_rnge(
+ "sbuffr", i__1, "ckr05_", (ftnlen)965)];
+ if (i__ + 1 < nsread) {
+ nnstrt = sbuffr[(i__1 = i__ + 1) < 103 && 0 <= i__1 ? i__1 :
+ s_rnge("sbuffr", i__1, "ckr05_", (ftnlen)969)];
+ } else {
+ nnstrt = dpmax_();
+ }
+ } else {
+ nstart = dpmax_();
+ nnstrt = dpmax_();
+ }
+ }
+
+/* If T does not lie within the interpolation interval starting */
+/* at time START, we'll determine whether T is closer to this */
+/* interval or the next. If the distance between T and the */
+/* closer interval is less than or equal to TOL, we'll map T */
+/* to the closer endpoint of the closer interval. Otherwise, */
+/* we return without finding pointing. */
+
+ if (hepoch == nstart) {
+
+/* The first time tag greater than or equal to T is the start */
+/* time of the next interpolation interval. */
+
+/* The request time lies between interpolation intervals. */
+/* LEPOCH is the last time tag of the first interval; HEPOCH */
+/* is the first time tag of the next interval. */
+
+ if ((d__1 = t - lepoch, abs(d__1)) <= (d__2 = hepoch - t, abs(d__2)))
+ {
+
+/* T is closer to the first interval... */
+
+ if ((d__1 = t - lepoch, abs(d__1)) > *tol) {
+
+/* ...But T is too far from the interval. */
+
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+
+/* Map T to the right endpoint of the preceding interval. */
+
+ t = lepoch;
+ high = low;
+ hepoch = lepoch;
+ } else {
+
+/* T is closer to the second interval... */
+
+ if ((d__1 = hepoch - t, abs(d__1)) > *tol) {
+
+/* ...But T is too far from the interval. */
+
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+
+/* Map T to the left endpoint of the next interval. */
+
+ t = hepoch;
+ low = high;
+ lepoch = hepoch;
+
+/* Since we're going to be picking time tags from the next */
+/* interval, we'll need to adjust START and NSTART. */
+
+ start = nstart;
+ nstart = nnstrt;
+ }
+ }
+
+/* We now have */
+
+/* LEPOCH < T < HEPOCH */
+/* - - */
+
+/* where LEPOCH and HEPOCH are the time tags at indices */
+/* LOW and HIGH, respectively. */
+
+/* Now select the set of packets used for interpolation. Note */
+/* that the window size is known to be even. */
+
+/* Unlike CK types 8, 9, 12, and 13, for type 05 we adjust */
+/* the window size to keep the request time within the central */
+/* interval of the window. */
+
+/* The nominal bracketing epochs we've found are the (WNDSIZ/2)nd */
+/* and (WNDSIZ/2 + 1)st of the interpolating set. If the request */
+/* time is too close to one end of the interpolation interval, we */
+/* reduce the window size, after which one endpoint of the window */
+/* will coincide with an endpoint of the interpolation interval. */
+
+/* We start out by looking up the set of time tags we'd use */
+/* if there were no gaps in the coverage. We then trim our */
+/* time tag set to ensure all tags are in the interpolation */
+/* interval. It's possible that the interpolation window will */
+/* collapse to a single point as a result of this last step. */
+
+/* Let LSIZE be the size of the "left half" of the window: the */
+/* size of the set of window epochs to the left of the request time. */
+/* We want this size to be WNDSIZ/2, but if not enough states are */
+/* available, the set ranges from index 1 to index LOW. */
+
+/* Computing MIN */
+ i__1 = wndsiz / 2;
+ lsize = min(i__1,low);
+
+/* RSIZE is defined analogously for the right half of the window. */
+
+/* Computing MIN */
+ i__1 = wndsiz / 2, i__2 = n - high + 1;
+ rsize = min(i__1,i__2);
+
+/* The window size is simply the sum of LSIZE and RSIZE. */
+
+ wndsiz = lsize + rsize;
+
+/* FIRST and LAST are the endpoints of the range of indices of */
+/* time tags (and packets) we'll collect in the output record. */
+
+ first = low - lsize + 1;
+ last = first + wndsiz - 1;
+
+/* Buffer the epochs. */
+
+ wstart = begin + n * packsz + first - 1;
+ i__1 = wstart + wndsiz - 1;
+ dafgda_(handle, &wstart, &i__1, pbuffr);
+
+/* Discard any epochs less than START or greater than or equal */
+/* to NSTART. The set of epochs we want ranges from indices */
+/* I+1 to J. This range is non-empty unless START and NSTART */
+/* are both DPMAX(). */
+
+ i__ = lstltd_(&start, &wndsiz, pbuffr);
+ j = lstltd_(&nstart, &wndsiz, pbuffr);
+ if (i__ == j) {
+
+/* Fuggedaboudit. */
+
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+ }
+
+/* Update FIRST, LAST, and WNDSIZ. */
+
+ wndsiz = j - i__;
+ first += i__;
+ last = first + wndsiz - 1;
+
+/* Put the subtype into the output record. The size of the group */
+/* of packets is derived from the subtype, so we need not include */
+/* the size. */
+
+ record[0] = t;
+ record[1] = (doublereal) subtyp;
+ record[2] = (doublereal) wndsiz;
+ record[3] = rate;
+
+/* Read the packets. */
+
+ i__1 = begin + (first - 1) * packsz;
+ i__2 = begin + last * packsz - 1;
+ dafgda_(handle, &i__1, &i__2, &record[4]);
+
+/* Finally, add the epochs to the output record. */
+
+ i__2 = j - i__;
+ moved_(&pbuffr[(i__1 = i__) < 101 && 0 <= i__1 ? i__1 : s_rnge("pbuffr",
+ i__1, "ckr05_", (ftnlen)1158)], &i__2, &record[wndsiz * packsz +
+ 4]);
+
+/* Save the information about the interval and segment. */
+
+ lhand = *handle;
+ lbeg = begin;
+ lend = end;
+ prevs = start;
+ prevn = nstart;
+ prevnn = nnstrt;
+
+/* Indicate pointing was found. */
+
+ *found = TRUE_;
+ chkout_("CKR05", (ftnlen)5);
+ return 0;
+} /* ckr05_ */
+
diff --git a/ext/spice/src/cspice/ckupf_c.c b/ext/spice/src/cspice/ckupf_c.c
new file mode 100644
index 0000000000..b4f9ca2781
--- /dev/null
+++ b/ext/spice/src/cspice/ckupf_c.c
@@ -0,0 +1,146 @@
+/*
+
+-Procedure ckupf_c ( C-kernel, Unload pointing file )
+
+-Abstract
+
+ Unload a CK pointing file so that it will no longer be searched
+ by the readers.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CK
+ DAF
+
+-Keywords
+
+ POINTING
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+ void ckupf_c ( SpiceInt handle )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of CK file to be unloaded
+
+-Detailed_Input
+
+ handle Integer handle assigned to the file upon loading.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+ 1) If the file specified by handle does not appear in the file
+ table, nothing happens.
+
+-Files
+
+ The file referred to by handle is unloaded.
+
+-Particulars
+
+ See Particulars section above, in ckbsr.for.
+
+ Unloading a file with ckupf_c removes that file from consideration
+ by the CK readers. In doing so, it frees up space for another
+ file to be loaded.
+
+-Examples
+
+ See the Example in ckbsr.for.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ J.M. Lynch (JPL)
+ R.E. Thurman (JPL)
+ I.M. Underwood (JPL)
+ E.D. Wright (JPL)
+ B.V. Semenov (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.2, 31-JAN-2008 (BVS)
+
+ Removed '-Revisions' from the header.
+
+ -CSPICE Version 1.0.1, 03-JUN-2003 (EDW)
+
+ Correct typo in Procedure line.
+
+ -CSPICE Version 1.0.0, 08-FEB-1998 (EDW)
+
+-Index_Entries
+
+ unload ck pointing file
+
+-&
+*/
+
+{ /* Begin ckupf_c */
+
+ /*
+ Participate in error handling
+ */
+
+ chkin_c ( "ckupf_c");
+
+
+ /*
+ Call the f2c'd Fortran routine.
+ */
+ ckupf_ ( &handle );
+
+
+ chkout_c ( "ckupf_c");
+
+} /* End ckupf_c */
diff --git a/ext/spice/src/cspice/ckw01.c b/ext/spice/src/cspice/ckw01.c
new file mode 100644
index 0000000000..d38db86374
--- /dev/null
+++ b/ext/spice/src/cspice/ckw01.c
@@ -0,0 +1,772 @@
+/* ckw01.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+static integer c__4 = 4;
+static integer c__3 = 3;
+static integer c__1 = 1;
+
+/* $Procedure CKW01 ( C-Kernel, write segment to C-kernel, data type 1 ) */
+/* Subroutine */ int ckw01_(integer *handle, doublereal *begtim, doublereal *
+ endtim, integer *inst, char *ref, logical *avflag, char *segid,
+ integer *nrec, doublereal *sclkdp, doublereal *quats, doublereal *
+ avvs, ftnlen ref_len, ftnlen segid_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+ doublereal d__1;
+
+ /* Local variables */
+ integer ndir, i__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafps_(integer *,
+ integer *, doublereal *, integer *, doublereal *);
+ doublereal descr[5];
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
+ integer index, value;
+ extern /* Subroutine */ int errdp_(char *, doublereal *, ftnlen), dafada_(
+ doublereal *, integer *), dafbna_(integer *, doublereal *, char *,
+ ftnlen), dafena_(void);
+ extern logical failed_(void);
+ integer refcod;
+ extern /* Subroutine */ int namfrm_(char *, integer *, ftnlen);
+ extern integer lastnb_(char *, ftnlen);
+ doublereal dirent;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern logical vzerog_(doublereal *, integer *), return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+
+/* $ Abstract */
+
+/* Add a type 1 segment to a C-kernel. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+/* SCLK */
+
+/* $ Keywords */
+
+/* POINTING */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of an open CK file. */
+/* BEGTIM I The beginning encoded SCLK of the segment. */
+/* ENDTIM I The ending encoded SCLK of the segment. */
+/* INST I The NAIF instrument ID code. */
+/* REF I The reference frame of the segment. */
+/* AVFLAG I True if the segment will contain angular velocity. */
+/* SEGID I Segment identifier. */
+/* NREC I Number of pointing records. */
+/* SCLKDP I Encoded SCLK times. */
+/* QUATS I SPICE quaternions representing instrument pointing. */
+/* AVVS I Angular velocity vectors. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the CK file to which the segment will */
+/* be written. The file must have been opened with write */
+/* access. */
+
+/* BEGTIM is the beginning encoded SCLK time of the segment. This */
+/* value should be less than or equal to the first time in */
+/* the segment. */
+
+/* ENDTIM is the encoded SCLK time at which the segment ends. */
+/* This value should be greater than or equal to the last */
+/* time in the segment. */
+
+/* INST is the NAIF integer ID code for the instrument. */
+
+/* REF is a character string which specifies the */
+/* reference frame of the segment. This should be one of */
+/* the frames supported by the SPICELIB routine NAMFRM */
+/* which is an entry point of FRAMEX. */
+
+/* AVFLAG is a logical flag which indicates whether or not the */
+/* segment will contain angular velocity. */
+
+/* SEGID is the segment identifier. A CK segment identifier may */
+/* contain up to 40 characters. */
+
+/* NREC is the number of pointing instances in the segment. */
+
+/* SCLKDP are the encoded spacecraft clock times associated with */
+/* each pointing instance. These times must be strictly */
+/* increasing. */
+
+/* QUATS is an array of SPICE-style quaternions representing a */
+/* sequence of C-matrices. See the discussion of */
+/* quaternion styles in Particulars below. */
+
+/* AVVS are the angular velocity vectors ( optional ). */
+
+/* If AVFLAG is FALSE then this array is ignored by the */
+/* routine, however it still must be supplied as part of */
+/* the calling sequence. */
+
+/* $ Detailed_Output */
+
+/* None. See Files section. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If HANDLE is not the handle of a C-kernel opened for writing */
+/* the error will be diagnosed by routines called by this */
+/* routine. */
+
+/* 2) If SEGID is more than 40 characters long, the error */
+/* SPICE(SEGIDTOOLONG) is signalled. */
+
+/* 3) If SEGID contains any nonprintable characters, the error */
+/* SPICE(NONPRINTABLECHARS) is signalled. */
+
+/* 4) If the first encoded SCLK time is negative then the error */
+/* SPICE(INVALIDSCLKTIME) is signalled. If any subsequent times */
+/* are negative the error SPICE(TIMESOUTOFORDER) is signalled. */
+
+/* 5) If the encoded SCLK times are not strictly increasing, */
+/* the error SPICE(TIMESOUTOFORDER) is signalled. */
+
+/* 6) If BEGTIM is greater than SCLKDP(1) or ENDTIM is less than */
+/* SCLKDP(NREC), the error SPICE(INVALIDDESCRTIME) is */
+/* signalled. */
+
+/* 7) If the name of the reference frame is not one of those */
+/* supported by the routine NAMFRM, the error */
+/* SPICE(INVALIDREFFRAME) is signalled. */
+
+/* 8) If NREC, the number of pointing records, is less than or */
+/* equal to 0, the error SPICE(INVALIDNUMRECS) is signalled. */
+
+/* 9) If the squared length of any quaternion differes from 1 */
+/* by more than 1.0D-2, the error SPICE(NONUNITQUATERNION) is */
+/* signalled. */
+
+/* $ Files */
+
+/* This routine adds a type 1 segment to a C-kernel. The C-kernel */
+/* may be either a new one or an existing one opened for writing. */
+
+/* $ Particulars */
+
+/* For a detailed description of a type 1 CK segment please see the */
+/* CK Required Reading. */
+
+/* This routine relieves the user from performing the repetitive */
+/* calls to the DAF routines necessary to construct a CK segment. */
+
+
+/* Quaternion Styles */
+/* ----------------- */
+
+/* There are different "styles" of quaternions used in */
+/* science and engineering applications. Quaternion styles */
+/* are characterized by */
+
+/* - The order of quaternion elements */
+
+/* - The quaternion multiplication formula */
+
+/* - The convention for associating quaternions */
+/* with rotation matrices */
+
+/* Two of the commonly used styles are */
+
+/* - "SPICE" */
+
+/* > Invented by Sir William Rowan Hamilton */
+/* > Frequently used in mathematics and physics textbooks */
+
+/* - "Engineering" */
+
+/* > Widely used in aerospace engineering applications */
+
+
+/* SPICELIB subroutine interfaces ALWAYS use SPICE quaternions. */
+/* Quaternions of any other style must be converted to SPICE */
+/* quaternions before they are passed to SPICELIB routines. */
+
+
+/* Relationship between SPICE and Engineering Quaternions */
+/* ------------------------------------------------------ */
+
+/* Let M be a rotation matrix such that for any vector V, */
+
+/* M*V */
+
+/* is the result of rotating V by theta radians in the */
+/* counterclockwise direction about unit rotation axis vector A. */
+/* Then the SPICE quaternions representing M are */
+
+/* (+/-) ( cos(theta/2), */
+/* sin(theta/2) A(1), */
+/* sin(theta/2) A(2), */
+/* sin(theta/2) A(3) ) */
+
+/* while the engineering quaternions representing M are */
+
+/* (+/-) ( -sin(theta/2) A(1), */
+/* -sin(theta/2) A(2), */
+/* -sin(theta/2) A(3), */
+/* cos(theta/2) ) */
+
+/* For both styles of quaternions, if a quaternion q represents */
+/* a rotation matrix M, then -q represents M as well. */
+
+/* Given an engineering quaternion */
+
+/* QENG = ( q0, q1, q2, q3 ) */
+
+/* the equivalent SPICE quaternion is */
+
+/* QSPICE = ( q3, -q0, -q1, -q2 ) */
+
+
+/* Associating SPICE Quaternions with Rotation Matrices */
+/* ---------------------------------------------------- */
+
+/* Let FROM and TO be two right-handed reference frames, for */
+/* example, an inertial frame and a spacecraft-fixed frame. Let the */
+/* symbols */
+
+/* V , V */
+/* FROM TO */
+
+/* denote, respectively, an arbitrary vector expressed relative to */
+/* the FROM and TO frames. Let M denote the transformation matrix */
+/* that transforms vectors from frame FROM to frame TO; then */
+
+/* V = M * V */
+/* TO FROM */
+
+/* where the expression on the right hand side represents left */
+/* multiplication of the vector by the matrix. */
+
+/* Then if the unit-length SPICE quaternion q represents M, where */
+
+/* q = (q0, q1, q2, q3) */
+
+/* the elements of M are derived from the elements of q as follows: */
+
+/* +- -+ */
+/* | 2 2 | */
+/* | 1 - 2*( q2 + q3 ) 2*(q1*q2 - q0*q3) 2*(q1*q3 + q0*q2) | */
+/* | | */
+/* | | */
+/* | 2 2 | */
+/* M = | 2*(q1*q2 + q0*q3) 1 - 2*( q1 + q3 ) 2*(q2*q3 - q0*q1) | */
+/* | | */
+/* | | */
+/* | 2 2 | */
+/* | 2*(q1*q3 - q0*q2) 2*(q2*q3 + q0*q1) 1 - 2*( q1 + q2 ) | */
+/* | | */
+/* +- -+ */
+
+/* Note that substituting the elements of -q for those of q in the */
+/* right hand side leaves each element of M unchanged; this shows */
+/* that if a quaternion q represents a matrix M, then so does the */
+/* quaternion -q. */
+
+/* To map the rotation matrix M to a unit quaternion, we start by */
+/* decomposing the rotation matrix as a sum of symmetric */
+/* and skew-symmetric parts: */
+
+/* 2 */
+/* M = [ I + (1-cos(theta)) OMEGA ] + [ sin(theta) OMEGA ] */
+
+/* symmetric skew-symmetric */
+
+
+/* OMEGA is a skew-symmetric matrix of the form */
+
+/* +- -+ */
+/* | 0 -n3 n2 | */
+/* | | */
+/* OMEGA = | n3 0 -n1 | */
+/* | | */
+/* | -n2 n1 0 | */
+/* +- -+ */
+
+/* The vector N of matrix entries (n1, n2, n3) is the rotation axis */
+/* of M and theta is M's rotation angle. Note that N and theta */
+/* are not unique. */
+
+/* Let */
+
+/* C = cos(theta/2) */
+/* S = sin(theta/2) */
+
+/* Then the unit quaternions Q corresponding to M are */
+
+/* Q = +/- ( C, S*n1, S*n2, S*n3 ) */
+
+/* The mappings between quaternions and the corresponding rotations */
+/* are carried out by the SPICELIB routines */
+
+/* Q2M {quaternion to matrix} */
+/* M2Q {matrix to quaternion} */
+
+/* M2Q always returns a quaternion with scalar part greater than */
+/* or equal to zero. */
+
+
+/* SPICE Quaternion Multiplication Formula */
+/* --------------------------------------- */
+
+/* Given a SPICE quaternion */
+
+/* Q = ( q0, q1, q2, q3 ) */
+
+/* corresponding to rotation axis A and angle theta as above, we can */
+/* represent Q using "scalar + vector" notation as follows: */
+
+/* s = q0 = cos(theta/2) */
+
+/* v = ( q1, q2, q3 ) = sin(theta/2) * A */
+
+/* Q = s + v */
+
+/* Let Q1 and Q2 be SPICE quaternions with respective scalar */
+/* and vector parts s1, s2 and v1, v2: */
+
+/* Q1 = s1 + v1 */
+/* Q2 = s2 + v2 */
+
+/* We represent the dot product of v1 and v2 by */
+
+/* */
+
+/* and the cross product of v1 and v2 by */
+
+/* v1 x v2 */
+
+/* Then the SPICE quaternion product is */
+
+/* Q1*Q2 = s1*s2 - + s1*v2 + s2*v1 + (v1 x v2) */
+
+/* If Q1 and Q2 represent the rotation matrices M1 and M2 */
+/* respectively, then the quaternion product */
+
+/* Q1*Q2 */
+
+/* represents the matrix product */
+
+/* M1*M2 */
+
+
+/* $ Examples */
+
+/* C */
+/* C This example writes a type 1 C-kernel segment for the */
+/* C Galileo scan platform to a previously opened file attached to */
+/* C HANDLE. */
+
+/* C */
+/* C Assume arrays of quaternions, angular velocities, and the */
+/* C associated SCLK times are produced elsewhere. */
+/* C */
+/* . */
+/* . */
+/* . */
+
+/* C */
+/* C The subroutine CKW01 needs the following items for the */
+/* C segment descriptor: */
+/* C */
+/* C 1) SCLK limits of the segment. */
+/* C 2) Instrument code. */
+/* C 3) Reference frame. */
+/* C 4) The angular velocity flag. */
+/* C */
+/* BEGTIM = SCLK ( 1 ) */
+/* ENDTIM = SCLK ( NREC ) */
+
+/* INST = -77001 */
+/* REF = 'J2000' */
+/* AVFLAG = .TRUE. */
+
+/* SEGID = 'GLL SCAN PLT - DATA TYPE 1' */
+
+/* C */
+/* C Write the segment. */
+/* C */
+/* CALL CKW01 ( HANDLE, BEGTIM, ENDTIM, INST, REF, AVFLAG, */
+/* . SEGID, NREC, SCLKDP, QUATS, AVVS ) */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* J.M. Lynch (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 01-JUN-2010 (NJB) */
+
+/* The check for non-unit quaternions has been replaced */
+/* with a check for zero-length quaternions. */
+
+/* - SPICELIB Version 2.2.0, 26-FEB-2008 (NJB) */
+
+/* Updated header; added information about SPICE */
+/* quaternion conventions. */
+
+/* Minor typo in a long error message was corrected. */
+
+/* - SPICELIB Version 2.1.0, 22-FEB-1999 (WLT) */
+
+/* Added check to make sure that all quaternions are unit */
+/* length to single precision. */
+
+/* - SPICELIB Version 2.0.0, 28-DEC-1993 (WLT) */
+
+/* The routine was upgraded to support non-inertial reference */
+/* frames. */
+
+/* - SPICELIB Version 1.1.1, 05-SEP-1993 (KRG) */
+
+/* Removed all references to a specific method of opening the CK */
+/* file in the $ Brief_I/O, $ Detailed_Input, $ Exceptions, */
+/* $ Files, and $ Examples sections of the header. It is assumed */
+/* that a person using this routine has some knowledge of the DAF */
+/* system and the methods for obtaining file handles. */
+
+/* - SPICELIB Version 1.1.0, 25-NOV-1992 (JML) */
+
+/* If the number of pointing records is not positive an error */
+/* is now signalled. */
+
+/* FAILED is checked after the call to DAFBNA. */
+
+/* The variable HLDCLK was removed from the loop where the times */
+/* were checked. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 30-AUG-1991 (JML) (NJB) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write ck type_1 pointing data segment */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.1, 05-SEP-1993 (KRG) */
+
+/* Removed all references to a specific method of opening the CK */
+/* file in the $ Brief_I/O, $ Detailed_Input, $ Exceptions, */
+/* $ Files, and $ Examples sections of the header. It is assumed */
+/* that a person using this routine has some knowledge of the DAF */
+/* system and the methods for obtaining file handles. */
+
+/* - SPICELIB Version 1.1.0, 25-NOV-1992 (JML) */
+
+/* If the number of pointing records is not positive an error */
+/* is now signalled. */
+
+/* FAILED is checked after the call to DAFBNA. */
+
+/* The variable HLDCLK was removed from the loop where the times */
+/* were checked. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 30-AUG-1991 (JML) (NJB) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* SIDLEN is the maximum number of characters allowed in a CK */
+/* segment identifier. */
+
+/* NDC is the size of a packed CK segment descriptor. */
+
+/* ND is the number of double precision components in a CK */
+/* segment descriptor. */
+
+/* NI is the number of integer components in a CK segment */
+/* descriptor. */
+
+/* DTYPE is the data type of the segment that this routine */
+/* operates on. */
+
+/* FPRINT is the integer value of the first printable ASCII */
+/* character. */
+
+/* LPRINT is the integer value of the last printable ASCII */
+/* character. */
+
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("CKW01", (ftnlen)5);
+
+/* The first thing that we will do is create the segment descriptor. */
+
+/* The structure of the segment descriptor is as follows. */
+
+/* DCD( 1 ) and DCD( 2 ) -- SCLK limits of the segment. */
+/* ICD( 1 ) -- Instrument code. */
+/* ICD( 2 ) -- Reference frame ID. */
+/* ICD( 3 ) -- Data type of the segment. */
+/* ICD( 4 ) -- Angular rates flag. */
+/* ICD( 5 ) -- Beginning address of segment. */
+/* ICD( 6 ) -- Ending address of segment. */
+
+
+/* Make sure that there is a positive number of pointing records. */
+
+ if (*nrec <= 0) {
+ setmsg_("# is an invalid number of pointing instances for type 1.", (
+ ftnlen)56);
+ errint_("#", nrec, (ftnlen)1);
+ sigerr_("SPICE(INVALIDNUMREC)", (ftnlen)20);
+ chkout_("CKW01", (ftnlen)5);
+ return 0;
+ }
+
+/* Check that the SCLK bounds on the segment are reasonable. */
+
+ if (*begtim > sclkdp[0]) {
+ setmsg_("The first d.p. component of the descriptor is invalid. DCD("
+ "1) = # and SCLKDP(1) = # ", (ftnlen)84);
+ errdp_("#", begtim, (ftnlen)1);
+ errdp_("#", sclkdp, (ftnlen)1);
+ sigerr_("SPICE(INVALIDDESCRTIME)", (ftnlen)23);
+ chkout_("CKW01", (ftnlen)5);
+ return 0;
+ }
+ if (*endtim < sclkdp[*nrec - 1]) {
+ setmsg_("The second d.p. component of the descriptor is invalid. DCD"
+ "(2) = # and SCLKDP(NREC) = # ", (ftnlen)88);
+ errdp_("#", endtim, (ftnlen)1);
+ errdp_("#", &sclkdp[*nrec - 1], (ftnlen)1);
+ sigerr_("SPICE(INVALIDDESCRTIME)", (ftnlen)23);
+ chkout_("CKW01", (ftnlen)5);
+ return 0;
+ }
+ dcd[0] = *begtim;
+ dcd[1] = *endtim;
+
+/* Get the NAIF integer code for the reference frame. */
+
+ namfrm_(ref, &refcod, ref_len);
+ if (refcod == 0) {
+ setmsg_("The reference frame # is not supported.", (ftnlen)39);
+ errch_("#", ref, (ftnlen)1, ref_len);
+ sigerr_("SPICE(INVALIDREFFRAME)", (ftnlen)22);
+ chkout_("CKW01", (ftnlen)5);
+ return 0;
+ }
+
+/* Assign values to the integer components of the segment descriptor. */
+
+ icd[0] = *inst;
+ icd[1] = refcod;
+ icd[2] = 1;
+ if (*avflag) {
+ icd[3] = 1;
+ } else {
+ icd[3] = 0;
+ }
+
+/* Now pack the segment descriptor. */
+
+ dafps_(&c__2, &c__6, dcd, icd, descr);
+
+/* Check that all the characters in the segid can be printed. */
+
+ i__1 = lastnb_(segid, segid_len);
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ value = *(unsigned char *)&segid[i__ - 1];
+ if (value < 32 || value > 126) {
+ setmsg_("The segment identifier contains nonprintable characters",
+ (ftnlen)55);
+ sigerr_("SPICE(NONPRINTABLECHARS)", (ftnlen)24);
+ chkout_("CKW01", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Also check to see if the segment identifier is too long. */
+
+ if (lastnb_(segid, segid_len) > 40) {
+ setmsg_("Segment identifier contains more than 40 characters.", (
+ ftnlen)52);
+ sigerr_("SPICE(SEGIDTOOLONG)", (ftnlen)19);
+ chkout_("CKW01", (ftnlen)5);
+ return 0;
+ }
+
+/* Now check that the encoded SCLK times are positive and strictly */
+/* increasing. */
+
+/* Check that the first time is nonnegative. */
+
+ if (sclkdp[0] < 0.) {
+ setmsg_("The first SCLKDP time: # is negative.", (ftnlen)37);
+ errdp_("#", sclkdp, (ftnlen)1);
+ sigerr_("SPICE(INVALIDSCLKTIME)", (ftnlen)22);
+ chkout_("CKW01", (ftnlen)5);
+ return 0;
+ }
+
+/* Now check that the times are ordered properly. */
+
+ i__1 = *nrec;
+ for (i__ = 2; i__ <= i__1; ++i__) {
+ if (sclkdp[i__ - 1] <= sclkdp[i__ - 2]) {
+ setmsg_("The SCLKDP times are not strictly increasing. SCLKDP(#)"
+ " = # and SCLKDP(#) = #.", (ftnlen)78);
+ errint_("#", &i__, (ftnlen)1);
+ errdp_("#", &sclkdp[i__ - 1], (ftnlen)1);
+ i__2 = i__ - 1;
+ errint_("#", &i__2, (ftnlen)1);
+ errdp_("#", &sclkdp[i__ - 2], (ftnlen)1);
+ sigerr_("SPICE(TIMESOUTOFORDER)", (ftnlen)22);
+ chkout_("CKW01", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Make sure that the quaternions are non-zero. This is just */
+/* a check for uninitialized data. */
+
+ i__1 = *nrec;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ if (vzerog_(&quats[(i__ << 2) - 4], &c__4)) {
+ setmsg_("The quaternion at index # has magnitude zero.", (ftnlen)
+ 45);
+ errint_("#", &i__, (ftnlen)1);
+ sigerr_("SPICE(ZEROQUATERNION)", (ftnlen)21);
+ chkout_("CKW01", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* No more checks, begin writing the segment. */
+
+ dafbna_(handle, descr, segid, segid_len);
+ if (failed_()) {
+ chkout_("CKW01", (ftnlen)5);
+ return 0;
+ }
+
+/* Now add the quaternions and optionally, the angular velocity */
+/* vectors. */
+
+ if (*avflag) {
+ i__1 = *nrec;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dafada_(&quats[(i__ << 2) - 4], &c__4);
+ dafada_(&avvs[i__ * 3 - 3], &c__3);
+ }
+ } else {
+ i__1 = *nrec;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dafada_(&quats[(i__ << 2) - 4], &c__4);
+ }
+ }
+
+/* Add the SCLK times. */
+
+ dafada_(sclkdp, nrec);
+
+/* The time tag directory. The Ith element is defined to be the */
+/* average of the (I*100)th and the (I*100+1)st SCLK time. */
+
+ ndir = (*nrec - 1) / 100;
+ index = 100;
+ i__1 = ndir;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dirent = (sclkdp[index - 1] + sclkdp[index]) / 2.;
+ dafada_(&dirent, &c__1);
+ index += 100;
+ }
+
+/* Finally, the number of records. */
+
+ d__1 = (doublereal) (*nrec);
+ dafada_(&d__1, &c__1);
+
+/* End the segment. */
+
+ dafena_();
+ chkout_("CKW01", (ftnlen)5);
+ return 0;
+} /* ckw01_ */
+
diff --git a/ext/spice/src/cspice/ckw01_c.c b/ext/spice/src/cspice/ckw01_c.c
new file mode 100644
index 0000000000..e3f7902fcc
--- /dev/null
+++ b/ext/spice/src/cspice/ckw01_c.c
@@ -0,0 +1,546 @@
+/*
+
+-Procedure ckw01_c ( C-Kernel, write segment to C-kernel, data type 1 )
+
+-Abstract
+
+ Add a type 1 segment to a C-kernel.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CK
+ DAF
+ SCLK
+
+-Keywords
+
+ POINTING
+ UTILITY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+ #include "SpiceZim.h"
+ #undef ckw01_c
+
+
+ void ckw01_c ( SpiceInt handle,
+ SpiceDouble begtim,
+ SpiceDouble endtim,
+ SpiceInt inst,
+ ConstSpiceChar * ref,
+ SpiceBoolean avflag,
+ ConstSpiceChar * segid,
+ SpiceInt nrec,
+ ConstSpiceDouble sclkdp [],
+ ConstSpiceDouble quats [][4],
+ ConstSpiceDouble avvs [][3] )
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of an open CK file.
+ begtim I The beginning encoded SCLK of the segment.
+ endtim I The ending encoded SCLK of the segment.
+ inst I The NAIF instrument ID code.
+ ref I The reference frame of the segment.
+ avflag I True if the segment will contain angular velocity.
+ segid I Segment identifier.
+ nrec I Number of pointing records.
+ sclkdp I Encoded SCLK times.
+ quats I Quaternions representing instrument pointing.
+ avvs I Angular velocity vectors.
+
+-Detailed_Input
+
+ handle is the handle of the CK file to which the segment will
+ be written. The file must have been opened with write
+ access.
+
+ begtim is the beginning encoded SCLK time of the segment. This
+ value should be less than or equal to the first time in
+ the segment.
+
+ endtim is the encoded SCLK time at which the segment ends.
+ This value should be greater than or equal to the last
+ time in the segment.
+
+ inst is the NAIF integer ID code for the instrument.
+
+ ref is a character string which specifies the
+ reference frame of the segment. This should be one of
+ the frames supported by the SPICELIB routine NAMFRM
+ which is an entry point of FRAMEX.
+
+ avflag is a logical flag which indicates whether or not the
+ segment will contain angular velocity.
+
+ segid is the segment identifier. A CK segment identifier may
+ contain up to 40 characters, excluding the terminating
+ null.
+
+ nrec is the number of pointing instances in the segment.
+
+ sclkdp are the encoded spacecraft clock times associated with
+ each pointing instance. These times must be strictly
+ increasing.
+
+ quats is an array of SPICE-style quaternions representing a
+ sequence of C-matrices. See the discussion of "Quaternion
+ Styles" in the Particulars section below.
+
+ avvs are the angular velocity vectors (optional).
+
+ If avflag is FALSE then this array is ignored by the
+ routine, however it still must be supplied as part of
+ the calling sequence.
+
+-Detailed_Output
+
+ None. See Files section.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If handle is not the handle of a C-kernel opened for writing
+ the error will be diagnosed by routines called by this
+ routine.
+
+ 2) If segid is more than 40 characters long, the error
+ SPICE(SEGIDTOOLONG) is signaled.
+
+ 3) If segid contains any nonprintable characters, the error
+ SPICE(NONPRINTABLECHARS) is signaled.
+
+ 4) If the first encoded SCLK time is negative then the error
+ SPICE(INVALIDSCLKTIME) is signaled. If any subsequent times
+ are negative the error SPICE(TIMESOUTOFORDER) is signaled.
+
+ 5) If the encoded SCLK times are not strictly increasing,
+ the error SPICE(TIMESOUTOFORDER) is signaled.
+
+ 6) If begtim is greater than sclkdp[0] or endtim is less than
+ sclkdp[nrec-1], the error SPICE(INVALIDDESCRTIME) is
+ signaled.
+
+ 7) If the name of the reference frame is not one of those
+ supported by the SPICELIB routine NAMFRM, the error
+ SPICE(INVALIDREFFRAME) is signaled.
+
+ 8) If nrec, the number of pointing records, is less than or
+ equal to 0, the error SPICE(INVALIDNUMRECS) is signaled.
+
+ 9) If any quaternion has magnitude zero, the error
+ SPICE(ZEROQUATERNION) is signaled.
+
+
+-Files
+
+ This routine adds a type 1 segment to a C-kernel. The C-kernel
+ may be either a new one or an existing one opened for writing.
+
+-Particulars
+
+ For a detailed description of a type 1 CK segment please see the
+ CK Required Reading.
+
+ This routine relieves the user from performing the repetitive
+ calls to the DAF routines necessary to construct a CK segment.
+
+
+ Quaternion Styles
+ -----------------
+
+ There are different "styles" of quaternions used in
+ science and engineering applications. Quaternion styles
+ are characterized by
+
+ - The order of quaternion elements
+
+ - The quaternion multiplication formula
+
+ - The convention for associating quaternions
+ with rotation matrices
+
+ Two of the commonly used styles are
+
+ - "SPICE"
+
+ > Invented by Sir William Rowan Hamilton
+ > Frequently used in mathematics and physics textbooks
+
+ - "Engineering"
+
+ > Widely used in aerospace engineering applications
+
+
+ CSPICE function interfaces ALWAYS use SPICE quaternions.
+ Quaternions of any other style must be converted to SPICE
+ quaternions before they are passed to CSPICE functions.
+
+
+ Relationship between SPICE and Engineering Quaternions
+ ------------------------------------------------------
+
+ Let M be a rotation matrix such that for any vector V,
+
+ M*V
+
+ is the result of rotating V by theta radians in the
+ counterclockwise direction about unit rotation axis vector A.
+ Then the SPICE quaternions representing M are
+
+ (+/-) ( cos(theta/2),
+ sin(theta/2) A(1),
+ sin(theta/2) A(2),
+ sin(theta/2) A(3) )
+
+ while the engineering quaternions representing M are
+
+ (+/-) ( -sin(theta/2) A(1),
+ -sin(theta/2) A(2),
+ -sin(theta/2) A(3),
+ cos(theta/2) )
+
+ For both styles of quaternions, if a quaternion q represents
+ a rotation matrix M, then -q represents M as well.
+
+ Given an engineering quaternion
+
+ QENG = ( q0, q1, q2, q3 )
+
+ the equivalent SPICE quaternion is
+
+ QSPICE = ( q3, -q0, -q1, -q2 )
+
+
+ Associating SPICE Quaternions with Rotation Matrices
+ ----------------------------------------------------
+
+ Let FROM and TO be two right-handed reference frames, for
+ example, an inertial frame and a spacecraft-fixed frame. Let the
+ symbols
+
+ V , V
+ FROM TO
+
+ denote, respectively, an arbitrary vector expressed relative to
+ the FROM and TO frames. Let M denote the transformation matrix
+ that transforms vectors from frame FROM to frame TO; then
+
+ V = M * V
+ TO FROM
+
+ where the expression on the right hand side represents left
+ multiplication of the vector by the matrix.
+
+ Then if the unit-length SPICE quaternion q represents M, where
+
+ q = (q0, q1, q2, q3)
+
+ the elements of M are derived from the elements of q as follows:
+
+ +- -+
+ | 2 2 |
+ | 1 - 2*( q2 + q3 ) 2*(q1*q2 - q0*q3) 2*(q1*q3 + q0*q2) |
+ | |
+ | |
+ | 2 2 |
+ M = | 2*(q1*q2 + q0*q3) 1 - 2*( q1 + q3 ) 2*(q2*q3 - q0*q1) |
+ | |
+ | |
+ | 2 2 |
+ | 2*(q1*q3 - q0*q2) 2*(q2*q3 + q0*q1) 1 - 2*( q1 + q2 ) |
+ | |
+ +- -+
+
+ Note that substituting the elements of -q for those of q in the
+ right hand side leaves each element of M unchanged; this shows
+ that if a quaternion q represents a matrix M, then so does the
+ quaternion -q.
+
+ To map the rotation matrix M to a unit quaternion, we start by
+ decomposing the rotation matrix as a sum of symmetric
+ and skew-symmetric parts:
+
+ 2
+ M = [ I + (1-cos(theta)) OMEGA ] + [ sin(theta) OMEGA ]
+
+ symmetric skew-symmetric
+
+
+ OMEGA is a skew-symmetric matrix of the form
+
+ +- -+
+ | 0 -n3 n2 |
+ | |
+ OMEGA = | n3 0 -n1 |
+ | |
+ | -n2 n1 0 |
+ +- -+
+
+ The vector N of matrix entries (n1, n2, n3) is the rotation axis
+ of M and theta is M's rotation angle. Note that N and theta
+ are not unique.
+
+ Let
+
+ C = cos(theta/2)
+ S = sin(theta/2)
+
+ Then the unit quaternions Q corresponding to M are
+
+ Q = +/- ( C, S*n1, S*n2, S*n3 )
+
+ The mappings between quaternions and the corresponding rotations
+ are carried out by the CSPICE routines
+
+ q2m_c {quaternion to matrix}
+ m2q_c {matrix to quaternion}
+
+ m2q_c always returns a quaternion with scalar part greater than
+ or equal to zero.
+
+
+ SPICE Quaternion Multiplication Formula
+ ---------------------------------------
+
+ Given a SPICE quaternion
+
+ Q = ( q0, q1, q2, q3 )
+
+ corresponding to rotation axis A and angle theta as above, we can
+ represent Q using "scalar + vector" notation as follows:
+
+ s = q0 = cos(theta/2)
+
+ v = ( q1, q2, q3 ) = sin(theta/2) * A
+
+ Q = s + v
+
+ Let Q1 and Q2 be SPICE quaternions with respective scalar
+ and vector parts s1, s2 and v1, v2:
+
+ Q1 = s1 + v1
+ Q2 = s2 + v2
+
+ We represent the dot product of v1 and v2 by
+
+
+
+ and the cross product of v1 and v2 by
+
+ v1 x v2
+
+ Then the SPICE quaternion product is
+
+ Q1*Q2 = s1*s2 - + s1*v2 + s2*v1 + (v1 x v2)
+
+ If Q1 and Q2 represent the rotation matrices M1 and M2
+ respectively, then the quaternion product
+
+ Q1*Q2
+
+ represents the matrix product
+
+ M1*M2
+
+
+-Examples
+
+
+ This example writes a type 1 C-kernel segment for the
+ Galileo scan platform to a previously opened file attached to
+ handle.
+
+ /.
+ Include CSPICE interface definitions.
+ ./
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Assume arrays of quaternions, angular velocities, and the
+ associated SCLK times are produced elsewhere.
+ ./
+ .
+ .
+ .
+ /.
+ The subroutine ckw01_c needs the following items for the
+ segment descriptor:
+
+ 1) SCLK limits of the segment.
+ 2) Instrument code.
+ 3) Reference frame.
+ 4) The angular velocity flag.
+ ./
+
+ begtim = (SpiceChar *) sclk[0];
+ endtim = (SpiceChar *) sclk[nrec-1];
+
+ inst = -77001;
+ ref = "J2000";
+ avflag = SPICETRUE;
+ segid = "GLL SCAN PLT - DATA TYPE 1";
+
+ /.
+ Write the segment.
+ ./
+ ckw01_c ( handle, begtim, endtim, inst, ref, avflag,
+ segid, nrec, sclkdp, quats, avvs );
+
+ .
+ .
+ .
+
+ /.
+ After all segments are written, close the C-kernel.
+ ./
+ ckcls_c ( handle );
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ K.R. Gehringer (JPL)
+ N.J. Bachman (JPL)
+ J.M. Lynch (JPL)
+
+-Version
+
+ -CSPICE Version 2.0.0, 01-JUN-2010 (NJB)
+
+ The check for non-unit quaternions has been replaced
+ with a check for zero-length quaternions. (The
+ implementation of the check is located in ckw01_.)
+
+ -CSPICE Version 1.3.2, 27-FEB-2008 (NJB)
+
+ Updated header; added information about SPICE
+ quaternion conventions.
+
+ -CSPICE Version 1.3.1, 12-JUN-2006 (NJB)
+
+ Corrected typo in example, the sclk indexes for the begtim
+ and endtim assignments used FORTRAN convention.
+
+ -CSPICE Version 1.3.0, 28-AUG-2001 (NJB)
+
+ Changed prototype: inputs sclkdp, quats, and avvs are now
+ const-qualified. Implemented interface macros for casting
+ these inputs to const.
+
+ -CSPICE Version 1.2.0, 02-SEP-1999 (NJB)
+
+ Local type logical variable now used for angular velocity
+ flag used in interface of ckw01_.
+
+ -CSPICE Version 1.1.0, 08-FEB-1998 (NJB)
+
+ References to C2F_CreateStr_Sig were removed; code was
+ cleaned up accordingly. String checks are now done using
+ the macro CHKFSTR.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB)
+
+ Based on SPICELIB Version 2.0.0, 28-DEC-1993 (WLT)
+
+-Index_Entries
+
+ write ck type_1 pointing data segment
+
+-&
+*/
+
+{ /* Begin ckw01_c */
+
+
+ /*
+ Local variables
+ */
+ logical avf;
+
+
+ /*
+ Participate in error handling.
+ */
+ chkin_c ( "ckw01_c" );
+
+
+ /*
+ Check the input strings to make sure the pointers
+ are non-null and the string lengths are non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "ckw01_c", ref );
+ CHKFSTR ( CHK_STANDARD, "ckw01_c", segid );
+
+ /*
+ Get a type logical copy of the a.v. flag.
+ */
+ avf = avflag;
+
+
+ /*
+ Write the segment. Note that the quaternion and angular velocity
+ arrays DO NOT require transposition!
+ */
+
+ ckw01_( ( integer * ) &handle,
+ ( doublereal * ) &begtim,
+ ( doublereal * ) &endtim,
+ ( integer * ) &inst,
+ ( char * ) ref,
+ ( logical * ) &avf,
+ ( char * ) segid,
+ ( integer * ) &nrec,
+ ( doublereal * ) sclkdp,
+ ( doublereal * ) quats,
+ ( doublereal * ) avvs,
+ ( ftnlen ) strlen(ref),
+ ( ftnlen ) strlen(segid) );
+
+
+ chkout_c ( "ckw01_c" );
+
+} /* End ckw01_c */
diff --git a/ext/spice/src/cspice/ckw02.c b/ext/spice/src/cspice/ckw02.c
new file mode 100644
index 0000000000..599f893770
--- /dev/null
+++ b/ext/spice/src/cspice/ckw02.c
@@ -0,0 +1,839 @@
+/* ckw02.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+static integer c__4 = 4;
+static integer c__3 = 3;
+static integer c__1 = 1;
+
+/* $Procedure CKW02 ( C-Kernel, write segment to C-kernel, data type 2 ) */
+/* Subroutine */ int ckw02_(integer *handle, doublereal *begtim, doublereal *
+ endtim, integer *inst, char *ref, char *segid, integer *nrec,
+ doublereal *start, doublereal *stop, doublereal *quats, doublereal *
+ avvs, doublereal *rates, ftnlen ref_len, ftnlen segid_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer ndir, i__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafps_(integer *,
+ integer *, doublereal *, integer *, doublereal *);
+ doublereal descr[5];
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
+ integer index, value;
+ extern /* Subroutine */ int errdp_(char *, doublereal *, ftnlen), dafada_(
+ doublereal *, integer *), dafbna_(integer *, doublereal *, char *,
+ ftnlen), dafena_(void);
+ extern logical failed_(void);
+ integer refcod;
+ extern /* Subroutine */ int namfrm_(char *, integer *, ftnlen);
+ extern integer lastnb_(char *, ftnlen);
+ doublereal dirent;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern logical vzerog_(doublereal *, integer *), return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+
+/* $ Abstract */
+
+/* Write a type 2 segment to a C-kernel. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+/* SCLK */
+
+/* $ Keywords */
+
+/* POINTING */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of an open CK file. */
+/* BEGTIM I The beginning encoded SCLK of the segment. */
+/* ENDTIM I The ending encoded SCLK of the segment. */
+/* INST I The NAIF instrument ID code. */
+/* REF I The reference frame of the segment. */
+/* SEGID I Segment identifier. */
+/* NREC I Number of pointing records. */
+/* START I Encoded SCLK interval start times. */
+/* STOP I Encoded SCLK interval stop times. */
+/* QUATS I SPICE quaternions representing instrument pointing. */
+/* AVVS I Angular velocity vectors. */
+/* RATES I Number of seconds per tick for each interval. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the CK file to which the segment will */
+/* be written. The file must have been opened with write */
+/* access. */
+
+/* BEGTIM is the beginning encoded SCLK time of the segment. This */
+/* value should be less than or equal to the first START */
+/* time in the segment. */
+
+/* ENDTIM is the encoded SCLK time at which the segment ends. */
+/* This value should be greater than or equal to the last */
+/* STOP time in the segment. */
+
+/* INST is the NAIF integer ID code for the instrument. */
+
+/* REF is a character string that specifies the */
+/* reference frame of the segment. This should be one of */
+/* the frames supported by the SPICELIB routine NAMFRM */
+/* which is an entry point to FRAMEX. */
+
+/* SEGID is the segment identifier. A CK segment identifier may */
+/* contain up to 40 characters. */
+
+/* NREC is the number of pointing intervals that will be */
+/* written to the segment. */
+
+/* START are the start times of each interval in encoded */
+/* spacecraft clock. These times must be strictly */
+/* increasing. */
+
+/* STOP are the stop times of each interval in encoded */
+/* spacecraft clock. These times must be greater than */
+/* the START times that they correspond to but less */
+/* than or equal to the START time of the next interval. */
+
+/* QUATS is an array of SPICE-style quaternions representing */
+/* the C-matrices associated with the start times of each */
+/* interval. See the discussion of quaternion styles in */
+/* Particulars below. */
+
+/* AVVS are the angular velocity vectors for each interval. */
+
+/* RATES are the number of seconds per encoded spacecraft clock */
+/* tick for each interval. */
+
+/* In most applications this value will be the same for */
+/* each interval within a segment. For example, when */
+/* constructing a predict C-kernel for Mars Observer, the */
+/* rate would be 1/256 for each interval since this is */
+/* the smallest time unit expressible by the MO clock. The */
+/* nominal seconds per tick rates for Galileo and Voyager */
+/* are 1/120 and 0.06 respectively. */
+
+/* $ Detailed_Output */
+
+/* None. See Files section. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If HANDLE is not the handle of a C-kernel opened for writing */
+/* the error will be diagnosed by routines called by this */
+/* routine. */
+
+/* 2) If SEGID is more than 40 characters long, the error */
+/* SPICE(SEGIDTOOLONG) is signalled. */
+
+/* 3) If SEGID contains any nonprintable characters, the error */
+/* SPICE(NONPRINTABLECHARS) is signalled. */
+
+/* 4) If the first START time is negative, the error */
+/* SPICE(INVALIDSCLKTIME) is signalled. If any of the subsequent */
+/* START times are negative the error SPICE(TIMESOUTOFORDER) */
+/* will be signalled. */
+
+/* 5) If any of the STOP times are negative, the error */
+/* SPICE(DEGENERATEINTERVAL) is signalled. */
+
+/* 6) If the STOP time of any of the intervals is less than or equal */
+/* to the START time, the error SPICE(DEGENERATEINTERVAL) is */
+/* signalled. */
+
+/* 7) If the START times are not strictly increasing, the */
+/* error SPICE(TIMESOUTOFORDER) is signalled. */
+
+/* 8) If the STOP time of one interval is greater than the START */
+/* time of the next interval, the error SPICE(BADSTOPTIME) */
+/* is signalled. */
+
+/* 9) If BEGTIM is greater than START(1) or ENDTIM is less than */
+/* STOP(NREC), the error SPICE(INVALIDDESCRTIME) is */
+/* signalled. */
+
+/* 10) If the name of the reference frame is not one of those */
+/* supported by the routine NAMFRM, the error */
+/* SPICE(INVALIDREFFRAME) is signalled. */
+
+/* 11) If NREC, the number of pointing records, is less than or */
+/* equal to 0, the error SPICE(INVALIDNUMRECS) is signalled. */
+
+/* 12) If the squared length of any quaternion differes from 1 */
+/* by more than 1.0D-2, the error SPICE(NONUNITQUATERNION) is */
+/* signalled. */
+
+/* $ Files */
+
+/* This routine adds a type 2 segment to a C-kernel. The C-kernel */
+/* may be either a new one or an existing one opened for writing. */
+
+/* $ Particulars */
+
+/* For a detailed description of a type 2 CK segment please see the */
+/* CK Required Reading. */
+
+/* This routine relieves the user from performing the repetitive */
+/* calls to the DAF routines necessary to construct a CK segment. */
+
+
+/* Quaternion Styles */
+/* ----------------- */
+
+/* There are different "styles" of quaternions used in */
+/* science and engineering applications. Quaternion styles */
+/* are characterized by */
+
+/* - The order of quaternion elements */
+
+/* - The quaternion multiplication formula */
+
+/* - The convention for associating quaternions */
+/* with rotation matrices */
+
+/* Two of the commonly used styles are */
+
+/* - "SPICE" */
+
+/* > Invented by Sir William Rowan Hamilton */
+/* > Frequently used in mathematics and physics textbooks */
+
+/* - "Engineering" */
+
+/* > Widely used in aerospace engineering applications */
+
+
+/* SPICELIB subroutine interfaces ALWAYS use SPICE quaternions. */
+/* Quaternions of any other style must be converted to SPICE */
+/* quaternions before they are passed to SPICELIB routines. */
+
+
+/* Relationship between SPICE and Engineering Quaternions */
+/* ------------------------------------------------------ */
+
+/* Let M be a rotation matrix such that for any vector V, */
+
+/* M*V */
+
+/* is the result of rotating V by theta radians in the */
+/* counterclockwise direction about unit rotation axis vector A. */
+/* Then the SPICE quaternions representing M are */
+
+/* (+/-) ( cos(theta/2), */
+/* sin(theta/2) A(1), */
+/* sin(theta/2) A(2), */
+/* sin(theta/2) A(3) ) */
+
+/* while the engineering quaternions representing M are */
+
+/* (+/-) ( -sin(theta/2) A(1), */
+/* -sin(theta/2) A(2), */
+/* -sin(theta/2) A(3), */
+/* cos(theta/2) ) */
+
+/* For both styles of quaternions, if a quaternion q represents */
+/* a rotation matrix M, then -q represents M as well. */
+
+/* Given an engineering quaternion */
+
+/* QENG = ( q0, q1, q2, q3 ) */
+
+/* the equivalent SPICE quaternion is */
+
+/* QSPICE = ( q3, -q0, -q1, -q2 ) */
+
+
+/* Associating SPICE Quaternions with Rotation Matrices */
+/* ---------------------------------------------------- */
+
+/* Let FROM and TO be two right-handed reference frames, for */
+/* example, an inertial frame and a spacecraft-fixed frame. Let the */
+/* symbols */
+
+/* V , V */
+/* FROM TO */
+
+/* denote, respectively, an arbitrary vector expressed relative to */
+/* the FROM and TO frames. Let M denote the transformation matrix */
+/* that transforms vectors from frame FROM to frame TO; then */
+
+/* V = M * V */
+/* TO FROM */
+
+/* where the expression on the right hand side represents left */
+/* multiplication of the vector by the matrix. */
+
+/* Then if the unit-length SPICE quaternion q represents M, where */
+
+/* q = (q0, q1, q2, q3) */
+
+/* the elements of M are derived from the elements of q as follows: */
+
+/* +- -+ */
+/* | 2 2 | */
+/* | 1 - 2*( q2 + q3 ) 2*(q1*q2 - q0*q3) 2*(q1*q3 + q0*q2) | */
+/* | | */
+/* | | */
+/* | 2 2 | */
+/* M = | 2*(q1*q2 + q0*q3) 1 - 2*( q1 + q3 ) 2*(q2*q3 - q0*q1) | */
+/* | | */
+/* | | */
+/* | 2 2 | */
+/* | 2*(q1*q3 - q0*q2) 2*(q2*q3 + q0*q1) 1 - 2*( q1 + q2 ) | */
+/* | | */
+/* +- -+ */
+
+/* Note that substituting the elements of -q for those of q in the */
+/* right hand side leaves each element of M unchanged; this shows */
+/* that if a quaternion q represents a matrix M, then so does the */
+/* quaternion -q. */
+
+/* To map the rotation matrix M to a unit quaternion, we start by */
+/* decomposing the rotation matrix as a sum of symmetric */
+/* and skew-symmetric parts: */
+
+/* 2 */
+/* M = [ I + (1-cos(theta)) OMEGA ] + [ sin(theta) OMEGA ] */
+
+/* symmetric skew-symmetric */
+
+
+/* OMEGA is a skew-symmetric matrix of the form */
+
+/* +- -+ */
+/* | 0 -n3 n2 | */
+/* | | */
+/* OMEGA = | n3 0 -n1 | */
+/* | | */
+/* | -n2 n1 0 | */
+/* +- -+ */
+
+/* The vector N of matrix entries (n1, n2, n3) is the rotation axis */
+/* of M and theta is M's rotation angle. Note that N and theta */
+/* are not unique. */
+
+/* Let */
+
+/* C = cos(theta/2) */
+/* S = sin(theta/2) */
+
+/* Then the unit quaternions Q corresponding to M are */
+
+/* Q = +/- ( C, S*n1, S*n2, S*n3 ) */
+
+/* The mappings between quaternions and the corresponding rotations */
+/* are carried out by the SPICELIB routines */
+
+/* Q2M {quaternion to matrix} */
+/* M2Q {matrix to quaternion} */
+
+/* M2Q always returns a quaternion with scalar part greater than */
+/* or equal to zero. */
+
+
+/* SPICE Quaternion Multiplication Formula */
+/* --------------------------------------- */
+
+/* Given a SPICE quaternion */
+
+/* Q = ( q0, q1, q2, q3 ) */
+
+/* corresponding to rotation axis A and angle theta as above, we can */
+/* represent Q using "scalar + vector" notation as follows: */
+
+/* s = q0 = cos(theta/2) */
+
+/* v = ( q1, q2, q3 ) = sin(theta/2) * A */
+
+/* Q = s + v */
+
+/* Let Q1 and Q2 be SPICE quaternions with respective scalar */
+/* and vector parts s1, s2 and v1, v2: */
+
+/* Q1 = s1 + v1 */
+/* Q2 = s2 + v2 */
+
+/* We represent the dot product of v1 and v2 by */
+
+/* */
+
+/* and the cross product of v1 and v2 by */
+
+/* v1 x v2 */
+
+/* Then the SPICE quaternion product is */
+
+/* Q1*Q2 = s1*s2 - + s1*v2 + s2*v1 + (v1 x v2) */
+
+/* If Q1 and Q2 represent the rotation matrices M1 and M2 */
+/* respectively, then the quaternion product */
+
+/* Q1*Q2 */
+
+/* represents the matrix product */
+
+/* M1*M2 */
+
+
+/* $ Examples */
+
+/* C */
+/* C This example writes a predict type 2 C-kernel segment for */
+/* C the Mars Observer spacecraft bus to a previously opened CK file */
+/* C attached to HANDLE. */
+
+/* C */
+/* C Assume arrays of quaternions, angular velocities, and interval */
+/* C start and stop times are produced elsewhere. */
+/* C */
+/* . */
+/* . */
+/* . */
+
+/* C */
+/* C The nominal number of seconds in a tick for MO is 1/256 */
+/* C */
+/* SECTIK = 1.D0 / 256.D0 */
+
+/* DO I = 1, NREC */
+/* RATE(I) = SECTIK */
+/* END DO */
+
+/* C */
+/* C The subroutine CKW02 needs the following components of the */
+/* C segment descriptor: */
+/* C */
+/* C 1) SCLK limits of the segment. */
+/* C 2) Instrument code. */
+/* C 3) Reference frame. */
+
+/* BEGTIM = START ( 1 ) */
+/* ENDTIM = STOP ( NREC ) */
+
+/* INST = -94000 */
+/* REF = 'J2000' */
+
+/* SEGID = 'MO PREDICT SEG TYPE 2' */
+
+/* C */
+/* C Write the segment. */
+/* C */
+/* CALL CKW02 ( HANDLE, BEGTIM, ENDTIM, INST, REF, SEGID, */
+/* . NREC, START, STOP, QUAT, AVV, RATES ) */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* J.M. Lynch (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 01-JUN-2010 (NJB) */
+
+/* The check for non-unit quaternions has been replaced */
+/* with a check for zero-length quaternions. */
+
+/* - SPICELIB Version 2.2.0, 26-FEB-2008 (NJB) */
+
+/* Updated header; added information about SPICE */
+/* quaternion conventions. */
+
+/* Minor typo in a long error message was corrected. */
+
+/* - SPICELIB Version 2.1.0, 22-FEB-1999 (WLT) */
+
+/* Added check to make sure that all quaternions are unit */
+/* length to single precision. */
+
+/* - SPICELIB Version 2.0.0, 28-DEC-1993 (WLT) */
+
+/* The routine was upgraded to support non-inertial reference */
+/* frames. */
+
+/* - SPICELIB Version 1.1.1, 05-SEP-1993 (KRG) */
+
+/* Removed all references to a specific method of opening the CK */
+/* file in the $ Brief_I/O, $ Detailed_Input, $ Exceptions, */
+/* $ Files, and $ Examples sections of the header. It is assumed */
+/* that a person using this routine has some knowledge of the DAF */
+/* system and the methods for obtaining file handles. */
+
+/* - SPICELIB Version 1.1.0, 25-NOV-1992 (JML) */
+
+/* 1) If the number of pointing records is not positive an error */
+/* is now signalled. */
+
+/* 2) FAILED is checked after the call to DAFBNA. */
+
+/* 3) The variables HLDBEG and HLDEND were removed from the loop */
+/* where the interval start and stop times are tested. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 30-AUG-1991 (JML) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write ck type_2 pointing data segment */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.1.0, 22-FEB-1999 (WLT) */
+
+/* Added check to make sure that all quaternions are unit */
+/* length to single precision. */
+
+/* - SPICELIB Version 1.1.1, 05-SEP-1993 (KRG) */
+
+/* Removed all references to a specific method of opening the CK */
+/* file in the $ Brief_I/O, $ Detailed_Input, $ Exceptions, */
+/* $ Files, and $ Examples sections of the header. It is assumed */
+/* that a person using this routine has some knowledge of the DAF */
+/* system and the methods for obtaining file handles. */
+
+/* - SPICELIB Version 1.1.0, 25-NOV-1992 (JML) */
+
+/* 1) If the number of pointing records is not positive an error */
+/* is now signalled. */
+
+/* 2) FAILED is checked after the call to DAFBNA. */
+
+/* 3) The variables HLDBEG and HLDEND were removed from the loop */
+/* where the interval start and stop times are tested. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 30-AUG-1991 (JML) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* SIDLEN is the maximum number of characters allowed in a CK */
+/* segment identifier. */
+
+/* NDC is the size of a packed CK segment descriptor. */
+
+/* ND is the number of double precision components in a CK */
+/* segment descriptor. */
+
+/* NI is the number of integer components in a CK segment */
+/* descriptor. */
+
+/* DTYPE is the data type of the segment that this routine */
+/* operates on. */
+
+/* FPRINT is the integer value of the first printable ASCII */
+/* character. */
+
+/* LPRINT is the integer value of the last printable ASCII */
+/* character. */
+
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKW02", (ftnlen)5);
+ }
+
+/* The first thing that we will do is create the segment descriptor. */
+
+/* The structure of the segment descriptor is as follows. */
+
+/* DCD( 1 ) and DCD( 2 ) -- SCLK limits of the segment. */
+/* ICD( 1 ) -- Instrument code. */
+/* ICD( 2 ) -- Reference frame ID. */
+/* ICD( 3 ) -- Data type of the segment. */
+/* ICD( 4 ) -- Angular rates flag. */
+/* ICD( 5 ) -- Beginning address of the segment. */
+/* ICD( 6 ) -- Ending address of the segment. */
+
+
+/* Make sure that there is a positive number of pointing records. */
+
+ if (*nrec <= 0) {
+ setmsg_("# is an invalid number of pointing instances for type 2.", (
+ ftnlen)56);
+ errint_("#", nrec, (ftnlen)1);
+ sigerr_("SPICE(INVALIDNUMREC)", (ftnlen)20);
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+
+/* Check that the SCLK bounds on the segment are reasonable. */
+
+ if (*begtim > start[0]) {
+ setmsg_("The first d.p. component of the descriptor is invalid. DCD"
+ "(1) = # and START(1) = # ", (ftnlen)84);
+ errdp_("#", begtim, (ftnlen)1);
+ errdp_("#", start, (ftnlen)1);
+ sigerr_("SPICE(INVALIDDESCRTIME)", (ftnlen)23);
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+ if (*endtim < stop[*nrec - 1]) {
+ setmsg_("The second d.p. component of the descriptor is invalid. DC"
+ "D(2) = # and STOP(NREC) = # ", (ftnlen)87);
+ errdp_("#", endtim, (ftnlen)1);
+ errdp_("#", &stop[*nrec - 1], (ftnlen)1);
+ sigerr_("SPICE(INVALIDDESCRTIME)", (ftnlen)23);
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+ dcd[0] = *begtim;
+ dcd[1] = *endtim;
+
+/* Get the NAIF integer code for the reference frame. */
+
+ namfrm_(ref, &refcod, ref_len);
+ if (refcod == 0) {
+ setmsg_("The reference frame # is not supported.", (ftnlen)39);
+ errch_("#", ref, (ftnlen)1, ref_len);
+ sigerr_("SPICE(INVALIDREFFRAME)", (ftnlen)22);
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+
+/* Assign values to the integer components of the segment descriptor. */
+/* By definition data type two must have angular velocity. */
+
+ icd[0] = *inst;
+ icd[1] = refcod;
+ icd[2] = 2;
+ icd[3] = 1;
+
+/* Now pack the segment descriptor. */
+
+ dafps_(&c__2, &c__6, dcd, icd, descr);
+
+/* Now check that all the characters in the segid can be printed. */
+
+ i__1 = lastnb_(segid, segid_len);
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ value = *(unsigned char *)&segid[i__ - 1];
+ if (value < 32 || value > 126) {
+ setmsg_("The segment identifier contains nonprintable characters",
+ (ftnlen)55);
+ sigerr_("SPICE(NONPRINTABLECHARS)", (ftnlen)24);
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Also check to see if the segment identifier is too long. */
+
+ if (lastnb_(segid, segid_len) > 40) {
+ setmsg_("Segment identifier contains more than 40 characters.", (
+ ftnlen)52);
+ sigerr_("SPICE(SEGIDTOOLONG)", (ftnlen)19);
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+
+/* Now check that the START and STOP times on the intervals */
+/* make sense. Three checks will be performed on each interval: */
+
+/* 1) Check that the STOP time is greater than the START time. */
+
+/* 2) Check that the START times are strictly increasing. */
+
+/* 3) Check that the START time is greater than or equal to the */
+/* STOP time from the previous interval. */
+
+/* For the first interval also make sure that the START time is */
+/* nonnegative. */
+
+ if (start[0] < 0.) {
+ setmsg_("The first START time: # is negative.", (ftnlen)36);
+ errdp_("#", start, (ftnlen)1);
+ sigerr_("SPICE(INVALIDSCLKTIME)", (ftnlen)22);
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+ if (stop[0] <= start[0]) {
+ setmsg_("The STOP time is less than or equal to the START time for i"
+ "nterval number 1. START time is # and STOP time is #.", (
+ ftnlen)112);
+ errdp_("#", start, (ftnlen)1);
+ errdp_("#", stop, (ftnlen)1);
+ sigerr_("SPICE(DEGENERATEINTERVAL)", (ftnlen)25);
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+ i__1 = *nrec;
+ for (i__ = 2; i__ <= i__1; ++i__) {
+ if (stop[i__ - 1] <= start[i__ - 1]) {
+ setmsg_("The STOP time is less than or equal to the START time f"
+ "or interval number #. START time is # and STOP time is #."
+ , (ftnlen)112);
+ errint_("#", &i__, (ftnlen)1);
+ errdp_("#", &start[i__ - 1], (ftnlen)1);
+ errdp_("#", &stop[i__ - 1], (ftnlen)1);
+ sigerr_("SPICE(DEGENERATEINTERVAL)", (ftnlen)25);
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+ if (start[i__ - 1] <= start[i__ - 2]) {
+ setmsg_("The START times are not strictly increasing. START(#) "
+ "= # and START(#) = #.", (ftnlen)76);
+ errint_("#", &i__, (ftnlen)1);
+ errdp_("#", &start[i__ - 1], (ftnlen)1);
+ i__2 = i__ - 1;
+ errint_("#", &i__2, (ftnlen)1);
+ errdp_("#", &start[i__ - 2], (ftnlen)1);
+ sigerr_("SPICE(TIMESOUTOFORDER)", (ftnlen)22);
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+ if (stop[i__ - 2] > start[i__ - 1]) {
+ setmsg_("The STOP time for interval # is greater than the follow"
+ "ing START time. STOP(#) = # and START(#) = #.", (ftnlen)
+ 100);
+ i__2 = i__ - 1;
+ errint_("#", &i__2, (ftnlen)1);
+ i__2 = i__ - 1;
+ errint_("#", &i__2, (ftnlen)1);
+ errdp_("#", &stop[i__ - 2], (ftnlen)1);
+ errint_("#", &i__, (ftnlen)1);
+ errdp_("#", &start[i__ - 1], (ftnlen)1);
+ sigerr_("SPICE(BADSTOPTIME)", (ftnlen)18);
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Make sure that the quaternions are non-zero. This is just */
+/* a check for uninitialized data. */
+
+ i__1 = *nrec;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ if (vzerog_(&quats[(i__ << 2) - 4], &c__4)) {
+ setmsg_("The quaternion at index # has magnitude zero.", (ftnlen)
+ 45);
+ errint_("#", &i__, (ftnlen)1);
+ sigerr_("SPICE(ZEROQUATERNION)", (ftnlen)21);
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* No more checks, begin writing the segment. */
+
+ dafbna_(handle, descr, segid, segid_len);
+ if (failed_()) {
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+ }
+
+/* Now add the quaternions, angular velocity vectors, and time */
+/* conversion factors for each interval. */
+
+ i__1 = *nrec;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dafada_(&quats[(i__ << 2) - 4], &c__4);
+ dafada_(&avvs[i__ * 3 - 3], &c__3);
+ dafada_(&rates[i__ - 1], &c__1);
+ }
+
+/* The SCLK start times. */
+
+ dafada_(start, nrec);
+
+/* The SCLK stop times. */
+
+ dafada_(stop, nrec);
+
+/* The time tag directory. The Ith element is defined to be the */
+/* average of the (I*100)th STOP time and the (I*100+1)th START time. */
+
+ ndir = (*nrec - 1) / 100;
+ index = 100;
+ i__1 = ndir;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dirent = (stop[index - 1] + start[index]) / 2.;
+ dafada_(&dirent, &c__1);
+ index += 100;
+ }
+
+/* End the segment. */
+
+ dafena_();
+ chkout_("CKW02", (ftnlen)5);
+ return 0;
+} /* ckw02_ */
+
diff --git a/ext/spice/src/cspice/ckw02_c.c b/ext/spice/src/cspice/ckw02_c.c
new file mode 100644
index 0000000000..d3a8e967d8
--- /dev/null
+++ b/ext/spice/src/cspice/ckw02_c.c
@@ -0,0 +1,544 @@
+/*
+
+-Procedure ckw02_c ( C-Kernel, write segment to C-kernel, data type 2 )
+
+-Abstract
+
+ Write a type 2 segment to a C-kernel.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CK
+ DAF
+ SCLK
+
+-Keywords
+
+ POINTING
+ UTILITY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+ #include "SpiceZim.h"
+ #undef ckw02_c
+
+
+ void ckw02_c ( SpiceInt handle,
+ SpiceDouble begtim,
+ SpiceDouble endtim,
+ SpiceInt inst,
+ ConstSpiceChar * ref,
+ ConstSpiceChar * segid,
+ SpiceInt nrec,
+ ConstSpiceDouble start [],
+ ConstSpiceDouble stop [],
+ ConstSpiceDouble quats [][4],
+ ConstSpiceDouble avvs [][3],
+ ConstSpiceDouble rates [] )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of an open CK file.
+ begtim I The beginning encoded SCLK of the segment.
+ endtim I The ending encoded SCLK of the segment.
+ inst I The NAIF instrument ID code.
+ ref I The reference frame of the segment.
+ segid I Segment identifier.
+ nrec I Number of pointing records.
+ start I Encoded SCLK interval start times.
+ stop I Encoded SCLK interval stop times.
+ quats I Quaternions representing instrument pointing.
+ avvs I Angular velocity vectors.
+ rates I Number of seconds per tick for each interval.
+
+-Detailed_Input
+
+ handle is the handle of the CK file to which the segment will
+ be written. The file must have been opened with write
+ access.
+
+ begtim is the beginning encoded SCLK time of the segment. This
+ value should be less than or equal to the first START
+ time in the segment.
+
+ endtim is the encoded SCLK time at which the segment ends.
+ This value should be greater than or equal to the last
+ STOP time in the segment.
+
+ inst is the NAIF integer ID code for the instrument.
+
+ ref is a character string that specifies the
+ reference frame of the segment. This should be one of
+ the frames supported by the SPICELIB routine NAMFRM
+ which is an entry point of FRAMEX.
+
+ segid is the segment identifier. A CK segment identifier may
+ contain up to 40 characters.
+
+ nrec is the number of pointing intervals that will be
+ written to the segment.
+
+ start are the start times of each interval in encoded
+ spacecraft clock. These times must be strictly
+ increasing.
+
+ stop are the stop times of each interval in encoded
+ spacecraft clock. These times must be greater than
+ the START times that they correspond to but less
+ than or equal to the START time of the next interval.
+
+ quats are the quaternions representing the C-matrices
+ associated with the start times of each interval. See the
+ discussion of "Quaternion Styles" in the Particulars
+ section below.
+
+ AVVS are the angular velocity vectors for each interval.
+
+ RATES are the number of seconds per encoded spacecraft clock
+ tick for each interval.
+
+ In most applications this value will be the same for
+ each interval within a segment. For example, when
+ constructing a predict C-kernel for Mars Observer, the
+ rate would be 1/256 for each interval since this is
+ the smallest time unit expressible by the MO clock. The
+ nominal seconds per tick rates for Galileo and Voyager
+ are 1/120 and 0.06 respectively.
+
+-Detailed_Output
+
+ None. See Files section.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If handle is not the handle of a C-kernel opened for writing
+ the error will be diagnosed by routines called by this
+ routine.
+
+ 2) If segid is more than 40 characters long, the error
+ SPICE(SEGIDTOOLONG) is signaled.
+
+ 3) If segid contains any nonprintable characters, the error
+ SPICE(NONPRINTABLECHARS) is signaled.
+
+ 4) If the first START time is negative, the error
+ SPICE(INVALIDSCLKTIME) is signaled. If any of the subsequent
+ START times are negative the error SPICE(TIMESOUTOFORDER)
+ will be signaled.
+
+ 5) If any of the STOP times are negative, the error
+ SPICE(DEGENERATEINTERVAL) is signaled.
+
+ 6) If the STOP time of any of the intervals is less than or equal
+ to the START time, the error SPICE(DEGENERATEINTERVAL) is
+ signaled.
+
+ 7) If the START times are not strictly increasing, the
+ error SPICE(TIMESOUTOFORDER) is signaled.
+
+ 8) If the STOP time of one interval is greater than the START
+ time of the next interval, the error SPICE(BADSTOPTIME)
+ is signaled.
+
+ 9) If begtim is greater than START[0] or endtim is less than
+ STOP[NREC-1], the error SPICE(INVALIDDESCRTIME) is
+ signaled.
+
+ 10) If the name of the reference frame is not one of those
+ supported by the routine NAMFRM, the error
+ SPICE(INVALIDREFFRAME) is signaled.
+
+ 11) If nrec, the number of pointing records, is less than or
+ equal to 0, the error SPICE(INVALIDNUMRECS) is signaled.
+
+ 12) If any quaternion has magnitude zero, the error
+ SPICE(ZEROQUATERNION) is signaled.
+
+
+-Files
+
+ This routine adds a type 2 segment to a C-kernel. The C-kernel
+ may be either a new one or an existing one opened for writing.
+
+-Particulars
+
+ For a detailed description of a type 2 CK segment please see the
+ CK Required Reading.
+
+ This routine relieves the user from performing the repetitive
+ calls to the DAF routines necessary to construct a CK segment.
+
+
+ Quaternion Styles
+ -----------------
+
+ There are different "styles" of quaternions used in
+ science and engineering applications. Quaternion styles
+ are characterized by
+
+ - The order of quaternion elements
+
+ - The quaternion multiplication formula
+
+ - The convention for associating quaternions
+ with rotation matrices
+
+ Two of the commonly used styles are
+
+ - "SPICE"
+
+ > Invented by Sir William Rowan Hamilton
+ > Frequently used in mathematics and physics textbooks
+
+ - "Engineering"
+
+ > Widely used in aerospace engineering applications
+
+
+ CSPICE function interfaces ALWAYS use SPICE quaternions.
+ Quaternions of any other style must be converted to SPICE
+ quaternions before they are passed to CSPICE functions.
+
+
+ Relationship between SPICE and Engineering Quaternions
+ ------------------------------------------------------
+
+ Let M be a rotation matrix such that for any vector V,
+
+ M*V
+
+ is the result of rotating V by theta radians in the
+ counterclockwise direction about unit rotation axis vector A.
+ Then the SPICE quaternions representing M are
+
+ (+/-) ( cos(theta/2),
+ sin(theta/2) A(1),
+ sin(theta/2) A(2),
+ sin(theta/2) A(3) )
+
+ while the engineering quaternions representing M are
+
+ (+/-) ( -sin(theta/2) A(1),
+ -sin(theta/2) A(2),
+ -sin(theta/2) A(3),
+ cos(theta/2) )
+
+ For both styles of quaternions, if a quaternion q represents
+ a rotation matrix M, then -q represents M as well.
+
+ Given an engineering quaternion
+
+ QENG = ( q0, q1, q2, q3 )
+
+ the equivalent SPICE quaternion is
+
+ QSPICE = ( q3, -q0, -q1, -q2 )
+
+
+ Associating SPICE Quaternions with Rotation Matrices
+ ----------------------------------------------------
+
+ Let FROM and TO be two right-handed reference frames, for
+ example, an inertial frame and a spacecraft-fixed frame. Let the
+ symbols
+
+ V , V
+ FROM TO
+
+ denote, respectively, an arbitrary vector expressed relative to
+ the FROM and TO frames. Let M denote the transformation matrix
+ that transforms vectors from frame FROM to frame TO; then
+
+ V = M * V
+ TO FROM
+
+ where the expression on the right hand side represents left
+ multiplication of the vector by the matrix.
+
+ Then if the unit-length SPICE quaternion q represents M, where
+
+ q = (q0, q1, q2, q3)
+
+ the elements of M are derived from the elements of q as follows:
+
+ +- -+
+ | 2 2 |
+ | 1 - 2*( q2 + q3 ) 2*(q1*q2 - q0*q3) 2*(q1*q3 + q0*q2) |
+ | |
+ | |
+ | 2 2 |
+ M = | 2*(q1*q2 + q0*q3) 1 - 2*( q1 + q3 ) 2*(q2*q3 - q0*q1) |
+ | |
+ | |
+ | 2 2 |
+ | 2*(q1*q3 - q0*q2) 2*(q2*q3 + q0*q1) 1 - 2*( q1 + q2 ) |
+ | |
+ +- -+
+
+ Note that substituting the elements of -q for those of q in the
+ right hand side leaves each element of M unchanged; this shows
+ that if a quaternion q represents a matrix M, then so does the
+ quaternion -q.
+
+ To map the rotation matrix M to a unit quaternion, we start by
+ decomposing the rotation matrix as a sum of symmetric
+ and skew-symmetric parts:
+
+ 2
+ M = [ I + (1-cos(theta)) OMEGA ] + [ sin(theta) OMEGA ]
+
+ symmetric skew-symmetric
+
+
+ OMEGA is a skew-symmetric matrix of the form
+
+ +- -+
+ | 0 -n3 n2 |
+ | |
+ OMEGA = | n3 0 -n1 |
+ | |
+ | -n2 n1 0 |
+ +- -+
+
+ The vector N of matrix entries (n1, n2, n3) is the rotation axis
+ of M and theta is M's rotation angle. Note that N and theta
+ are not unique.
+
+ Let
+
+ C = cos(theta/2)
+ S = sin(theta/2)
+
+ Then the unit quaternions Q corresponding to M are
+
+ Q = +/- ( C, S*n1, S*n2, S*n3 )
+
+ The mappings between quaternions and the corresponding rotations
+ are carried out by the CSPICE routines
+
+ q2m_c {quaternion to matrix}
+ m2q_c {matrix to quaternion}
+
+ m2q_c always returns a quaternion with scalar part greater than
+ or equal to zero.
+
+
+ SPICE Quaternion Multiplication Formula
+ ---------------------------------------
+
+ Given a SPICE quaternion
+
+ Q = ( q0, q1, q2, q3 )
+
+ corresponding to rotation axis A and angle theta as above, we can
+ represent Q using "scalar + vector" notation as follows:
+
+ s = q0 = cos(theta/2)
+
+ v = ( q1, q2, q3 ) = sin(theta/2) * A
+
+ Q = s + v
+
+ Let Q1 and Q2 be SPICE quaternions with respective scalar
+ and vector parts s1, s2 and v1, v2:
+
+ Q1 = s1 + v1
+ Q2 = s2 + v2
+
+ We represent the dot product of v1 and v2 by
+
+
+
+ and the cross product of v1 and v2 by
+
+ v1 x v2
+
+ Then the SPICE quaternion product is
+
+ Q1*Q2 = s1*s2 - + s1*v2 + s2*v1 + (v1 x v2)
+
+ If Q1 and Q2 represent the rotation matrices M1 and M2
+ respectively, then the quaternion product
+
+ Q1*Q2
+
+ represents the matrix product
+
+ M1*M2
+
+
+-Examples
+
+
+ This example writes a predict type 2 C-kernel segment for
+ the Mars Observer spacecraft bus to a previously opened CK file
+ attached to handle.
+
+
+ /.
+ Assume arrays of quaternions, angular velocities, and interval
+ start and stop times are produced elsewhere.
+ ./
+
+ .
+ .
+ .
+
+ /.
+ The nominal number of seconds in a tick for MO is 1/256.
+ ./
+ sectik = 1. / 256.;
+
+ for ( i = 0; i < nrec; i++ )
+ {
+ rate[i] = sectik;
+ }
+
+ /.
+ The subroutine ckw02_c needs the following components of the
+ segment descriptor:
+
+ 1) SCLK limits of the segment.
+ 2) Instrument code.
+ 3) Reference frame.
+ ./
+ begtim = start [ 0 ];
+ endtim = stop [nrec-1];
+
+ inst = -94000;
+ ref = "j2000";
+
+ segid = "mo predict seg type 2";
+
+ /.
+ Write the segment.
+ ./
+ ckw02_c ( handle, begtim, endtim, inst, ref, segid,
+ nrec, start, stop, quat, avv, rates );
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ J.M. Lynch (JPL)
+
+-Version
+
+ -CSPICE Version 2.0.0, 01-JUN-2010 (NJB)
+
+ The check for non-unit quaternions has been replaced
+ with a check for zero-length quaternions. (The
+ implementation of the check is located in ckw02_.)
+
+ -CSPICE Version 1.2.1, 27-FEB-2008 (NJB)
+
+ Updated header; added information about SPICE
+ quaternion conventions.
+
+ -CSPICE Version 1.2.0, 28-AUG-2001 (NJB)
+
+ Changed prototype: inputs start, stop, sclkdp, quats,
+ and avvs are now const-qualified. Implemented interface
+ macros for casting these inputs to const.
+
+ -CSPICE Version 1.1.0, 08-FEB-1998 (NJB)
+
+ References to C2F_CreateStr_Sig were removed; code was
+ cleaned up accordingly. String checks are now done using
+ the macro CHKFSTR.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB)
+
+ Based on SPICELIB Version 2.0.0, 28-DEC-1993 (WLT)
+
+-Index_Entries
+
+ write ck type_2 pointing data segment
+
+-&
+*/
+
+{ /* Begin ckw02_c */
+
+ /*
+ Participate in error handling.
+ */
+ chkin_c ( "ckw02_c" );
+
+ /*
+ Check the input strings to make sure the pointers
+ are non-null and the string lengths are non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "ckw02_c", ref );
+ CHKFSTR ( CHK_STANDARD, "ckw02_c", segid );
+
+
+ /*
+ Write the segment. Note that the quaternion and angular velocity
+ arrays DO NOT require transposition!
+ */
+
+ ckw02_( ( integer * ) &handle,
+ ( doublereal * ) &begtim,
+ ( doublereal * ) &endtim,
+ ( integer * ) &inst,
+ ( char * ) ref,
+ ( char * ) segid,
+ ( integer * ) &nrec,
+ ( doublereal * ) start,
+ ( doublereal * ) stop,
+ ( doublereal * ) quats,
+ ( doublereal * ) avvs,
+ ( doublereal * ) rates,
+ ( ftnlen ) strlen(ref),
+ ( ftnlen ) strlen(segid) );
+
+
+ chkout_c ( "ckw02_c" );
+
+} /* End ckw02_c */
diff --git a/ext/spice/src/cspice/ckw03.c b/ext/spice/src/cspice/ckw03.c
new file mode 100644
index 0000000000..80f61f73b8
--- /dev/null
+++ b/ext/spice/src/cspice/ckw03.c
@@ -0,0 +1,951 @@
+/* ckw03.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+static integer c__4 = 4;
+static integer c__3 = 3;
+static integer c__1 = 1;
+
+/* $Procedure CKW03 ( C-Kernel, write segment to C-kernel, data type 3 ) */
+/* Subroutine */ int ckw03_(integer *handle, doublereal *begtim, doublereal *
+ endtim, integer *inst, char *ref, logical *avflag, char *segid,
+ integer *nrec, doublereal *sclkdp, doublereal *quats, doublereal *
+ avvs, integer *nints, doublereal *starts, ftnlen ref_len, ftnlen
+ segid_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+ doublereal d__1;
+
+ /* Local variables */
+ integer i__;
+ logical match;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafps_(integer *,
+ integer *, doublereal *, integer *, doublereal *);
+ doublereal descr[5];
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
+ integer nidir, index, value;
+ extern /* Subroutine */ int errdp_(char *, doublereal *, ftnlen);
+ integer nrdir;
+ extern /* Subroutine */ int dafada_(doublereal *, integer *), dafbna_(
+ integer *, doublereal *, char *, ftnlen), dafena_(void);
+ extern logical failed_(void);
+ integer refcod;
+ extern /* Subroutine */ int namfrm_(char *, integer *, ftnlen);
+ extern integer lastnb_(char *, ftnlen);
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern logical vzerog_(doublereal *, integer *), return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+
+/* $ Abstract */
+
+/* Add a type 3 segment to a C-kernel. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* DAF */
+/* ROTATION */
+/* SCLK */
+
+/* $ Keywords */
+
+/* POINTING */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of an open CK file. */
+/* BEGTIM I Beginning encoded SCLK of the segment. */
+/* ENDTIM I Ending encoded SCLK of the segment. */
+/* INST I NAIF instrument ID code. */
+/* REF I Reference frame of the segment. */
+/* AVFLAG I True if the segment will contain angular velocity. */
+/* SEGID I Segment identifier. */
+/* NREC I Number of pointing records. */
+/* SCLKDP I Encoded SCLK times. */
+/* QUATS I SPICE quaternions representing instrument pointing. */
+/* AVVS I Angular velocity vectors. */
+/* NINTS I Number of intervals. */
+/* STARTS I Encoded SCLK interval start times. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of the CK file to which the segment will */
+/* be written. The file must have been opened with write */
+/* access. */
+
+/* BEGTIM, are the beginning and ending encoded SCLK times for */
+/* ENDTIM which the segment provides pointing information. */
+/* BEGTIM must be less than or equal to the SCLK time */
+/* associated with the first pointing instance in the */
+/* segment, and ENDTIM must be greater than or equal to */
+/* the time associated with the last pointing instance */
+/* in the segment. */
+
+/* INST is the NAIF integer ID code for the instrument that */
+/* this segment will contain pointing information for. */
+
+/* REF is a character string which specifies the inertial */
+/* reference frame of the segment. */
+
+/* The rotation matrices represented by the quaternions */
+/* that are to be written to the segment transform the */
+/* components of vectors from the inertial reference frame */
+/* specified by REF to components in the instrument fixed */
+/* frame. Also, the components of the angular velocity */
+/* vectors to be written to the segment should be given */
+/* with respect to REF. */
+
+/* REF should be the name of one of the frames supported */
+/* by the SPICELIB routine FRAMEX. */
+
+/* AVFLAG is a logical flag which indicates whether or not the */
+/* segment will contain angular velocity. */
+
+/* SEGID is the segment identifier. A CK segment identifier may */
+/* contain up to 40 printable characters and spaces. */
+
+/* NREC is the number of pointing instances in the segment. */
+
+/* SCLKDP are the encoded spacecraft clock times associated with */
+/* each pointing instance. These times must be strictly */
+/* increasing. */
+
+/* QUATS is an array of SPICE-style quaternions representing */
+/* a sequence of C-matrices. See the discussion of */
+/* quaternion styles in Particulars below. */
+
+/* The C-matrix represented by the Ith quaternion in */
+/* QUATS is a rotation matrix that transforms the */
+/* components of a vector expressed in the inertial */
+/* frame specified by REF to components expressed in */
+/* the instrument fixed frame at the time SCLKDP(I). */
+
+/* Thus, if a vector V has components x, y, z in the */
+/* inertial frame, then V has components x', y', z' in */
+/* the instrument fixed frame where: */
+
+/* [ x' ] [ ] [ x ] */
+/* | y' | = | CMAT | | y | */
+/* [ z' ] [ ] [ z ] */
+
+/* AVVS are the angular velocity vectors ( optional ). */
+
+/* The Ith vector in AVVS gives the angular velocity of */
+/* the instrument fixed frame at time SCLKDP(I). The */
+/* components of the angular velocity vectors should */
+/* be given with respect to the inertial reference frame */
+/* specified by REF. */
+
+/* The direction of an angular velocity vector gives */
+/* the right-handed axis about which the instrument fixed */
+/* reference frame is rotating. The magnitude of the */
+/* vector is the magnitude of the instantaneous velocity */
+/* of the rotation, in radians per second. */
+
+/* If AVFLAG is FALSE then this array is ignored by the */
+/* routine; however it still must be supplied as part of */
+/* the calling sequence. */
+
+/* NINTS is the number of intervals that the pointing instances */
+/* are partitioned into. */
+
+/* STARTS are the start times of each of the interpolation */
+/* intervals. These times must be strictly increasing */
+/* and must coincide with times for which the segment */
+/* contains pointing. */
+
+/* $ Detailed_Output */
+
+/* None. See Files section. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If HANDLE is not the handle of a C-kernel opened for writing */
+/* the error will be diagnosed by routines called by this */
+/* routine. */
+
+/* 2) If SEGID is more than 40 characters long, the error */
+/* SPICE(SEGIDTOOLONG) is signaled. */
+
+/* 3) If SEGID contains any non-printable characters, the error */
+/* SPICE(NONPRINTABLECHARS) is signaled. */
+
+/* 4) If the first encoded SCLK time is negative then the error */
+/* SPICE(INVALIDSCLKTIME) is signaled. If any subsequent times */
+/* are negative the error will be detected in exception (5). */
+
+/* 5) If the encoded SCLK times are not strictly increasing, */
+/* the error SPICE(TIMESOUTOFORDER) is signaled. */
+
+/* 6) If BEGTIM is greater than SCLKDP(1) or ENDTIM is less than */
+/* SCLKDP(NREC), the error SPICE(INVALIDDESCRTIME) is */
+/* signaled. */
+
+/* 7) If the name of the reference frame is not one of those */
+/* supported by the routine FRAMEX, the error */
+/* SPICE(INVALIDREFFRAME) is signaled. */
+
+/* 8) If NREC, the number of pointing records, is less than or */
+/* equal to 0, the error SPICE(INVALIDNUMREC) is signaled. */
+
+/* 9) If NINTS, the number of interpolation intervals, is less than */
+/* or equal to 0, the error SPICE(INVALIDNUMINT) is signaled. */
+
+/* 10) If the encoded SCLK interval start times are not strictly */
+/* increasing, the error SPICE(TIMESOUTOFORDER) is signaled. */
+
+/* 11) If an interval start time does not coincide with a time for */
+/* which there is an actual pointing instance in the segment, */
+/* then the error SPICE(INVALIDSTARTTIME) is signaled. */
+
+/* 12) This routine assumes that the rotation between adjacent */
+/* quaternions that are stored in the same interval has a */
+/* rotation angle of THETA radians, where */
+
+/* 0 < THETA < pi. */
+/* _ */
+
+/* The routines that evaluate the data in the segment produced */
+/* by this routine cannot distinguish between rotations of THETA */
+/* radians, where THETA is in the interval [0, pi), and */
+/* rotations of */
+
+/* THETA + 2 * k * pi */
+
+/* radians, where k is any integer. These `large' rotations will */
+/* yield invalid results when interpolated. You must ensure that */
+/* the data stored in the segment will not be subject to this */
+/* sort of ambiguity. */
+
+/* 13) If any quaternion has magnitude zero, the error */
+/* SPICE(ZEROQUATERNION) is signaled. */
+
+/* 14) If the start time of the first interval and the time of the */
+/* first pointing instance are not the same, the error */
+/* SPICE(TIMESDONTMATCH) is signaled. */
+
+/* $ Files */
+
+/* This routine adds a type 3 segment to a C-kernel. The C-kernel */
+/* may be either a new one or an existing one opened for writing. */
+
+/* $ Particulars */
+
+/* For a detailed description of a type 3 CK segment please see the */
+/* CK Required Reading. */
+
+/* This routine relieves the user from performing the repetitive */
+/* calls to the DAF routines necessary to construct a CK segment. */
+
+
+/* Quaternion Styles */
+/* ----------------- */
+
+/* There are different "styles" of quaternions used in */
+/* science and engineering applications. Quaternion styles */
+/* are characterized by */
+
+/* - The order of quaternion elements */
+
+/* - The quaternion multiplication formula */
+
+/* - The convention for associating quaternions */
+/* with rotation matrices */
+
+/* Two of the commonly used styles are */
+
+/* - "SPICE" */
+
+/* > Invented by Sir William Rowan Hamilton */
+/* > Frequently used in mathematics and physics textbooks */
+
+/* - "Engineering" */
+
+/* > Widely used in aerospace engineering applications */
+
+
+/* SPICELIB subroutine interfaces ALWAYS use SPICE quaternions. */
+/* Quaternions of any other style must be converted to SPICE */
+/* quaternions before they are passed to SPICELIB routines. */
+
+
+/* Relationship between SPICE and Engineering Quaternions */
+/* ------------------------------------------------------ */
+
+/* Let M be a rotation matrix such that for any vector V, */
+
+/* M*V */
+
+/* is the result of rotating V by theta radians in the */
+/* counterclockwise direction about unit rotation axis vector A. */
+/* Then the SPICE quaternions representing M are */
+
+/* (+/-) ( cos(theta/2), */
+/* sin(theta/2) A(1), */
+/* sin(theta/2) A(2), */
+/* sin(theta/2) A(3) ) */
+
+/* while the engineering quaternions representing M are */
+
+/* (+/-) ( -sin(theta/2) A(1), */
+/* -sin(theta/2) A(2), */
+/* -sin(theta/2) A(3), */
+/* cos(theta/2) ) */
+
+/* For both styles of quaternions, if a quaternion q represents */
+/* a rotation matrix M, then -q represents M as well. */
+
+/* Given an engineering quaternion */
+
+/* QENG = ( q0, q1, q2, q3 ) */
+
+/* the equivalent SPICE quaternion is */
+
+/* QSPICE = ( q3, -q0, -q1, -q2 ) */
+
+
+/* Associating SPICE Quaternions with Rotation Matrices */
+/* ---------------------------------------------------- */
+
+/* Let FROM and TO be two right-handed reference frames, for */
+/* example, an inertial frame and a spacecraft-fixed frame. Let the */
+/* symbols */
+
+/* V , V */
+/* FROM TO */
+
+/* denote, respectively, an arbitrary vector expressed relative to */
+/* the FROM and TO frames. Let M denote the transformation matrix */
+/* that transforms vectors from frame FROM to frame TO; then */
+
+/* V = M * V */
+/* TO FROM */
+
+/* where the expression on the right hand side represents left */
+/* multiplication of the vector by the matrix. */
+
+/* Then if the unit-length SPICE quaternion q represents M, where */
+
+/* q = (q0, q1, q2, q3) */
+
+/* the elements of M are derived from the elements of q as follows: */
+
+/* +- -+ */
+/* | 2 2 | */
+/* | 1 - 2*( q2 + q3 ) 2*(q1*q2 - q0*q3) 2*(q1*q3 + q0*q2) | */
+/* | | */
+/* | | */
+/* | 2 2 | */
+/* M = | 2*(q1*q2 + q0*q3) 1 - 2*( q1 + q3 ) 2*(q2*q3 - q0*q1) | */
+/* | | */
+/* | | */
+/* | 2 2 | */
+/* | 2*(q1*q3 - q0*q2) 2*(q2*q3 + q0*q1) 1 - 2*( q1 + q2 ) | */
+/* | | */
+/* +- -+ */
+
+/* Note that substituting the elements of -q for those of q in the */
+/* right hand side leaves each element of M unchanged; this shows */
+/* that if a quaternion q represents a matrix M, then so does the */
+/* quaternion -q. */
+
+/* To map the rotation matrix M to a unit quaternion, we start by */
+/* decomposing the rotation matrix as a sum of symmetric */
+/* and skew-symmetric parts: */
+
+/* 2 */
+/* M = [ I + (1-cos(theta)) OMEGA ] + [ sin(theta) OMEGA ] */
+
+/* symmetric skew-symmetric */
+
+
+/* OMEGA is a skew-symmetric matrix of the form */
+
+/* +- -+ */
+/* | 0 -n3 n2 | */
+/* | | */
+/* OMEGA = | n3 0 -n1 | */
+/* | | */
+/* | -n2 n1 0 | */
+/* +- -+ */
+
+/* The vector N of matrix entries (n1, n2, n3) is the rotation axis */
+/* of M and theta is M's rotation angle. Note that N and theta */
+/* are not unique. */
+
+/* Let */
+
+/* C = cos(theta/2) */
+/* S = sin(theta/2) */
+
+/* Then the unit quaternions Q corresponding to M are */
+
+/* Q = +/- ( C, S*n1, S*n2, S*n3 ) */
+
+/* The mappings between quaternions and the corresponding rotations */
+/* are carried out by the SPICELIB routines */
+
+/* Q2M {quaternion to matrix} */
+/* M2Q {matrix to quaternion} */
+
+/* M2Q always returns a quaternion with scalar part greater than */
+/* or equal to zero. */
+
+
+/* SPICE Quaternion Multiplication Formula */
+/* --------------------------------------- */
+
+/* Given a SPICE quaternion */
+
+/* Q = ( q0, q1, q2, q3 ) */
+
+/* corresponding to rotation axis A and angle theta as above, we can */
+/* represent Q using "scalar + vector" notation as follows: */
+
+/* s = q0 = cos(theta/2) */
+
+/* v = ( q1, q2, q3 ) = sin(theta/2) * A */
+
+/* Q = s + v */
+
+/* Let Q1 and Q2 be SPICE quaternions with respective scalar */
+/* and vector parts s1, s2 and v1, v2: */
+
+/* Q1 = s1 + v1 */
+/* Q2 = s2 + v2 */
+
+/* We represent the dot product of v1 and v2 by */
+
+/* */
+
+/* and the cross product of v1 and v2 by */
+
+/* v1 x v2 */
+
+/* Then the SPICE quaternion product is */
+
+/* Q1*Q2 = s1*s2 - + s1*v2 + s2*v1 + (v1 x v2) */
+
+/* If Q1 and Q2 represent the rotation matrices M1 and M2 */
+/* respectively, then the quaternion product */
+
+/* Q1*Q2 */
+
+/* represents the matrix product */
+
+/* M1*M2 */
+
+
+/* $ Examples */
+
+/* C */
+/* C This example code fragment writes a type 3 C-kernel segment */
+/* C for the Mars Observer spacecraft bus to a previously opened CK */
+/* C file attached to HANDLE. */
+/* C */
+
+/* C */
+/* C Assume arrays of quaternions, angular velocities, and the */
+/* C associated SCLK times are produced elsewhere. The software */
+/* C that calls CKW03 must then decide how to partition these */
+/* C pointing instances into intervals over which linear */
+/* C interpolation between adjacent points is valid. */
+/* C */
+/* . */
+/* . */
+/* . */
+
+/* C */
+/* C The subroutine CKW03 needs the following items for the */
+/* C segment descriptor: */
+/* C */
+/* C 1) SCLK limits of the segment. */
+/* C 2) Instrument code. */
+/* C 3) Reference frame. */
+/* C 4) The angular velocity flag. */
+/* C */
+/* BEGTIM = SCLK ( 1 ) */
+/* ENDTIM = SCLK ( NREC ) */
+
+/* INST = -94000 */
+/* REF = 'J2000' */
+/* AVFLAG = .TRUE. */
+
+/* SEGID = 'MO SPACECRAFT BUS - DATA TYPE 3' */
+
+/* C */
+/* C Write the segment. */
+/* C */
+/* CALL CKW03 ( HANDLE, BEGTIM, ENDTIM, INST, REF, AVFLAG, */
+/* . SEGID, NREC, SCLKDP, QUATS, AVVS, NINTS, */
+/* . STARTS ) */
+
+/* $ Restrictions */
+
+/* 1) The creator of the segment is given the responsibility for */
+/* determining whether it is reasonable to interpolate between */
+/* two given pointing values. */
+
+/* 2) This routine assumes that the rotation between adjacent */
+/* quaternions that are stored in the same interval has a */
+/* rotation angle of THETA radians, where */
+
+/* 0 < THETA < pi. */
+/* _ */
+
+/* The routines that evaluate the data in the segment produced */
+/* by this routine cannot distinguish between rotations of THETA */
+/* radians, where THETA is in the interval [0, pi), and */
+/* rotations of */
+
+/* THETA + 2 * k * pi */
+
+/* radians, where k is any integer. These `large' rotations will */
+/* yield invalid results when interpolated. You must ensure that */
+/* the data stored in the segment will not be subject to this */
+/* sort of ambiguity. */
+
+/* 3) All pointing instances in the segment must belong to one and */
+/* only one of the intervals. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* K.R. Gehringer (JPL) */
+/* J.M. Lynch (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 01-JUN-2010 (NJB) */
+
+/* The check for non-unit quaternions has been replaced */
+/* with a check for zero-length quaternions. */
+
+/* - SPICELIB Version 2.3.0, 26-FEB-2008 (NJB) */
+
+/* Updated header; added information about SPICE */
+/* quaternion conventions. */
+
+/* Minor typo in a long error message was corrected. */
+
+/* - SPICELIB Version 2.2.0, 26-SEP-2005 (BVS) */
+
+/* Added check to ensure that the start time of the first */
+/* interval is the same as the time of the first pointing */
+/* instance. */
+
+/* - SPICELIB Version 2.1.0, 22-FEB-1999 (WLT) */
+
+/* Added check to make sure that all quaternions are unit */
+/* length to single precision. */
+
+/* - SPICELIB Version 2.0.0, 28-DEC-1993 (WLT) */
+
+/* The routine was upgraded to support non-inertial reference */
+/* frames. */
+
+/* - SPICELIB Version 1.1.1, 05-SEP-1993 (KRG) */
+
+/* Removed all references to a specific method of opening the CK */
+/* file in the $ Brief_I/O, $ Detailed_Input, $ Exceptions, */
+/* $ Files, and $ Examples sections of the header. It is assumed */
+/* that a person using this routine has some knowledge of the DAF */
+/* system and the methods for obtaining file handles. */
+
+/* - SPICELIB Version 1.0.0, 25-NOV-1992 (JML) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write ck type_3 pointing data segment */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.2.0, 26-SEP-2005 (BVS) */
+
+/* Added check to ensure that the start time of the first */
+/* interval is the same as the time of the first pointing */
+/* instance. */
+
+/* - SPICELIB Version 2.1.0, 22-FEB-1999 (WLT) */
+
+/* Added check to make sure that all quaternions are unit */
+/* length to single precision. */
+
+/* - SPICELIB Version 1.1.1, 05-SEP-1993 (KRG) */
+
+/* Removed all references to a specific method of opening the CK */
+/* file in the $ Brief_I/O, $ Detailed_Input, $ Exceptions, */
+/* $ Files, and $ Examples sections of the header. It is assumed */
+/* that a person using this routine has some knowledge of the DAF */
+/* system and the methods for obtaining file handles. */
+
+/* - SPICELIB Version 1.0.0, 25-NOV-1992 (JML) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* SIDLEN is the maximum number of characters allowed in a CK */
+/* segment identifier. */
+
+/* NDC is the size of a packed CK segment descriptor. */
+
+/* ND is the number of double precision components in a CK */
+/* segment descriptor. */
+
+/* NI is the number of integer components in a CK segment */
+/* descriptor. */
+
+/* DTYPE is the data type of the segment that this routine */
+/* operates on. */
+
+/* FPRINT is the integer value of the first printable ASCII */
+/* character. */
+
+/* LPRINT is the integer value of the last printable ASCII */
+/* character. */
+
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("CKW03", (ftnlen)5);
+
+/* The first thing that we will do is create the segment descriptor. */
+
+/* The structure of the segment descriptor is as follows. */
+
+/* DCD( 1 ) and DCD( 2 ) -- SCLK limits of the segment. */
+/* ICD( 1 ) -- Instrument code. */
+/* ICD( 2 ) -- Reference frame ID. */
+/* ICD( 3 ) -- Data type of the segment. */
+/* ICD( 4 ) -- Angular rates flag. */
+/* ICD( 5 ) -- Beginning address of segment. */
+/* ICD( 6 ) -- Ending address of segment. */
+
+
+/* Make sure that there is a positive number of pointing records. */
+
+ if (*nrec <= 0) {
+ setmsg_("# is an invalid number of pointing instances for type 3.", (
+ ftnlen)56);
+ errint_("#", nrec, (ftnlen)1);
+ sigerr_("SPICE(INVALIDNUMREC)", (ftnlen)20);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+
+/* Make sure that there is a positive number of interpolation */
+/* intervals. */
+
+ if (*nints <= 0) {
+ setmsg_("# is an invalid number of interpolation intervals for type "
+ "3.", (ftnlen)61);
+ errint_("#", nints, (ftnlen)1);
+ sigerr_("SPICE(INVALIDNUMINT)", (ftnlen)20);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+
+/* Check that the SCLK bounds on the segment are reasonable. */
+
+ if (*begtim > sclkdp[0]) {
+ setmsg_("The segment begin time is greater than the time associated "
+ "with the first pointing instance in the segment. DCD(1) = # "
+ "and SCLKDP(1) = # ", (ftnlen)137);
+ errdp_("#", begtim, (ftnlen)1);
+ errdp_("#", sclkdp, (ftnlen)1);
+ sigerr_("SPICE(INVALIDDESCRTIME)", (ftnlen)23);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+ if (*endtim < sclkdp[*nrec - 1]) {
+ setmsg_("The segment end time is less than the time associated with "
+ "the last pointing instance in the segment. DCD(2) = # and SC"
+ "LKDP(#) = #", (ftnlen)130);
+ errdp_("#", endtim, (ftnlen)1);
+ errint_("#", nrec, (ftnlen)1);
+ errdp_("#", &sclkdp[*nrec - 1], (ftnlen)1);
+ sigerr_("SPICE(INVALIDDESCRTIME)", (ftnlen)23);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+ dcd[0] = *begtim;
+ dcd[1] = *endtim;
+
+/* Get the NAIF integer code for the reference frame. */
+
+ namfrm_(ref, &refcod, ref_len);
+ if (refcod == 0) {
+ setmsg_("The reference frame # is not supported.", (ftnlen)39);
+ errch_("#", ref, (ftnlen)1, ref_len);
+ sigerr_("SPICE(INVALIDREFFRAME)", (ftnlen)22);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+
+/* Assign values to the integer components of the segment descriptor. */
+
+ icd[0] = *inst;
+ icd[1] = refcod;
+ icd[2] = 3;
+ if (*avflag) {
+ icd[3] = 1;
+ } else {
+ icd[3] = 0;
+ }
+
+/* Now pack the segment descriptor. */
+
+ dafps_(&c__2, &c__6, dcd, icd, descr);
+
+/* Check that all the characters in the segid can be printed. */
+
+ i__1 = lastnb_(segid, segid_len);
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ value = *(unsigned char *)&segid[i__ - 1];
+ if (value < 32 || value > 126) {
+ setmsg_("The segment identifier contains nonprintable characters",
+ (ftnlen)55);
+ sigerr_("SPICE(NONPRINTABLECHARS)", (ftnlen)24);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Also check to see if the segment identifier is too long. */
+
+ if (lastnb_(segid, segid_len) > 40) {
+ setmsg_("Segment identifier contains more than 40 characters.", (
+ ftnlen)52);
+ sigerr_("SPICE(SEGIDTOOLONG)", (ftnlen)19);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+
+/* Now check that the encoded SCLK times are positive and strictly */
+/* increasing. */
+
+/* Check that the first time is nonnegative. */
+
+ if (sclkdp[0] < 0.) {
+ setmsg_("The first SCLKDP time: # is negative.", (ftnlen)37);
+ errdp_("#", sclkdp, (ftnlen)1);
+ sigerr_("SPICE(INVALIDSCLKTIME)", (ftnlen)22);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+
+/* Now check that the times are ordered properly. */
+
+ i__1 = *nrec;
+ for (i__ = 2; i__ <= i__1; ++i__) {
+ if (sclkdp[i__ - 1] <= sclkdp[i__ - 2]) {
+ setmsg_("The SCLKDP times are not strictly increasing. SCLKDP(#)"
+ " = # and SCLKDP(#) = #.", (ftnlen)78);
+ errint_("#", &i__, (ftnlen)1);
+ errdp_("#", &sclkdp[i__ - 1], (ftnlen)1);
+ i__2 = i__ - 1;
+ errint_("#", &i__2, (ftnlen)1);
+ errdp_("#", &sclkdp[i__ - 2], (ftnlen)1);
+ sigerr_("SPICE(TIMESOUTOFORDER)", (ftnlen)22);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Now check that the start time of the first interval is the */
+/* same as the time of the first pointing instance. */
+
+ if (sclkdp[0] != starts[0]) {
+ setmsg_("The start time of the first interval # and the time of the "
+ "first pointing instance # are not the same.", (ftnlen)102);
+ errdp_("#", starts, (ftnlen)1);
+ errdp_("#", sclkdp, (ftnlen)1);
+ sigerr_("SPICE(TIMESDONTMATCH)", (ftnlen)21);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+
+/* Now check that the interval start times are ordered properly. */
+
+ i__1 = *nints;
+ for (i__ = 2; i__ <= i__1; ++i__) {
+ if (starts[i__ - 1] <= starts[i__ - 2]) {
+ setmsg_("The interval start times are not strictly increasing. S"
+ "TARTS(#) = # and STARTS(#) = #.", (ftnlen)86);
+ errint_("#", &i__, (ftnlen)1);
+ errdp_("#", &starts[i__ - 1], (ftnlen)1);
+ i__2 = i__ - 1;
+ errint_("#", &i__2, (ftnlen)1);
+ errdp_("#", &starts[i__ - 2], (ftnlen)1);
+ sigerr_("SPICE(TIMESOUTOFORDER)", (ftnlen)22);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Now make sure that all of the interval start times coincide with */
+/* one of the times associated with the actual pointing. */
+
+ index = 0;
+ i__1 = *nints;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ match = FALSE_;
+ while(! match && index < *nrec) {
+ ++index;
+ match = starts[i__ - 1] == sclkdp[index - 1];
+ }
+ if (! match) {
+ setmsg_("Interval start time number # is invalid. STARTS(#) = *",
+ (ftnlen)54);
+ errint_("#", &i__, (ftnlen)1);
+ errint_("#", &i__, (ftnlen)1);
+ errdp_("*", &starts[i__ - 1], (ftnlen)1);
+ sigerr_("SPICE(INVALIDSTARTTIME)", (ftnlen)23);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Make sure that the quaternions are non-zero. This is just */
+/* a check for uninitialized data. */
+
+ i__1 = *nrec;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ if (vzerog_(&quats[(i__ << 2) - 4], &c__4)) {
+ setmsg_("The quaternion at index # has magnitude zero.", (ftnlen)
+ 45);
+ errint_("#", &i__, (ftnlen)1);
+ sigerr_("SPICE(ZEROQUATERNION)", (ftnlen)21);
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* No more checks, begin writing the segment. */
+
+ dafbna_(handle, descr, segid, segid_len);
+ if (failed_()) {
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+ }
+
+/* Now add the quaternions and optionally, the angular velocity */
+/* vectors. */
+
+ if (*avflag) {
+ i__1 = *nrec;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dafada_(&quats[(i__ << 2) - 4], &c__4);
+ dafada_(&avvs[i__ * 3 - 3], &c__3);
+ }
+ } else {
+ i__1 = *nrec << 2;
+ dafada_(quats, &i__1);
+ }
+
+/* Add the SCLK times. */
+
+ dafada_(sclkdp, nrec);
+
+/* The time tag directory. The Ith element is defined to be the */
+/* (I*100)th SCLK time. */
+
+ nrdir = (*nrec - 1) / 100;
+ index = 100;
+ i__1 = nrdir;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dafada_(&sclkdp[index - 1], &c__1);
+ index += 100;
+ }
+
+/* Now add the interval start times. */
+
+ dafada_(starts, nints);
+
+/* And the directory of interval start times. The directory of */
+/* start times will simply be every 100th start time. */
+
+ nidir = (*nints - 1) / 100;
+ index = 100;
+ i__1 = nidir;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dafada_(&starts[index - 1], &c__1);
+ index += 100;
+ }
+
+/* Finally, the number of intervals and records. */
+
+ d__1 = (doublereal) (*nints);
+ dafada_(&d__1, &c__1);
+ d__1 = (doublereal) (*nrec);
+ dafada_(&d__1, &c__1);
+
+/* End the segment. */
+
+ dafena_();
+ chkout_("CKW03", (ftnlen)5);
+ return 0;
+} /* ckw03_ */
+
diff --git a/ext/spice/src/cspice/ckw03_c.c b/ext/spice/src/cspice/ckw03_c.c
new file mode 100644
index 0000000000..9e6e9b82f5
--- /dev/null
+++ b/ext/spice/src/cspice/ckw03_c.c
@@ -0,0 +1,667 @@
+/*
+
+-Procedure ckw03_c ( C-Kernel, write segment to C-kernel, data type 3 )
+
+-Abstract
+
+ Add a type 3 segment to a C-kernel.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CK
+ DAF
+ SCLK
+
+-Keywords
+
+ POINTING
+ UTILITY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+ #include "SpiceZim.h"
+ #undef ckw03_c
+
+
+ void ckw03_c ( SpiceInt handle,
+ SpiceDouble begtim,
+ SpiceDouble endtim,
+ SpiceInt inst,
+ ConstSpiceChar * ref,
+ SpiceBoolean avflag,
+ ConstSpiceChar * segid,
+ SpiceInt nrec,
+ ConstSpiceDouble sclkdp [],
+ ConstSpiceDouble quats [][4],
+ ConstSpiceDouble avvs [][3],
+ SpiceInt nints,
+ ConstSpiceDouble starts [] )
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of an open CK file.
+ begtim I The beginning encoded SCLK of the segment.
+ endtim I The ending encoded SCLK of the segment.
+ inst I The NAIF instrument ID code.
+ ref I The reference frame of the segment.
+ avflag I True if the segment will contain angular velocity.
+ segid I Segment identifier.
+ nrec I Number of pointing records.
+ sclkdp I Encoded SCLK times.
+ quats I Quaternions representing instrument pointing.
+ avvs I Angular velocity vectors.
+ nints I Number of intervals.
+ starts I Encoded SCLK interval start times.
+
+-Detailed_Input
+
+ handle is the handle of the CK file to which the segment will
+ be written. The file must have been opened with write
+ access.
+
+ begtim is the beginning encoded SCLK time of the segment. This
+ value should be less than or equal to the first time in
+ the segment.
+
+ endtim is the encoded SCLK time at which the segment ends.
+ This value should be greater than or equal to the last
+ time in the segment.
+
+ inst is the NAIF integer ID code for the instrument.
+
+ ref is a character string which specifies the
+ reference frame of the segment. This should be one of
+ the frames supported by the SPICELIB routine NAMFRM
+ which is an entry point of FRAMEX.
+
+ The rotation matrices represented by the quaternions
+ that are to be written to the segment transform the
+ components of vectors from the inertial reference frame
+ specified by ref to components in the instrument fixed
+ frame. Also, the components of the angular velocity
+ vectors to be written to the segment should be given
+ with respect to ref.
+
+ ref should be the name of one of the frames supported
+ by the SPICELIB routine NAMFRM.
+
+
+ avflag is a boolean flag which indicates whether or not the
+ segment will contain angular velocity.
+
+ segid is the segment identifier. A CK segment identifier may
+ contain up to 40 characters, excluding the terminating
+ null.
+
+ nrec is the number of pointing instances in the segment.
+
+ sclkdp are the encoded spacecraft clock times associated with
+ each pointing instance. These times must be strictly
+ increasing.
+
+ quats is an array of SPICE-style quaternions representing a
+ sequence of C-matrices. See the discussion of "Quaternion
+ Styles" in the Particulars section below.
+
+ The C-matrix represented by the ith quaternion in
+ quats is a rotation matrix that transforms the
+ components of a vector expressed in the inertial
+ frame specified by ref to components expressed in
+ the instrument fixed frame at the time sclkdp[i].
+
+ Thus, if a vector V has components x, y, z in the
+ inertial frame, then V has components x', y', z' in
+ the instrument fixed frame where:
+
+ [ x' ] [ ] [ x ]
+ | y' | = | cmat | | y |
+ [ z' ] [ ] [ z ]
+
+ avvs are the angular velocity vectors ( optional ).
+
+ The ith vector in avvs gives the angular velocity of
+ the instrument fixed frame at time sclkdp[i]. The
+ components of the angular velocity vectors should
+ be given with respect to the inertial reference frame
+ specified by ref.
+
+ The direction of an angular velocity vector gives
+ the right-handed axis about which the instrument fixed
+ reference frame is rotating. The magnitude of the
+ vector is the magnitude of the instantaneous velocity
+ of the rotation, in radians per second.
+
+ If avflag is FALSE then this array is ignored by the
+ routine; however it still must be supplied as part of
+ the calling sequence.
+
+ nints is the number of intervals that the pointing instances
+ are partitioned into.
+
+ starts are the start times of each of the interpolation
+ intervals. These times must be strictly increasing
+ and must coincide with times for which the segment
+ contains pointing.
+
+-Detailed_Output
+
+ None. See Files section.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If handle is not the handle of a C-kernel opened for writing
+ the error will be diagnosed by routines called by this
+ routine.
+
+ 2) If segid is more than 40 characters long, the error
+ SPICE(SEGIDTOOLONG) is signaled.
+
+ 3) If segid contains any nonprintable characters, the error
+ SPICE(NONPRINTABLECHARS) is signaled.
+
+ 4) If the first encoded SCLK time is negative then the error
+ SPICE(INVALIDSCLKTIME) is signaled. If any subsequent times
+ are negative the error SPICE(TIMESOUTOFORDER) is signaled.
+
+ 5) If the encoded SCLK times are not strictly increasing,
+ the error SPICE(TIMESOUTOFORDER) is signaled.
+
+ 6) If begtim is greater than sclkdp[0] or endtim is less than
+ sclkdp[nrec-1], the error SPICE(INVALIDDESCRTIME) is
+ signaled.
+
+ 7) If the name of the reference frame is not one of those
+ supported by the SPICELIB routine NAMFRM, the error
+ SPICE(INVALIDREFFRAME) is signaled.
+
+ 8) If nrec, the number of pointing records, is less than or
+ equal to 0, the error SPICE(INVALIDNUMRECS) is signaled.
+
+ 9) If nints, the number of interpolation intervals, is less than
+ or equal to 0, the error SPICE(INVALIDNUMINTS) is signaled.
+
+ 10) If the encoded SCLK interval start times are not strictly
+ increasing, the error SPICE(TIMESOUTOFORDER) is signaled.
+
+ 11) If an interval start time does not coincide with a time for
+ which there is an actual pointing instance in the segment,
+ then the error SPICE(INVALIDSTARTTIME) is signaled.
+
+ 12) This routine assumes that the rotation between adjacent
+ quaternions that are stored in the same interval has a
+ rotation angle of THETA radians, where
+
+ 0 < THETA < pi.
+ _
+
+ The routines that evaluate the data in the segment produced
+ by this routine cannot distinguish between rotations of THETA
+ radians, where THETA is in the interval [0, pi), and
+ rotations of
+
+ THETA + 2 * k * pi
+
+ radians, where k is any integer. These `large' rotations will
+ yield invalid results when interpolated. You must ensure that
+ the data stored in the segment will not be subject to this
+ sort of ambiguity.
+
+ 14) If the start time of the first interval and the time of the
+ first pointing instance are not the same, the error
+ SPICE(TIMESDONTMATCH) is signaled.
+
+ 15) If any quaternion has magnitude zero, the error
+ SPICE(ZEROQUATERNION) is signaled.
+
+
+-Files
+
+ This routine adds a type 3 segment to a C-kernel. The C-kernel
+ may be either a new one or an existing one opened for writing.
+
+-Particulars
+
+ For a detailed description of a type 3 CK segment please see the
+ CK Required Reading.
+
+ This routine relieves the user from performing the repetitive
+ calls to the DAF routines necessary to construct a CK segment.
+
+
+ Quaternion Styles
+ -----------------
+
+ There are different "styles" of quaternions used in
+ science and engineering applications. Quaternion styles
+ are characterized by
+
+ - The order of quaternion elements
+
+ - The quaternion multiplication formula
+
+ - The convention for associating quaternions
+ with rotation matrices
+
+ Two of the commonly used styles are
+
+ - "SPICE"
+
+ > Invented by Sir William Rowan Hamilton
+ > Frequently used in mathematics and physics textbooks
+
+ - "Engineering"
+
+ > Widely used in aerospace engineering applications
+
+
+ CSPICE function interfaces ALWAYS use SPICE quaternions.
+ Quaternions of any other style must be converted to SPICE
+ quaternions before they are passed to CSPICE functions.
+
+
+ Relationship between SPICE and Engineering Quaternions
+ ------------------------------------------------------
+
+ Let M be a rotation matrix such that for any vector V,
+
+ M*V
+
+ is the result of rotating V by theta radians in the
+ counterclockwise direction about unit rotation axis vector A.
+ Then the SPICE quaternions representing M are
+
+ (+/-) ( cos(theta/2),
+ sin(theta/2) A(1),
+ sin(theta/2) A(2),
+ sin(theta/2) A(3) )
+
+ while the engineering quaternions representing M are
+
+ (+/-) ( -sin(theta/2) A(1),
+ -sin(theta/2) A(2),
+ -sin(theta/2) A(3),
+ cos(theta/2) )
+
+ For both styles of quaternions, if a quaternion q represents
+ a rotation matrix M, then -q represents M as well.
+
+ Given an engineering quaternion
+
+ QENG = ( q0, q1, q2, q3 )
+
+ the equivalent SPICE quaternion is
+
+ QSPICE = ( q3, -q0, -q1, -q2 )
+
+
+ Associating SPICE Quaternions with Rotation Matrices
+ ----------------------------------------------------
+
+ Let FROM and TO be two right-handed reference frames, for
+ example, an inertial frame and a spacecraft-fixed frame. Let the
+ symbols
+
+ V , V
+ FROM TO
+
+ denote, respectively, an arbitrary vector expressed relative to
+ the FROM and TO frames. Let M denote the transformation matrix
+ that transforms vectors from frame FROM to frame TO; then
+
+ V = M * V
+ TO FROM
+
+ where the expression on the right hand side represents left
+ multiplication of the vector by the matrix.
+
+ Then if the unit-length SPICE quaternion q represents M, where
+
+ q = (q0, q1, q2, q3)
+
+ the elements of M are derived from the elements of q as follows:
+
+ +- -+
+ | 2 2 |
+ | 1 - 2*( q2 + q3 ) 2*(q1*q2 - q0*q3) 2*(q1*q3 + q0*q2) |
+ | |
+ | |
+ | 2 2 |
+ M = | 2*(q1*q2 + q0*q3) 1 - 2*( q1 + q3 ) 2*(q2*q3 - q0*q1) |
+ | |
+ | |
+ | 2 2 |
+ | 2*(q1*q3 - q0*q2) 2*(q2*q3 + q0*q1) 1 - 2*( q1 + q2 ) |
+ | |
+ +- -+
+
+ Note that substituting the elements of -q for those of q in the
+ right hand side leaves each element of M unchanged; this shows
+ that if a quaternion q represents a matrix M, then so does the
+ quaternion -q.
+
+ To map the rotation matrix M to a unit quaternion, we start by
+ decomposing the rotation matrix as a sum of symmetric
+ and skew-symmetric parts:
+
+ 2
+ M = [ I + (1-cos(theta)) OMEGA ] + [ sin(theta) OMEGA ]
+
+ symmetric skew-symmetric
+
+
+ OMEGA is a skew-symmetric matrix of the form
+
+ +- -+
+ | 0 -n3 n2 |
+ | |
+ OMEGA = | n3 0 -n1 |
+ | |
+ | -n2 n1 0 |
+ +- -+
+
+ The vector N of matrix entries (n1, n2, n3) is the rotation axis
+ of M and theta is M's rotation angle. Note that N and theta
+ are not unique.
+
+ Let
+
+ C = cos(theta/2)
+ S = sin(theta/2)
+
+ Then the unit quaternions Q corresponding to M are
+
+ Q = +/- ( C, S*n1, S*n2, S*n3 )
+
+ The mappings between quaternions and the corresponding rotations
+ are carried out by the CSPICE routines
+
+ q2m_c {quaternion to matrix}
+ m2q_c {matrix to quaternion}
+
+ m2q_c always returns a quaternion with scalar part greater than
+ or equal to zero.
+
+
+ SPICE Quaternion Multiplication Formula
+ ---------------------------------------
+
+ Given a SPICE quaternion
+
+ Q = ( q0, q1, q2, q3 )
+
+ corresponding to rotation axis A and angle theta as above, we can
+ represent Q using "scalar + vector" notation as follows:
+
+ s = q0 = cos(theta/2)
+
+ v = ( q1, q2, q3 ) = sin(theta/2) * A
+
+ Q = s + v
+
+ Let Q1 and Q2 be SPICE quaternions with respective scalar
+ and vector parts s1, s2 and v1, v2:
+
+ Q1 = s1 + v1
+ Q2 = s2 + v2
+
+ We represent the dot product of v1 and v2 by
+
+
+
+ and the cross product of v1 and v2 by
+
+ v1 x v2
+
+ Then the SPICE quaternion product is
+
+ Q1*Q2 = s1*s2 - + s1*v2 + s2*v1 + (v1 x v2)
+
+ If Q1 and Q2 represent the rotation matrices M1 and M2
+ respectively, then the quaternion product
+
+ Q1*Q2
+
+ represents the matrix product
+
+ M1*M2
+
+
+-Examples
+
+ This example code fragment writes a type 3 C-kernel segment
+ for the Mars Global Surveyor spacecraft bus to a previously opened CK
+ file attached to HANDLE.
+
+ /.
+ Include CSPICE interface definitions.
+ ./
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Assume arrays of quaternions, angular velocities, and the
+ associated SCLK times are produced elsewhere. The software
+ that calls ckw03_c must then decide how to partition these
+ pointing instances into intervals over which linear
+ interpolation between adjacent points is valid.
+ ./
+ .
+ .
+ .
+
+ /.
+ The subroutine ckw03_c needs the following items for the
+ segment descriptor:
+
+ 1) SCLK limits of the segment.
+ 2) Instrument code.
+ 3) Reference frame.
+ 4) The angular velocity flag.
+
+ ./
+
+ begtim = sclk [ 0 ];
+ endtim = sclk [ nrec-1 ];
+
+ inst = -94000;
+ ref = "j2000";
+ avflag = SPICETRUE;
+
+ segid = "MGS spacecraft bus - data type 3";
+
+ /.
+ Write the segment.
+ ./
+ ckw03_c ( handle, begtim, endtim, inst, ref, avflag,
+ segid, nrec, sclkdp, quats, avvs, nints,
+ starts );
+ .
+ .
+ .
+ /.
+ After all segments are written, close the C-kernel.
+ ./
+ ckcls_c ( handle );
+
+
+-Restrictions
+
+ 1) The creator of the segment is given the responsibility for
+ determining whether it is reasonable to interpolate between
+ two given pointing values.
+
+ 2) This routine assumes that the rotation between adjacent
+ quaternions that are stored in the same interval has a
+ rotation angle of THETA radians, where
+
+ 0 < THETA < pi.
+ _
+
+ The routines that evaluate the data in the segment produced
+ by this routine cannot distinguish between rotations of THETA
+ radians, where THETA is in the interval [0, pi), and
+ rotations of
+
+ THETA + 2 * k * pi
+
+ radians, where k is any integer. These `large' rotations will
+ yield invalid results when interpolated. You must ensure that
+ the data stored in the segment will not be subject to this
+ sort of ambiguity.
+
+ 3) All pointing instances in the segment must belong to one and
+ only one of the intervals.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ K.R. Gehringer (JPL)
+ N.J. Bachman (JPL)
+ J.M. Lynch (JPL)
+ B.V. Semenov (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 2.0.0, 01-JUN-2010 (NJB)
+
+ The check for non-unit quaternions has been replaced
+ with a check for zero-length quaternions. (The
+ implementation of the check is located in ckw03_.)
+
+ -CSPICE Version 1.4.2, 27-FEB-2008 (NJB)
+
+ Updated header; added information about SPICE
+ quaternion conventions.
+
+ -CSPICE Version 1.4.1, 27-SEP-2005 (BVS)
+
+ Added an item for SPICE(TIMESDONTMATCH) exception to the
+ Exceptions section of the header.
+
+ -CSPICE Version 1.3.1, 07-JAN-2004 (EDW)
+
+ Trivial typo correction in index entries section.
+
+ -CSPICE Version 1.3.0, 28-AUG-2001 (NJB)
+
+ Changed prototype: inputs sclkdp, quats, avvs, and starts
+ are now const-qualified. Implemented interface macros for
+ casting these inputs to const.
+
+ -CSPICE Version 1.2.0, 02-SEP-1999 (NJB)
+
+ Local type logical variable now used for angular velocity
+ flag used in interface of ckw03_.
+
+ -CSPICE Version 1.1.0, 08-FEB-1998 (NJB)
+
+ References to C2F_CreateStr_Sig were removed; code was
+ cleaned up accordingly. String checks are now done using
+ the macro CHKFSTR.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (NJB)
+
+ Based on SPICELIB Version 2.0.0, 28-DEC-1993 (WLT)
+
+-Index_Entries
+
+ write ck type_3 pointing data segment
+
+-&
+*/
+
+{ /* Begin ckw03_c */
+
+
+
+ /*
+ Local variables
+ */
+ logical avf;
+
+
+ /*
+ Participate in error handling.
+ */
+ chkin_c ( "ckw03_c" );
+
+
+ /*
+ Check the input strings to make sure the pointers
+ are non-null and the string lengths are non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "ckw03_c", ref );
+ CHKFSTR ( CHK_STANDARD, "ckw03_c", segid );
+
+
+ /*
+ Get a type logical copy of the a.v. flag.
+ */
+ avf = avflag;
+
+
+ /*
+ Write the segment. Note that the quaternion and angular velocity
+ arrays DO NOT require transposition!
+ */
+
+ ckw03_( ( integer * ) &handle,
+ ( doublereal * ) &begtim,
+ ( doublereal * ) &endtim,
+ ( integer * ) &inst,
+ ( char * ) ref,
+ ( logical * ) &avf,
+ ( char * ) segid,
+ ( integer * ) &nrec,
+ ( doublereal * ) sclkdp,
+ ( doublereal * ) quats,
+ ( doublereal * ) avvs,
+ ( integer * ) &nints,
+ ( doublereal * ) starts,
+ ( ftnlen ) strlen(ref),
+ ( ftnlen ) strlen(segid) );
+
+
+ chkout_c ( "ckw03_c" );
+
+} /* End ckw03_c */
diff --git a/ext/spice/src/cspice/ckw04a.c b/ext/spice/src/cspice/ckw04a.c
new file mode 100644
index 0000000000..d4fcb40f98
--- /dev/null
+++ b/ext/spice/src/cspice/ckw04a.c
@@ -0,0 +1,764 @@
+/* ckw04a.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__142 = 142;
+static integer c__7 = 7;
+static doublereal c_b20 = 128.;
+
+/* $Procedure CKW04A ( CK type 04: Add data to a segment ) */
+/* Subroutine */ int ckw04a_(integer *handle, integer *npkts, integer *pktsiz,
+ doublereal *pktdat, doublereal *sclkdp)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer k;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer dispm, kk;
+ extern /* Subroutine */ int errhan_(char *, integer *, ftnlen);
+ integer displm;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ integer numcft[7];
+ extern /* Subroutine */ int chkout_(char *, ftnlen), setmsg_(char *,
+ ftnlen), errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int sgwvpk_(integer *, integer *, integer *,
+ doublereal *, integer *, doublereal *), zzck4i2d_(integer *,
+ integer *, doublereal *, doublereal *);
+
+/* $ Abstract */
+
+/* Add data to a type 4 CK segment currently being written to */
+/* the file associated with HANDLE. See also CKW04B and CKW04E. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+/* DAF.REQ */
+/* GS.REQ */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* Declarations of the CK data type specific and general CK low */
+/* level routine parameters. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* 1) If new CK types are added, the size of the record passed */
+/* between CKRxx and CKExx must be registered as separate */
+/* parameter. If this size will be greater than current value */
+/* of the CKMRSZ parameter (which specifies the maximum record */
+/* size for the record buffer used inside CKPFS) then it should */
+/* be assigned to CKMRSZ as a new value. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Literature_References */
+
+/* CK Required Reading. */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 19-AUG-2002 (NJB) */
+
+/* Updated to support CK type 5. */
+
+/* - SPICELIB Version 1.0.0, 05-APR-1999 (BVS) */
+
+/* -& */
+
+/* Number of quaternion components and number of quaternion and */
+/* angular rate components together. */
+
+
+/* CK Type 1 parameters: */
+
+/* CK1DTP CK data type 1 ID; */
+
+/* CK1RSZ maximum size of a record passed between CKR01 */
+/* and CKE01. */
+
+
+/* CK Type 2 parameters: */
+
+/* CK2DTP CK data type 2 ID; */
+
+/* CK2RSZ maximum size of a record passed between CKR02 */
+/* and CKE02. */
+
+
+/* CK Type 3 parameters: */
+
+/* CK3DTP CK data type 3 ID; */
+
+/* CK3RSZ maximum size of a record passed between CKR03 */
+/* and CKE03. */
+
+
+/* CK Type 4 parameters: */
+
+/* CK4DTP CK data type 4 ID; */
+
+/* CK4PCD parameter defining integer to DP packing schema that */
+/* is applied when seven number integer array containing */
+/* polynomial degrees for quaternion and angular rate */
+/* components packed into a single DP number stored in */
+/* actual CK records in a file; the value of must not be */
+/* changed or compatibility with existing type 4 CK files */
+/* will be lost. */
+
+/* CK4MXD maximum Chebychev polynomial degree allowed in type 4 */
+/* records; the value of this parameter must never exceed */
+/* value of the CK4PCD; */
+
+/* CK4SFT number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 4 */
+/* CK record that passed between routines CKR04 and CKE04; */
+
+/* CK4RSZ maximum size of type 4 CK record passed between CKR04 */
+/* and CKE04; CK4RSZ is computed as follows: */
+
+/* CK4RSZ = ( CK4MXD + 1 ) * QAVSIZ + CK4SFT */
+
+
+/* CK Type 5 parameters: */
+
+
+/* CK5DTP CK data type 5 ID; */
+
+/* CK5MXD maximum polynomial degree allowed in type 5 */
+/* records. */
+
+/* CK5MET number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 5 */
+/* CK record that passed between routines CKR05 and CKE05; */
+
+/* CK5MXP maximum packet size for any subtype. Subtype 2 */
+/* has the greatest packet size, since these packets */
+/* contain a quaternion, its derivative, an angular */
+/* velocity vector, and its derivative. See ck05.inc */
+/* for a description of the subtypes. */
+
+/* CK5RSZ maximum size of type 5 CK record passed between CKR05 */
+/* and CKE05; CK5RSZ is computed as follows: */
+
+/* CK5RSZ = ( CK5MXD + 1 ) * CK5MXP + CK5MET */
+
+
+
+/* Maximum record size that can be handled by CKPFS. This value */
+/* must be set to the maximum of all CKxRSZ parameters (currently */
+/* CK4RSZ.) */
+
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of an DAF file opened for writing. */
+/* NPKTS I Number of data packets to write to a segment. */
+/* PKTSIZ I The numbers of values in the data packets */
+/* PKTDAT I The data packets. */
+/* SCLKDP I The SCLK times associated with the data packets. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the file handle of a CK file in which a CK type 4 */
+/* segment is currently being written. */
+
+/* NPKTS is the number of data packets to write to a segment. */
+
+/* PKTSIZ is the number of values in all data packets. */
+
+/* PKTDAT is the data packets. The data packets in this array */
+/* must be organized as described in the $ Particulars */
+/* section of the header. */
+
+/* SCLKDP contains the initial SCLK times corresponding to the */
+/* Chebyshev coefficients in PKTSIZ. The I'th time is */
+/* start time of the I'th packet coverage interval. */
+/* The times must form a strictly increasing sequence. */
+
+/* $ Detailed_Output */
+
+/* None. Data is stored in a segment in the DAF file */
+/* associated with HANDLE. */
+
+/* $ Parameters */
+
+/* See 'ckparam.inc'. */
+
+/* $ Exceptions */
+
+/* 1) If the number of coefficient sets and epochs is not positive, */
+/* the error SPICE(INVALIDARGUMENT) will be signalled. */
+
+/* 2) If size of any input packet is greater that maximum allowed */
+/* type 4 CK record size minus one, the error */
+/* SPICE(INVALIDARGUMENT) will be signalled. */
+
+/* $ Files */
+
+/* See HANDLE in the $ Detailed_Input section. */
+
+/* $ Particulars */
+
+/* This routine adds data to a type 4 CK segment that is currently */
+/* being written to the associated with HANDLE. The segment must */
+/* have been started by a call to the routine CKW04B, the routine */
+/* which begins a type 4 CK segment. */
+
+/* This routine is one of a set of three routines for creating and */
+/* adding data to type 4 CK segments. These routines are: */
+
+/* CKW04B: Begin a type 4 CK segment. This routine must be */
+/* called before any data may be added to a type 4 */
+/* segment. */
+
+/* CKW04A: Add data to a type 4 CK segment. This routine may be */
+/* called any number of times after a call to CKW04B to */
+/* add type 4 records to the CK segment that was */
+/* started. */
+
+/* CKW04E: End a type 4 CK segment. This routine is called to */
+/* make the type 4 segment a permanent addition to the */
+/* DAF file. Once this routine is called, no further type */
+/* 4 records may be added to the segment. A new segment */
+/* must be started. */
+
+/* A type 4 CK segment consists of coefficient sets for variable */
+/* order Chebyshev polynomials over consecutive time intervals of a */
+/* variable length. The gaps between intervals are allowed. The */
+/* Chebyshev polynomials represent individual SPICE-style quaternion */
+/* components q0, q1, q2 and q3 and individual angular velocities */
+/* AV1, AV2 and AV3 if they are included with the data. */
+
+/* See the discussion of quaternion styles below. */
+
+/* The pointing data supplied to the type 4 CK writer (CKW04A) */
+/* is packed into an array as a sequence of records, */
+
+/* ---------------------------------------------------- */
+/* | Record 1 | Record 2 | .. | Record N-1 | Record N | */
+/* ---------------------------------------------------- */
+
+/* with each record in data packets has the following format. */
+
+/* ---------------------------------------------------- */
+/* | The midpoint of the approximation interval | */
+/* ---------------------------------------------------- */
+/* | The radius of the approximation interval | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for q0 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for q1 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for q2 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for q3 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for AV1 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for AV2 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for AV3 | */
+/* ---------------------------------------------------- */
+/* | q0 Cheby coefficients | */
+/* ---------------------------------------------------- */
+/* | q1 Cheby coefficients | */
+/* ---------------------------------------------------- */
+/* | q2 Cheby coefficients | */
+/* ---------------------------------------------------- */
+/* | q3 Cheby coefficients | */
+/* ---------------------------------------------------- */
+/* | AV1 Cheby coefficients (optional) | */
+/* ---------------------------------------------------- */
+/* | AV2 Cheby coefficients (optional) | */
+/* ---------------------------------------------------- */
+/* | AV3 Cheby coefficients (optional) | */
+/* ---------------------------------------------------- */
+
+
+
+/* Quaternion Styles */
+/* ----------------- */
+
+/* There are different "styles" of quaternions used in */
+/* science and engineering applications. Quaternion styles */
+/* are characterized by */
+
+/* - The order of quaternion elements */
+
+/* - The quaternion multiplication formula */
+
+/* - The convention for associating quaternions */
+/* with rotation matrices */
+
+/* Two of the commonly used styles are */
+
+/* - "SPICE" */
+
+/* > Invented by Sir William Rowan Hamilton */
+/* > Frequently used in mathematics and physics textbooks */
+
+/* - "Engineering" */
+
+/* > Widely used in aerospace engineering applications */
+
+
+/* SPICELIB subroutine interfaces ALWAYS use SPICE quaternions. */
+/* Quaternions of any other style must be converted to SPICE */
+/* quaternions before they are passed to SPICELIB routines. */
+
+
+/* Relationship between SPICE and Engineering Quaternions */
+/* ------------------------------------------------------ */
+
+/* Let M be a rotation matrix such that for any vector V, */
+
+/* M*V */
+
+/* is the result of rotating V by theta radians in the */
+/* counterclockwise direction about unit rotation axis vector A. */
+/* Then the SPICE quaternions representing M are */
+
+/* (+/-) ( cos(theta/2), */
+/* sin(theta/2) A(1), */
+/* sin(theta/2) A(2), */
+/* sin(theta/2) A(3) ) */
+
+/* while the engineering quaternions representing M are */
+
+/* (+/-) ( -sin(theta/2) A(1), */
+/* -sin(theta/2) A(2), */
+/* -sin(theta/2) A(3), */
+/* cos(theta/2) ) */
+
+/* For both styles of quaternions, if a quaternion q represents */
+/* a rotation matrix M, then -q represents M as well. */
+
+/* Given an engineering quaternion */
+
+/* QENG = ( q0, q1, q2, q3 ) */
+
+/* the equivalent SPICE quaternion is */
+
+/* QSPICE = ( q3, -q0, -q1, -q2 ) */
+
+
+/* Associating SPICE Quaternions with Rotation Matrices */
+/* ---------------------------------------------------- */
+
+/* Let FROM and TO be two right-handed reference frames, for */
+/* example, an inertial frame and a spacecraft-fixed frame. Let the */
+/* symbols */
+
+/* V , V */
+/* FROM TO */
+
+/* denote, respectively, an arbitrary vector expressed relative to */
+/* the FROM and TO frames. Let M denote the transformation matrix */
+/* that transforms vectors from frame FROM to frame TO; then */
+
+/* V = M * V */
+/* TO FROM */
+
+/* where the expression on the right hand side represents left */
+/* multiplication of the vector by the matrix. */
+
+/* Then if the unit-length SPICE quaternion q represents M, where */
+
+/* q = (q0, q1, q2, q3) */
+
+/* the elements of M are derived from the elements of q as follows: */
+
+/* +- -+ */
+/* | 2 2 | */
+/* | 1 - 2*( q2 + q3 ) 2*(q1*q2 - q0*q3) 2*(q1*q3 + q0*q2) | */
+/* | | */
+/* | | */
+/* | 2 2 | */
+/* M = | 2*(q1*q2 + q0*q3) 1 - 2*( q1 + q3 ) 2*(q2*q3 - q0*q1) | */
+/* | | */
+/* | | */
+/* | 2 2 | */
+/* | 2*(q1*q3 - q0*q2) 2*(q2*q3 + q0*q1) 1 - 2*( q1 + q2 ) | */
+/* | | */
+/* +- -+ */
+
+/* Note that substituting the elements of -q for those of q in the */
+/* right hand side leaves each element of M unchanged; this shows */
+/* that if a quaternion q represents a matrix M, then so does the */
+/* quaternion -q. */
+
+/* To map the rotation matrix M to a unit quaternion, we start by */
+/* decomposing the rotation matrix as a sum of symmetric */
+/* and skew-symmetric parts: */
+
+/* 2 */
+/* M = [ I + (1-cos(theta)) OMEGA ] + [ sin(theta) OMEGA ] */
+
+/* symmetric skew-symmetric */
+
+
+/* OMEGA is a skew-symmetric matrix of the form */
+
+/* +- -+ */
+/* | 0 -n3 n2 | */
+/* | | */
+/* OMEGA = | n3 0 -n1 | */
+/* | | */
+/* | -n2 n1 0 | */
+/* +- -+ */
+
+/* The vector N of matrix entries (n1, n2, n3) is the rotation axis */
+/* of M and theta is M's rotation angle. Note that N and theta */
+/* are not unique. */
+
+/* Let */
+
+/* C = cos(theta/2) */
+/* S = sin(theta/2) */
+
+/* Then the unit quaternions Q corresponding to M are */
+
+/* Q = +/- ( C, S*n1, S*n2, S*n3 ) */
+
+/* The mappings between quaternions and the corresponding rotations */
+/* are carried out by the SPICELIB routines */
+
+/* Q2M {quaternion to matrix} */
+/* M2Q {matrix to quaternion} */
+
+/* M2Q always returns a quaternion with scalar part greater than */
+/* or equal to zero. */
+
+
+/* SPICE Quaternion Multiplication Formula */
+/* --------------------------------------- */
+
+/* Given a SPICE quaternion */
+
+/* Q = ( q0, q1, q2, q3 ) */
+
+/* corresponding to rotation axis A and angle theta as above, we can */
+/* represent Q using "scalar + vector" notation as follows: */
+
+/* s = q0 = cos(theta/2) */
+
+/* v = ( q1, q2, q3 ) = sin(theta/2) * A */
+
+/* Q = s + v */
+
+/* Let Q1 and Q2 be SPICE quaternions with respective scalar */
+/* and vector parts s1, s2 and v1, v2: */
+
+/* Q1 = s1 + v1 */
+/* Q2 = s2 + v2 */
+
+/* We represent the dot product of v1 and v2 by */
+
+/* */
+
+/* and the cross product of v1 and v2 by */
+
+/* v1 x v2 */
+
+/* Then the SPICE quaternion product is */
+
+/* Q1*Q2 = s1*s2 - + s1*v2 + s2*v1 + (v1 x v2) */
+
+/* If Q1 and Q2 represent the rotation matrices M1 and M2 */
+/* respectively, then the quaternion product */
+
+/* Q1*Q2 */
+
+/* represents the matrix product */
+
+/* M1*M2 */
+
+
+/* $ Examples */
+
+/* Assume that we have: */
+
+/* HANDLE is the handle of an CK file opened with write */
+/* access. */
+
+/* SEGID is a character string of no more than 40 characters */
+/* which provides a pedigree for the data in the CK */
+/* segment we will create. */
+
+/* INST is the SPICE ID code for the instrument whose */
+/* pointing data is to be placed into the file. */
+
+/* AVFLAG angular rates flag. */
+
+/* REFFRM is the name of the SPICE reference frame for the */
+/* pointing data. */
+
+/* BEGTIM is the starting encoded SCLK time for which the */
+/* segment is valid. */
+
+/* ENDTIM is the ending encoded SCLK time for which the segment */
+/* is valid. */
+
+/* N is the number of type 4 records that we want to */
+/* put into a segment in an CK file. */
+
+/* NPKTS is integer array which contains the lengths of */
+/* variable size data packets */
+
+/* RECRDS contains N type 4 records packaged for the CK */
+/* file. */
+
+/* SCSTRT contains the initial encoded SC time for each of */
+/* the records contained in RECRDS, where */
+
+/* SCSTRT(I) < SCSTRT(I+1), I = 1, N-1 */
+
+/* SCSTRT(1) <= FIRST, SCSTRT(N) < LAST */
+
+/* Then the following code fragment demonstrates how to create */
+/* a type 4 CK segment if all of the data for the segment is */
+/* available at one time. */
+
+/* C */
+/* C Begin the segment. */
+/* C */
+/* CALL CKW04B ( HANDLE, BEGTIM, INST, REF, AVFLAG, SEGID ) */
+/* C */
+/* C Add the data to the segment all at once. */
+/* C */
+/* CALL CKW04A ( HANDLE, N, NPKTS, RECRDS, SCSTRT ) */
+/* C */
+/* C End the segment, making the segment a permanent */
+/* C addition to the CK file. */
+/* C */
+/* CALL CKW04E ( HANDLE, ENDTIM ) */
+
+/* $ Restrictions */
+
+/* 1) The type 4 CK segment to which the data is added must have */
+/* been started by the routine CKW04B, the routine which begins */
+/* a type 4 CK segment. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* Y.K. Zaiko (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1, 26-FEB-2008 (NJB) */
+
+/* Updated header; added information about SPICE */
+/* quaternion conventions. */
+
+/* - SPICELIB Version 1.1.0, 07-SEP-2001 (EDW) */
+
+/* Removed DAFHLU call; replaced ERRFNM call with ERRHAN. */
+/* Added IMPLICIT NONE. */
+
+/* - SPICELIB Version 1.0.0, 05-MAY-1999 (YKZ) (BVS) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* add data to a type_4 ck segment */
+
+/* -& */
+
+/* Spicelib functions. */
+
+
+/* Local parameters. */
+
+
+/* The number of elements by which coefficients in each packet */
+/* have to be shifted to the left after numbers of coefficients */
+/* were packed into a single integer. */
+
+
+/* Local Variables. */
+
+
+/* Standard SPICELIB error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKW04A", (ftnlen)6);
+ }
+
+/* First, check if the number of coefficient sets and epochs */
+/* is positive and whether each packet is smaller than the */
+/* maximum size of a record that CKPFS can handle. */
+
+ i__1 = *npkts;
+ for (k = 1; k <= i__1; ++k) {
+ if (pktsiz[k - 1] <= 0) {
+ setmsg_("The number of coefficient sets and epochs in the # data"
+ " packet (record) to be added to the DAF segment in the f"
+ "ile '#' was not positive. Its value was: #.", (ftnlen)154)
+ ;
+ errint_("#", &k, (ftnlen)1);
+ errhan_("#", handle, (ftnlen)1);
+ errint_("#", &pktsiz[k - 1], (ftnlen)1);
+ sigerr_("SPICE(INVALIDARGUMENT)", (ftnlen)22);
+ chkout_("CKW04A", (ftnlen)6);
+ return 0;
+ }
+
+/* We do .GE. comparison because a type 4 CK record passed */
+/* inside CKPFS will have one more element -- time at which */
+/* the pointing will be evaluated. */
+
+ if (pktsiz[k - 1] >= 143) {
+ setmsg_("The total size of the # data packet (record) to be adde"
+ "d to the DAF segment in the file '#' is greater than the"
+ " maximum allowed type 4 record size #. Its value was: #.",
+ (ftnlen)167);
+ errint_("#", &k, (ftnlen)1);
+ errhan_("#", handle, (ftnlen)1);
+ errint_("#", &c__142, (ftnlen)1);
+ errint_("#", &pktsiz[k - 1], (ftnlen)1);
+ sigerr_("SPICE(INVALIDARGUMENT)", (ftnlen)22);
+ chkout_("CKW04A", (ftnlen)6);
+ return 0;
+ }
+ }
+ displm = 0;
+ dispm = 0;
+
+/* The cycle below encodes groups of numbers of coefficients in */
+/* data packets to single double precision numbers and shift */
+/* data in packets to the left to decrease the data packet */
+/* lengths. */
+
+ i__1 = *npkts;
+ for (k = 1; k <= i__1; ++k) {
+
+/* Encode integer numbers of coefficients for each component */
+/* to single double precision variable */
+
+ for (kk = 1; kk <= 7; ++kk) {
+ numcft[(i__2 = kk - 1) < 7 && 0 <= i__2 ? i__2 : s_rnge("numcft",
+ i__2, "ckw04a_", (ftnlen)577)] = (integer) pktdat[kk + 2
+ + displm - 1];
+ }
+ zzck4i2d_(numcft, &c__7, &c_b20, &pktdat[dispm + 2]);
+
+/* Shift coefficients sets to the left to overwrite numbers of */
+/* packets */
+
+ i__2 = pktsiz[k - 1];
+ for (kk = 4; kk <= i__2; ++kk) {
+ pktdat[kk + dispm - 1] = pktdat[kk + 6 + displm - 1];
+ }
+
+/* Shift middle value and radii of interval */
+
+ pktdat[dispm] = pktdat[displm];
+ pktdat[dispm + 1] = pktdat[displm + 1];
+ displm += pktsiz[k - 1];
+
+/* Length of each data packet became less for 6 elements because */
+/* of encoding of 7 double precision numbers, which are the */
+/* numbers of polynomial coefficients, to one double precision */
+/* number */
+
+ pktsiz[k - 1] += -6;
+ dispm += pktsiz[k - 1];
+ }
+
+/* Add the data. */
+
+ sgwvpk_(handle, npkts, pktsiz, pktdat, npkts, sclkdp);
+
+/* No need to check FAILED() here, since all we do is check out. */
+/* Leave it up to the caller. */
+
+ chkout_("CKW04A", (ftnlen)6);
+ return 0;
+} /* ckw04a_ */
+
diff --git a/ext/spice/src/cspice/ckw04b.c b/ext/spice/src/cspice/ckw04b.c
new file mode 100644
index 0000000000..43e16666f7
--- /dev/null
+++ b/ext/spice/src/cspice/ckw04b.c
@@ -0,0 +1,948 @@
+/* ckw04b.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+static integer c__0 = 0;
+static integer c__3 = 3;
+
+/* $Procedure CKW04B ( CK type 04: Begin a segment ) */
+/* Subroutine */ int ckw04b_(integer *handle, doublereal *begtim, integer *
+ inst, char *ref, logical *avflag, char *segid, ftnlen ref_len, ftnlen
+ segid_len)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Local variables */
+ integer i__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafps_(integer *,
+ integer *, doublereal *, integer *, doublereal *);
+ doublereal descr[5];
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
+ integer value;
+ doublereal dcoeff;
+ integer refcod;
+ extern /* Subroutine */ int namfrm_(char *, integer *, ftnlen);
+ extern integer lastnb_(char *, ftnlen);
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), sgbwvs_(integer *, doublereal *,
+ char *, integer *, doublereal *, integer *, ftnlen);
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+
+/* $ Abstract */
+
+/* Begin a type CK04 segment in the DAF file associated with */
+/* HANDLE. See also CKW04A and CKW04E. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+/* DAF.REQ */
+/* GS.REQ */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+
+/* $ Abstract */
+
+/* Parameter declarations for the generic segments subroutines. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF Required Reading */
+
+/* $ Keywords */
+
+/* GENERIC SEGMENTS */
+
+/* $ Particulars */
+
+/* This include file contains the parameters used by the generic */
+/* segments subroutines, SGxxxx. A generic segment is a */
+/* generalization of a DAF array which places a particular structure */
+/* on the data contained in the array, as described below. */
+
+/* This file defines the mnemonics that are used for the index types */
+/* allowed in generic segments as well as mnemonics for the meta data */
+/* items which are used to describe a generic segment. */
+
+/* A DAF generic segment contains several logical data partitions: */
+
+/* 1) A partition for constant values to be associated with each */
+/* data packet in the segment. */
+
+/* 2) A partition for the data packets. */
+
+/* 3) A partition for reference values. */
+
+/* 4) A partition for a packet directory, if the segment contains */
+/* variable sized packets. */
+
+/* 5) A partition for a reference value directory. */
+
+/* 6) A reserved partition that is not currently used. This */
+/* partition is only for the use of the NAIF group at the Jet */
+/* Propulsion Laboratory (JPL). */
+
+/* 7) A partition for the meta data which describes the locations */
+/* and sizes of other partitions as well as providing some */
+/* additional descriptive information about the generic */
+/* segment. */
+
+/* +============================+ */
+/* | Constants | */
+/* +============================+ */
+/* | Packet 1 | */
+/* |----------------------------| */
+/* | Packet 2 | */
+/* |----------------------------| */
+/* | . | */
+/* | . | */
+/* | . | */
+/* |----------------------------| */
+/* | Packet N | */
+/* +============================+ */
+/* | Reference Values | */
+/* +============================+ */
+/* | Packet Directory | */
+/* +============================+ */
+/* | Reference Directory | */
+/* +============================+ */
+/* | Reserved Area | */
+/* +============================+ */
+/* | Segment Meta Data | */
+/* +----------------------------+ */
+
+/* Only the placement of the meta data at the end of a generic */
+/* segment is required. The other data partitions may occur in any */
+/* order in the generic segment because the meta data will contain */
+/* pointers to their appropriate locations within the generic */
+/* segment. */
+
+/* The meta data for a generic segment should only be obtained */
+/* through use of the subroutine SGMETA. The meta data should not be */
+/* written through any mechanism other than the ending of a generic */
+/* segment begun by SGBWFS or SGBWVS using SGWES. */
+
+/* $ Restrictions */
+
+/* 1) If new reference index types are added, the new type(s) should */
+/* be defined to be the consecutive integer(s) after the last */
+/* defined reference index type used. In this way a value for */
+/* the maximum allowed index type may be maintained. This value */
+/* must also be updated if new reference index types are added. */
+
+/* 2) If new meta data items are needed, mnemonics for them must be */
+/* added to the end of the current list of mnemonics and before */
+/* the NMETA mnemonic. In this way compatibility with files having */
+/* a different, but smaller, number of meta data items may be */
+/* maintained. See the description and example below. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+
+/* $ Literature_References */
+
+/* Generic Segments Required Reading. */
+/* DAF Required Reading. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1, 28-JAN-2004 (NJB) */
+
+/* Header update: equations for comptutations of packet indices */
+/* for the cases of index types 0 and 1 were corrected. */
+
+/* - SPICELIB Version 1.1.0, 25-09-98 (FST) */
+
+/* Added parameter MNMETA, the minimum number of meta data items */
+/* that must be present in a generic DAF segment. */
+
+/* - SPICELIB Version 1.0.0, 04-03-95 (KRG) (WLT) */
+
+/* -& */
+
+/* Mnemonics for the type of reference value index. */
+
+/* Two forms of indexing are provided: */
+
+/* 1) An implicit form of indexing based on using two values, a */
+/* starting value, which will have an index of 1, and a step */
+/* size between reference values, which are used to compute an */
+/* index and a reference value associated with a specified key */
+/* value. See the descriptions of the implicit types below for */
+/* the particular formula used in each case. */
+
+/* 2) An explicit form of indexing based on a reference value for */
+/* each data packet. */
+
+
+/* Reference Index Type 0 */
+/* ---------------------- */
+
+/* Implied index. The index and reference value of a data packet */
+/* associated with a specified key value are computed from the two */
+/* generic segment reference values using the formula below. The two */
+/* generic segment reference values, REF(1) and REF(2), represent, */
+/* respectively, a starting value and a step size between reference */
+/* values. The index of the data packet associated with a key value */
+/* of VALUE is given by: */
+
+/* / VALUE - REF(1) \ */
+/* INDEX = 1 + INT | -------------------- | */
+/* \ REF(2) / */
+
+/* and the reference value associated with VALUE is given by: */
+
+/* REFVAL = REF(1) + DBLE (INDEX-1) * REF(2) */
+
+
+/* Reference Index Type 1 */
+/* ---------------------- */
+
+/* Implied index. The index and reference value of a data packet */
+/* associated with a specified key value are computed from the two */
+/* generic segment reference values using the formula below. The two */
+/* generic segment reference values, REF(1) and REF(2), represent, */
+/* respectively, a starting value and a step size between reference */
+/* values. The index of the data packet associated with a key value */
+/* of VALUE is given by: */
+
+/* / VALUE - REF(1) \ */
+/* INDEX = 1 + INT | 0.5 + -------------------- | */
+/* \ REF(2) / */
+
+
+/* and the reference value associated with VALUE is given by: */
+
+/* REFVAL = REF(1) + DBLE (INDEX-1) * REF(2) */
+
+/* We get the larger index in the event that VALUE is halfway between */
+/* X(I) and X(I+1), where X(I) = BUFFER(1) + DBLE (I-1) * REFDAT(2). */
+
+
+/* Reference Index Type 2 */
+/* ---------------------- */
+
+/* Explicit index. In this case the number of packets must equal the */
+/* number of reference values. The index of the packet associated */
+/* with a key value of VALUE is the index of the last reference item */
+/* that is strictly less than VALUE. The reference values must be in */
+/* ascending order, REF(I) < REF(I+1). */
+
+
+/* Reference Index Type 3 */
+/* ---------------------- */
+
+/* Explicit index. In this case the number of packets must equal the */
+/* number of reference values. The index of the packet associated */
+/* with a key value of VALUE is the index of the last reference item */
+/* that is less than or equal to VALUE. The reference values must be */
+/* in ascending order, REF(I) < REF(I+1). */
+
+
+/* Reference Index Type 4 */
+/* ---------------------- */
+
+/* Explicit index. In this case the number of packets must equal the */
+/* number of reference values. The index of the packet associated */
+/* with a key value of VALUE is the index of the reference item */
+/* that is closest to the value of VALUE. In the event of a "tie" */
+/* the larger index is selected. The reference values must be in */
+/* ascending order, REF(I) < REF(I+1). */
+
+
+/* These parameters define the valid range for the index types. An */
+/* index type code, MYTYPE, for a generic segment must satisfy the */
+/* relation MNIDXT <= MYTYPE <= MXIDXT. */
+
+
+/* The following meta data items will appear in all generic segments. */
+/* Other meta data items may be added if a need arises. */
+
+/* 1) CONBAS Base Address of the constants in a generic segment. */
+
+/* 2) NCON Number of constants in a generic segment. */
+
+/* 3) RDRBAS Base Address of the reference directory for a */
+/* generic segment. */
+
+/* 4) NRDR Number of items in the reference directory of a */
+/* generic segment. */
+
+/* 5) RDRTYP Type of the reference directory 0, 1, 2 ... for a */
+/* generic segment. */
+
+/* 6) REFBAS Base Address of the reference items for a generic */
+/* segment. */
+
+/* 7) NREF Number of reference items in a generic segment. */
+
+/* 8) PDRBAS Base Address of the Packet Directory for a generic */
+/* segment. */
+
+/* 9) NPDR Number of items in the Packet Directory of a generic */
+/* segment. */
+
+/* 10) PDRTYP Type of the packet directory 0, 1, ... for a generic */
+/* segment. */
+
+/* 11) PKTBAS Base Address of the Packets for a generic segment. */
+
+/* 12) NPKT Number of Packets in a generic segment. */
+
+/* 13) RSVBAS Base Address of the Reserved Area in a generic */
+/* segment. */
+
+/* 14) NRSV Number of items in the reserved area of a generic */
+/* segment. */
+
+/* 15) PKTSZ Size of the packets for a segment with fixed width */
+/* data packets or the size of the largest packet for a */
+/* segment with variable width data packets. */
+
+/* 16) PKTOFF Offset of the packet data from the start of a packet */
+/* record. Each data packet is placed into a packet */
+/* record which may have some bookkeeping information */
+/* prepended to the data for use by the generic */
+/* segments software. */
+
+/* 17) NMETA Number of meta data items in a generic segment. */
+
+/* Meta Data Item 1 */
+/* ----------------- */
+
+
+/* Meta Data Item 2 */
+/* ----------------- */
+
+
+/* Meta Data Item 3 */
+/* ----------------- */
+
+
+/* Meta Data Item 4 */
+/* ----------------- */
+
+
+/* Meta Data Item 5 */
+/* ----------------- */
+
+
+/* Meta Data Item 6 */
+/* ----------------- */
+
+
+/* Meta Data Item 7 */
+/* ----------------- */
+
+
+/* Meta Data Item 8 */
+/* ----------------- */
+
+
+/* Meta Data Item 9 */
+/* ----------------- */
+
+
+/* Meta Data Item 10 */
+/* ----------------- */
+
+
+/* Meta Data Item 11 */
+/* ----------------- */
+
+
+/* Meta Data Item 12 */
+/* ----------------- */
+
+
+/* Meta Data Item 13 */
+/* ----------------- */
+
+
+/* Meta Data Item 14 */
+/* ----------------- */
+
+
+/* Meta Data Item 15 */
+/* ----------------- */
+
+
+/* Meta Data Item 16 */
+/* ----------------- */
+
+
+/* If new meta data items are to be added to this list, they should */
+/* be added above this comment block as described below. */
+
+/* INTEGER NEW1 */
+/* PARAMETER ( NEW1 = PKTOFF + 1 ) */
+
+/* INTEGER NEW2 */
+/* PARAMETER ( NEW2 = NEW1 + 1 ) */
+
+/* INTEGER NEWEST */
+/* PARAMETER ( NEWEST = NEW2 + 1 ) */
+
+/* and then the value of NMETA must be changed as well to be: */
+
+/* INTEGER NMETA */
+/* PARAMETER ( NMETA = NEWEST + 1 ) */
+
+/* Meta Data Item 17 */
+/* ----------------- */
+
+
+/* Maximum number of meta data items. This is always set equal to */
+/* NMETA. */
+
+
+/* Minimum number of meta data items that must be present in a DAF */
+/* generic segment. This number is to remain fixed even if more */
+/* meta data items are added for compatibility with old DAF files. */
+
+/* $ Abstract */
+
+/* Declarations of the CK data type specific and general CK low */
+/* level routine parameters. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* 1) If new CK types are added, the size of the record passed */
+/* between CKRxx and CKExx must be registered as separate */
+/* parameter. If this size will be greater than current value */
+/* of the CKMRSZ parameter (which specifies the maximum record */
+/* size for the record buffer used inside CKPFS) then it should */
+/* be assigned to CKMRSZ as a new value. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Literature_References */
+
+/* CK Required Reading. */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 19-AUG-2002 (NJB) */
+
+/* Updated to support CK type 5. */
+
+/* - SPICELIB Version 1.0.0, 05-APR-1999 (BVS) */
+
+/* -& */
+
+/* Number of quaternion components and number of quaternion and */
+/* angular rate components together. */
+
+
+/* CK Type 1 parameters: */
+
+/* CK1DTP CK data type 1 ID; */
+
+/* CK1RSZ maximum size of a record passed between CKR01 */
+/* and CKE01. */
+
+
+/* CK Type 2 parameters: */
+
+/* CK2DTP CK data type 2 ID; */
+
+/* CK2RSZ maximum size of a record passed between CKR02 */
+/* and CKE02. */
+
+
+/* CK Type 3 parameters: */
+
+/* CK3DTP CK data type 3 ID; */
+
+/* CK3RSZ maximum size of a record passed between CKR03 */
+/* and CKE03. */
+
+
+/* CK Type 4 parameters: */
+
+/* CK4DTP CK data type 4 ID; */
+
+/* CK4PCD parameter defining integer to DP packing schema that */
+/* is applied when seven number integer array containing */
+/* polynomial degrees for quaternion and angular rate */
+/* components packed into a single DP number stored in */
+/* actual CK records in a file; the value of must not be */
+/* changed or compatibility with existing type 4 CK files */
+/* will be lost. */
+
+/* CK4MXD maximum Chebychev polynomial degree allowed in type 4 */
+/* records; the value of this parameter must never exceed */
+/* value of the CK4PCD; */
+
+/* CK4SFT number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 4 */
+/* CK record that passed between routines CKR04 and CKE04; */
+
+/* CK4RSZ maximum size of type 4 CK record passed between CKR04 */
+/* and CKE04; CK4RSZ is computed as follows: */
+
+/* CK4RSZ = ( CK4MXD + 1 ) * QAVSIZ + CK4SFT */
+
+
+/* CK Type 5 parameters: */
+
+
+/* CK5DTP CK data type 5 ID; */
+
+/* CK5MXD maximum polynomial degree allowed in type 5 */
+/* records. */
+
+/* CK5MET number of additional DPs, which are not polynomial */
+/* coefficients, located at the beginning of a type 5 */
+/* CK record that passed between routines CKR05 and CKE05; */
+
+/* CK5MXP maximum packet size for any subtype. Subtype 2 */
+/* has the greatest packet size, since these packets */
+/* contain a quaternion, its derivative, an angular */
+/* velocity vector, and its derivative. See ck05.inc */
+/* for a description of the subtypes. */
+
+/* CK5RSZ maximum size of type 5 CK record passed between CKR05 */
+/* and CKE05; CK5RSZ is computed as follows: */
+
+/* CK5RSZ = ( CK5MXD + 1 ) * CK5MXP + CK5MET */
+
+
+
+/* Maximum record size that can be handled by CKPFS. This value */
+/* must be set to the maximum of all CKxRSZ parameters (currently */
+/* CK4RSZ.) */
+
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of an DAF file open for writing. */
+/* SEGID I The string to use for segment identifier. */
+/* INST I The NAIF ID code for the SC or instrument. */
+/* AVFLAG I The angular rates flag. */
+/* REF I The reference frame for this segment. */
+/* BEGTIM I The segment coverage start encoded SCLK time */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the file handle of a CK file that has been */
+/* opened for writing. */
+
+/* SEGID is the segment identifier. CK segment identifier */
+/* may contain up to 40 printing ASCII characters. */
+
+/* INST is the SPICE ID for the SC structure or instrument */
+/* whose orientation are to be recorded in a CK file. */
+
+/* AVFLAG angular rates flag indicates whether segment will */
+/* contain angular rate information. */
+
+/* REF is the name of a reference frame that pointing is */
+/* given with respect to, for example 'J2000'. */
+
+/* BEGTIM is the encoded SCLK time for the start of the segment */
+/* coverage. */
+
+/* $ Detailed_Output */
+
+/* None. The input data is used to create the segment summary */
+/* for the segment being started in the DAF file */
+/* associated with HANDLE. */
+
+/* See the $ Particulars section for details about the */
+/* structure of a type 4 CK segment. */
+
+/* $ Parameters */
+
+/* This subroutine makes use of parameters defined in the files */
+/* 'sgparam.inc' and 'ckparam.inc'. */
+
+/* $ Files */
+
+/* See HANDLE in the $ Detailed_Input section. */
+
+/* $ Exceptions */
+
+/* 1) File access errors are diagnosed by routines in the call tree */
+/* of this routine. */
+
+/* 2) If numeric ID for given reference frame cannot be resolved */
+/* from it's name SPICE(INVALIDREFFRAME) is signalled. */
+
+/* 2) If SEGID is more than 40 characters long, the error */
+/* SPICE(SEGIDTOOLONG) is signalled. */
+
+/* 3) If SEGID contains any nonprintable characters, the error */
+/* SPICE(NONPRINTABLECHARS) is signalled. */
+
+/* $ Particulars */
+
+/* This routine begins writing a type 4 CK segment to the open DAF */
+/* file that is associated with HANDLE. The file must have been */
+/* opened with write access. */
+
+/* This routine is one of a set of three routines for creating and */
+/* adding data to type 4 CK segments. These routines are: */
+
+/* CKW04B: Begin a type 4 CK segment. This routine must be */
+/* called before any data may be added to a type 4 */
+/* segment. */
+
+/* CKW04A: Add data to a type 4 CK segment. This routine may be */
+/* called any number of times after a call to CKW04B to */
+/* add type 4 records to the CK segment that was */
+/* started. */
+
+/* CKW04E: End a type 4 CK segment. This routine is called to */
+/* make the type 4 segment a permanent addition to the */
+/* DAF file. Once this routine is called, no further type */
+/* 4 records may be added to the segment. A new segment */
+/* must be started. */
+
+/* A type 4 CK segment consists of coefficient sets for variable */
+/* order Chebyshev polynomials over consecutive time intervals of */
+/* a variable length. The gaps between intervals are allowed. */
+/* The Chebyshev polynomials represent individual quaternion */
+/* components q0, q1, q2 and q3 and individual angular velocities */
+/* AV1, AV2 and AV3 if they are included with the data. */
+
+/* The pointing data supplied to the type 4 CK writer (CKW04A) */
+/* is packed into an array as a sequence of records, */
+
+/* ---------------------------------------------------- */
+/* | Record 1 | Record 2 | .. | Record N-1 | Record N | */
+/* ---------------------------------------------------- */
+
+/* with each record in data packets has the following format. */
+
+/* ---------------------------------------------------- */
+/* | The midpoint of the approximation interval | */
+/* ---------------------------------------------------- */
+/* | The radius of the approximation interval | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for q0 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for q1 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for q2 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for q3 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for AV1 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for AV2 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for AV3 | */
+/* ---------------------------------------------------- */
+/* | q0 Cheby coefficients | */
+/* ---------------------------------------------------- */
+/* | q1 Cheby coefficients | */
+/* ---------------------------------------------------- */
+/* | q2 Cheby coefficients | */
+/* ---------------------------------------------------- */
+/* | q3 Cheby coefficients | */
+/* ---------------------------------------------------- */
+/* | AV1 Cheby coefficients (optional) | */
+/* ---------------------------------------------------- */
+/* | AV2 Cheby coefficients (optional) | */
+/* ---------------------------------------------------- */
+/* | AV3 Cheby coefficients (optional) | */
+/* ---------------------------------------------------- */
+
+/* $ Examples */
+
+/* Assume that we have: */
+
+/* HANDLE is the handle of an CK file opened with write */
+/* access. */
+
+/* SEGID is a character string of no more than 40 characters */
+/* which provides a pedigree for the data in the CK */
+/* segment we will create. */
+
+/* INST is the SPICE ID code for the instrument whose */
+/* pointing data is to be placed into the file. */
+
+/* AVFLAG angular rates flag. */
+
+/* REFFRM is the name of the SPICE reference frame for the */
+/* pointing data. */
+
+/* BEGTIM is the starting encoded SCLK time for which the */
+/* segment is valid. */
+
+/* ENDTIM is the ending encoded SCLK time for which the segment */
+/* is valid. */
+
+/* N is the number of type 4 records that we want to */
+/* put into a segment in an CK file. */
+
+/* NPKTS is integer array which contains the lengths of */
+/* variable size data packets */
+
+/* RECRDS contains N type 4 records packaged for the CK */
+/* file. */
+
+/* SCSTRT contains the initial encoded SC time for each of */
+/* the records contained in RECRDS, where */
+
+/* SCSTRT(I) < SCSTRT(I+1), I = 1, N-1 */
+
+/* SCSTRT(1) <= FIRST, SCSTRT(N) < LAST */
+
+/* Then the following code fragment demonstrates how to create */
+/* a type 4 CK segment if all of the data for the segment is */
+/* available at one time. */
+
+/* C */
+/* C Begin the segment. */
+/* C */
+/* CALL CKW04B ( HANDLE, BEGTIM, INST, REF, AVFLAG, SEGID ) */
+/* C */
+/* C Add the data to the segment all at once. */
+/* C */
+/* CALL CKW04A ( HANDLE, N, NPKTS, RECRDS, SCSTRT ) */
+/* C */
+/* C End the segment, making the segment a permanent */
+/* C addition to the CK file. */
+/* C */
+/* CALL CKW04E ( HANDLE, ENDTIM ) */
+
+/* $ Restrictions */
+
+/* 1) The file containing the segment should be opened for read */
+/* or write access either by CKOPN or DAFOPW. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* Y.K. Zaiko (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 05-MAY-1999 (YKZ) (BVS) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* begin writing a type_4 CK segment */
+
+/* -& */
+
+/* Spicelib functions */
+
+
+/* Local Parameters */
+
+
+/* DAF ND and NI values for CK files and length of a DAF descriptor. */
+
+
+/* The number of generic segment constants in a type 4 CK segment. */
+
+
+/* The integer codes of the first and last printable ASCII */
+/* characters. */
+
+
+/* The maximum number of characters allowed in a CK segment */
+/* identifier. */
+
+
+/* Local variables */
+
+
+/* Standard SPICELIB error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKW04B", (ftnlen)6);
+ }
+
+/* Create a descriptor for the segment we are about to write. First */
+/* assign start and stop times. */
+
+ dcd[0] = *begtim;
+ dcd[1] = 0.;
+
+/* Second, resolve reference frame ID code from its name and */
+/* assign it to the corresponding descriptor component. Signal */
+/* an error if frame is not recognized. */
+
+ namfrm_(ref, &refcod, ref_len);
+ if (refcod == 0) {
+ setmsg_("The reference frame # is not supported.", (ftnlen)39);
+ errch_("#", ref, (ftnlen)1, ref_len);
+ sigerr_("SPICE(INVALIDREFFRAME)", (ftnlen)22);
+ chkout_("CKW04B", (ftnlen)6);
+ return 0;
+ }
+ icd[1] = refcod;
+
+/* Third, assign values to the rest of the integer components of */
+/* the segment descriptor. */
+
+ icd[0] = *inst;
+ icd[2] = 4;
+ if (*avflag) {
+ icd[3] = 1;
+ } else {
+ icd[3] = 0;
+ }
+
+/* Now pack the segment descriptor. */
+
+ dafps_(&c__2, &c__6, dcd, icd, descr);
+
+/* Check that all characters in the SEGID are printable. */
+
+ i__1 = lastnb_(segid, segid_len);
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ value = *(unsigned char *)&segid[i__ - 1];
+ if (value < 32 || value > 126) {
+ setmsg_("The segment identifier contains nonprintable characters",
+ (ftnlen)55);
+ sigerr_("SPICE(NONPRINTABLECHARS)", (ftnlen)24);
+ chkout_("CKW04B", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* Also check if the segment identifier is too long. */
+
+ if (lastnb_(segid, segid_len) > 40) {
+ setmsg_("Segment identifier contains more than 40 characters.", (
+ ftnlen)52);
+ sigerr_("SPICE(SEGIDTOOLONG)", (ftnlen)19);
+ chkout_("CKW04B", (ftnlen)6);
+ return 0;
+ }
+
+/* We've got a valid descriptor and identifier and can begin */
+/* the segment. For this data type, we want to use an explicit */
+/* reference value index where the reference epochs are in */
+/* increasing order. We also want the index returned for a */
+/* particular request epoch to be the index of the greatest */
+/* reference epoch less than or equal to the request epoch. These */
+/* characteristics are prescribed by the mnemonic EXPLE. See the */
+/* include file 'sgparam.inc' for more details. */
+
+ sgbwvs_(handle, descr, segid, &c__0, &dcoeff, &c__3, segid_len);
+
+/* No need to check FAILED() here, since all we do after this */
+/* point is checking out. */
+
+ chkout_("CKW04B", (ftnlen)6);
+ return 0;
+} /* ckw04b_ */
+
diff --git a/ext/spice/src/cspice/ckw04e.c b/ext/spice/src/cspice/ckw04e.c
new file mode 100644
index 0000000000..e709619d61
--- /dev/null
+++ b/ext/spice/src/cspice/ckw04e.c
@@ -0,0 +1,328 @@
+/* ckw04e.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__6 = 6;
+
+/* $Procedure CKW04E ( CK type 04: End a segment ) */
+/* Subroutine */ int ckw04e_(integer *handle, doublereal *endtim)
+{
+ extern /* Subroutine */ int dafgs_(doublereal *), chkin_(char *, ftnlen),
+ dafps_(integer *, integer *, doublereal *, integer *, doublereal *
+ ), dafrs_(doublereal *);
+ doublereal descr[5];
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *);
+ logical found;
+ extern /* Subroutine */ int sgwes_(integer *), dafbbs_(integer *),
+ daffpa_(logical *);
+ extern logical failed_(void);
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen);
+ extern logical return_(void);
+ doublereal dcd[2];
+ integer icd[6];
+
+/* $ Abstract */
+
+/* End the type 04 CK segment currently being written to the DAF */
+/* file associated with HANDLE. See also CKW04B and CKW04E. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK.REQ */
+/* DAF.REQ */
+/* GS.REQ */
+
+/* $ Keywords */
+
+/* POINTING */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of an CK file open for writing. */
+/* ENDTIM I The segment coverage end encoded SCLK time. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the file handle of an CK file that has been */
+/* opened for writing, and to which a type 4 CK segment */
+/* is being written. */
+
+/* ENDTIM is the encoded SCLK time for the end of the segment */
+/* coverage. */
+
+/* $ Detailed_Output */
+
+/* None. The type 4 segment in the DAF file associated with */
+/* HANDLE will be ended, making the addition of the */
+/* data to the file permanent. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See the argument HANDLE. */
+
+/* $ Exceptions */
+
+/* 1) Errors reading or writing the file indicated by HANDLE will */
+/* be diagnosed by routine in the call tree of this routine. */
+
+/* $ Particulars */
+
+/* This routine ends a type 4 CK segment which is being written to */
+/* the DAF file associated with HANDLE. Ending the DAF segment is a */
+/* necessary step in the process of making the data a permanent part */
+/* of the DAF file. */
+
+/* This routine is one of a set of three routines for creating and */
+/* adding data to type 4 CK segments. These routines are: */
+
+/* CKW04B: Begin a type 4 CK segment. This routine must be */
+/* called before any data may be added to a type 4 */
+/* segment. */
+
+/* CKW04A: Add data to a type 4 CK segment. This routine may be */
+/* called any number of times after a call to CKW04B to */
+/* add type 4 records to the CK segment that was */
+/* started. */
+
+/* CKW04E: End a type 4 CK segment. This routine is called to */
+/* make the type 4 segment a permanent addition to the */
+/* DAF file. Once this routine is called, no further type */
+/* 4 records may be added to the segment. A new segment */
+/* must be started. */
+
+/* A type 4 CK segment consists of coefficient sets for variable */
+/* order Chebyshev polynomials over consecutive time intervals of */
+/* a variable length. The gaps between intervals are allowed. */
+/* The Chebyshev polynomials represent individual quaternion */
+/* components q0, q1, q2 and q3 and individual angular velocities */
+/* AV1, AV2 and AV3 if they are included with the data. */
+
+/* The pointing data supplied to the type 4 CK writer (CKW04A) */
+/* is packed into an array as a sequence of records, */
+
+/* ---------------------------------------------------- */
+/* | Record 1 | Record 2 | .. | Record N-1 | Record N | */
+/* ---------------------------------------------------- */
+
+/* with each record in data packets has the following format. */
+
+/* ---------------------------------------------------- */
+/* | The midpoint of the approximation interval | */
+/* ---------------------------------------------------- */
+/* | The radius of the approximation interval | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for q0 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for q1 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for q2 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for q3 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for AV1 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for AV2 | */
+/* ---------------------------------------------------- */
+/* | Number of coefficients for AV3 | */
+/* ---------------------------------------------------- */
+/* | q0 Cheby coefficients | */
+/* ---------------------------------------------------- */
+/* | q1 Cheby coefficients | */
+/* ---------------------------------------------------- */
+/* | q2 Cheby coefficients | */
+/* ---------------------------------------------------- */
+/* | q3 Cheby coefficients | */
+/* ---------------------------------------------------- */
+/* | AV1 Cheby coefficients (optional) | */
+/* ---------------------------------------------------- */
+/* | AV2 Cheby coefficients (optional) | */
+/* ---------------------------------------------------- */
+/* | AV3 Cheby coefficients (optional) | */
+/* ---------------------------------------------------- */
+
+/* $ Examples */
+
+/* Assume that we have: */
+
+/* HANDLE is the handle of an CK file opened with write */
+/* access. */
+
+/* SEGID is a character string of no more than 40 characters */
+/* which provides a pedigree for the data in the CK */
+/* segment we will create. */
+
+/* INST is the SPICE ID code for the instrument whose */
+/* pointing data is to be placed into the file. */
+
+/* AVFLAG angular rates flag. */
+
+/* REFFRM is the name of the SPICE reference frame for the */
+/* pointing data. */
+
+/* BEGTIM is the starting encoded SCLK time for which the */
+/* segment is valid. */
+
+/* ENDTIM is the ending encoded SCLK time for which the segment */
+/* is valid. */
+
+/* N is the number of type 4 records that we want to */
+/* put into a segment in an CK file. */
+
+/* NPKTS is integer array which contains the lengths of */
+/* variable size data packets */
+
+/* RECRDS contains N type 4 records packaged for the CK */
+/* file. */
+
+/* SCSTRT contains the initial encoded SC time for each of */
+/* the records contained in RECRDS, where */
+
+/* SCSTRT(I) < SCSTRT(I+1), I = 1, N-1 */
+
+/* SCSTRT(1) <= FIRST, SCSTRT(N) < LAST */
+
+/* Then the following code fragment demonstrates how to create */
+/* a type 4 CK segment if all of the data for the segment is */
+/* available at one time. */
+
+/* C */
+/* C Begin the segment. */
+/* C */
+/* CALL CKW04B ( HANDLE, BEGTIM, INST, REF, AVFLAG, SEGID ) */
+/* C */
+/* C Add the data to the segment all at once. */
+/* C */
+/* CALL CKW04A ( HANDLE, N, NPKTS, RECRDS, SCSTRT ) */
+/* C */
+/* C End the segment, making the segment a permanent */
+/* C addition to the CK file. */
+/* C */
+/* CALL CKW04E ( HANDLE, ENDTIM ) */
+
+/* $ Restrictions */
+
+/* 1) The type 4 CK segment being closed must have been started by */
+/* the routine CKW04B, the routine which begins a type 4 CK */
+/* segment. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* Y.K. Zaiko (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 05-MAY-1999 (YKZ) (BVS) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* end a type_4 ck segment */
+
+/* -& */
+
+/* SPICELIB functions. */
+
+
+/* Local parameters. */
+
+
+/* DAF ND and NI values for CK files and length of a DAF descriptor. */
+
+
+/* Local variables. */
+
+
+/* Standard SPICELIB error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKW04E", (ftnlen)6);
+ }
+
+/* This is simple, just call the routine which ends a generic */
+/* segment. */
+
+ sgwes_(handle);
+ if (failed_()) {
+ chkout_("CKW04E", (ftnlen)6);
+ return 0;
+ }
+
+/* Now update the descriptor with the end time. Locate the segment */
+/* with a backward search. */
+
+ dafbbs_(handle);
+ daffpa_(&found);
+ if (! found) {
+
+/* We have a bug. */
+
+ setmsg_("The segment which was just written could not be found by a "
+ "DAF search. This indicates a serious error. Contact NAIF.",
+ (ftnlen)118);
+ sigerr_("SPICE(BUG)", (ftnlen)10);
+ chkout_("CKW04E", (ftnlen)6);
+ return 0;
+ }
+
+/* Get the descriptor, set the end time, and update the descriptor */
+/* in the file. */
+
+ dafgs_(descr);
+ dafus_(descr, &c__2, &c__6, dcd, icd);
+ dcd[1] = *endtim;
+ dafps_(&c__2, &c__6, dcd, icd, descr);
+ dafrs_(descr);
+
+/* All done. */
+
+ chkout_("CKW04E", (ftnlen)6);
+ return 0;
+} /* ckw04e_ */
+
diff --git a/ext/spice/src/cspice/ckw05.c b/ext/spice/src/cspice/ckw05.c
new file mode 100644
index 0000000000..f0ff062697
--- /dev/null
+++ b/ext/spice/src/cspice/ckw05.c
@@ -0,0 +1,1112 @@
+/* ckw05.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__4 = 4;
+static integer c__15 = 15;
+static integer c__2 = 2;
+static integer c__6 = 6;
+static integer c__1 = 1;
+
+/* $Procedure CKW05 ( Write CK segment, type 5 ) */
+/* Subroutine */ int ckw05_(integer *handle, integer *subtyp, integer *degree,
+ doublereal *begtim, doublereal *endtim, integer *inst, char *ref,
+ logical *avflag, char *segid, integer *n, doublereal *sclkdp,
+ doublereal *packts, doublereal *rate, integer *nints, doublereal *
+ starts, ftnlen ref_len, ftnlen segid_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+ doublereal d__1;
+
+ /* Local variables */
+ integer addr__, i__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafps_(integer *,
+ integer *, doublereal *, integer *, doublereal *);
+ doublereal descr[5];
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen),
+ errdp_(char *, doublereal *, ftnlen), dafada_(doublereal *,
+ integer *);
+ doublereal dc[2];
+ extern /* Subroutine */ int dafbna_(integer *, doublereal *, char *,
+ ftnlen);
+ integer ic[6];
+ extern /* Subroutine */ int dafena_(void);
+ extern logical failed_(void);
+ integer chrcod, refcod;
+ extern integer bsrchd_(doublereal *, integer *, doublereal *);
+ extern /* Subroutine */ int namfrm_(char *, integer *, ftnlen);
+ extern integer lastnb_(char *, ftnlen);
+ integer packsz;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern integer lstltd_(doublereal *, integer *, doublereal *);
+ extern logical vzerog_(doublereal *, integer *), return_(void);
+ integer winsiz;
+ extern logical odd_(integer *);
+
+/* $ Abstract */
+
+/* Write a type 5 segment to a CK file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+/* NAIF_IDS */
+/* ROTATION */
+/* TIME */
+
+/* $ Keywords */
+
+/* POINTING */
+/* FILES */
+
+/* $ Declarations */
+/* $ Abstract */
+
+/* Declare parameters specific to CK type 05. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CK */
+
+/* $ Keywords */
+
+/* CK */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 20-AUG-2002 (NJB) */
+
+/* -& */
+
+/* CK type 5 subtype codes: */
+
+
+/* Subtype 0: Hermite interpolation, 8-element packets. Quaternion */
+/* and quaternion derivatives only, no angular velocity */
+/* vector provided. Quaternion elements are listed */
+/* first, followed by derivatives. Angular velocity is */
+/* derived from the quaternions and quaternion */
+/* derivatives. */
+
+
+/* Subtype 1: Lagrange interpolation, 4-element packets. Quaternion */
+/* only. Angular velocity is derived by differentiating */
+/* the interpolating polynomials. */
+
+
+/* Subtype 2: Hermite interpolation, 14-element packets. */
+/* Quaternion and angular angular velocity vector, as */
+/* well as derivatives of each, are provided. The */
+/* quaternion comes first, then quaternion derivatives, */
+/* then angular velocity and its derivatives. */
+
+
+/* Subtype 3: Lagrange interpolation, 7-element packets. Quaternion */
+/* and angular velocity vector provided. The quaternion */
+/* comes first. */
+
+
+/* Packet sizes associated with the various subtypes: */
+
+
+/* End of file ck05.inc. */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of an CK file open for writing. */
+/* SUBTYP I CK type 5 subtype code. */
+/* DEGREE I Degree of interpolating polynomials. */
+/* BEGTIM I Start time of interval covered by segment. */
+/* ENDTIM I End time of interval covered by segment. */
+/* INST I NAIF code for a s/c instrument or structure. */
+/* REF I Reference frame name. */
+/* AVFLAG I True if the segment will contain angular velocity. */
+/* SEGID I Segment identifier. */
+/* N I Number of packets. */
+/* SCLKDP I Encoded SCLK times. */
+/* PACKTS I Array of packets. */
+/* RATE I Nominal SCLK rate in seconds per tick. */
+/* NINTS I Number of intervals. */
+/* STARTS I Encoded SCLK interval start times. */
+/* MAXDEG P Maximum allowed degree of interpolating polynomial. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the file handle of a CK file that has been */
+/* opened for writing. */
+
+/* SUBTYP is an integer code indicating the subtype of the */
+/* the segment to be created. */
+
+/* DEGREE is the degree of the polynomials used to */
+/* interpolate the quaternions contained in the input */
+/* packets. All components of the quaternions are */
+/* interpolated by polynomials of fixed degree. */
+
+/* BEGTIM, */
+/* ENDTIM are the beginning and ending encoded SCLK times */
+/* for which the segment provides pointing */
+/* information. BEGTIM must be less than or equal to */
+/* ENDTIM, and at least one data packet must have a */
+/* time tag T such that */
+
+/* BEGTIM < T < ENDTIM */
+/* - - */
+
+/* INST is the NAIF integer code for the instrument or */
+/* structure for which a segment is to be created. */
+
+/* REF is the NAIF name for a reference frame relative to */
+/* which the pointing information for INST is */
+/* specified. */
+
+/* AVFLAG is a logical flag which indicates whether or not */
+/* the segment will contain angular velocity. */
+
+/* SEGID is the segment identifier. A CK segment */
+/* identifier may contain up to 40 characters. */
+
+/* N is the number of packets in the input packet */
+/* array. */
+
+/* SCLKDP are the encoded spacecraft clock times associated */
+/* with each pointing instance. These times must be */
+/* strictly increasing. */
+
+/* PACKTS contains a time-ordered array of data packets */
+/* representing the orientation of INST relative to */
+/* the frame REF. Each packet contains a SPICE-style */
+/* quaternion and optionally, depending on the */
+/* segment subtype, attitude derivative data, from */
+/* which a C-matrix and an angular velocity vector */
+/* may be derived. */
+
+/* See the discussion of quaternion styles in */
+/* Particulars below. */
+
+/* The C-matrix represented by the Ith data packet is */
+/* a rotation matrix that transforms the components */
+/* of a vector expressed in the base frame specified */
+/* by REF to components expressed in the instrument */
+/* fixed frame at the time SCLKDP(I). */
+
+/* Thus, if a vector V has components x, y, z in the */
+/* base frame, then V has components x', y', z' */
+/* in the instrument fixed frame where: */
+
+/* [ x' ] [ ] [ x ] */
+/* | y' | = | CMAT | | y | */
+/* [ z' ] [ ] [ z ] */
+
+
+/* The attitude derivative information in PACKTS(I) */
+/* gives the angular velocity of the instrument fixed */
+/* frame at time SCLKDP(I) with respect to the */
+/* reference frame specified by REF. */
+
+/* The direction of an angular velocity vector gives */
+/* the right-handed axis about which the instrument */
+/* fixed reference frame is rotating. The magnitude */
+/* of the vector is the magnitude of the */
+/* instantaneous velocity of the rotation, in radians */
+/* per second. */
+
+/* Packet contents and the corresponding */
+/* interpolation methods depend on the segment */
+/* subtype, and are as follows: */
+
+/* Subtype 0: Hermite interpolation, 8-element */
+/* packets. Quaternion and quaternion */
+/* derivatives only, no angular */
+/* velocity vector provided. */
+/* Quaternion elements are listed */
+/* first, followed by derivatives. */
+/* Angular velocity is derived from */
+/* the quaternions and quaternion */
+/* derivatives. */
+
+/* Subtype 1: Lagrange interpolation, 4-element */
+/* packets. Quaternion only. Angular */
+/* velocity is derived by */
+/* differentiating the interpolating */
+/* polynomials. */
+
+/* Subtype 2: Hermite interpolation, 14-element */
+/* packets. Quaternion and angular */
+/* angular velocity vector, as well as */
+/* derivatives of each, are provided. */
+/* The quaternion comes first, then */
+/* quaternion derivatives, then */
+/* angular velocity and its */
+/* derivatives. */
+
+/* Subtype 3: Lagrange interpolation, 7-element */
+/* packets. Quaternion and angular */
+/* velocity vector provided. The */
+/* quaternion comes first. */
+
+/* Angular velocity is always specified relative to */
+/* the base frame. */
+
+/* RATE is the nominal rate of the spacecraft clock */
+/* associated with INST. Units are seconds per */
+/* tick. RATE is used to scale angular velocity */
+/* to radians/second. */
+
+/* NINTS is the number of intervals that the pointing */
+/* instances are partitioned into. */
+
+/* STARTS are the start times of each of the interpolation */
+/* intervals. These times must be strictly increasing */
+/* and must coincide with times for which the segment */
+/* contains pointing. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the effect of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* MAXDEG is the maximum allowed degree of the interpolating */
+/* polynomial. If the value of MAXDEG is increased, */
+/* the SPICELIB routine CKPFS must be changed */
+/* accordingly. In particular, the size of the */
+/* record passed to CKRnn and CKEnn must be */
+/* increased, and comments describing the record size */
+/* must be changed. */
+
+/* $ Exceptions */
+
+/* If any of the following exceptions occur, this routine will return */
+/* without creating a new segment. */
+
+/* 1) If HANDLE is not the handle of a C-kernel opened for writing */
+/* the error will be diagnosed by routines called by this */
+/* routine. */
+
+/* 2) If the last non-blank character of SEGID occurs past index 40, */
+/* the error SPICE(SEGIDTOOLONG) is signaled. */
+
+/* 3) If SEGID contains any nonprintable characters, the error */
+/* SPICE(NONPRINTABLECHARS) is signaled. */
+
+/* 4) If the first encoded SCLK time is negative then the error */
+/* SPICE(INVALIDSCLKTIME) is signaled. If any subsequent times */
+/* are negative the error will be detected in exception (5). */
+
+/* 5) If the encoded SCLK times are not strictly increasing, */
+/* the error SPICE(TIMESOUTOFORDER) is signaled. */
+
+/* 6) If the name of the reference frame is not one of those */
+/* supported by the routine FRAMEX, the error */
+/* SPICE(INVALIDREFFRAME) is signaled. */
+
+/* 7) If the number of packets N is not at least 1, the error */
+/* SPICE(TOOFEWPACKETS) will be signaled. */
+
+/* 8) If NINTS, the number of interpolation intervals, is less than */
+/* or equal to 0, the error SPICE(INVALIDNUMINTS) is signaled. */
+
+/* 9) If the encoded SCLK interval start times are not strictly */
+/* increasing, the error SPICE(TIMESOUTOFORDER) is signaled. */
+
+/* 10) If an interval start time does not coincide with a time for */
+/* which there is an actual pointing instance in the segment, */
+/* then the error SPICE(INVALIDSTARTTIME) is signaled. */
+
+/* 11) This routine assumes that the rotation between adjacent */
+/* quaternions that are stored in the same interval has a */
+/* rotation angle of THETA radians, where */
+
+/* 0 < THETA < pi. */
+/* _ */
+
+/* The routines that evaluate the data in the segment produced */
+/* by this routine cannot distinguish between rotations of THETA */
+/* radians, where THETA is in the interval [0, pi), and */
+/* rotations of */
+
+/* THETA + 2 * k * pi */
+
+/* radians, where k is any integer. These "large" rotations will */
+/* yield invalid results when interpolated. You must ensure that */
+/* the data stored in the segment will not be subject to this */
+/* sort of ambiguity. */
+
+/* 12) If any quaternion has magnitude zero, the error */
+/* SPICE(ZEROQUATERNION) is signaled. */
+
+/* 13) If the interpolation window size implied by DEGREE is not */
+/* even, the error SPICE(INVALIDDEGREE) is signaled. The window */
+/* size is DEGREE+1 for Lagrange subtypes and is (DEGREE+1)/2 */
+/* for Hermite subtypes. */
+
+/* 14) If an unrecognized subtype code is supplied, the error */
+/* SPICE(NOTSUPPORTED) is signaled. */
+
+/* 15) If DEGREE is not at least 1 or is greater than MAXDEG, the */
+/* error SPICE(INVALIDDEGREE) is signaled. */
+
+/* 16) If the segment descriptor bounds are out of order, the */
+/* error SPICE(BADDESCRTIMES) is signaled. */
+
+/* 17) If there is no element of SCLKDP that lies between BEGTIM and */
+/* ENDTIM inclusive, the error SPICE(EMPTYSEGMENT) is signaled. */
+
+/* 18) If RATE is zero, the error SPICE(INVALIDVALUE) is signaled. */
+
+
+/* $ Files */
+
+/* A new type 5 CK segment is written to the CK file attached */
+/* to HANDLE. */
+
+/* $ Particulars */
+
+/* This routine writes a CK type 5 data segment to the open CK */
+/* file according to the format described in the type 5 section of */
+/* the CK Required Reading. The CK file must have been opened with */
+/* write access. */
+
+
+/* Quaternion Styles */
+/* ----------------- */
+
+/* There are different "styles" of quaternions used in */
+/* science and engineering applications. Quaternion styles */
+/* are characterized by */
+
+/* - The order of quaternion elements */
+
+/* - The quaternion multiplication formula */
+
+/* - The convention for associating quaternions */
+/* with rotation matrices */
+
+/* Two of the commonly used styles are */
+
+/* - "SPICE" */
+
+/* > Invented by Sir William Rowan Hamilton */
+/* > Frequently used in mathematics and physics textbooks */
+
+/* - "Engineering" */
+
+/* > Widely used in aerospace engineering applications */
+
+
+/* SPICELIB subroutine interfaces ALWAYS use SPICE quaternions. */
+/* Quaternions of any other style must be converted to SPICE */
+/* quaternions before they are passed to SPICELIB routines. */
+
+
+/* Relationship between SPICE and Engineering Quaternions */
+/* ------------------------------------------------------ */
+
+/* Let M be a rotation matrix such that for any vector V, */
+
+/* M*V */
+
+/* is the result of rotating V by theta radians in the */
+/* counterclockwise direction about unit rotation axis vector A. */
+/* Then the SPICE quaternions representing M are */
+
+/* (+/-) ( cos(theta/2), */
+/* sin(theta/2) A(1), */
+/* sin(theta/2) A(2), */
+/* sin(theta/2) A(3) ) */
+
+/* while the engineering quaternions representing M are */
+
+/* (+/-) ( -sin(theta/2) A(1), */
+/* -sin(theta/2) A(2), */
+/* -sin(theta/2) A(3), */
+/* cos(theta/2) ) */
+
+/* For both styles of quaternions, if a quaternion q represents */
+/* a rotation matrix M, then -q represents M as well. */
+
+/* Given an engineering quaternion */
+
+/* QENG = ( q0, q1, q2, q3 ) */
+
+/* the equivalent SPICE quaternion is */
+
+/* QSPICE = ( q3, -q0, -q1, -q2 ) */
+
+
+/* Associating SPICE Quaternions with Rotation Matrices */
+/* ---------------------------------------------------- */
+
+/* Let FROM and TO be two right-handed reference frames, for */
+/* example, an inertial frame and a spacecraft-fixed frame. Let the */
+/* symbols */
+
+/* V , V */
+/* FROM TO */
+
+/* denote, respectively, an arbitrary vector expressed relative to */
+/* the FROM and TO frames. Let M denote the transformation matrix */
+/* that transforms vectors from frame FROM to frame TO; then */
+
+/* V = M * V */
+/* TO FROM */
+
+/* where the expression on the right hand side represents left */
+/* multiplication of the vector by the matrix. */
+
+/* Then if the unit-length SPICE quaternion q represents M, where */
+
+/* q = (q0, q1, q2, q3) */
+
+/* the elements of M are derived from the elements of q as follows: */
+
+/* +- -+ */
+/* | 2 2 | */
+/* | 1 - 2*( q2 + q3 ) 2*(q1*q2 - q0*q3) 2*(q1*q3 + q0*q2) | */
+/* | | */
+/* | | */
+/* | 2 2 | */
+/* M = | 2*(q1*q2 + q0*q3) 1 - 2*( q1 + q3 ) 2*(q2*q3 - q0*q1) | */
+/* | | */
+/* | | */
+/* | 2 2 | */
+/* | 2*(q1*q3 - q0*q2) 2*(q2*q3 + q0*q1) 1 - 2*( q1 + q2 ) | */
+/* | | */
+/* +- -+ */
+
+/* Note that substituting the elements of -q for those of q in the */
+/* right hand side leaves each element of M unchanged; this shows */
+/* that if a quaternion q represents a matrix M, then so does the */
+/* quaternion -q. */
+
+/* To map the rotation matrix M to a unit quaternion, we start by */
+/* decomposing the rotation matrix as a sum of symmetric */
+/* and skew-symmetric parts: */
+
+/* 2 */
+/* M = [ I + (1-cos(theta)) OMEGA ] + [ sin(theta) OMEGA ] */
+
+/* symmetric skew-symmetric */
+
+
+/* OMEGA is a skew-symmetric matrix of the form */
+
+/* +- -+ */
+/* | 0 -n3 n2 | */
+/* | | */
+/* OMEGA = | n3 0 -n1 | */
+/* | | */
+/* | -n2 n1 0 | */
+/* +- -+ */
+
+/* The vector N of matrix entries (n1, n2, n3) is the rotation axis */
+/* of M and theta is M's rotation angle. Note that N and theta */
+/* are not unique. */
+
+/* Let */
+
+/* C = cos(theta/2) */
+/* S = sin(theta/2) */
+
+/* Then the unit quaternions Q corresponding to M are */
+
+/* Q = +/- ( C, S*n1, S*n2, S*n3 ) */
+
+/* The mappings between quaternions and the corresponding rotations */
+/* are carried out by the SPICELIB routines */
+
+/* Q2M {quaternion to matrix} */
+/* M2Q {matrix to quaternion} */
+
+/* M2Q always returns a quaternion with scalar part greater than */
+/* or equal to zero. */
+
+
+/* SPICE Quaternion Multiplication Formula */
+/* --------------------------------------- */
+
+/* Given a SPICE quaternion */
+
+/* Q = ( q0, q1, q2, q3 ) */
+
+/* corresponding to rotation axis A and angle theta as above, we can */
+/* represent Q using "scalar + vector" notation as follows: */
+
+/* s = q0 = cos(theta/2) */
+
+/* v = ( q1, q2, q3 ) = sin(theta/2) * A */
+
+/* Q = s + v */
+
+/* Let Q1 and Q2 be SPICE quaternions with respective scalar */
+/* and vector parts s1, s2 and v1, v2: */
+
+/* Q1 = s1 + v1 */
+/* Q2 = s2 + v2 */
+
+/* We represent the dot product of v1 and v2 by */
+
+/* */
+
+/* and the cross product of v1 and v2 by */
+
+/* v1 x v2 */
+
+/* Then the SPICE quaternion product is */
+
+/* Q1*Q2 = s1*s2 - + s1*v2 + s2*v1 + (v1 x v2) */
+
+/* If Q1 and Q2 represent the rotation matrices M1 and M2 */
+/* respectively, then the quaternion product */
+
+/* Q1*Q2 */
+
+/* represents the matrix product */
+
+/* M1*M2 */
+
+
+/* $ Examples */
+
+/* Suppose that you have data packets and are prepared to produce */
+/* a segment of type 5 in a CK file. */
+
+/* The following code fragment could be used to add the new segment */
+/* to a previously opened CK file attached to HANDLE. The file must */
+/* have been opened with write access. */
+
+/* C */
+/* C Create a segment identifier. */
+/* C */
+/* SEGID = 'MY_SAMPLE_CK_TYPE_5_SEGMENT' */
+
+/* C */
+/* C Write the segment. */
+/* C */
+/* CALL CKW05 ( HANDLE, SUBTYP, DEGREE, BEGTIM, ENDTIM, */
+/* . INST, REF, AVFLAG, SEGID, N, */
+/* . SCLKDP, PACKTS, RATE, NINTS, STARTS ) */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* K.R. Gehringer (JPL) */
+/* J.M. Lynch (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 08-FEB-2010 (NJB) */
+
+/* The check for non-unit quaternions has been replaced */
+/* with a check for zero-length quaternions. */
+
+/* - SPICELIB Version 1.1.0, 26-FEB-2008 (NJB) */
+
+/* Updated header; added information about SPICE */
+/* quaternion conventions. */
+
+/* Minor typo in a long error message was corrected. */
+
+/* - SPICELIB Version 1.0.1, 07-JAN-2005 (NJB) */
+
+/* Description in Detailed_Input header section of */
+/* constraints on BEGTIM and ENDTIM was corrected. */
+
+/* - SPICELIB Version 1.0.0, 30-AUG-2002 (NJB) (KRG) (JML) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write ck type_5 data segment */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 08-FEB-2010 (NJB) */
+
+/* The check for non-unit quaternions has been replaced */
+/* with a check for zero-length quaternions. */
+
+/* This change was made to accommodate CK generation, */
+/* via the non-SPICE utility MEX2KER, for European missions. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Packet structure parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CKW05", (ftnlen)5);
+ }
+
+/* Make sure that the number of packets is positive. */
+
+ if (*n < 1) {
+ setmsg_("At least 1 packet is required for CK type 5. Number of pack"
+ "ets supplied: #", (ftnlen)75);
+ errint_("#", n, (ftnlen)1);
+ sigerr_("SPICE(TOOFEWPACKETS)", (ftnlen)20);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+
+/* Make sure that there is a positive number of interpolation */
+/* intervals. */
+
+ if (*nints <= 0) {
+ setmsg_("# is an invalid number of interpolation intervals for type "
+ "5.", (ftnlen)61);
+ errint_("#", nints, (ftnlen)1);
+ sigerr_("SPICE(INVALIDNUMINTS)", (ftnlen)21);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+
+/* Get the NAIF integer code for the reference frame. */
+
+ namfrm_(ref, &refcod, ref_len);
+ if (refcod == 0) {
+ setmsg_("The reference frame # is not supported.", (ftnlen)39);
+ errch_("#", ref, (ftnlen)1, ref_len);
+ sigerr_("SPICE(INVALIDREFFRAME)", (ftnlen)22);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the segment identifier is too long. */
+
+ if (lastnb_(segid, segid_len) > 40) {
+ setmsg_("Segment identifier contains more than 40 characters.", (
+ ftnlen)52);
+ sigerr_("SPICE(SEGIDTOOLONG)", (ftnlen)19);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+
+/* Now check that all the characters in the segment identifier */
+/* can be printed. */
+
+ i__1 = lastnb_(segid, segid_len);
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ chrcod = *(unsigned char *)&segid[i__ - 1];
+ if (chrcod < 32 || chrcod > 126) {
+ setmsg_("The segment identifier contains nonprintable characters",
+ (ftnlen)55);
+ sigerr_("SPICE(NONPRINTABLECHARS)", (ftnlen)24);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Now check that the encoded SCLK times are positive and strictly */
+/* increasing. */
+
+/* Check that the first time is nonnegative. */
+
+ if (sclkdp[0] < 0.) {
+ setmsg_("The first SCLKDP time: # is negative.", (ftnlen)37);
+ errdp_("#", sclkdp, (ftnlen)1);
+ sigerr_("SPICE(INVALIDSCLKTIME)", (ftnlen)22);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+
+/* Now check that the times are ordered properly. */
+
+ i__1 = *n;
+ for (i__ = 2; i__ <= i__1; ++i__) {
+ if (sclkdp[i__ - 1] <= sclkdp[i__ - 2]) {
+ setmsg_("The SCLKDP times are not strictly increasing. SCLKDP(#)"
+ " = # and SCLKDP(#) = #.", (ftnlen)78);
+ errint_("#", &i__, (ftnlen)1);
+ errdp_("#", &sclkdp[i__ - 1], (ftnlen)1);
+ i__2 = i__ - 1;
+ errint_("#", &i__2, (ftnlen)1);
+ errdp_("#", &sclkdp[i__ - 2], (ftnlen)1);
+ sigerr_("SPICE(TIMESOUTOFORDER)", (ftnlen)22);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Now check that the interval start times are ordered properly. */
+
+ i__1 = *nints;
+ for (i__ = 2; i__ <= i__1; ++i__) {
+ if (starts[i__ - 1] <= starts[i__ - 2]) {
+ setmsg_("The interval start times are not strictly increasing. S"
+ "TARTS(#) = # and STARTS(#) = #.", (ftnlen)86);
+ errint_("#", &i__, (ftnlen)1);
+ errdp_("#", &starts[i__ - 1], (ftnlen)1);
+ i__2 = i__ - 1;
+ errint_("#", &i__2, (ftnlen)1);
+ errdp_("#", &starts[i__ - 2], (ftnlen)1);
+ sigerr_("SPICE(TIMESOUTOFORDER)", (ftnlen)22);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Now make sure that all of the interval start times coincide with */
+/* one of the times associated with the actual pointing. */
+
+ i__1 = *nints;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+
+/* We know the SCLKDP array is ordered, so a binary search is */
+/* ok. */
+
+ if (bsrchd_(&starts[i__ - 1], n, sclkdp) == 0) {
+ setmsg_("Interval start time number # is invalid. STARTS(#) = *",
+ (ftnlen)54);
+ errint_("#", &i__, (ftnlen)1);
+ errint_("#", &i__, (ftnlen)1);
+ errdp_("*", &starts[i__ - 1], (ftnlen)1);
+ sigerr_("SPICE(INVALIDSTARTTIME)", (ftnlen)23);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Set the window, packet size and angular velocity flag, all of */
+/* which are functions of the subtype. */
+
+ if (*subtyp == 0) {
+ winsiz = (*degree + 1) / 2;
+ packsz = 8;
+ } else if (*subtyp == 1) {
+ winsiz = *degree + 1;
+ packsz = 4;
+ } else if (*subtyp == 2) {
+ winsiz = (*degree + 1) / 2;
+ packsz = 14;
+ } else if (*subtyp == 3) {
+ winsiz = *degree + 1;
+ packsz = 7;
+ } else {
+ setmsg_("CK type 5 subtype <#> is not supported.", (ftnlen)39);
+ errint_("#", subtyp, (ftnlen)1);
+ sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+
+/* Make sure that the quaternions are non-zero. This is just */
+/* a check for uninitialized data. */
+
+ i__1 = *n;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+
+/* We have to address the quaternion explicitly, since the shape */
+/* of the packet array is not known at compile time. */
+
+ addr__ = packsz * (i__ - 1) + 1;
+ if (vzerog_(&packts[addr__ - 1], &c__4)) {
+ setmsg_("The quaternion at index # has magnitude zero.", (ftnlen)
+ 45);
+ errint_("#", &i__, (ftnlen)1);
+ sigerr_("SPICE(ZEROQUATERNION)", (ftnlen)21);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Make sure that the degree of the interpolating polynomials is */
+/* in range. */
+
+ if (*degree < 1 || *degree > 15) {
+ setmsg_("The interpolating polynomials have degree #; the valid degr"
+ "ee range is [1, #]", (ftnlen)77);
+ errint_("#", degree, (ftnlen)1);
+ errint_("#", &c__15, (ftnlen)1);
+ sigerr_("SPICE(INVALIDDEGREE)", (ftnlen)20);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+
+/* Make sure that the window size is even. If not, the input */
+/* DEGREE is incompatible with the subtype. */
+
+ if (odd_(&winsiz)) {
+ setmsg_("The interpolating polynomials have degree #; for CK type 5,"
+ " the degree must be equivalent to 3 mod 4 for Hermite interp"
+ "olation and odd for for Lagrange interpolation.", (ftnlen)166)
+ ;
+ errint_("#", degree, (ftnlen)1);
+ sigerr_("SPICE(INVALIDDEGREE)", (ftnlen)20);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+
+/* If we made it this far, we're ready to start writing the segment. */
+
+/* Create the segment descriptor. */
+
+/* Assign values to the integer components of the segment descriptor. */
+
+ ic[0] = *inst;
+ ic[1] = refcod;
+ ic[2] = 5;
+ if (*avflag) {
+ ic[3] = 1;
+ } else {
+ ic[3] = 0;
+ }
+ dc[0] = *begtim;
+ dc[1] = *endtim;
+
+/* Make sure the descriptor times are in increasing order. */
+
+ if (*endtim < *begtim) {
+ setmsg_("Descriptor bounds are non-increasing: #:#", (ftnlen)41);
+ errdp_("#", begtim, (ftnlen)1);
+ errdp_("#", endtim, (ftnlen)1);
+ sigerr_("SPICE(BADDESCRTIMES)", (ftnlen)20);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+
+/* Make sure that at least one time tag lies between BEGTIM and */
+/* ENDTIM. The first time tag not less than BEGTIM must exist */
+/* and must be less than or equal to ENDTIM. */
+
+ i__ = lstltd_(begtim, n, sclkdp);
+ if (i__ == *n) {
+ setmsg_("All time tags are less than segment start time #.", (ftnlen)
+ 49);
+ errdp_("#", begtim, (ftnlen)1);
+ sigerr_("SPICE(EMPTYSEGMENT)", (ftnlen)19);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ } else if (sclkdp[i__] > *endtim) {
+ setmsg_("No time tags lie between the segment start time # and segme"
+ "nt end time #", (ftnlen)72);
+ errdp_("#", begtim, (ftnlen)1);
+ errdp_("#", endtim, (ftnlen)1);
+ sigerr_("SPICE(EMPTYSEGMENT)", (ftnlen)19);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+
+/* The clock rate must be non-zero. */
+
+ if (*rate == 0.) {
+ setmsg_("The SCLK rate RATE was zero.", (ftnlen)28);
+ sigerr_("SPICE(INVALIDVALUE)", (ftnlen)19);
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+
+/* Now pack the segment descriptor. */
+
+ dafps_(&c__2, &c__6, dc, ic, descr);
+
+/* Begin a new segment. */
+
+ dafbna_(handle, descr, segid, segid_len);
+ if (failed_()) {
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+ }
+
+/* The type 5 segment structure is eloquently described by this */
+/* diagram from the CK Required Reading: */
+
+/* +-----------------------+ */
+/* | Packet 1 | */
+/* +-----------------------+ */
+/* | Packet 2 | */
+/* +-----------------------+ */
+/* . */
+/* . */
+/* . */
+/* +-----------------------+ */
+/* | Packet N | */
+/* +-----------------------+ */
+/* | Epoch 1 | */
+/* +-----------------------+ */
+/* | Epoch 2 | */
+/* +-----------------------+ */
+/* . */
+/* . */
+/* . */
+/* +----------------------------+ */
+/* | Epoch N | */
+/* +----------------------------+ */
+/* | Epoch 100 | (First directory) */
+/* +----------------------------+ */
+/* . */
+/* . */
+/* . */
+/* +----------------------------+ */
+/* | Epoch ((N-1)/100)*100 | (Last directory) */
+/* +----------------------------+ */
+/* | Start time 1 | */
+/* +----------------------------+ */
+/* | Start time 2 | */
+/* +----------------------------+ */
+/* . */
+/* . */
+/* . */
+/* +----------------------------+ */
+/* | Start time M | */
+/* +----------------------------+ */
+/* | Start time 100 | (First interval start */
+/* +----------------------------+ time directory) */
+/* . */
+/* . */
+/* . */
+/* +----------------------------+ */
+/* | Start time ((M-1)/100)*100 | (Last interval start */
+/* +----------------------------+ time directory) */
+/* | Seconds per tick | */
+/* +----------------------------+ */
+/* | Subtype code | */
+/* +----------------------------+ */
+/* | Window size | */
+/* +----------------------------+ */
+/* | Number of interp intervals | */
+/* +----------------------------+ */
+/* | Number of packets | */
+/* +----------------------------+ */
+
+
+ i__1 = *n * packsz;
+ dafada_(packts, &i__1);
+ dafada_(sclkdp, n);
+ i__1 = (*n - 1) / 100;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dafada_(&sclkdp[i__ * 100 - 1], &c__1);
+ }
+
+/* Now add the interval start times. */
+
+ dafada_(starts, nints);
+
+/* And the directory of interval start times. The directory of */
+/* start times will simply be every (DIRSIZ)th start time. */
+
+ i__1 = (*nints - 1) / 100;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dafada_(&starts[i__ * 100 - 1], &c__1);
+ }
+
+/* Add the SCLK rate, segment subtype, window size, interval */
+/* count, and packet count. */
+
+ dafada_(rate, &c__1);
+ d__1 = (doublereal) (*subtyp);
+ dafada_(&d__1, &c__1);
+ d__1 = (doublereal) winsiz;
+ dafada_(&d__1, &c__1);
+ d__1 = (doublereal) (*nints);
+ dafada_(&d__1, &c__1);
+ d__1 = (doublereal) (*n);
+ dafada_(&d__1, &c__1);
+
+/* As long as nothing went wrong, end the segment. */
+
+ if (! failed_()) {
+ dafena_();
+ }
+ chkout_("CKW05", (ftnlen)5);
+ return 0;
+} /* ckw05_ */
+
diff --git a/ext/spice/src/cspice/ckw05_c.c b/ext/spice/src/cspice/ckw05_c.c
new file mode 100644
index 0000000000..b691a5c294
--- /dev/null
+++ b/ext/spice/src/cspice/ckw05_c.c
@@ -0,0 +1,701 @@
+/*
+
+-Procedure ckw05_c ( Write CK segment, type 5 )
+
+-Abstract
+
+ Write a type 5 segment to a CK file.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CK
+ NAIF_IDS
+ ROTATION
+ TIME
+
+-Keywords
+
+ POINTING
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+ #undef ckw05_c
+
+
+ void ckw05_c ( SpiceInt handle,
+ SpiceCK05Subtype subtyp,
+ SpiceInt degree,
+ SpiceDouble begtim,
+ SpiceDouble endtim,
+ SpiceInt inst,
+ ConstSpiceChar * ref,
+ SpiceBoolean avflag,
+ ConstSpiceChar * segid,
+ SpiceInt n,
+ ConstSpiceDouble sclkdp [],
+ const void * packts,
+ SpiceDouble rate,
+ SpiceInt nints,
+ ConstSpiceDouble starts [] )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of an open CK file.
+ subtyp I CK type 5 subtype code.
+ degree I Degree of interpolating polynomials.
+ begtim I The beginning encoded SCLK of the segment.
+ endtim I The ending encoded SCLK of the segment.
+ inst I The NAIF instrument ID code.
+ ref I The reference frame of the segment.
+ avflag I True if the segment will contain angular velocity.
+ segid I Segment identifier.
+ n I Number of packets.
+ sclkdp I Encoded SCLK times.
+ packts I Array of packets.
+ rate I Nominal SCLK rate in seconds per tick.
+ nints I Number of intervals.
+ starts I Encoded SCLK interval start times.
+ MAXDEG P Maximum allowed degree of interpolating polynomial.
+
+-Detailed_Input
+
+
+ handle is the handle of the CK file to which the segment will be
+ written. The file must have been opened with write
+ access.
+
+ subtyp is an integer code indicating the subtype of the
+ segment to be created.
+
+ degree is the degree of the polynomials used to interpolate the
+ quaternions contained in the input packets. All
+ components of the quaternions are interpolated by
+ polynomials of fixed degree.
+
+ begtim,
+ endtim are the beginning and ending encoded SCLK times
+ for which the segment provides pointing information.
+ begtim must be less than or equal to endtim, and at least
+ one data packet must have a time tag t such that
+
+ begtim < t < endtim
+ - -
+
+ inst is the NAIF integer ID code for the instrument.
+
+ ref is a character string which specifies the
+ reference frame of the segment. This should be one of
+ the frames supported by the SPICELIB routine NAMFRM
+ which is an entry point of FRAMEX.
+
+ The rotation matrices represented by the quaternions
+ that are to be written to the segment transform the
+ components of vectors from the inertial reference frame
+ specified by ref to components in the instrument fixed
+ frame. Also, the components of the angular velocity
+ vectors to be written to the segment should be given
+ with respect to ref.
+
+ ref should be the name of one of the frames supported
+ by the SPICELIB routine NAMFRM.
+
+
+ avflag is a boolean flag which indicates whether or not the
+ segment will contain angular velocity.
+
+ segid is the segment identifier. A CK segment identifier may
+ contain up to 40 characters, excluding the terminating
+ null.
+
+ packts contains a time-ordered array of data packets
+ representing the orientation of inst relative to the
+ frame ref. Each packet contains a SPICE-style quaternion
+ and optionally, depending on the segment subtype,
+ attitude derivative data, from which a C-matrix and an
+ angular velocity vector may be derived.
+
+ See the discussion of "Quaternion Styles" in the
+ Particulars section below.
+
+ The C-matrix represented by the Ith data packet is a
+ rotation matrix that transforms the components of a
+ vector expressed in the base frame specified by ref to
+ components expressed in the instrument fixed frame at the
+ time sclkdp(I).
+
+ Thus, if a vector v has components x, y, z in the base
+ frame, then v has components x', y', z' in the instrument
+ fixed frame where:
+
+ [ x' ] [ ] [ x ]
+ | y' | = | cmat | | y |
+ [ z' ] [ ] [ z ]
+
+
+ The attitude derivative information in packts[i] gives
+ the angular velocity of the instrument fixed frame at
+ time sclkdp[i] with respect to the reference frame
+ specified by ref.
+
+ The direction of an angular velocity vector gives the
+ right-handed axis about which the instrument fixed
+ reference frame is rotating. The magnitude of the vector
+ is the magnitude of the instantaneous velocity of the
+ rotation, in radians per second.
+
+ Packet contents and the corresponding interpolation
+ methods depend on the segment subtype, and are as
+ follows:
+
+ Subtype 0: Hermite interpolation, 8-element packets.
+ Quaternion and quaternion derivatives
+ only, no angular velocity vector provided.
+ Quaternion elements are listed first,
+ followed by derivatives. Angular velocity
+ is derived from the quaternions and
+ quaternion derivatives.
+
+ Subtype 1: Lagrange interpolation, 4-element packets.
+ Quaternion only. Angular velocity is
+ derived by differentiating the
+ interpolating polynomials.
+
+ Subtype 2: Hermite interpolation, 14-element packets.
+ Quaternion and angular angular velocity
+ vector, as well as derivatives of each,
+ are provided. The quaternion comes first,
+ then quaternion derivatives, then angular
+ velocity and its derivatives.
+
+ Subtype 3: Lagrange interpolation, 7-element packets.
+ Quaternion and angular velocity vector
+ provided. The quaternion comes first.
+
+ Angular velocity is always specified relative to the base
+ frame.
+
+ rate is the nominal rate of the spacecraft clock associated
+ with inst. Units are seconds per tick. rate is used to
+ scale angular velocity to radians/second.
+
+ nints is the number of intervals that the pointing instances
+ are partitioned into.
+
+ starts are the start times of each of the interpolation
+ intervals. These times must be strictly increasing and
+ must coincide with times for which the segment contains
+ pointing.
+
+-Detailed_Output
+
+ None. See Files section.
+
+-Parameters
+
+ MAXDEG is the maximum allowed degree of the interpolating
+ polynomial. If the value of MAXDEG is increased, the
+ CSPICE routine ckpfs_ must be changed accordingly. In
+ particular, the size of the record passed to ckrNN_ and
+ ckeNN_ must be increased, and comments describing the
+ record size must be changed.
+
+-Exceptions
+
+ If any of the following exceptions occur, this routine will return
+ without creating a new segment.
+
+ 1) If handle is not the handle of a C-kernel opened for writing
+ the error will be diagnosed by routines called by this
+ routine.
+
+ 2) If the last non-blank character of segid occurs past index 40,
+ the error SPICE(SEGIDTOOLONG) is signaled.
+
+ 3) If segid contains any nonprintable characters, the error
+ SPICE(NONPRINTABLECHARS) is signaled.
+
+ 4) If the first encoded SCLK time is negative then the error
+ SPICE(INVALIDSCLKTIME) is signaled. If any subsequent times
+ are negative the error will be detected in exception (5).
+
+ 5) If the encoded SCLK times are not strictly increasing,
+ the error SPICE(TIMESOUTOFORDER) is signaled.
+
+ 6) If the name of the reference frame is not one of those
+ supported by the routine framex_, the error
+ SPICE(INVALIDREFFRAME) is signaled.
+
+ 7) If the number of packets n is not at least 1, the error
+ SPICE(TOOFEWPACKETS) will be signaled.
+
+ 8) If nints, the number of interpolation intervals, is less than
+ or equal to 0, the error SPICE(INVALIDNUMINTS) is signaled.
+
+ 9) If the encoded SCLK interval start times are not strictly
+ increasing, the error SPICE(TIMESOUTOFORDER) is signaled.
+
+ 10) If an interval start time does not coincide with a time for
+ which there is an actual pointing instance in the segment,
+ then the error SPICE(INVALIDSTARTTIME) is signaled.
+
+ 11) This routine assumes that the rotation between adjacent
+ quaternions that are stored in the same interval has a
+ rotation angle of theta radians, where
+
+ 0 < theta < pi.
+ _
+
+ The routines that evaluate the data in the segment produced
+ by this routine cannot distinguish between rotations of theta
+ radians, where theta is in the interval [0, pi), and
+ rotations of
+
+ theta + 2 * k * pi
+
+ radians, where k is any integer. These "large" rotations will
+ yield invalid results when interpolated. You must ensure that
+ the data stored in the segment will not be subject to this
+ sort of ambiguity.
+
+ 12) If any quaternion is the zero vector, the error
+ SPICE(ZEROQUATERNION) is signaled.
+
+ 13) If the interpolation window size implied by degree is not
+ even, the error SPICE(INVALIDDEGREE) is signaled. The window
+ size is degree+1 for Lagrange subtypes and is (degree+1)/2
+ for Hermite subtypes.
+
+ 14) If an unrecognized subtype code is supplied, the error
+ SPICE(NOTSUPPORTED) is signaled.
+
+ 15) If degree is not at least 1 or is greater than MAXDEG, the
+ error SPICE(INVALIDDEGREE) is signaled.
+
+ 16) If the segment descriptor bounds are out of order, the
+ error SPICE(BADDESCRTIMES) is signaled.
+
+ 17) If there is no element of SCLKDP that lies between BEGTIM and
+ ENDTIM inclusive, the error SPICE(EMPTYSEGMENT) is signaled.
+
+ 18) If RATE is zero, the error SPICE(INVALIDVALUE) is signaled.
+
+ 18) If either the input frame or segment ID have null string
+ pointers, the error SPICE(NULLPOINTER) is signaled.
+
+ 19) If either the input frame or segment ID are zero-length
+ strings, the error SPICE(EMPTYSTRING) is signaled.
+
+
+-Files
+
+ A new type 5 CK segment is written to the CK file attached
+ to handle.
+
+-Particulars
+
+ This routine writes a CK type 5 data segment to the open CK
+ file according to the format described in the type 5 section of
+ the CK Required Reading. The CK file must have been opened with
+ write access.
+
+
+ Quaternion Styles
+ -----------------
+
+ There are different "styles" of quaternions used in
+ science and engineering applications. Quaternion styles
+ are characterized by
+
+ - The order of quaternion elements
+
+ - The quaternion multiplication formula
+
+ - The convention for associating quaternions
+ with rotation matrices
+
+ Two of the commonly used styles are
+
+ - "SPICE"
+
+ > Invented by Sir William Rowan Hamilton
+ > Frequently used in mathematics and physics textbooks
+
+ - "Engineering"
+
+ > Widely used in aerospace engineering applications
+
+
+ CSPICE function interfaces ALWAYS use SPICE quaternions.
+ Quaternions of any other style must be converted to SPICE
+ quaternions before they are passed to CSPICE functions.
+
+
+ Relationship between SPICE and Engineering Quaternions
+ ------------------------------------------------------
+
+ Let M be a rotation matrix such that for any vector V,
+
+ M*V
+
+ is the result of rotating V by theta radians in the
+ counterclockwise direction about unit rotation axis vector A.
+ Then the SPICE quaternions representing M are
+
+ (+/-) ( cos(theta/2),
+ sin(theta/2) A(1),
+ sin(theta/2) A(2),
+ sin(theta/2) A(3) )
+
+ while the engineering quaternions representing M are
+
+ (+/-) ( -sin(theta/2) A(1),
+ -sin(theta/2) A(2),
+ -sin(theta/2) A(3),
+ cos(theta/2) )
+
+ For both styles of quaternions, if a quaternion q represents
+ a rotation matrix M, then -q represents M as well.
+
+ Given an engineering quaternion
+
+ QENG = ( q0, q1, q2, q3 )
+
+ the equivalent SPICE quaternion is
+
+ QSPICE = ( q3, -q0, -q1, -q2 )
+
+
+ Associating SPICE Quaternions with Rotation Matrices
+ ----------------------------------------------------
+
+ Let FROM and TO be two right-handed reference frames, for
+ example, an inertial frame and a spacecraft-fixed frame. Let the
+ symbols
+
+ V , V
+ FROM TO
+
+ denote, respectively, an arbitrary vector expressed relative to
+ the FROM and TO frames. Let M denote the transformation matrix
+ that transforms vectors from frame FROM to frame TO; then
+
+ V = M * V
+ TO FROM
+
+ where the expression on the right hand side represents left
+ multiplication of the vector by the matrix.
+
+ Then if the unit-length SPICE quaternion q represents M, where
+
+ q = (q0, q1, q2, q3)
+
+ the elements of M are derived from the elements of q as follows:
+
+ +- -+
+ | 2 2 |
+ | 1 - 2*( q2 + q3 ) 2*(q1*q2 - q0*q3) 2*(q1*q3 + q0*q2) |
+ | |
+ | |
+ | 2 2 |
+ M = | 2*(q1*q2 + q0*q3) 1 - 2*( q1 + q3 ) 2*(q2*q3 - q0*q1) |
+ | |
+ | |
+ | 2 2 |
+ | 2*(q1*q3 - q0*q2) 2*(q2*q3 + q0*q1) 1 - 2*( q1 + q2 ) |
+ | |
+ +- -+
+
+ Note that substituting the elements of -q for those of q in the
+ right hand side leaves each element of M unchanged; this shows
+ that if a quaternion q represents a matrix M, then so does the
+ quaternion -q.
+
+ To map the rotation matrix M to a unit quaternion, we start by
+ decomposing the rotation matrix as a sum of symmetric
+ and skew-symmetric parts:
+
+ 2
+ M = [ I + (1-cos(theta)) OMEGA ] + [ sin(theta) OMEGA ]
+
+ symmetric skew-symmetric
+
+
+ OMEGA is a skew-symmetric matrix of the form
+
+ +- -+
+ | 0 -n3 n2 |
+ | |
+ OMEGA = | n3 0 -n1 |
+ | |
+ | -n2 n1 0 |
+ +- -+
+
+ The vector N of matrix entries (n1, n2, n3) is the rotation axis
+ of M and theta is M's rotation angle. Note that N and theta
+ are not unique.
+
+ Let
+
+ C = cos(theta/2)
+ S = sin(theta/2)
+
+ Then the unit quaternions Q corresponding to M are
+
+ Q = +/- ( C, S*n1, S*n2, S*n3 )
+
+ The mappings between quaternions and the corresponding rotations
+ are carried out by the CSPICE routines
+
+ q2m_c {quaternion to matrix}
+ m2q_c {matrix to quaternion}
+
+ m2q_c always returns a quaternion with scalar part greater than
+ or equal to zero.
+
+
+ SPICE Quaternion Multiplication Formula
+ ---------------------------------------
+
+ Given a SPICE quaternion
+
+ Q = ( q0, q1, q2, q3 )
+
+ corresponding to rotation axis A and angle theta as above, we can
+ represent Q using "scalar + vector" notation as follows:
+
+ s = q0 = cos(theta/2)
+
+ v = ( q1, q2, q3 ) = sin(theta/2) * A
+
+ Q = s + v
+
+ Let Q1 and Q2 be SPICE quaternions with respective scalar
+ and vector parts s1, s2 and v1, v2:
+
+ Q1 = s1 + v1
+ Q2 = s2 + v2
+
+ We represent the dot product of v1 and v2 by
+
+
+
+ and the cross product of v1 and v2 by
+
+ v1 x v2
+
+ Then the SPICE quaternion product is
+
+ Q1*Q2 = s1*s2 - + s1*v2 + s2*v1 + (v1 x v2)
+
+ If Q1 and Q2 represent the rotation matrices M1 and M2
+ respectively, then the quaternion product
+
+ Q1*Q2
+
+ represents the matrix product
+
+ M1*M2
+
+
+-Examples
+
+ This example code fragment writes a type 5 C-kernel segment
+ for the Mars Express spacecraft bus to a previously opened CK
+ file attached to handle.
+
+ /.
+ Include CSPICE interface definitions.
+ ./
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Assume arrays of quaternions, angular velocities, and the
+ associated SCLK times are produced elsewhere. The software
+ that calls ckw05_c must then decide how to partition these
+ pointing instances into intervals over which linear
+ interpolation between adjacent points is valid.
+ ./
+ .
+ .
+ .
+
+ /.
+ The subroutine ckw05_c needs the following items for the
+ segment descriptor:
+
+ 1) SCLK limits of the segment.
+ 2) Instrument code.
+ 3) Reference frame.
+ 4) The angular velocity flag.
+
+ ./
+
+ begtim = sclk [ 0 ];
+ endtim = sclk [ nrec-1 ];
+
+ inst = -41000;
+ ref = "J2000";
+ avflag = SPICETRUE;
+
+ segid = "MEX spacecraft bus - data type 5";
+
+ /.
+ Write the segment.
+ ./
+ ckw05_c ( handle, subtyp, degree, begtim, endtim, inst,
+ ref, avflag, segid, n, sclkdp, packts,
+ rate, nints, starts );
+ .
+ .
+ .
+ /.
+ After all segments are written, close the C-kernel.
+ ./
+ ckcls_c ( handle );
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ K.R. Gehringer (JPL)
+ J.M. Lynch (JPL)
+
+-Version
+
+ -CSPICE Version 2.0.0, 01-JUN-2010 (NJB)
+
+ The check for non-unit quaternions has been replaced
+ with a check for zero-length quaternions. (The
+ implementation of the check is located in ckw05_.)
+
+ -CSPICE Version 1.0.2, 27-FEB-2008 (NJB)
+
+ Updated header; added information about SPICE
+ quaternion conventions.
+
+ -CSPICE Version 1.0.1, 07-JAN-2005 (NJB)
+
+ Description in Detailed_Input header section of
+ constraints on BEGTIM and ENDTIM was corrected
+
+ -CSPICE Version 1.0.0, 30-AUG-2002 (NJB) (WLT) (KRG) (JML)
+
+-Index_Entries
+
+ write ck type_5 data segment
+
+-&
+*/
+
+{ /* Begin ckw05_c */
+
+
+
+ /*
+ Local variables
+ */
+ logical avf;
+
+ SpiceInt locSubtype;
+
+
+
+
+ /*
+ Participate in error tracingx.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+ chkin_c ( "ckw05_c" );
+
+
+ /*
+ Check the input strings to make sure the pointers
+ are non-null and the string lengths are non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "ckw05_c", ref );
+ CHKFSTR ( CHK_STANDARD, "ckw05_c", segid );
+
+
+ /*
+ Get a type logical copy of the a.v. flag. Get a type SpiceInt
+ copy of the CK type 5 subtype.
+ */
+ avf = (logical) avflag;
+
+ locSubtype = (SpiceInt) subtyp;
+
+
+ /*
+ Write the segment. Note that the packet array
+ DOES NOT require transposition!
+ */
+ ckw05_( ( integer * ) &handle,
+ ( integer * ) &locSubtype,
+ ( integer * ) °ree,
+ ( doublereal * ) &begtim,
+ ( doublereal * ) &endtim,
+ ( integer * ) &inst,
+ ( char * ) ref,
+ ( logical * ) &avf,
+ ( char * ) segid,
+ ( integer * ) &n,
+ ( doublereal * ) sclkdp,
+ ( doublereal * ) packts,
+ ( doublereal * ) &rate,
+ ( integer * ) &nints,
+ ( doublereal * ) starts,
+ ( ftnlen ) strlen(ref),
+ ( ftnlen ) strlen(segid) );
+
+
+ chkout_c ( "ckw05_c" );
+
+} /* End ckw05_c */
diff --git a/ext/spice/src/cspice/clearc.c b/ext/spice/src/cspice/clearc.c
new file mode 100644
index 0000000000..5acab4bf2d
--- /dev/null
+++ b/ext/spice/src/cspice/clearc.c
@@ -0,0 +1,139 @@
+/* clearc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CLEARC ( Clear a character-string array ) */
+/* Subroutine */ int clearc_(integer *ndim, char *array, ftnlen array_len)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer i__;
+
+/* $ Abstract */
+
+/* Fill a character-string array with blank strings. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY, ASSIGNMENT */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- --------------------------------------- */
+/* NDIM I The number of elements of ARRAY which are to be */
+/* set to blank. */
+/* ARRAY O Character-string array to be filled. */
+
+/* $ Detailed_Input */
+
+/* NDIM is the number of elements in ARRAY which are to be */
+/* set to blank. */
+
+/* $ Detailed_Output */
+
+/* ARRAY is the character string array which is to be filled */
+/* with blank elements. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* If NDIM = 4, then the contents of ARRAY are: */
+
+/* ARRAY (1) = ' ' */
+/* ARRAY (2) = ' ' */
+/* ARRAY (3) = ' ' */
+/* ARRAY (4) = ' ' */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* 1) If NDIM < 1, the array is not modified. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.M. Owen (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WMO) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* clear a character array */
+
+/* -& */
+
+/* Local variables */
+
+ i__1 = *ndim;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ s_copy(array + (i__ - 1) * array_len, " ", array_len, (ftnlen)1);
+ }
+ return 0;
+} /* clearc_ */
+
diff --git a/ext/spice/src/cspice/cleard.c b/ext/spice/src/cspice/cleard.c
new file mode 100644
index 0000000000..68ea17050b
--- /dev/null
+++ b/ext/spice/src/cspice/cleard.c
@@ -0,0 +1,136 @@
+/* cleard.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CLEARD ( Clear a double precision array ) */
+/* Subroutine */ int cleard_(integer *ndim, doublereal *array)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Local variables */
+ integer i__;
+
+/* $ Abstract */
+
+/* Fill a double precision array with zeros. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY, ASSIGNMENT */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- --------------------------------------- */
+/* NDIM I The number of elements of ARRAY which are to be */
+/* set to zero. */
+/* ARRAY O Double precision array to be filled. */
+
+/* $ Detailed_Input */
+
+/* NDIM is the number of elements in ARRAY which are to be */
+/* set to zero. */
+
+/* $ Detailed_Output */
+
+/* ARRAY is the double precision array which it to be filled */
+/* with zeros. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* If NDIM = 4, then the contents of ARRAY are: */
+
+/* ARRAY (1) = 0.0D0 */
+/* ARRAY (2) = 0.0D0 */
+/* ARRAY (3) = 0.0D0 */
+/* ARRAY (4) = 0.0D0 */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* 1) If NDIM < 1, the array is not modified. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.M. Owen (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WMO) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* clear a d.p. array */
+
+/* -& */
+
+/* Local variables */
+
+ i__1 = *ndim;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ array[i__ - 1] = 0.;
+ }
+ return 0;
+} /* cleard_ */
+
diff --git a/ext/spice/src/cspice/cleari.c b/ext/spice/src/cspice/cleari.c
new file mode 100644
index 0000000000..876d817c14
--- /dev/null
+++ b/ext/spice/src/cspice/cleari.c
@@ -0,0 +1,136 @@
+/* cleari.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CLEARI ( Clear an integer array ) */
+/* Subroutine */ int cleari_(integer *ndim, integer *array)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Local variables */
+ integer i__;
+
+/* $ Abstract */
+
+/* Fill an integer array with zeros. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY, ASSIGNMENT */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- --------------------------------------- */
+/* NDIM I The number of elements of ARRAY which are to be */
+/* set to zero. */
+/* ARRAY O Integer array to be filled. */
+
+/* $ Detailed_Input */
+
+/* NDIM is the number of elements in ARRAY which are to be */
+/* set to zero. */
+
+/* $ Detailed_Output */
+
+/* ARRAY is the integer array which it to be filled with */
+/* zeros. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* If NDIM = 4, then the contents of ARRAY are: */
+
+/* ARRAY (1) = 0 */
+/* ARRAY (2) = 0 */
+/* ARRAY (3) = 0 */
+/* ARRAY (4) = 0 */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* 1) If NDIM < 1, the array is not modified. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.M. Owen (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WMO) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* clear an integer array */
+
+/* -& */
+
+/* Local variables */
+
+ i__1 = *ndim;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ array[i__ - 1] = 0;
+ }
+ return 0;
+} /* cleari_ */
+
diff --git a/ext/spice/src/cspice/clight.c b/ext/spice/src/cspice/clight.c
new file mode 100644
index 0000000000..c1ba4675d7
--- /dev/null
+++ b/ext/spice/src/cspice/clight.c
@@ -0,0 +1,156 @@
+/* clight.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CLIGHT ( C, Speed of light in a vacuum ) */
+doublereal clight_(void)
+{
+ /* System generated locals */
+ doublereal ret_val;
+
+/* $ Abstract */
+
+/* Return the speed of light in a vacuum (IAU official */
+/* value, in km/sec). */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CONSTANTS */
+
+/* $ Declarations */
+
+/* None. */
+
+/* $ Brief_I/O */
+
+/* The function returns the speed of light in vacuo (km/sec). */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* The function returns the IAU official value for the speed of light */
+/* in vacuo: 299792.458 km/sec. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The function always returns the constant value shown above. */
+
+/* $ Examples */
+
+/* Find the light time corresponding to the length of a given */
+/* 3-dimensional position vector. Length units are km. */
+
+/* To use CLIGHT, declare it as having double precision type: */
+
+/* DOUBLE PRECISION CLIGHT */
+
+/* Let POS be a 3-vector of interest; let TAU be the light time. */
+/* VNORM is the SPICELIB function that returns the norm of a */
+/* 3-vector. */
+
+/* DOUBLE PRECISION VNORM */
+/* DOUBLE PRECISION TAU */
+/* DOUBLE PRECISION POS (3 ) */
+
+/* Find the light time: */
+
+/* TAU = VNORM ( POS ) / CLIGHT () */
+
+/* Note that the SPK readers */
+
+/* SPKEZR */
+/* SPKEZ */
+/* SPKPOS */
+/* SPKEZP */
+
+/* return the one-way light time between target and observer */
+/* as an output. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 08-JAN-2008 (NJB) */
+
+/* Example section was updated to remove references to SPKAPP */
+/* and BODMAT. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* c speed of light in a vacuum */
+
+/* -& */
+
+/* Just like it says. */
+
+ ret_val = 299792.458;
+ return ret_val;
+} /* clight_ */
+
diff --git a/ext/spice/src/cspice/clight_c.c b/ext/spice/src/cspice/clight_c.c
new file mode 100644
index 0000000000..606c679d9e
--- /dev/null
+++ b/ext/spice/src/cspice/clight_c.c
@@ -0,0 +1,146 @@
+/*
+
+-Procedure clight_c ( C, Speed of light in a vacuum )
+
+-Abstract
+
+ Return the speed of light in a vacuum (IAU official
+ value, in km/sec).
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ CONSTANTS
+
+*/
+
+ #include "SpiceUsr.h"
+
+ SpiceDouble clight_c ( void )
+
+/*
+
+-Brief_I/O
+
+ The function returns the speed of light in vacuo (km/sec).
+
+-Detailed_Input
+
+ None.
+
+-Detailed_Output
+
+ The function returns the IAU official value for the speed of light
+ in vacuo: 299792.458 km/sec.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+-Files
+
+ None.
+
+-Particulars
+
+ The function always returns the constant value shown above.
+
+-Examples
+
+ The following example uses clight_c to determine the one-way
+ light-time (tau) to an object whose position relative to an
+ observer is contained in pos.
+
+ tau = vnorm_c ( pos ) / clight_c ();
+
+ Note that the SPK readers
+
+ spkezr_c
+ spkez_c
+ spkpos_c
+ spkezp_c
+
+ return the one-way light time as an output, for example
+
+ spkez_c ( ..., &tau );
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.2, 07-FEB-2008 (EDW) (NJB)
+
+ Corrected typos in header titles:
+
+ Detailed Input to Detailed_Input
+ Detailed Output to Detailed_Output
+
+ Updated example to show pointer output argument
+ `tau' and list other high-level SPK routines that
+ return light time. Call to bodmat_c was removed
+ from example.
+
+ -CSPICE Version 1.0.1, 11-NOV-2006 (EDW)
+
+ Added Parameters section header.
+
+ -CSPICE Version 1.0.0, 16-APR-1999 (EDW)
+
+-Index_Entries
+
+ measured velocity of light in a vacuum
+
+-&
+*/
+
+{ /* Begin clight_c */
+
+ return 299792.458;
+
+} /* End clight_c */
+
diff --git a/ext/spice/src/cspice/close.c b/ext/spice/src/cspice/close.c
new file mode 100644
index 0000000000..58100593f7
--- /dev/null
+++ b/ext/spice/src/cspice/close.c
@@ -0,0 +1,94 @@
+#include "f2c.h"
+#include "fio.h"
+#ifdef KR_headers
+integer f_clos(a) cllist *a;
+#else
+#undef abs
+#undef min
+#undef max
+#include "stdlib.h"
+#ifdef NON_UNIX_STDIO
+#ifndef unlink
+#define unlink remove
+#endif
+#else
+#ifdef MSDOS
+#include "io.h"
+#else
+#ifdef __cplusplus
+extern "C" int unlink(const char*);
+#else
+extern int unlink(const char*);
+#endif
+#endif
+#endif
+
+integer f_clos(cllist *a)
+#endif
+{ unit *b;
+
+ if(a->cunit >= MXUNIT) return(0);
+ b= &f__units[a->cunit];
+ if(b->ufd==NULL)
+ goto done;
+ if (b->uscrtch == 1)
+ goto Delete;
+ if (!a->csta)
+ goto Keep;
+ switch(*a->csta) {
+ default:
+ Keep:
+ case 'k':
+ case 'K':
+ if(b->uwrt == 1)
+ t_runc((alist *)a);
+ if(b->ufnm) {
+ fclose(b->ufd);
+ free(b->ufnm);
+ }
+ break;
+ case 'd':
+ case 'D':
+ Delete:
+ fclose(b->ufd);
+ if(b->ufnm) {
+ unlink(b->ufnm); /*SYSDEP*/
+ free(b->ufnm);
+ }
+ }
+ b->ufd=NULL;
+ done:
+ b->uend=0;
+ b->ufnm=NULL;
+ return(0);
+ }
+ void
+#ifdef KR_headers
+f_exit()
+#else
+f_exit(void)
+#endif
+{ int i;
+ static cllist xx;
+ if (!xx.cerr) {
+ xx.cerr=1;
+ xx.csta=NULL;
+ for(i=0;i_FRAME
+
+ where is the non-blank portion of the string CNAME.
+
+ For those PCK objects that have "built-in" frame names this
+ routine returns the corresponding "IAU" frame and frame ID code.
+
+-Examples
+
+ Suppose that you want to determine the state of a target
+ in the preferred reference frame of some observer. This
+ routine can be used in conjunction with spkezr_c to compute
+ the state.
+
+ #include
+ #include
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ #define LENOUT 80
+
+ cnmfrm_c ( obsnam, LENOUT, &frcode, frname, &found );
+
+ if ( !found )
+ {
+ printf ( "The bodyfixed frame for object %s "
+ "could not be identified.\n",
+ obsnam );
+ exit(1);
+ }
+
+ spkezr_c ( target, et, frname, abcorr, obsnam, state, < );
+
+
+-Restrictions
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 25-JUN-1999 (NJB) (WLT)
+
+-Index_Entries
+
+ Fetch reference frame attributes
+
+-&
+*/
+
+{ /* Begin cnmfrm_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "cnmfrm_c" );
+
+ /*
+ Check the input object's name string to make sure the pointer
+ is non-null and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "cnmfrm_c", cname );
+
+ /*
+ Make sure the output string has at least enough room for one output
+ character and a null terminator. Also check for a null pointer.
+ */
+ CHKOSTR ( CHK_STANDARD, "cnmfrm_c", frname, lenout );
+
+
+ /*
+ Invoke the f2c'd routine.
+ */
+ cnmfrm_ ( ( char * ) cname,
+ ( integer * ) frcode,
+ ( char * ) frname,
+ ( logical * ) found,
+ ( ftnlen ) strlen(cname),
+ ( ftnlen ) lenout-1 );
+
+
+ /*
+ Convert the output string to C-style.
+ */
+ F2C_ConvertStr ( lenout, frname );
+
+
+ chkout_c ( "cnmfrm_c" );
+
+} /* End cnmfrm_c */
diff --git a/ext/spice/src/cspice/conics.c b/ext/spice/src/cspice/conics.c
new file mode 100644
index 0000000000..1505d16b4a
--- /dev/null
+++ b/ext/spice/src/cspice/conics.c
@@ -0,0 +1,436 @@
+/* conics.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CONICS ( Determine state from conic elements ) */
+/* Subroutine */ int conics_(doublereal *elts, doublereal *et, doublereal *
+ state)
+{
+ /* System generated locals */
+ doublereal d__1;
+
+ /* Builtin functions */
+ double cos(doublereal), sin(doublereal), sqrt(doublereal), d_mod(
+ doublereal *, doublereal *);
+
+ /* Local variables */
+ doublereal cnci, argp, snci, cosi, sini, cosn, sinn;
+ extern /* Subroutine */ int vscl_(doublereal *, doublereal *, doublereal *
+ );
+ doublereal cosw, sinw, n, v;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ doublereal lnode;
+ extern /* Subroutine */ int errdp_(char *, doublereal *, ftnlen);
+ doublereal m0;
+ extern doublereal twopi_(void);
+ doublereal t0;
+ extern /* Subroutine */ int prop2b_(doublereal *, doublereal *,
+ doublereal *, doublereal *);
+ doublereal dt, rp, mu, basisp[3], period, basisq[3];
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen);
+ doublereal pstate[6], ainvrs;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen);
+ extern logical return_(void);
+ doublereal ecc, inc;
+
+/* $ Abstract */
+
+/* Determine the state (position, velocity) of an orbiting body */
+/* from a set of elliptic, hyperbolic, or parabolic orbital */
+/* elements. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CONIC */
+/* EPHEMERIS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* ELTS I Conic elements. */
+/* ET I Input time. */
+/* STATE O State of orbiting body at ET. */
+
+/* $ Detailed_Input */
+
+/* ELTS are conic elements describing the orbit of a body */
+/* around a primary. The elements are, in order: */
+
+/* RP Perifocal distance. */
+/* ECC Eccentricity. */
+/* INC Inclination. */
+/* LNODE Longitude of the ascending node. */
+/* ARGP Argument of periapse. */
+/* M0 Mean anomaly at epoch. */
+/* T0 Epoch. */
+/* MU Gravitational parameter. */
+
+/* Units are km, rad, rad/sec, km**3/sec**2. The epoch */
+/* is given in ephemeris seconds past J2000. The same */
+/* elements are used to describe all three types */
+/* (elliptic, hyperbolic, and parabolic) of conic orbit. */
+
+/* ET is the time at which the state of the orbiting body */
+/* is to be determined, in ephemeris seconds J2000. */
+
+/* $ Detailed_Output */
+
+/* STATE is the state (position and velocity) of the body at */
+/* time ET. Components are x, y, z, dx/dt, dy/dt, dz/dt. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the eccentricity supplied is less than 0, the error */
+/* 'SPICE(BADECCENTRICITY)' is signalled. */
+
+/* 2) If a non-positive periapse distance is supplied, the error */
+/* 'SPICE(BADPERIAPSEVALUE)' is signalled. */
+
+/* 3) If a non-positive value for the attracting mass is supplied, */
+/* the error 'SPICE(BADGM)', is signalled. */
+
+/* 4) Errors such as an out of bounds value for ET are diagnosed */
+/* by routines called by this routine. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* Let VINIT contain the initial state of a spacecraft relative to */
+/* the center of a planet at epoch ET, and let GM be the gravitation */
+/* parameter of the planet. The call */
+
+/* CALL OSCELT ( VINIT, ET, GM, ELTS ) */
+
+/* produces a set of osculating elements describing the nominal */
+/* orbit that the spacecraft would follow in the absence of all */
+/* other bodies in the solar system and non-gravitational forces */
+/* on the spacecraft. */
+
+/* Now let STATE contain the state of the same spacecraft at some */
+/* other epoch, LATER. The difference between this state and the */
+/* state predicted by the nominal orbit at the same epoch can be */
+/* computed as follows. */
+
+/* CALL CONICS ( ELTS, LATER, NOMINAL ) */
+/* CALL VSUBG ( NOMINAL, STATE, 6, DIFF ) */
+
+/* WRITE (*,*) 'Perturbation in x, dx/dt = ', DIFF(1), DIFF(4) */
+/* WRITE (*,*) ' y, dy/dt = ', DIFF(2), DIFF(5) */
+/* WRITE (*,*) ' z, dz/dt = ', DIFF(3), DIFF(6) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* [1] Roger Bate, Fundamentals of Astrodynamics, Dover, 1971. */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.0.0, 26-MAR-1998 (WLT) */
+
+/* There was a coding error in the computation of the mean */
+/* anomaly in the parabolic case. This problem has been */
+/* corrected. */
+
+/* - SPICELIB Version 3.0.1, 15-OCT-1996 (WLT) */
+
+/* Corrected a typo in the description of the units associated */
+/* with the input elements. */
+
+/* - SPICELIB Version 3.0.0, 12-NOV-1992 (WLT) */
+
+/* The routine was re-written to make use of NAIF's universal */
+/* variables formulation for state propagation (PROP2B). As */
+/* a result, several problems were simultaneously corrected. */
+
+/* A major bug was fixed that caused improper state evaluations */
+/* for ET's that precede the epoch of the elements in the */
+/* elliptic case. */
+
+/* A danger of non-convergence in the solution of Kepler's */
+/* equation has been eliminated. */
+
+/* In addition to this reformulation of CONICS checks were */
+/* installed that ensure the elements supplied are physically */
+/* meaningful. Eccentricity must be non-negative. The */
+/* distance at periapse and central mass must be positive. If */
+/* not errors are signalled. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 19-APR-1991 (WLT) */
+
+/* An error in the hyperbolic state generation was corrected. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* state from conic elements */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 3.0.1, 15-OCT-1996 (WLT) */
+
+/* Corrected a typo in the description of the units associated */
+/* with the input elements. */
+
+/* - SPICELIB Version 3.0.0, 12-NOV-1992 (WLT) */
+
+/* The routine was re-written to make use of NAIF's universal */
+/* variables formulation for state propagation (PROP2B). As */
+/* a result, several problems were simultaneously corrected. */
+
+/* A major bug was fixed that caused improper state evaluations */
+/* for ET's that precede the epoch of the elements in the */
+/* elliptic case. */
+
+/* A danger of non-convergence in the solution of Kepler's */
+/* equation has been eliminated. */
+
+/* In addition to this reformulation of CONICS checks were */
+/* installed that ensure the elements supplied are physically */
+/* meaningful. Eccentricity must be non-negative. The */
+/* distance at periapse and central mass must be positive. If */
+/* not errors are signalled. */
+
+/* These changes were prompted by the discovery that the old */
+/* formulation had a severe bug for elliptic orbits and epochs */
+/* prior to the epoch of the input elements, and by the discovery */
+/* that the time of flight routines had problems with convergence. */
+
+/* - SPICELIB Version 2.0.0, 19-APR-1991 (WLT) */
+
+/* The original version of the routine had a bug in that */
+/* it attempted to restrict the hyperbolic anomaly to */
+/* the interval 0 to 2*PI. This has been fixed. */
+
+/* - Beta Version 1.0.1, 27-JAN-1989 (IMU) */
+
+/* Examples section completed. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* The only real work required by this routine is the construction */
+/* of a preliminary state vector from the input elements. Once this */
+/* is in hand, we can simply let the routine PROP2B do the real */
+/* work, free from the instabilities inherent in the classical */
+/* elements formulation of two-body motion. */
+
+/* To do this we shall construct a basis of vectors that lie in the */
+/* plane of the orbit. The first vector P shall point towards the */
+/* position of the orbiting body at periapse. The second */
+/* vector Q shall point along the velocity vector of the body at */
+/* periapse. */
+
+/* The only other consideration is determining an epoch, TP, of */
+/* this state and the delta time ET - TP. */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CONICS", (ftnlen)6);
+ }
+
+/* Unpack the element vector. */
+
+ rp = elts[0];
+ ecc = elts[1];
+ inc = elts[2];
+ lnode = elts[3];
+ argp = elts[4];
+ m0 = elts[5];
+ t0 = elts[6];
+ mu = elts[7];
+
+/* Handle all of the exceptions first. */
+
+ if (ecc < 0.) {
+ setmsg_("The eccentricity supplied was negative. Only positive value"
+ "s are meaningful. The value was #", (ftnlen)93);
+ errdp_("#", &ecc, (ftnlen)1);
+ sigerr_("SPICE(BADECCENTRICITY)", (ftnlen)22);
+ chkout_("CONICS", (ftnlen)6);
+ return 0;
+ }
+ if (rp <= 0.) {
+ setmsg_("The value of periapse range supplied was non-positive. Onl"
+ "y positive values are allowed. The value supplied was #. ", (
+ ftnlen)117);
+ errdp_("#", &rp, (ftnlen)1);
+ sigerr_("SPICE(BADPERIAPSEVALUE)", (ftnlen)23);
+ chkout_("CONICS", (ftnlen)6);
+ return 0;
+ }
+ if (mu <= 0.) {
+ setmsg_("The value of GM supplied was non-positive. Only positive v"
+ "alues are allowed. The value supplied was #. ", (ftnlen)105);
+ errdp_("#", &mu, (ftnlen)1);
+ sigerr_("SPICE(BADGM)", (ftnlen)12);
+ chkout_("CONICS", (ftnlen)6);
+ return 0;
+ }
+
+/* First construct the orthonormal basis vectors that span the orbit */
+/* plane. */
+
+ cosi = cos(inc);
+ sini = sin(inc);
+ cosn = cos(lnode);
+ sinn = sin(lnode);
+ cosw = cos(argp);
+ sinw = sin(argp);
+ snci = sinn * cosi;
+ cnci = cosn * cosi;
+ basisp[0] = cosn * cosw - snci * sinw;
+ basisp[1] = sinn * cosw + cnci * sinw;
+ basisp[2] = sini * sinw;
+ basisq[0] = -cosn * sinw - snci * cosw;
+ basisq[1] = -sinn * sinw + cnci * cosw;
+ basisq[2] = sini * cosw;
+
+/* Next construct the state at periapse. */
+
+/* The position at periapse is just BASISP scaled by the distance */
+/* at periapse. */
+
+/* The velocity must be constructed so that we can get an orbit */
+/* of this shape. Recall that the magnitude of the specific angular */
+/* momentum vector is given by DSQRT ( MU*RP*(1+ECC) ) */
+/* The velocity will be given by V * BASISQ. But we must have the */
+/* magnitude of the cross product of position and velocity be */
+/* equal to DSQRT ( MU*RP*(1+ECC) ). So we must have */
+
+/* RP*V = DSQRT( MU*RP*(1+ECC) ) */
+
+/* so that: */
+
+ v = sqrt(mu * (ecc + 1.) / rp);
+ vscl_(&rp, basisp, pstate);
+ vscl_(&v, basisq, &pstate[3]);
+
+/* Finally compute DT the elapsed time since the epoch of periapse. */
+/* Ellipses first, since they are the most common. */
+
+ if (ecc < 1.) {
+
+/* Recall that: */
+
+/* N ( mean motion ) is given by DSQRT( MU / A**3 ). */
+/* But since, A = RP / ( 1 - ECC ) ... */
+
+ ainvrs = (1. - ecc) / rp;
+ n = sqrt(mu * ainvrs) * ainvrs;
+ period = twopi_() / n;
+
+/* In general the mean anomaly is given by */
+
+/* M = (T - TP) * N */
+
+/* Where TP is the time of periapse passage. M0 is the mean */
+/* anomaly at time T0 so that */
+/* Thus */
+
+/* M0 = ( T0 - TP ) * N */
+
+/* So TP = T0-M0/N hence the time since periapse at time ET */
+/* is given by ET - T0 + M0/N. Finally, since elliptic orbits are */
+/* periodic, we can mod this value by the period of the orbit. */
+
+ d__1 = *et - t0 + m0 / n;
+ dt = d_mod(&d__1, &period);
+
+/* Hyperbolas next. */
+
+ } else if (ecc > 1.) {
+
+/* Again, recall that: */
+
+/* N ( mean motion ) is given by DSQRT( MU / |A**3| ). */
+/* But since, |A| = RP / ( ECC - 1 ) ... */
+
+ ainvrs = (ecc - 1.) / rp;
+ n = sqrt(mu * ainvrs) * ainvrs;
+ dt = *et - t0 + m0 / n;
+
+/* Finally, parabolas. */
+
+ } else {
+ n = sqrt(mu / (rp * 2.)) / rp;
+ dt = *et - t0 + m0 / n;
+ }
+
+/* Now let PROP2B do the work of propagating the state. */
+
+ prop2b_(&mu, pstate, &dt, state);
+ chkout_("CONICS", (ftnlen)6);
+ return 0;
+} /* conics_ */
+
diff --git a/ext/spice/src/cspice/conics_c.c b/ext/spice/src/cspice/conics_c.c
new file mode 100644
index 0000000000..bd72da8ed4
--- /dev/null
+++ b/ext/spice/src/cspice/conics_c.c
@@ -0,0 +1,203 @@
+/*
+
+-Procedure conics_c ( Determine state from conic elements )
+
+-Abstract
+
+ Determine the state (position, velocity) of an orbiting body
+ from a set of elliptic, hyperbolic, or parabolic orbital
+ elements.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ CONIC
+ EPHEMERIS
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZim.h"
+ #undef conics_c
+
+
+ void conics_c ( ConstSpiceDouble elts[8],
+ SpiceDouble et,
+ SpiceDouble state[6] )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ elts I Conic elements.
+ et I Input time.
+ state O State of orbiting body at et.
+
+-Detailed_Input
+
+ elts are conic osculating elements describing the orbit of a
+ body around a primary. The elements are, in order:
+
+ RP Perifocal distance.
+ ECC Eccentricity.
+ INC Inclination.
+ LNODE Longitude of the ascending node.
+ ARGP Argument of periapse.
+ M0 Mean anomaly at epoch.
+ T0 Epoch.
+ MU Gravitational parameter.
+
+ Units are km, rad, rad/sec, km**3/sec**2.
+
+ The epoch T0 is given in ephemeris seconds past J2000.
+ T0 is the instant at which the state of the body is
+ specified by the elements.
+
+ The same elements are used to describe all three types
+ (elliptic, hyperbolic, and parabolic) of conic orbit.
+
+ et is the time at which the state of the orbiting body
+ is to be determined, in ephemeris seconds J2000.
+
+-Detailed_Output
+
+ state is the state (position and velocity) of the body at
+ time `et'. Components are x, y, z, dx/dt, dy/dt, dz/dt.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the eccentricity supplied is less than 0, the error
+ SPICE(BADECCENTRICITY) is signaled.
+
+ 2) If a non-positive periapse distance is supplied, the error
+ SPICE(BADPERIAPSEVALUE) is signaled.
+
+ 3) If a non-positive value for the attracting mass is supplied,
+ the error SPICE(BADGM), is signaled.
+
+ 4) Errors such as an out of bounds value for `et' are diagnosed
+ by routines in the call tree of this routine.
+
+-Files
+
+ None.
+
+-Particulars
+
+ None.
+
+-Examples
+
+ Let vinit contain the initial state of a spacecraft relative to the
+ center of a planet at epoch `et', and let `gm' be the gravitation
+ parameter of the planet. The call
+
+ oscelt_c ( vinit, et, gm, elts );
+
+ produces a set of osculating elements describing the nominal
+ orbit that the spacecraft would follow in the absence of all
+ other bodies in the solar system and non-gravitational forces
+ on the spacecraft.
+
+ Now let `state' contain the state of the same spacecraft at some
+ other, later epoch. The difference between this state and the
+ state predicted by the nominal orbit at the same epoch can be
+ computed as follows.
+
+ conics_c ( elts, later, nominal );
+ vsubg_c ( nominal, state, 6, diff );
+
+ printf( "Perturbation in x, dx/dt = %f %f", diff[0], diff[3] );
+ printf( " y, dy/dt = %f %f", diff[1], diff[4] );
+ printf( " z, dz/dt = %f %f", diff[2], diff[5] );
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ [1] Roger Bate, Fundamentals of Astrodynamics, Dover, 1971.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ I.M. Underwood (JPL)
+ W.L. Taber (JPL)
+ E.D. Wright (JPL)
+
+-Version
+
+ -CSPICE Version 1.1.1, 29-JUL-2003 (NJB)
+
+ Various header corrections were made.
+
+ -CSPICE Version 1.1.0, 24-JUL-2001 (NJB)
+
+ Changed protoype: input elts is now type (ConstSpiceDouble *).
+ Implemented interface macro for casting input array to const.
+
+ -CSPICE Version 1.0.1, 08-FEB-1998 (EDW)
+
+ Corrected and clarified header entries.
+
+ -CSPICE Version 1.0.0, 10-NOV-1997 (EDW)
+
+-Index_Entries
+
+ state from conic elements
+
+-&
+*/
+
+{ /* Begin conics_c */
+
+ /*
+ Participate in error tracing.
+ */
+
+ chkin_c ( "conics_c");
+
+ conics_ ( ( doublereal * ) elts,
+ ( doublereal * ) &et,
+ ( doublereal * ) state );
+
+ chkout_c ( "conics_c");
+
+
+} /* End conics_c */
diff --git a/ext/spice/src/cspice/convrt.c b/ext/spice/src/cspice/convrt.c
new file mode 100644
index 0000000000..d648c96cb7
--- /dev/null
+++ b/ext/spice/src/cspice/convrt.c
@@ -0,0 +1,414 @@
+/* convrt.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__27 = 27;
+static integer c__5 = 5;
+static integer c__3 = 3;
+static integer c__9 = 9;
+
+/* $Procedure CONVRT ( Convert Units ) */
+/* Subroutine */ int convrt_(doublereal *x, char *in, char *out, doublereal *
+ y, ftnlen in_len, ftnlen out_len)
+{
+ /* Initialized data */
+
+ static logical first = TRUE_;
+ static char units[16*27] = "RADIANS " "DEGREES " "ARCMIN"
+ "UTES " "ARCSECONDS " "HOURANGLE " "MINUTEANGLE "
+ " " "SECONDANGLE " "METERS " "KM "
+ "CM " "MM " "LIGHTSECS " "AU "
+ " " "FEET " "INCHES " "STATUTE_MILES"
+ " " "NAUTICAL_MILES " "YARDS " "LIGHTYEARS "
+ "PARSECS " "SECONDS " "MINUTES " "HOURS "
+ " " "DAYS " "JULIAN_YEARS " "TROPICAL_YEAR"
+ "S " "YEARS ";
+ static doublereal cnvrtn[27] = { 0.0,1.,.016666666666666666,
+ 2.7777777777777778e-4,15.,.25,.0041666666666666666,1.,1e3,.01,
+ .001,299792458.,149597870613.68887,.3048,.0254,1609.344,1852.,
+ .9144,9460730472580800.,30856775797231604.,1.,60.,3600.,86400.,
+ 31557600.,31556925.976319999,31557600. };
+ static char type__[8*27] = "ANGLE " "ANGLE " "ANGLE " "ANGLE "
+ "ANGLE " "ANGLE " "ANGLE " "DISTANCE" "DISTANCE" "DISTANCE"
+ "DISTANCE" "DISTANCE" "DISTANCE" "DISTANCE" "DISTANCE" "DISTANCE"
+ "DISTANCE" "DISTANCE" "DISTANCE" "DISTANCE" "TIME " "TIME "
+ "TIME " "TIME " "TIME " "TIME " "TIME ";
+
+ /* System generated locals */
+ address a__1[5], a__2[3], a__3[9];
+ integer i__1[5], i__2[3], i__3, i__4, i__5[9];
+ char ch__1[101], ch__2[56], ch__3[57], ch__4[123];
+
+ /* Builtin functions */
+ /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
+ integer s_rnge(char *, integer, char *, integer), s_cmp(char *, char *,
+ ftnlen, ftnlen);
+
+ /* Local variables */
+ doublereal temp;
+ char outu[16];
+ integer i__, j;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), ucase_(char *, char *,
+ ftnlen, ftnlen);
+ extern integer isrchc_(char *, integer *, char *, ftnlen, ftnlen);
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen);
+ extern logical return_(void);
+ extern doublereal dpr_(void);
+ char inu[16];
+
+/* $ Abstract */
+
+/* Take a measurement X, the units associated with */
+/* X, and units to which X should be converted; return Y --- */
+/* the value of the measurement in the output units. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CONVERSION, UNITS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- ------------------------------------------------- */
+/* X I Number representing a measurement in some units. */
+/* IN I The units in which X is measured. */
+/* OUT I Desired units for the measurement. */
+/* Y O The measurment in the desired units. */
+
+/* $ Detailed_Input */
+
+/* X is a number representing a measurement in the units */
+/* specified by IN. */
+
+/* IN represents the units associated with a measurement X. */
+/* Acceptable units are: */
+
+/* Angles: 'RADIANS' */
+/* 'DEGREES' */
+/* 'ARCMINUTES' */
+/* 'ARCSECONDS' */
+/* 'HOURANGLE' */
+/* 'MINUTEANGLE' */
+/* 'SECONDANGLE' */
+
+/* Metric Distances: 'METERS' */
+/* 'KM' */
+/* 'CM' */
+/* 'MM' */
+
+/* English Distances: 'FEET' */
+/* 'INCHES' */
+/* 'YARDS' */
+/* 'STATUTE_MILES' */
+/* 'NAUTICAL_MILES' */
+
+/* Astrometric Distances: 'AU' */
+/* 'PARSECS' */
+/* 'LIGHTSECS' */
+/* 'LIGHTYEARS' julian lightyears */
+
+/* Time: 'SECONDS' */
+/* 'MINUTES' */
+/* 'HOURS' */
+/* 'DAYS' */
+/* 'JULIAN_YEARS' */
+/* 'TROPICAL_YEARS' */
+/* 'YEARS' (same as julian years) */
+
+/* OUT represents the units desired for the measurement X. */
+/* See the description of IN. */
+
+/* $ Detailed_Output */
+
+/* Y is the input measurement converted to the desired */
+/* units. */
+
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine converts a measurement X given in units specified by */
+/* IN to the equivalent value Y in units specified by OUT. */
+
+/* If a unit is not recognized, an error message is produced that */
+/* indicates which one was not recognized. */
+
+/* If input and output units are incompatible (for example ANGLE */
+/* and DISTANCE units) and error message will be produced stating */
+/* the requested units and associated types. */
+
+/* $ Examples */
+
+/* To convert 1 meter to statute miles and feet you could */
+
+/* CALL CONVRT ( 1.0D0, 'METERS', 'STATUTE_MILES', MILES ) */
+/* CALL CONVRT ( MILES, 'STATUTE_MILES', 'FEET', FEET ) */
+
+/* or */
+
+/* CALL CONVRT ( 1.0D0, 'METERS', 'STATUTE_MILES', MILES ) */
+/* CALL CONVRT ( 1.0D0, 'METERS', 'FEET', FEET ) */
+
+
+/* $ Restrictions */
+
+/* You should make sure that your units are appropriate for the */
+/* measurement. This routine does not do any checking for over- */
+/* flow. Something like */
+
+/* CALL ( 10.0D22, 'LIGHTYEARS', 'MM', Y ) */
+
+/* will cause a floating point overflow. */
+
+/* Some of the units are not "defined" quantities. In such a case */
+/* a best estimate is provided as of the date of the current version */
+/* of this routine. Those estimated quantities are: */
+
+/* 1 AU --- the astronomical unit is taken from the JPL */
+/* ephemeris DE125. It is believed to be accurate to */
+/* about 40 meters. */
+
+/* The tropical year is the time from equinox to equinox. This */
+/* varies slightly with time. */
+
+/* 1 PARSEC --- is dependent upon the value of the astronomical */
+/* unit. */
+
+/* $ Exceptions */
+
+/* 1) If the input units, output units, or both input and */
+/* output units are not recognized, the error */
+/* SPICE(UNITSNOTREC) is signalled. */
+
+/* 2) If the units being converted between are incompatible, the */
+/* error SPICE(INCOMPATIBLEUNITS) is signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* C.A. Curzon (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.M. Owen (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (CAC) (WMO) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* convert units */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.2.0, 05-JAN-1990 (WLT) */
+
+/* Data statements for double precision values were changed */
+/* to include a 'D' so that this routine would function properly */
+/* on the Univac. */
+
+/* - Beta Version 1.1.0, 02-MAR-1989 (HAN) */
+
+/* The variable LIGHTYEAR was changed to LTYEAR in order to */
+/* comply with the ANSI Fortran Standard six character */
+/* variable name length restriction. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* 1.0d0 divided by the sin of 1 arc second */
+
+
+/* Angular Conversions: */
+
+/* (1) Degrees/Radians */
+/* (2) Degrees/Degrees */
+/* (3) Degrees/ARCMINUTES */
+/* (4) Degrees/ARCSECONDS */
+
+/* () Degrees/HOURANGLE */
+/* () Degrees/MINUTEANGLE */
+/* () Degrees/SECONDANGLE */
+
+
+/* DATA CNVRTN (ANG + 1) / DPR() / */
+
+/* This value will be loaded using the SPICELIB function DPR() */
+/* on the first execution of this routine. */
+
+
+/* Distance Conversions ( 5 through 17 ) */
+
+/* ( 5) Meters/Meter */
+/* ( 6) Meters/Km */
+/* ( 7) Meters/Cm */
+/* ( 8) Meters/mm */
+/* ( 9) Meters/Lightsecs */
+/* (10) Meters/AU */
+
+
+/* Distance Conversions */
+
+/* (+ 7 ) Meters/Foot */
+/* (+ 8 ) Meters/inch */
+/* (+ 9 ) Meters/Statute Mile */
+/* (+ 10) Meters/Nautical Mile */
+/* (+ 11) Meters/Yard */
+
+
+/* Distance Conversions */
+
+/* (+ 12) Meters/LightYear */
+/* (+ 13) Meters/Parsec */
+
+
+/* Time Conversions */
+
+/* (+ 1 ) seconds / second */
+/* (+ 2 ) seconds / minute */
+/* (+ 3 ) seconds / hour */
+/* (+ 4 ) seconds / day */
+/* (+ 5 ) Seconds / Julian year */
+/* (+ 6 ) Seconds / Tropical year */
+/* (+ 7 ) Seconds / year --- same as Julian year */
+
+
+/* Set up the error processing. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("CONVRT", (ftnlen)6);
+ if (first) {
+ cnvrtn[0] = dpr_();
+ first = FALSE_;
+ }
+ ucase_(in, inu, in_len, (ftnlen)16);
+ ucase_(out, outu, out_len, (ftnlen)16);
+ i__ = isrchc_(inu, &c__27, units, (ftnlen)16, (ftnlen)16);
+ j = isrchc_(outu, &c__27, units, (ftnlen)16, (ftnlen)16);
+ if (i__ == 0 || j == 0) {
+ if (i__ == 0 && j == 0) {
+/* Writing concatenation */
+ i__1[0] = 32, a__1[0] = "CONVRT: Neither the input units ";
+ i__1[1] = 16, a__1[1] = inu;
+ i__1[2] = 21, a__1[2] = "nor the output units ";
+ i__1[3] = 16, a__1[3] = outu;
+ i__1[4] = 16, a__1[4] = "were recognized.";
+ s_cat(ch__1, a__1, i__1, &c__5, (ftnlen)101);
+ setmsg_(ch__1, (ftnlen)101);
+ sigerr_("SPICE(UNITSNOTREC)", (ftnlen)18);
+ chkout_("CONVRT", (ftnlen)6);
+ return 0;
+ } else if (i__ == 0) {
+/* Writing concatenation */
+ i__2[0] = 20, a__2[0] = "CONVRT: Input units ";
+ i__2[1] = 16, a__2[1] = inu;
+ i__2[2] = 20, a__2[2] = " were not recognized";
+ s_cat(ch__2, a__2, i__2, &c__3, (ftnlen)56);
+ setmsg_(ch__2, (ftnlen)56);
+ sigerr_("SPICE(UNITSNOTREC)", (ftnlen)18);
+ chkout_("CONVRT", (ftnlen)6);
+ return 0;
+ } else if (j == 0) {
+/* Writing concatenation */
+ i__2[0] = 21, a__2[0] = "CONVRT: Output units ";
+ i__2[1] = 16, a__2[1] = outu;
+ i__2[2] = 20, a__2[2] = " were not recognized";
+ s_cat(ch__3, a__2, i__2, &c__3, (ftnlen)57);
+ setmsg_(ch__3, (ftnlen)57);
+ sigerr_("SPICE(UNITSNOTREC)", (ftnlen)18);
+ chkout_("CONVRT", (ftnlen)6);
+ return 0;
+ }
+ }
+ if (s_cmp(type__ + (((i__3 = i__ - 1) < 27 && 0 <= i__3 ? i__3 : s_rnge(
+ "type", i__3, "convrt_", (ftnlen)514)) << 3), type__ + (((i__4 =
+ j - 1) < 27 && 0 <= i__4 ? i__4 : s_rnge("type", i__4, "convrt_",
+ (ftnlen)514)) << 3), (ftnlen)8, (ftnlen)8) != 0) {
+/* Writing concatenation */
+ i__5[0] = 58, a__3[0] = "CONVRT: Incompatible units. You are attempt"
+ "ing to convert ";
+ i__5[1] = 16, a__3[1] = inu;
+ i__5[2] = 6, a__3[2] = "type: ";
+ i__5[3] = 8, a__3[3] = type__ + (((i__3 = i__ - 1) < 27 && 0 <= i__3 ?
+ i__3 : s_rnge("type", i__3, "convrt_", (ftnlen)516)) << 3);
+ i__5[4] = 4, a__3[4] = " to ";
+ i__5[5] = 16, a__3[5] = outu;
+ i__5[6] = 6, a__3[6] = "type: ";
+ i__5[7] = 8, a__3[7] = type__ + (((i__4 = j - 1) < 27 && 0 <= i__4 ?
+ i__4 : s_rnge("type", i__4, "convrt_", (ftnlen)516)) << 3);
+ i__5[8] = 1, a__3[8] = ".";
+ s_cat(ch__4, a__3, i__5, &c__9, (ftnlen)123);
+ setmsg_(ch__4, (ftnlen)123);
+ sigerr_("SPICE(INCOMPATIBLEUNITS)", (ftnlen)24);
+ chkout_("CONVRT", (ftnlen)6);
+ return 0;
+ }
+ temp = *x * cnvrtn[(i__3 = i__ - 1) < 27 && 0 <= i__3 ? i__3 : s_rnge(
+ "cnvrtn", i__3, "convrt_", (ftnlen)532)];
+ *y = temp / cnvrtn[(i__3 = j - 1) < 27 && 0 <= i__3 ? i__3 : s_rnge("cnv"
+ "rtn", i__3, "convrt_", (ftnlen)533)];
+ chkout_("CONVRT", (ftnlen)6);
+ return 0;
+} /* convrt_ */
+
diff --git a/ext/spice/src/cspice/convrt_c.c b/ext/spice/src/cspice/convrt_c.c
new file mode 100644
index 0000000000..ebf49f773c
--- /dev/null
+++ b/ext/spice/src/cspice/convrt_c.c
@@ -0,0 +1,248 @@
+/*
+
+-Procedure convrt_c ( Convert Units )
+
+-Abstract
+
+ Take a measurement X, the units associated with
+ X, and units to which X should be converted; return Y ---
+ the value of the measurement in the output units.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ CONVERSION, UNITS
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ void convrt_c ( SpiceDouble x,
+ ConstSpiceChar * in,
+ ConstSpiceChar * out,
+ SpiceDouble * y )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- -------------------------------------------------
+ x I Number representing a measurement in some units.
+ in I The units in which x is measured.
+ out I Desired units for the measurement.
+ y O The measurment in the desired units.
+
+-Detailed_Input
+
+ x is a number representing a measurement in the units
+ specified by in.
+
+ in represents the units associated with a measurement x.
+ Acceptable units are:
+
+ Angles: "RADIANS"
+ "DEGREES"
+ "ARCMINUTES"
+ "ARCSECONDS"
+ "HOURANGLE"
+ "MINUTEANGLE"
+ "SECONDANGLE"
+
+ Metric Distances: "METERS"
+ "KM"
+ "CM"
+ "MM"
+
+ English Distances: "FEET"
+ "INCHES"
+ "YARDS"
+ "STATUTE_MILES"
+ "NAUTICAL_MILES"
+
+ Astrometric Distances: "AU"
+ "PARSECS"
+ "LIGHTSECS"
+ "LIGHTYEARS" julian lightyears
+
+ Time: "SECONDS"
+ "MINUTES"
+ "HOURS"
+ "DAYS"
+ "JULIAN_YEARS"
+ "TROPICAL_YEARS"
+ "YEARS" (same as julian years)
+
+
+ The case of the string in is not significant.
+
+
+ out represents the units desired for the measurement x.
+ See the description of in.
+
+ The case of the string out is not significant.
+
+
+-Detailed_Output
+
+ y is the input measurement converted to the desired units.
+
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the input units, output units, or both input and
+ output units are not recognized, the error
+ SPICE(UNITSNOTREC) is signaled.
+
+ 2) If the units being converted between are incompatible, the
+ error SPICE(INCOMPATIBLEUNITS) is signaled.
+
+-Particulars
+
+ This routine converts a measurement x given in units specified by
+ in to the equivalent value y in units specified by out.
+
+ If a unit is not recognized, an error message is produced that
+ indicates which one was not recognized.
+
+ If input and output units are incompatible (for example angle
+ and distance units) and error message will be produced stating
+ the requested units and associated types.
+
+-Examples
+
+ To convert 1 meter to statute miles and feet you could make the
+ calls
+
+
+ convrt_c ( 1.0, "meters", "statute_miles", &miles );
+ convrt_c ( miles, "statute_miles", "feet", &feet );
+
+ or
+
+ convrt_c ( 1.0, "METERS", "STATUTE_MILES", &miles );
+ convrt_c ( 1.0, "METERS", "FEET", &feet );
+
+
+-Restrictions
+
+ You should make sure that your units are appropriate for the
+ measurement. This routine does not do any checking for over-
+ flow. Something like
+
+ convrt_c ( 10.0e302, "LIGHTYEARS", "MM", &y );
+
+ will cause a floating point overflow.
+
+ Some of the units are not "defined" quantities. In such a case
+ a best estimate is provided as of the date of the current version
+ of this routine. Those estimated quantities are:
+
+ 1 AU --- the astronomical unit is taken from the JPL
+ ephemeris DE125. It is believed to be accurate to
+ about 40 meters.
+
+ The tropical year is the time from equinox to equinox. This
+ varies slightly with time.
+
+ 1 PARSEC --- is dependent upon the value of the astronomical
+ unit.
+
+-Files
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ C.A. Curzon (JPL)
+ H.A. Neilan (JPL)
+ W.M. Owen (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.0, 17-MAY-1999 (NJB)(CAC)(HAN)(WMO)(WLT)(IMU)
+
+-Index_Entries
+
+ convert units
+
+-&
+*/
+
+{ /* Begin convrt_c */
+
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "convrt_c" );
+
+
+ /*
+ Check the column name to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "convrt_c", in );
+ CHKFSTR ( CHK_STANDARD, "convrt_c", out );
+
+
+ /*
+ Call the f2c'd Fortran routine.
+ */
+
+ convrt_ ( ( doublereal * ) &x,
+ ( char * ) in,
+ ( char * ) out,
+ ( doublereal * ) y,
+ ( ftnlen ) strlen(in),
+ ( ftnlen ) strlen(out) );
+
+
+ chkout_c ( "convrt_c" );
+
+} /* End convrt_c */
+
diff --git a/ext/spice/src/cspice/copy_c.c b/ext/spice/src/cspice/copy_c.c
new file mode 100644
index 0000000000..9c7590b0a9
--- /dev/null
+++ b/ext/spice/src/cspice/copy_c.c
@@ -0,0 +1,272 @@
+/*
+
+-Procedure copy_c ( Copy a CSPICE cell )
+
+-Abstract
+
+ Copy the contents of a SpiceCell of any data type to another
+ cell of the same type.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ CELLS
+
+-Keywords
+
+ CELLS
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+
+
+ void copy_c ( SpiceCell * cell,
+ SpiceCell * copy )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ cell I Cell to be copied.
+ copy O New cell.
+
+-Detailed_Input
+
+ cell is a cell of character, double precision, or
+ integer data type.
+
+
+-Detailed_Output
+
+ copy is a cell which contains the same elements as the
+ input cell, in the same order.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the cell arguments don't have matching data types,
+ the error SPICE(TYPEMISMATCH) is signaled.
+
+ 2) If the output cell in not large enough to hold the elements
+ of the input cell, the error SPICE(CELLTOOSMALL) is signaled.
+
+ 3) If the cell arguments have character type and the length of the
+ elements of the output cell is less than the length of the
+ elements of the input cell, the error SPICE(INSUFFLEN) is
+ signaled.
+
+-Files
+
+ None.
+
+-Particulars
+
+ This routine is used primarily to manipulate working cells, since
+ many routines that use cells (binary set routines, for instance) do
+ not allow cells to be combined or manipulated in place.
+
+-Examples
+
+ In the following example, copy_c is used to copy the result
+ of the union of two character CSICE sets from a temporary
+ working set back into the one of the original set.
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Declare the cell names with string length LNSIZE and maximum
+ number of strings SIZE.
+ ./
+ SPICECHAR_CELL ( bodies, SIZE, LNSIZE );
+ SPICECHAR_CELL ( planets, SIZE, LNSIZE );
+ SPICECHAR_CELL ( temp, SIZE, LNSIZE );
+ .
+ .
+ .
+ union_c ( &bodies, &planets, &temp );
+ copy_c ( &temp, &bodies );
+
+
+ If the size of the temporary cell is greater than the size
+ of the original set, the function failed_c should be checked to be
+ sure that no overflow occurred. If bodies is at least as
+ large as temp, no such check is necessary.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ C.A. Curzon (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 08-AUG-2002 (NJB) (CAC) (WLT) (IMU)
+
+-Index_Entries
+
+ copy a character cell
+
+-&
+*/
+
+{ /* Begin copy_c */
+
+
+ /*
+ Local variables
+ */
+ SpiceChar * fCell[2];
+
+ SpiceInt fLen [2];
+ SpiceInt i;
+
+
+ /*
+ Standard SPICE error handling.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+ chkin_c ( "copy_c" );
+
+
+ /*
+ Make sure data types match.
+ */
+ CELLMATCH2 ( CHK_STANDARD, "copy_c", cell, copy );
+
+
+ /*
+ Initialize the cells if necessary.
+ */
+ CELLINIT2 ( cell, copy );
+
+
+ /*
+ Call the copy routine appropriate for the data type of the cells.
+ */
+ if ( cell->dtype == SPICE_CHR )
+ {
+
+ /*
+ Construct Fortran-style sets suitable for passing to copyc_.
+ */
+ C2F_MAP_CELL2 ( "copy_c",
+ cell, fCell, fLen,
+ copy, fCell+1, fLen+1 );
+
+ if ( failed_c() )
+ {
+ chkout_c ( "copy_c" );
+ return;
+ }
+
+ copyc_ ( (char * ) fCell[0],
+ (char * ) fCell[1],
+ (ftnlen ) fLen[0],
+ (ftnlen ) fLen[1] );
+
+ if ( !failed_c() )
+ {
+ /*
+ Map the copy back to a C style cell.
+ */
+ F2C_MAP_CELL ( fCell[1], fLen[1], copy );
+ }
+
+ /*
+ We're done with the dynamically allocated Fortran-style arrays.
+ */
+ for ( i = 0; i < 2; i++ )
+ {
+ free ( fCell[i] );
+ }
+ }
+
+ else if ( cell->dtype == SPICE_DP )
+ {
+ copyd_ ( (doublereal * ) (cell->base),
+ (doublereal * ) (copy->base) );
+
+ /*
+ Sync the output cell.
+ */
+ if ( !failed_c() )
+ {
+ zzsynccl_c ( F2C, copy );
+ }
+
+ }
+
+ else if ( cell->dtype == SPICE_INT )
+ {
+ copyi_ ( (integer * ) (cell->base),
+ (integer * ) (copy->base) );
+
+ /*
+ Sync the output cell.
+ */
+ if ( !failed_c() )
+ {
+ zzsynccl_c ( F2C, copy );
+ }
+
+ }
+
+ else
+ {
+ setmsg_c ( "Source cell contains unrecognized data type code #." );
+ errint_c ( "#", (SpiceInt) (cell->dtype) );
+ sigerr_c ( "SPICE(NOTSUPPORTED)" );
+ chkout_c ( "copy_c" );
+ return;
+ }
+
+ chkout_c ( "copy_c" );
+
+} /* End copy_c */
diff --git a/ext/spice/src/cspice/copyc.c b/ext/spice/src/cspice/copyc.c
new file mode 100644
index 0000000000..408f95d2b8
--- /dev/null
+++ b/ext/spice/src/cspice/copyc.c
@@ -0,0 +1,263 @@
+/* copyc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure COPYC ( Copy a character cell ) */
+/* Subroutine */ int copyc_(char *cell, char *copy, ftnlen cell_len, ftnlen
+ copy_len)
+{
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_cmp(char *, char *, ftnlen, ftnlen), i_len(char *, ftnlen);
+
+ /* Local variables */
+ integer card, size, i__;
+ extern integer cardc_(char *, ftnlen);
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer moved;
+ extern integer sizec_(char *, ftnlen);
+ logical trunc;
+ extern /* Subroutine */ int scardc_(integer *, char *, ftnlen);
+ extern integer lastpc_(char *, ftnlen);
+ integer reqlen;
+ extern /* Subroutine */ int excess_(integer *, char *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen),
+ errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Copy the contents of a character cell to another cell. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CELLS */
+
+/* $ Keywords */
+
+/* CELLS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* CELL I Cell to be copied. */
+/* COPY O New cell. */
+
+/* $ Detailed_Input */
+
+
+/* CELL is a cell. */
+
+
+/* $ Detailed_Output */
+
+/* COPY is a cell which contains the same elements as the */
+/* input cell, in the same order. If the size (maximum */
+/* cardinality) of the output cell is smaller than */
+/* the cardinality of the input cell, then only as many */
+/* items as will fit in the output cell are copied, */
+/* and an error is signalled. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The copy routines (COPYC, COPYD, and COPYI) are used primarily */
+/* to manipulate working cells, since many routines that use cells */
+/* (binary set routines, for instance) do not allow cells to be */
+/* combined or manipulated in place. */
+
+/* $ Examples */
+
+/* In the following example, COPYC is used to copy the result */
+/* of the union of two sets (ordered cells) from a temporary */
+/* working set back into the one of the original set. */
+
+/* CALL UNIONC ( BODIES, PLANETS, TEMP ) */
+/* CALL COPYC ( TEMP, BODIES ) */
+
+/* If the size of the temporary cell is greater than the size */
+/* of the original set, the function FAILED should be checked to be */
+/* sure that no overflow occurred. If BODIES is at least as */
+/* large as TEMP, no such check is necessary. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the output cell in not large enough to hold the elements */
+/* of the input cell, the error SPICE(CELLTOOSMALL) is signalled. */
+
+/* 2) If length of the elements of the output cell is less than the */
+/* length of the elements of the input cell, the error */
+/* SPICE(ELEMENTSTOOSHORT) is signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* C.A. Curzon (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (CAC) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* copy a character cell */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 2.0.0, 09-JAN-1989 (NJB) */
+
+/* Error signalled if output set elements are not long enough. */
+/* Length must be at least max of lengths of input elements. */
+/* Also, calling protocol for EXCESS has been changed. And, */
+/* elements LBCELL through -2 of control area are now copied to */
+/* the output cell. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Set up the error processing. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("COPYC", (ftnlen)5);
+
+/* We need the cardinality of the input cell, and the size of */
+/* the output cell. */
+
+ card = cardc_(cell, cell_len);
+ size = sizec_(copy, copy_len);
+
+/* Start moving the elements, one by one. Stop if the output */
+/* cell fills up. Copy the control area too, except for the */
+/* the size and cardinality values. Truncation indicator */
+/* starts at .FALSE. */
+
+ trunc = FALSE_;
+ reqlen = 0;
+ moved = min(card,size);
+ i__1 = moved;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ s_copy(copy + (i__ + 5) * copy_len, cell + (i__ + 5) * cell_len,
+ copy_len, cell_len);
+
+/* Test for truncation: */
+
+ if (s_cmp(copy + (i__ + 5) * copy_len, cell + (i__ + 5) * cell_len,
+ copy_len, cell_len) != 0) {
+ trunc = TRUE_;
+/* Computing MAX */
+ i__2 = reqlen, i__3 = lastpc_(cell + (i__ + 5) * cell_len,
+ cell_len);
+ reqlen = max(i__2,i__3);
+ }
+ }
+ for (i__ = -5; i__ <= -2; ++i__) {
+ s_copy(copy + (i__ + 5) * copy_len, cell + (i__ + 5) * cell_len,
+ copy_len, cell_len);
+
+/* Test for truncation: */
+
+ if (s_cmp(copy + (i__ + 5) * copy_len, cell + (i__ + 5) * cell_len,
+ copy_len, cell_len) != 0) {
+ trunc = TRUE_;
+/* Computing MAX */
+ i__1 = reqlen, i__2 = lastpc_(cell + (i__ + 5) * cell_len,
+ cell_len);
+ reqlen = max(i__1,i__2);
+ }
+ }
+
+/* Set the cardinality of the output cell. */
+
+ scardc_(&moved, copy, copy_len);
+
+/* We've got an error if the output cell was too small. */
+
+ if (size < card) {
+ i__1 = card - size;
+ excess_(&i__1, "cell", (ftnlen)4);
+ sigerr_("SPICE(CELLTOOSMALL)", (ftnlen)19);
+ chkout_("COPYC", (ftnlen)5);
+ return 0;
+ }
+
+/* We also have an error if the output set elements are not long */
+/* enough. */
+
+ if (trunc) {
+ setmsg_("Length of output cell is #. Length required to contain res"
+ "ult is #.", (ftnlen)68);
+ i__1 = i_len(copy, copy_len);
+ errint_("#", &i__1, (ftnlen)1);
+ errint_("#", &reqlen, (ftnlen)1);
+ sigerr_("SPICE(ELEMENTSTOOSHORT)", (ftnlen)23);
+ chkout_("COPYC", (ftnlen)5);
+ return 0;
+ }
+ chkout_("COPYC", (ftnlen)5);
+ return 0;
+} /* copyc_ */
+
diff --git a/ext/spice/src/cspice/copyd.c b/ext/spice/src/cspice/copyd.c
new file mode 100644
index 0000000000..3962a35bdd
--- /dev/null
+++ b/ext/spice/src/cspice/copyd.c
@@ -0,0 +1,199 @@
+/* copyd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure COPYD ( Copy a double precision cell ) */
+/* Subroutine */ int copyd_(doublereal *cell, doublereal *copy)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Local variables */
+ integer card, size, i__;
+ extern integer cardd_(doublereal *);
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer moved;
+ extern integer sized_(doublereal *);
+ extern /* Subroutine */ int scardd_(integer *, doublereal *), excess_(
+ integer *, char *, ftnlen), sigerr_(char *, ftnlen), chkout_(char
+ *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Copy the contents of a double precision cell to another cell. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CELLS */
+
+/* $ Keywords */
+
+/* CELLS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* CELL I Cell to be copied. */
+/* COPY O New cell. */
+
+/* $ Detailed_Input */
+
+
+/* CELL is a cell. */
+
+
+/* $ Detailed_Output */
+
+/* COPY is a cell which contains the same elements as the */
+/* input cell, in the same order. If the size (maximum */
+/* cardinality) of the output cell is smaller than */
+/* the cardinality of the input cell, then only as many */
+/* items as will fit in the output cell are copied, */
+/* and an error is signalled. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The copy routines (COPYC, COPYD, and COPYI) are used primarily */
+/* to manipulate working cells, since many routines that use cells */
+/* (binary set routines, for instance) do not allow cells to be */
+/* combined or manipulated in place. */
+
+/* $ Examples */
+
+/* In the following example, COPYC is used to copy the result */
+/* of the union of two sets (ordered cells) from a temporary */
+/* working set back into the one of the original set. */
+
+/* CALL UNIONC ( BODIES, PLANETS, TEMP ) */
+/* CALL COPYC ( TEMP, BODIES ) */
+
+/* If the size of the temporary cell is greater than the size */
+/* of the original set, the function FAILED should be checked to be */
+/* sure that no overflow occurred. If BODIES is at least as */
+/* large as TEMP, no such check is necessary. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the output cell in not large enough to hold the elements */
+/* of the input cell, the error SPICE(CELLTOOSMALL) is signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* C.A. Curzon (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (CAC) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* copy a d.p. cell */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.1.0, 09-JAN-1989 (NJB) */
+
+/* Calling protocol for EXCESS has been changed. Call to SETMSG */
+/* has been removed. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Set up the error processing. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("COPYD", (ftnlen)5);
+
+/* We need the cardinality of the input cell, and the size of */
+/* the output cell. */
+
+ card = cardd_(cell);
+ size = sized_(copy);
+
+/* Start moving the elements, one by one. Stop if the output */
+/* cell fills up. */
+
+ moved = min(card,size);
+ i__1 = moved;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ copy[i__ + 5] = cell[i__ + 5];
+ }
+
+/* Set the cardinality of the output cell. Report any excess. */
+
+ scardd_(&moved, copy);
+ if (card > size) {
+ i__1 = card - size;
+ excess_(&i__1, "cell", (ftnlen)4);
+ sigerr_("SPICE(CELLTOOSMALL)", (ftnlen)19);
+ chkout_("COPYD", (ftnlen)5);
+ return 0;
+ }
+ chkout_("COPYD", (ftnlen)5);
+ return 0;
+} /* copyd_ */
+
diff --git a/ext/spice/src/cspice/copyi.c b/ext/spice/src/cspice/copyi.c
new file mode 100644
index 0000000000..9e3b887ffe
--- /dev/null
+++ b/ext/spice/src/cspice/copyi.c
@@ -0,0 +1,200 @@
+/* copyi.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure COPYI ( Copy an integer cell ) */
+/* Subroutine */ int copyi_(integer *cell, integer *copy)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Local variables */
+ integer card, size, i__;
+ extern integer cardi_(integer *);
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer moved;
+ extern integer sizei_(integer *);
+ extern /* Subroutine */ int scardi_(integer *, integer *), excess_(
+ integer *, char *, ftnlen), sigerr_(char *, ftnlen), chkout_(char
+ *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Copy the contents of an integer cell to another cell. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* CELLS */
+
+/* $ Keywords */
+
+/* CELLS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* CELL I Cell to be copied. */
+/* COPY O New cell. */
+
+/* $ Detailed_Input */
+
+
+/* CELL is a cell. */
+
+
+/* $ Detailed_Output */
+
+/* COPY is a cell which contains the same elements as the */
+/* input cell, in the same order. If the size (maximum */
+/* cardinality) of the output cell is smaller than */
+/* the cardinality of the input cell, then only as many */
+/* items as will fit in the output cell are copied, */
+/* and an error is signalled. */
+
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The copy routines (COPYC, COPYD, and COPYI) are used primarily */
+/* to manipulate working cells, since many routines that use cells */
+/* (binary set routines, for instance) do not allow cells to be */
+/* combined or manipulated in place. */
+
+/* $ Examples */
+
+/* In the following example, COPYC is used to copy the result */
+/* of the union of two sets (ordered cells) from a temporary */
+/* working set back into the one of the original set. */
+
+/* CALL UNIONC ( BODIES, PLANETS, TEMP ) */
+/* CALL COPYC ( TEMP, BODIES ) */
+
+/* If the size of the temporary cell is greater than the size */
+/* of the original set, the function FAILED should be checked to be */
+/* sure that no overflow occurred. If BODIES is at least as */
+/* large as TEMP, no such check is necessary. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the output cell in not large enough to hold the elements */
+/* of the input cell, the error SPICE(CELLTOOSMALL) is signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* C.A. Curzon (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (CAC) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* copy an integer cell */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.1.0, 09-JAN-1989 (NJB) */
+
+/* Calling protocol for EXCESS has been changed. Call to SETMSG */
+/* has been removed. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Set up the error processing. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("COPYI", (ftnlen)5);
+
+/* We need the cardinality of the input cell, and the size of */
+/* the output cell. */
+
+ card = cardi_(cell);
+ size = sizei_(copy);
+
+/* Start moving the elements, one by one. Stop if the output */
+/* cell fills up. */
+
+ moved = min(card,size);
+ i__1 = moved;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ copy[i__ + 5] = cell[i__ + 5];
+ }
+
+/* Set the cardinality of the output cell. Report any excess. */
+
+ scardi_(&moved, copy);
+ if (card > size) {
+ i__1 = card - size;
+ excess_(&i__1, "cell", (ftnlen)4);
+ sigerr_("SPICE(CELLTOOSMALL)", (ftnlen)19);
+ chkout_("COPYI", (ftnlen)5);
+ return 0;
+ }
+ chkout_("COPYI", (ftnlen)5);
+ return 0;
+} /* copyi_ */
+
diff --git a/ext/spice/src/cspice/countc.c b/ext/spice/src/cspice/countc.c
new file mode 100644
index 0000000000..a64578ba5f
--- /dev/null
+++ b/ext/spice/src/cspice/countc.c
@@ -0,0 +1,319 @@
+/* countc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+
+/* $Procedure COUNTC ( Count characters in a text file ) */
+integer countc_(integer *unit, integer *bline, integer *eline, char *line,
+ ftnlen line_len)
+{
+ /* System generated locals */
+ integer ret_val;
+ cilist ci__1;
+ alist al__1;
+
+ /* Builtin functions */
+ integer f_rew(alist *), s_rsfe(cilist *), do_fio(integer *, char *,
+ ftnlen), e_rsfe(void), s_cmp(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ logical done;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer chars, linect;
+ extern integer lastnb_(char *, ftnlen);
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen), astrip_(
+ char *, char *, char *, char *, ftnlen, ftnlen, ftnlen, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Count the characters in a group of lines in a text file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CHARACTERS */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* UNIT I Logical unit connected to text file. */
+/* BLINE I Beginning line number. */
+/* ELINE I Ending line number. */
+/* LINE I,O Workspace. */
+
+/* COUNTC returns the number of characters. */
+
+/* $ Detailed_Input */
+
+/* UNIT is a logical unit that has been connected to a */
+/* text file by the calling program. Use the routine */
+/* TXTOPR to open the file for read access and get its */
+/* logical unit. A text file is a formatted, */
+/* sequential file that contains only printable */
+/* characters: ASCII 32-126. */
+
+/* BLINE, */
+/* ELINE are line numbers in the text file. BLINE is */
+/* the line where the count will begin, and ELINE */
+/* is the line where the count will end. The */
+/* number of characters in the beginning and ending */
+/* lines are included in the total count. */
+
+/* By convention, line 1 is the first line of the file. */
+
+/* LINE on input, is an arbitrary character string whose */
+/* contents are ignored. LINE is used to read lines */
+/* from the file connected to UNIT; its function */
+/* is to determine the maximum length of the lines */
+/* that can be read from the file. Lines longer */
+/* than the declared length of LINE are truncated */
+/* as they are read. */
+
+/* $ Detailed_Output */
+
+/* LINE on output, is undefined. */
+
+/* The function, COUNTC, returns the number of characters in the */
+/* group of lines in the file beginning with BLINE and ending with */
+/* ELINE. Trailing blanks on a line are not included in the count. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If an error occurs while reading from the input file, */
+/* the error SPICE(FILEREADFAILED) is signalled. */
+
+/* 2) If a non-printing ASCII character is encountered during */
+/* the count, the error SPICE(INVALIDTEXT) is signalled. */
+
+/* 3) If BLINE is greater than ELINE or if the file does not */
+/* contain both of this lines, the error SPICE(CANNOTFINDGRP) */
+/* is signalled. */
+
+/* $ Files */
+
+/* See argument UNIT. COUNTC rewinds the text file connected to */
+/* UNIT and then steps through the file. The next read statement */
+/* after calling COUNTC would return the line after ELINE. */
+
+/* $ Particulars */
+
+/* This routine counts characters in a group of lines in a text */
+/* file. Using COUNTC, you can determine in advance how much space */
+/* is required to store those characters. */
+
+/* $ Examples */
+
+/* The following code fragment opens an existing text file for */
+/* read access and counts the characters that it contains in */
+/* the first five lines. We'll assume that the longest line */
+/* in the file is 80 characters. */
+
+/* INTEGER COUNTC */
+/* INTEGER UNIT */
+/* INTEGER N */
+/* CHARACTER*(80) LINE */
+
+/* CALL TXTOPR ( 'DATA.TXT', UNIT ) */
+
+/* N = COUNTC ( UNIT, 1, 5, LINE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* J.E. McLean (JPL) */
+/* H.A. Neilan (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 17-MAY-1994 (HAN) */
+
+/* Set the default function value to either 0, 0.0D0, .FALSE., */
+/* or blank depending on the type of the function. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 05-APR-1991 (JEM) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* count characters in a text file */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ ret_val = 0;
+ return ret_val;
+ } else {
+ chkin_("COUNTC", (ftnlen)6);
+ ret_val = 0;
+ }
+
+/* First, see if the line numbers make sense. */
+
+ if (*bline > *eline || *bline <= 0) {
+ setmsg_("The line numbers do not make sense: BLINE = # and ELINE ="
+ " #.", (ftnlen)62);
+ errint_("#", bline, (ftnlen)1);
+ errint_("#", eline, (ftnlen)1);
+ sigerr_("SPICE(CANNOTFINDGRP)", (ftnlen)20);
+ chkout_("COUNTC", (ftnlen)6);
+ return ret_val;
+ }
+
+/* Read through the file, line by line, beginning with the first */
+/* line in the file, checking for I/O errors, and counting */
+/* characters in the lines between and including BLINE and ELINE. */
+
+ al__1.aerr = 0;
+ al__1.aunit = *unit;
+ f_rew(&al__1);
+ linect = 0;
+ chars = 0;
+ done = FALSE_;
+ while(! done) {
+ ci__1.cierr = 1;
+ ci__1.ciend = 1;
+ ci__1.ciunit = *unit;
+ ci__1.cifmt = "(A)";
+ iostat = s_rsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_fio(&c__1, line, line_len);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rsfe();
+L100001:
+
+/* An end-of-file condition is indicated by a negative value */
+/* for IOSTAT. Any other non-zero value indicates some other */
+/* error. If IOSTAT is zero, the read was successful. */
+
+ if (iostat > 0) {
+ setmsg_("Error reading text file named FILENAME.The value of IOS"
+ "TAT is #.", (ftnlen)64);
+ errint_("#", &iostat, (ftnlen)1);
+ errfnm_("FILENAME", unit, (ftnlen)8);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("COUNTC", (ftnlen)6);
+ return ret_val;
+ } else if (iostat < 0) {
+ setmsg_("Reached end of file unexpectedly at line # in file FILE"
+ ". BLINE = # and ELINE = #.", (ftnlen)82);
+ errint_("#", &linect, (ftnlen)1);
+ errint_("#", bline, (ftnlen)1);
+ errint_("#", eline, (ftnlen)1);
+ errfnm_("FILE", unit, (ftnlen)4);
+ sigerr_("SPICE(CANNOTFINDGRP)", (ftnlen)20);
+ chkout_("COUNTC", (ftnlen)6);
+ return ret_val;
+ } else {
+
+/* We've read a line successfully, so add it to the line count. */
+/* If this line is in the group delimited by BLINE and ELINE, */
+/* count the characters in it, and if this line is ELINE, we're */
+/* done. */
+
+ ++linect;
+ if (linect >= *bline && linect <= *eline) {
+
+/* Add the number of characters in this line to the count. */
+/* If LINE is blank, LASTNB will return 0 which is just */
+/* what we want. */
+
+ chars += lastnb_(line, line_len);
+
+/* Remove the printable characters from the line. If */
+/* any characters remain, signal an error. */
+
+ astrip_(line, " ", "~", line, line_len, (ftnlen)1, (ftnlen)1,
+ line_len);
+ if (s_cmp(line, " ", line_len, (ftnlen)1) != 0) {
+ setmsg_("Non-printing ASCII characters were found when c"
+ "ounting characters on line number # in file FILE"
+ "NAME.", (ftnlen)100);
+ errint_("#", &linect, (ftnlen)1);
+ errfnm_("FILENAME", unit, (ftnlen)8);
+ sigerr_("SPICE(INVALIDTEXT)", (ftnlen)18);
+ chkout_("COUNTC", (ftnlen)6);
+ return ret_val;
+ }
+ }
+ if (linect == *eline) {
+ done = TRUE_;
+ }
+ }
+ }
+
+/* Assign the final character count. */
+
+ ret_val = chars;
+ chkout_("COUNTC", (ftnlen)6);
+ return ret_val;
+} /* countc_ */
+
diff --git a/ext/spice/src/cspice/cpos.c b/ext/spice/src/cspice/cpos.c
new file mode 100644
index 0000000000..e9544cb46a
--- /dev/null
+++ b/ext/spice/src/cspice/cpos.c
@@ -0,0 +1,226 @@
+/* cpos.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CPOS ( Character position ) */
+integer cpos_(char *str, char *chars, integer *start, ftnlen str_len, ftnlen
+ chars_len)
+{
+ /* System generated locals */
+ integer ret_val;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen), i_indx(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer b;
+ logical found;
+ integer lenstr;
+
+/* $ Abstract */
+
+/* Find the first occurrence in a string of a character belonging */
+/* to a collection of characters, starting at a specified location, */
+/* searching forward. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* SCANNING */
+
+/* $ Keywords */
+
+/* CHARACTER */
+/* SEARCH */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* STR I Any character string. */
+/* CHARS I A collection of characters. */
+/* START I Position to begin looking for one of CHARS */
+
+/* The function returns the index of the first character of STR */
+/* at or following index START that is in the collection CHARS. */
+
+/* $ Detailed_Input */
+
+/* STR is any character string. */
+
+/* CHARS is a character string containing a collection */
+/* of characters. Spaces in CHARS are significant. */
+
+/* START is the position in STR to begin looking for one of */
+/* the characters in CHARS. */
+
+/* $ Detailed_Output */
+
+/* The function returns the index of the first character of STR */
+/* (at or following index START) that is one of the characters in */
+/* the string CHARS. If none of the characters is found, the */
+/* function returns zero. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error Free. */
+
+/* 1) If START is less than 1, the search begins at the first */
+/* character of the string. */
+
+/* 2) If START is greater than the length of the string, CPOS */
+/* returns zero. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* CPOS is case sensitive. */
+
+/* An entire family of related SPICELIB routines (POS, CPOS, NCPOS, */
+/* POSR, CPOSR, NCPOSR) is described in the Required Reading. */
+
+/* Those familiar with the True BASIC language should note that */
+/* these functions are equivalent to the True BASIC intrinsic */
+/* functions with the same names. */
+
+/* $ Examples */
+
+/* Let STRING = 'BOB, JOHN, TED, AND MARTIN....' */
+/* 123456789012345678901234567890 */
+
+/* Normal (sequential) searching */
+/* ----------------------------- */
+
+/* CPOS( STRING, ' ,', 1 ) = 4 */
+
+/* CPOS( STRING, ' ,', 5 ) = 5 */
+
+/* CPOS( STRING, ' ,', 6 ) = 10 */
+
+/* CPOS( STRING, ' ,', 11 ) = 11 */
+
+/* CPOS( STRING, ' ,', 12 ) = 15 */
+
+/* CPOS( STRING, ' ,', 16 ) = 16 */
+
+/* CPOS( STRING, ' ,', 17 ) = 20 */
+
+/* CPOS( STRING, ' ,', 21 ) = 0 */
+
+
+/* START out of bounds */
+/* ------------------- */
+
+/* CPOS( STRING, ' ,', -113 ) = 4 */
+
+/* CPOS( STRING, ' ,', -1 ) = 4 */
+
+/* CPOS( STRING, ' ,', 31 ) = 0 */
+
+/* CPOS( STRING, ' ,', 1231 ) = 0 */
+
+
+/* Order within CHARS */
+/* ------------------ */
+
+/* CPOS( STRING, ',. ', 22 ) = 27 */
+
+/* CPOS( STRING, ' ,.', 22 ) = 27 */
+
+/* CPOS( STRING, ', .', 22 ) = 27 */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* H.A. Neilan (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.3, 31-JAN-2008 (BVS) */
+
+/* Removed non-standard end-of-declarations marker */
+/* 'C%&END_DECLARATIONS' from comments. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 26-MAR-1991 (HAN) */
+
+/* The Required Reading file POSITION was renamed to SCANNING. */
+/* This header was updated to reflect the change. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* forward search for position of character */
+
+/* -& */
+
+/* Local variables */
+
+ lenstr = i_len(str, str_len);
+ b = max(1,*start);
+ found = FALSE_;
+ ret_val = 0;
+ while(! found) {
+ if (b > lenstr) {
+ return ret_val;
+ } else if (i_indx(chars, str + (b - 1), chars_len, (ftnlen)1) != 0) {
+ ret_val = b;
+ return ret_val;
+ } else {
+ ++b;
+ }
+ }
+ return ret_val;
+} /* cpos_ */
+
diff --git a/ext/spice/src/cspice/cpos_c.c b/ext/spice/src/cspice/cpos_c.c
new file mode 100644
index 0000000000..5786ab7818
--- /dev/null
+++ b/ext/spice/src/cspice/cpos_c.c
@@ -0,0 +1,226 @@
+/*
+
+-Procedure cpos_c ( Character position )
+
+-Abstract
+
+ Find the first occurrence in a string of a character belonging
+ to a collection of characters, starting at a specified location,
+ searching forward.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ SCANNING
+
+-Keywords
+
+ CHARACTER
+ SEARCH
+ UTILITY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+
+
+ SpiceInt cpos_c ( ConstSpiceChar * str,
+ ConstSpiceChar * chars,
+ SpiceInt start )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ str I Any character string.
+ chars I A collection of characters.
+ start I Position to begin looking for one of chars.
+
+ The function returns the index of the first character of str
+ at or following index start that is in the collection chars.
+
+-Detailed_Input
+
+ str is any character string.
+
+ chars is a character string containing a collection
+ of characters. Spaces in chars are significant,
+ including trailing blanks. The order in which
+ characters are listed is not significant.
+
+ start is the position in str to begin looking for one of
+ the characters in chars. start may range from 0
+ to n-1, where n is the number of characters in str.
+
+-Detailed_Output
+
+ The function returns the index of the first character of str (at or
+ following index start) that is one of the characters in the string
+ chars. The returned value normally ranges from 0 to n-1, where n is
+ the number of characters in str. If none of the characters is found,
+ the function returns -1.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) The error SPICE(NULLPOINTER) is signaled if either of
+ the input string pointers is null.
+
+ 2) If start is less than 0, the search begins at the first
+ character of the string.
+
+ 3) If start is greater than or equal to the length of the string,
+ cpos_c returns -1.
+
+ 4) The function returns -1 if either of the input strings is empty.
+
+-Files
+
+ None.
+
+-Particulars
+
+ cpos_c is case sensitive.
+
+ An entire family of related CSPICE routines
+
+ cpos_c
+ cposr_c
+ ncpos_c
+ ncposr_c
+ pos_c
+ posr_c
+
+ is described in the Required Reading.
+
+-Examples
+
+ Let string == "BOB, JOHN, TED, AND MARTIN...."
+ 012345678901234567890123456789
+
+
+ Normal (sequential) searching
+ -----------------------------
+
+ cpos_c( string, " ,", 0 ) == 3
+ cpos_c( string, " ,", 4 ) == 4
+ cpos_c( string, " ,", 5 ) == 9
+ cpos_c( string, " ,", 10 ) == 10
+ cpos_c( string, " ,", 11 ) == 14
+ cpos_c( string, " ,", 15 ) == 15
+ cpos_c( string, " ,", 16 ) == 19
+ cpos_c( string, " ,", 20 ) == -1
+
+
+ start out of bounds
+ -------------------
+
+ cpos_c( string, " ,", -112 ) == 3
+ cpos_c( string, " ,", -1 ) == 3
+ cpos_c( string, " ,", 1230 ) == -1
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 15-AUG-2002 (NJB) (WLT)
+
+-Index_Entries
+
+ forward search for position of character
+
+-&
+*/
+
+{ /* Begin cpos_c */
+
+
+ /*
+ Local variables
+ */
+ SpiceInt fstart;
+ SpiceInt retval;
+
+
+
+ /*
+ Use discovery check-in.
+
+ Check for null pointers.
+ */
+ CHKPTR_VAL ( CHK_DISCOVER, "cpos_c", str, -1 );
+ CHKPTR_VAL ( CHK_DISCOVER, "cpos_c", chars, -1 );
+
+
+ /*
+ Check for empty strings.
+ */
+ if ( ( strlen(str) == 0 ) || ( strlen(chars) == 0 ) )
+ {
+ return ( -1 );
+ }
+
+
+ /*
+ The rest can be handled by the f2c'd SPICELIB routine. Adjust
+ the start index to account for Fortran indexing.
+ */
+
+ fstart = start + 1;
+
+ retval = cpos_ ( (char *) str,
+ (char *) chars,
+ (integer *) &fstart,
+ (ftnlen ) strlen(str),
+ (ftnlen ) strlen(chars) );
+
+ /*
+ Adjust the return value to account for C indexing.
+ */
+ return ( retval-1 );
+
+
+} /* End cpos_c */
diff --git a/ext/spice/src/cspice/cposr.c b/ext/spice/src/cspice/cposr.c
new file mode 100644
index 0000000000..64d8e32af2
--- /dev/null
+++ b/ext/spice/src/cspice/cposr.c
@@ -0,0 +1,234 @@
+/* cposr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CPOSR ( Character position, reverse ) */
+integer cposr_(char *str, char *chars, integer *start, ftnlen str_len, ftnlen
+ chars_len)
+{
+ /* System generated locals */
+ integer ret_val;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen), i_indx(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer b;
+ logical found;
+ integer lenstr;
+
+/* $ Abstract */
+
+/* Find the first occurrence in a string of a character belonging */
+/* to a collection of characters, starting at a specified location, */
+/* searching in reverse. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* SCANNING */
+
+/* $ Keywords */
+
+/* CHARACTER */
+/* SEARCH */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* STR I Any character string. */
+/* CHARS I A collection of characters. */
+/* START I Position to begin looking for one of CHARS */
+
+/* The function returns the index of the last character of STR */
+/* at or before index START that is in the collection CHARS. */
+
+/* $ Detailed_Input */
+
+/* STR is any character string. */
+
+/* CHARS is a character string containing a collection of */
+/* characters. Spaces in CHARS are significant. */
+
+/* START is the position in STR to begin looking for one of the */
+/* characters in CHARS. */
+
+/* $ Detailed_Output */
+
+/* The function returns the index of the last character of STR (at */
+/* or before index START) that is one of the characters in the */
+/* string CHARS. If none of the characters is found, the function */
+/* returns zero. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error Free. */
+
+/* 1) If START is less than 1, CPOSR returns zero. */
+
+/* 2) If START is greater than LEN(STRING), the search begins */
+/* at the last character of the string. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* CPOSR is case sensitive. */
+
+/* An entire family of related SPICELIB routines (POS, CPOS, NCPOS, */
+/* POSR, CPOSR, NCPOSR) is desribed in the Required Reading. */
+
+/* Those familiar with the True BASIC language should note that */
+/* these functions are equivalent to the True BASIC intrinsic */
+/* functions with the same name. */
+
+/* $ Examples */
+
+/* Let STRING = 'BOB, JOHN, TED, AND MARTIN ' */
+/* 123456789012345678901234567890 */
+
+/* Normal (sequential) searching: */
+/* ------------------------------ */
+
+/* CPOSR( STRING, ' ,', 30 ) = 30 */
+
+/* CPOSR( STRING, ' ,', 29 ) = 29 */
+
+/* CPOSR( STRING, ' ,', 28 ) = 28 */
+
+/* CPOSR( STRING, ' ,', 27 ) = 27 */
+
+/* CPOSR( STRING, ' ,', 26 ) = 20 */
+
+/* CPOSR( STRING, ' ,', 19 ) = 16 */
+
+/* CPOSR( STRING, ' ,', 15 ) = 15 */
+
+/* CPOSR( STRING, ' ,', 14 ) = 11 */
+
+/* CPOSR( STRING, ' ,', 10 ) = 10 */
+
+/* CPOSR( STRING, ' ,', 9 ) = 5 */
+
+/* CPOSR( STRING, ' ,', 4 ) = 4 */
+
+/* CPOSR( STRING, ' ,', 3 ) = 0 */
+
+/* START out of bounds: */
+/* -------------------- */
+
+/* CPOSR( STRING, ' ,', 231 ) = 30 */
+
+/* CPOSR( STRING, ' ,', 31 ) = 30 */
+
+/* CPOSR( STRING, ' ,', 0 ) = 0 */
+
+/* CPOSR( STRING, ' ,', -10 ) = 0 */
+
+
+/* Order within CHARS */
+/* ------------------ */
+
+/* CPOSR( STRING, 'JOHN', 23 ) = 18 */
+
+/* CPOSR( STRING, 'OHNJ', 23 ) = 18 */
+
+/* CPOSR( STRING, 'HNJO', 23 ) = 18 */
+
+/* CPOSR( STRING, 'NJOH', 23 ) = 18 */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* H.A. Neilan (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.3, 31-JAN-2008 (BVS) */
+
+/* Removed non-standard end-of-declarations marker */
+/* 'C%&END_DECLARATIONS' from comments. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 26-MAR-1991 (HAN) */
+
+/* The Required Reading file POSITION was renamed to SCANNING. */
+/* This header was updated to reflect the change. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* backward search for the position of a character */
+
+/* -& */
+
+/* Local variables */
+
+ lenstr = i_len(str, str_len);
+ b = min(lenstr,*start);
+ found = FALSE_;
+ ret_val = 0;
+ while(! found) {
+ if (b <= 0) {
+ return ret_val;
+ } else if (i_indx(chars, str + (b - 1), chars_len, (ftnlen)1) != 0) {
+ ret_val = b;
+ return ret_val;
+ } else {
+ --b;
+ }
+ }
+ return ret_val;
+} /* cposr_ */
+
diff --git a/ext/spice/src/cspice/cposr_c.c b/ext/spice/src/cspice/cposr_c.c
new file mode 100644
index 0000000000..ad7a9f4ed9
--- /dev/null
+++ b/ext/spice/src/cspice/cposr_c.c
@@ -0,0 +1,230 @@
+/*
+
+-Procedure cposr_c ( Character position, reverse )
+
+-Abstract
+
+ Find the first occurrence in a string of a character belonging
+ to a collection of characters, starting at a specified location,
+ searching in reverse.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ SCANNING
+
+-Keywords
+
+ CHARACTER
+ SEARCH
+ UTILITY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+
+
+ SpiceInt cposr_c ( ConstSpiceChar * str,
+ ConstSpiceChar * chars,
+ SpiceInt start )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ str I Any character string.
+ chars I A collection of characters.
+ start I Position to begin looking for one of chars.
+
+ The function returns the index of the last character of str
+ at or before index start that is in the collection chars.
+
+-Detailed_Input
+
+ str is any character string.
+
+ chars is a character string containing a collection
+ of characters. Spaces in chars are significant,
+ including trailing blanks. The order in which
+ characters are listed is not significant.
+
+ start is the position in str to begin looking for one of
+ the characters in chars. start may range from 0
+ to n-1, where n is the number of characters in str.
+
+-Detailed_Output
+
+ The function returns the index of the last character of str (at or
+ before index start) that is one of the characters in the string
+ chars. The returned value normally ranges from 0 to n-1, where n is
+ the number of characters in str. If none of the characters is found,
+ the function returns -1.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) The error SPICE(NULLPOINTER) is signaled if either of
+ the input string pointers is null.
+
+ 2) If start is less than 0, cposr_c returns -1.
+
+ 3) If start is greater than or equal to the length of the string,
+ the search begins at the last character of the string.
+
+ 4) The function returns -1 if either of the input strings is empty.
+
+-Files
+
+ None.
+
+-Particulars
+
+ cposr_c is case sensitive.
+
+ An entire family of related CSPICE routines
+
+ cpos_c
+ cposr_c
+ ncpos_c
+ ncposr_c
+ pos_c
+ posr_c
+
+ is described in the Required Reading.
+
+-Examples
+
+ Let string == "BOB, JOHN, TED, AND MARTIN...."
+ 012345678901234567890123456789
+
+
+ Normal (sequential) searching:
+ ------------------------------
+
+ cposr_c( string, ' ,', 29 ) = 29
+ cposr_c( string, ' ,', 28 ) = 28
+ cposr_c( string, ' ,', 27 ) = 27
+ cposr_c( string, ' ,', 26 ) = 26
+ cposr_c( string, ' ,', 25 ) = 19
+ cposr_c( string, ' ,', 18 ) = 15
+ cposr_c( string, ' ,', 14 ) = 14
+ cposr_c( string, ' ,', 13 ) = 10
+ cposr_c( string, ' ,', 9 ) = 9
+ cposr_c( string, ' ,', 8 ) = 4
+ cposr_c( string, ' ,', 3 ) = 3
+ cposr_c( string, ' ,', 2 ) = -1
+
+
+ start out of bounds:
+ --------------------
+
+ cposr_c( string, ' ,', 230 ) = 29
+ cposr_c( string, ' ,', 30 ) = 29
+ cposr_c( string, ' ,', -1 ) = -1
+ cposr_c( string, ' ,', -10 ) = -1
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 27-AUG-2002 (NJB) (WLT)
+
+-Index_Entries
+
+ backward search for position of character
+
+-&
+*/
+
+{ /* Begin cposr_c */
+
+ /*
+ Local variables
+ */
+ SpiceInt fstart;
+ SpiceInt retval;
+
+
+
+ /*
+ Use discovery check-in.
+
+ Check for null pointers.
+ */
+ CHKPTR_VAL ( CHK_DISCOVER, "cposr_c", str, -1 );
+ CHKPTR_VAL ( CHK_DISCOVER, "cposr_c", chars, -1 );
+
+
+ /*
+ Check for empty strings.
+ */
+ if ( ( strlen(str) == 0 ) || ( strlen(chars) == 0 ) )
+ {
+ return ( -1 );
+ }
+
+
+ /*
+ The rest can be handled by the f2c'd SPICELIB routine. Adjust
+ the start index to account for Fortran indexing.
+ */
+
+ fstart = start + 1;
+
+ retval = cposr_ ( (char *) str,
+ (char *) chars,
+ (integer *) &fstart,
+ (ftnlen ) strlen(str),
+ (ftnlen ) strlen(chars) );
+
+ /*
+ Adjust the return value to account for C indexing.
+ */
+ return ( retval-1 );
+
+
+} /* End cposr_c */
diff --git a/ext/spice/src/cspice/cvpool_c.c b/ext/spice/src/cspice/cvpool_c.c
new file mode 100644
index 0000000000..031dbc6832
--- /dev/null
+++ b/ext/spice/src/cspice/cvpool_c.c
@@ -0,0 +1,245 @@
+/*
+
+-Procedure cvpool_c ( Check variable in the pool for update)
+
+-Abstract
+
+ Determine whether or not any of the variables that are to be watched
+ and have a specified agent on their distribution list have been
+ updated.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ KERNEL
+
+-Keywords
+
+ SYMBOLS
+ UTILITY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ void cvpool_c ( ConstSpiceChar * agent,
+ SpiceBoolean * update )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ agent I Name of the agent to check for notices.
+ update O SPICETRUE if variables for agent have been updated.
+
+-Detailed_Input
+
+ agent is the name of a function or significant portion of code
+ that needs to access variables in the kernel pool.
+ Generally this agent will buffer these variables
+ internally and fetch them from the kernel pool only when
+ they are updated.
+
+-Detailed_Output
+
+ update is a logical flag that will be set to SPICETRUE if the
+ variables in the kernel pool that are required by agent
+ have been updated since the last call to cvpool_c.
+
+-Parameters
+
+ See function szpool_c.
+
+-Exceptions
+
+ 1) If the string pointer for agent is null, the error
+ SPICE(NULLPOINTER) will be signaled.
+
+ 2) If the input string haslength zero, the error SPICE(EMPTYSTRING)
+ will be signaled.
+
+-Files
+
+ None.
+
+-Particulars
+
+ This entry point allows the calling program to determine whether or
+ not variables associated with with agent have been updated. Making
+ use of this entry point in conjunction with the entry point swpool_c
+ (set watch on pool variables) modules can buffer kernel pool
+ variables they need and fetch values from the kernel pool only when
+ variables have been updated.
+
+ Note that the call to cvpool_c has a side effect. Two consecutive
+ calls to cvpool_c with the same agent will always result in the
+ update being SPICEFALSE on the second call. In other words, if you
+ imbed the following two lines of code in a piece of code
+
+ cvpool_c ( agent, &update );
+ cvpool_c ( agent, &update );
+
+ and then test update, it will be SPICEFALSE. The idea is that once
+ a call to cvpool_c has been made, the kernel pool has performed its
+ duty and notified the calling routine that one of the agent's
+ variables has been updated. Consequently, on the second call to
+ cvpool_c above, the kernel pool will not have any updates to report
+ about any of agent's variables.
+
+ If, on the other hand, you have code such as
+
+ cvpool_c ( agent, &update );
+ furnsh_c ( "myfile.dat" );
+ cvpool_c ( agent, &update );
+
+ the value of update will be true if one of the variables associated
+ with agent was updated by the call to furnsh_c (and that variable
+ has been specified as one to watch by call a call to swpool_c).
+
+ It should also be noted that any call to cvpool_c that occurs
+ immediately after a call to swpool_c will result in update being
+ returned as SPICETRUE In other words, code such as shown below,
+ will always result in the value of UPDATE as being returned
+ SPICETRUE:
+
+ swpool_c ( agent, nnames, namelen, names );
+ cvpool_c ( agent, &update );
+
+ See the header for swpool_c for a full discussion of this
+ feature.
+
+-Examples
+
+ Suppose that you have an application subroutine, MYTASK, that
+ needs to access a large data set in the kernel pool. If this
+ data could be kept in local storage and kernel pool queries
+ performed only when the data in the kernel pool has been
+ updated, the routine can perform much more efficiently.
+
+ The code fragment below illustrates how you might make use of this
+ feature.
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ On the first call to this routine establish those variables
+ that we will want to read from the kernel pool only when
+ new values have been assigned.
+ ./
+ if ( first )
+ {
+ first = SPICEFALSE;
+ swpool_c ( "MYTASK", nnames, namelen, names );
+ }
+
+ /.
+ If any of the variables has been updated, fetch them from the
+ kernel pool.
+ ./
+
+ cvpool_c ( "MYTASK", &update );
+
+ if ( update )
+ {
+ for ( i = 0; i < NVAR; i++ )
+ {
+ gdpool_c( MYTASK_VAR[i], 1, NMAX, n[i], val[i], &found[i] );
+ }
+ }
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.1, 14-AUG-2006 (EDW)
+
+ Replace mention of ldpool_c with furnsh_c.
+
+ -CSPICE Version 1.0.0, 05-JUN-1999 (NJB) (WLT)
+
+-Index_Entries
+
+ Check the kernel pool for updated variables
+
+-&
+*/
+
+{ /* Begin cvpool_c */
+
+
+ /*
+ Local variables
+ */
+ logical upd;
+
+
+ /*
+ Use discovery check-in.
+ */
+
+ /*
+ Check the input agent name to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_DISCOVER, "cvpool_c", agent );
+
+
+ /*
+ Call the f2c'd routine.
+ */
+ cvpool_ ( ( char * ) agent,
+ ( logical * ) &upd,
+ ( ftnlen ) strlen(agent) );
+
+
+ /*
+ Assign the SpiceBoolean output argument.
+ */
+
+ *update = upd;
+
+
+} /* End cvpool_c */
+
diff --git a/ext/spice/src/cspice/cyacip.c b/ext/spice/src/cspice/cyacip.c
new file mode 100644
index 0000000000..72cfd0a93d
--- /dev/null
+++ b/ext/spice/src/cspice/cyacip.c
@@ -0,0 +1,286 @@
+/* cyacip.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CYACIP ( Cycle the elements of a character array ) */
+/* Subroutine */ int cyacip_(integer *nelt, char *dir, integer *ncycle, char *
+ array, ftnlen dir_len, ftnlen array_len)
+{
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ char last[1], temp[1];
+ integer c__, g, i__, j, k, l, m;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ extern integer nbwid_(char *, integer *, ftnlen);
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen),
+ sigerr_(char *, ftnlen), chkout_(char *, ftnlen);
+ integer widest;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen);
+ integer outlen;
+ extern logical return_(void);
+ extern integer gcd_(integer *, integer *);
+
+/* $ Abstract */
+
+/* Cycle the elements of a character array forward or backward */
+/* in place. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* NELT I Number of elements. */
+/* DIR I Direction to cycle: 'F' or 'B'. */
+/* NCYCLE I Number of times to cycle. */
+/* ARRAY I-O Array to be cycled/cycled array. */
+
+/* $ Detailed_Input */
+
+/* NELT is the number of elements in the input array. */
+
+/* DIR is the direction in which the elements in the */
+/* array are to be cycled. */
+
+/* 'F' or 'f' to cycle forward. */
+/* 'B' or 'b' to cycle backward. */
+
+/* NCYCLE is the number of times the elements in the array */
+/* are to be cycled. */
+
+/* ARRAY is the array to be cycled. */
+
+
+/* $ Detailed_Output */
+
+/* ARRAY is the input array after it has been cycled. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the value of DIR is not recognized, the error */
+/* SPICE(INVALIDDIRECTION) is signaled. */
+
+/* 2) If NELT is less than 1, the output array is not modified. */
+
+/* 3) If NCYCLE is negative, the array is cycled NCYCLE times in */
+/* the opposite direction of DIR. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine cycles a character array in place. To cycle */
+/* an array and store the result in a new array, use CYCLAC. */
+
+/* An array is cycled when its contents are shifted forward or */
+/* backward by one place. An element pushed off one end of the */
+/* array is brought around to the other end of the array instead */
+/* of disappearing. */
+
+/* $ Examples */
+
+/* Let the integer array A contain the following elements. */
+
+/* A(1) = 'apple' */
+/* A(2) = 'bear' */
+/* A(3) = 'cake' */
+/* A(4) = 'dragon' */
+
+/* Cycling A forward once yields the array */
+
+/* A(1) = 'dragon' */
+/* A(2) = 'apple' */
+/* A(3) = 'bear' */
+/* A(4) = 'cake' */
+
+/* Cycling A backward once yields the array */
+
+/* A(1) = 'bear' */
+/* A(2) = 'cake' */
+/* A(3) = 'dragon' */
+/* A(4) = 'apple' */
+
+/* Cycling by any multiple of the number of elements in the array */
+/* yields the same array. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 09-SEP-2005 (NJB) (HAN) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cycle the elements of a character array in place */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CYACIP", (ftnlen)6);
+ }
+
+/* Don't even screw around if there are no elements in the array. */
+
+ if (*nelt < 1) {
+ chkout_("CYACIP", (ftnlen)6);
+ return 0;
+ }
+
+/* A backward cycle is the same as a forward cycle by the opposite */
+/* of NCYCLE. Moreover a cycle by K is the same as a cycle by */
+/* K + m*N for any integer m. Thus we compute the value of the */
+/* minimum forward right cycle that is equivalent to the inputs. */
+/* If the cycling direction is not recognized, signal an error. */
+
+ if (*(unsigned char *)dir == 'B' || *(unsigned char *)dir == 'b') {
+ k = -(*ncycle) % *nelt;
+ } else if (*(unsigned char *)dir == 'F' || *(unsigned char *)dir == 'f') {
+ k = *ncycle % *nelt;
+ } else {
+ setmsg_("Cycling direction was *.", (ftnlen)24);
+ errch_("*", dir, (ftnlen)1, (ftnlen)1);
+ sigerr_("SPICE(INVALIDDIRECTION)", (ftnlen)23);
+ chkout_("CYACIP", (ftnlen)6);
+ return 0;
+ }
+ if (k < 0) {
+ k += *nelt;
+ } else if (k == 0) {
+ chkout_("CYACIP", (ftnlen)6);
+ return 0;
+ }
+
+/* The algorithm used to cycle arrays is identical to the one used */
+/* to cycle character strings in CYCLEC. We won't repeat the (rather */
+/* lengthy) description here. */
+
+/* The character version of CYCLAx differs from the other */
+/* versions in that a single character is cycled at a time. That */
+/* is, the first trip through the outermost loop cycles the first */
+/* characters of the array elements; the second trip cycles the */
+/* second characters; and so on. This allows the same algorithm to */
+/* be used for all the routines. The local storage required is just */
+/* a couple of characters. */
+
+/* Don't swap the ends of strings if they're just blank padded. */
+/* And don't overwrite the elements of the output array, if they */
+/* happen to be shorter than those in the input array. */
+
+ outlen = i_len(array, array_len);
+ widest = nbwid_(array, nelt, array_len);
+
+/* The greatest common divisor need only be computed once. */
+
+ g = gcd_(&k, nelt);
+ m = *nelt / g;
+
+/* To make this a non-character routine, remove all references to C. */
+
+ i__1 = widest;
+ for (c__ = 1; c__ <= i__1; ++c__) {
+ i__2 = g;
+ for (i__ = 1; i__ <= i__2; ++i__) {
+ l = i__;
+ *(unsigned char *)last = *(unsigned char *)&array[(l - 1) *
+ array_len + (c__ - 1)];
+ i__3 = m;
+ for (j = 1; j <= i__3; ++j) {
+ l += k;
+ if (l > *nelt) {
+ l -= *nelt;
+ }
+ *(unsigned char *)temp = *(unsigned char *)&array[(l - 1) *
+ array_len + (c__ - 1)];
+ *(unsigned char *)&array[(l - 1) * array_len + (c__ - 1)] = *(
+ unsigned char *)last;
+ *(unsigned char *)last = *(unsigned char *)temp;
+ }
+ }
+ }
+
+/* If needed, pad the output array with blanks. */
+
+ if (outlen > widest) {
+ i__1 = *nelt;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ i__2 = widest;
+ s_copy(array + ((i__ - 1) * array_len + i__2), " ", array_len -
+ i__2, (ftnlen)1);
+ }
+ }
+ chkout_("CYACIP", (ftnlen)6);
+ return 0;
+} /* cyacip_ */
+
diff --git a/ext/spice/src/cspice/cyadip.c b/ext/spice/src/cspice/cyadip.c
new file mode 100644
index 0000000000..095a05b7c0
--- /dev/null
+++ b/ext/spice/src/cspice/cyadip.c
@@ -0,0 +1,239 @@
+/* cyadip.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CYADIP ( Cycle the elements of a DP array, in place ) */
+/* Subroutine */ int cyadip_(integer *nelt, char *dir, integer *ncycle,
+ doublereal *array, ftnlen dir_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ doublereal last, temp;
+ integer g, i__, j, k, l, m;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen), sigerr_(char *, ftnlen), chkout_(char *, ftnlen)
+ , setmsg_(char *, ftnlen);
+ extern logical return_(void);
+ extern integer gcd_(integer *, integer *);
+
+/* $ Abstract */
+
+/* Cycle the elements of a double precision array forward */
+/* or backward in place. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* NELT I Number of elements. */
+/* DIR I Direction to cycle: 'F' or 'B'. */
+/* NCYCLE I Number of times to cycle. */
+/* ARRAY I-O Array to be cycled/cycled array. */
+
+/* $ Detailed_Input */
+
+/* NELT is the number of elements in the input array. */
+
+/* DIR is the direction in which the elements in the */
+/* array are to be cycled. */
+
+/* 'F' or 'f' to cycle forward. */
+/* 'B' or 'b' to cycle backward. */
+
+/* NCYCLE is the number of times the elements in the array */
+/* are to be cycled. */
+
+/* ARRAY is the array to be cycled. */
+
+/* $ Detailed_Output */
+
+/* ARRAY is the input array after it has been cycled. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the value of DIR is not recognized, the error */
+/* SPICE(INVALIDDIRECTION) is signaled. */
+
+/* 2) If NELT is less than 1, the output array is not modified. */
+
+/* 3) If NCYCLE is negative, the array is cycled NCYCLE times in */
+/* the opposite direction of DIR. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine cycles a double precision array in place. To cycle */
+/* an array and store the result in a new array, use CYCLAD. */
+
+/* An array is cycled when its contents are shifted forward or */
+/* backward by one place. An element pushed off one end of the array */
+/* is brought around to the other end of the array instead of */
+/* disappearing. */
+
+/* $ Examples */
+
+/* Let the double precision A contain the following elements. */
+
+/* A(1) = 1.D0 */
+/* A(2) = 2.D0 */
+/* A(3) = 3.D0 */
+/* A(4) = 4.D0 */
+
+/* Cycling A forward once yields the array */
+
+/* A(1) = 4.D0 */
+/* A(2) = 1.D0 */
+/* A(3) = 2.D0 */
+/* A(4) = 3.D0 */
+
+/* Cycling A backward once yields the array */
+
+/* A(1) = 2.D0 */
+/* A(2) = 3.D0 */
+/* A(3) = 4.D0 */
+/* A(4) = 1.D0 */
+
+/* Cycling by any multiple of the number of elements in the array */
+/* yields the same array. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 09-SEP-2005 (NJB) (HAN) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cycle the elements of a d.p. array in place */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CYADIP", (ftnlen)6);
+ }
+
+/* Don't even screw around if there are no elements in the array. */
+
+ if (*nelt < 1) {
+ chkout_("CYADIP", (ftnlen)6);
+ return 0;
+ }
+
+/* A backward cycle is the same as a forward cycle by the opposite */
+/* of NCYCLE. Moreover a cycle by K is the same as a cycle by */
+/* K + m*N for any integer m. Thus we compute the value of the */
+/* minimum forward right cycle that is equivalent to the inputs. */
+
+ if (*(unsigned char *)dir == 'B' || *(unsigned char *)dir == 'b') {
+ k = -(*ncycle) % *nelt;
+ } else if (*(unsigned char *)dir == 'F' || *(unsigned char *)dir == 'F') {
+ k = *ncycle % *nelt;
+ } else {
+ setmsg_("Cycling direction was *.", (ftnlen)24);
+ errch_("*", dir, (ftnlen)1, (ftnlen)1);
+ sigerr_("SPICE(INVALIDDIRECTION)", (ftnlen)23);
+ chkout_("CYADIP", (ftnlen)6);
+ return 0;
+ }
+ if (k < 0) {
+ k += *nelt;
+ } else if (k == 0) {
+ chkout_("CYADIP", (ftnlen)6);
+ return 0;
+ }
+
+/* The algorithm used to cycle arrays is identical to the one used */
+/* to cycle character strings in CYCLEC. We won't repeat the (rather */
+/* lengthy) description here. */
+
+ g = gcd_(&k, nelt);
+ m = *nelt / g;
+ i__1 = g;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ l = i__;
+ last = array[l - 1];
+ i__2 = m;
+ for (j = 1; j <= i__2; ++j) {
+ l += k;
+ if (l > *nelt) {
+ l -= *nelt;
+ }
+ temp = array[l - 1];
+ array[l - 1] = last;
+ last = temp;
+ }
+ }
+ chkout_("CYADIP", (ftnlen)6);
+ return 0;
+} /* cyadip_ */
+
diff --git a/ext/spice/src/cspice/cyaiip.c b/ext/spice/src/cspice/cyaiip.c
new file mode 100644
index 0000000000..a1cfd969ea
--- /dev/null
+++ b/ext/spice/src/cspice/cyaiip.c
@@ -0,0 +1,238 @@
+/* cyaiip.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CYAIIP ( Cycle the elements of an integer array, in place ) */
+/* Subroutine */ int cyaiip_(integer *nelt, char *dir, integer *ncycle,
+ integer *array, ftnlen dir_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer last, temp, g, i__, j, k, l, m;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen), sigerr_(char *, ftnlen), chkout_(char *, ftnlen)
+ , setmsg_(char *, ftnlen);
+ extern logical return_(void);
+ extern integer gcd_(integer *, integer *);
+
+/* $ Abstract */
+
+/* Cycle the elements of an integer array forward or backward */
+/* in place. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* NELT I Number of elements. */
+/* DIR I Direction to cycle: 'F' or 'B'. */
+/* NCYCLE I Number of times to cycle. */
+/* ARRAY I-O Array to be cycled/cycled array. */
+
+/* $ Detailed_Input */
+
+/* NELT is the number of elements in the input array. */
+
+/* DIR is the direction in which the elements in the */
+/* array are to be cycled. */
+
+/* 'F' or 'f' to cycle forward. */
+/* 'B' or 'b' to cycle backward. */
+
+/* NCYCLE is the number of times the elements in the array */
+/* are to be cycled. */
+
+/* ARRAY is the array to be cycled. */
+
+/* $ Detailed_Output */
+
+/* ARRAY is the input array after it has been cycled. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the value of DIR is not recognized, the error */
+/* SPICE(INVALIDDIRECTION) is signaled. */
+
+/* 2) If NELT is less than 1, the output array is not modified. */
+
+/* 3) If NCYCLE is negative, the array is cycled NCYCLE times in */
+/* the opposite direction of DIR. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine cycles an integer array in place. To cycle */
+/* an array and store the result in a new array, use CYCLAI. */
+
+/* An array is cycled when its contents are shifted forward or */
+/* backward by one place. An element pushed off one end of the */
+/* array is brought around to the other end of the array instead */
+/* of disappearing. */
+
+/* $ Examples */
+
+/* Let the integer array A contain the following elements. */
+
+/* A(1) = 1 */
+/* A(2) = 2 */
+/* A(3) = 3 */
+/* A(4) = 4 */
+
+/* Cycling A forward once yields the array */
+
+/* A(1) = 4 */
+/* A(2) = 1 */
+/* A(3) = 2 */
+/* A(4) = 3 */
+
+/* Cycling A backward once yields the array */
+
+/* A(1) = 2 */
+/* A(2) = 3 */
+/* A(3) = 4 */
+/* A(4) = 1 */
+
+/* Cycling by any multiple of the number of elements in the array */
+/* yields the same array. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 09-SEP-2005 (NJB) (HAN) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cycle the elements of an integer array in place */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CYAIIP", (ftnlen)6);
+ }
+
+/* Don't even screw around if there are no elements in the array. */
+
+ if (*nelt < 1) {
+ chkout_("CYAIIP", (ftnlen)6);
+ return 0;
+ }
+
+/* A backward cycle is the same as a forward cycle by the opposite */
+/* of NCYCLE. Moreover a cycle by K is the same as a cycle by */
+/* K + m*N for any integer m. Thus we compute the value of the */
+/* minimum forward right cycle that is equivalent to the inputs. */
+
+ if (*(unsigned char *)dir == 'B' || *(unsigned char *)dir == 'b') {
+ k = -(*ncycle) % *nelt;
+ } else if (*(unsigned char *)dir == 'F' || *(unsigned char *)dir == 'F') {
+ k = *ncycle % *nelt;
+ } else {
+ setmsg_("Cycling direction was *.", (ftnlen)24);
+ errch_("*", dir, (ftnlen)1, (ftnlen)1);
+ sigerr_("SPICE(INVALIDDIRECTION)", (ftnlen)23);
+ chkout_("CYAIIP", (ftnlen)6);
+ return 0;
+ }
+ if (k < 0) {
+ k += *nelt;
+ } else if (k == 0) {
+ chkout_("CYAIIP", (ftnlen)6);
+ return 0;
+ }
+
+/* The algorithm used to cycle arrays is identical to the one used */
+/* to cycle character strings in CYCLEC. We won't repeat the (rather */
+/* lengthy) description here. */
+
+ g = gcd_(&k, nelt);
+ m = *nelt / g;
+ i__1 = g;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ l = i__;
+ last = array[l - 1];
+ i__2 = m;
+ for (j = 1; j <= i__2; ++j) {
+ l += k;
+ if (l > *nelt) {
+ l -= *nelt;
+ }
+ temp = array[l - 1];
+ array[l - 1] = last;
+ last = temp;
+ }
+ }
+ chkout_("CYAIIP", (ftnlen)6);
+ return 0;
+} /* cyaiip_ */
+
diff --git a/ext/spice/src/cspice/cyclac.c b/ext/spice/src/cspice/cyclac.c
new file mode 100644
index 0000000000..0c10a73936
--- /dev/null
+++ b/ext/spice/src/cspice/cyclac.c
@@ -0,0 +1,322 @@
+/* cyclac.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CYCLAC ( Cycle the elements of a character array ) */
+/* Subroutine */ int cyclac_(char *array, integer *nelt, char *dir, integer *
+ ncycle, char *out, ftnlen array_len, ftnlen dir_len, ftnlen out_len)
+{
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ char last[1], temp[1];
+ integer c__, g, i__, j, k, l, m;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ extern integer nbwid_(char *, integer *, ftnlen);
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen),
+ movec_(char *, integer *, char *, ftnlen, ftnlen);
+ integer limit;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen);
+ integer widest;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen);
+ integer outlen;
+ extern logical return_(void);
+ extern integer gcd_(integer *, integer *);
+
+/* $ Abstract */
+
+/* Cycle the elements of a character array forward or backward. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* ARRAY I Input array. */
+/* NELT I Number of elements. */
+/* DIR I Direction to cycle: 'F' or 'B'. */
+/* NCYCLE I Number of times to cycle. */
+/* OUT O Cycled array. */
+
+/* $ Detailed_Input */
+
+/* ARRAY is the array to be cycled. */
+
+/* NELT is the number of elements in the input array. */
+
+/* DIR is the direction in which the elements in the */
+/* array are to be cycled. */
+
+/* 'F' or 'f' to cycle forward. */
+/* 'B' or 'b' to cycle backward. */
+
+/* NCYCLE is the number of times the elements in the array */
+/* are to be cycled. */
+
+/* $ Detailed_Output */
+
+/* OUT is the input array after it has been cycled. */
+/* OUT may overwrite ARRAY. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the value of DIR is not recognized, the error */
+/* SPICE(INVALIDDIRECTION) is signalled. */
+
+/* 2) If NELT is less than 1, the output array is not modified. */
+
+/* 3) If NCYCLE is negative, the array is cycled NCYCLE times in */
+/* the opposite direction of DIR. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* An array is cycled when its contents are shifted forward or */
+/* backward by one place. An element pushed off one end of the */
+/* array is brought around to the other end of the array instead */
+/* of disappearing. */
+
+/* $ Examples */
+
+/* Let the integer array A contain the following elements. */
+
+/* A(1) = 'apple' */
+/* A(2) = 'bear' */
+/* A(3) = 'cake' */
+/* A(4) = 'dragon' */
+
+/* Cycling A forward once yields the array */
+
+/* A(1) = 'dragon' */
+/* A(2) = 'apple' */
+/* A(3) = 'bear' */
+/* A(4) = 'cake' */
+
+/* Cycling A backward once yields the array */
+
+/* A(1) = 'bear' */
+/* A(2) = 'cake' */
+/* A(3) = 'dragon' */
+/* A(4) = 'apple' */
+
+/* Cycling by any multiple of the number of elements in the array */
+/* yields the same array. */
+
+/* $ Restrictions */
+
+/* The memory used for the output array must be identical to or */
+/* disjoint from the memory used for the input array. */
+
+/* That is: */
+
+/* CALL CYCLAC ( ARRAY, NELT, DIR, NCYCLE, ARRAY ) */
+
+/* will produce correct results, while */
+
+/* CALL CYCLAC ( ARRAY, NELT-3, DIR, NCYCLE, ARRAY(4) ) */
+
+/* will produce garbage. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 18-MAY-2010 (BVS) */
+
+/* Removed "C$" marker from text in the header. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cycle the elements of a character array */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 2.0.0, 16-JAN-1989 (HAN) */
+
+/* Error handling was added to detect an invalid value for */
+/* the cycling direction. If the direction is not recognized */
+/* the error SPICE(INVALIDDIRECTION) is signalled and the */
+/* output array is not modified. (The routine used to copy the */
+/* input array into the output array if the direction was not */
+/* recognized.) */
+
+/* The "Exceptions" section was filled out in more detail. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CYCLAC", (ftnlen)6);
+ }
+
+/* Don't even screw around if there are no elements in the array. */
+
+ if (*nelt < 1) {
+ chkout_("CYCLAC", (ftnlen)6);
+ return 0;
+ }
+
+/* A backward cycle is the same as a forward cycle by the opposite */
+/* of NCYCLE. Moreover a cycle by K is the same as a cycle by */
+/* K + m*N for any integer m. Thus we compute the value of the */
+/* minimum forward right cycle that is equivalent to the inputs. */
+/* If the cycling direction is not recognized, signal an error. */
+
+ if (*(unsigned char *)dir == 'B' || *(unsigned char *)dir == 'b') {
+ k = -(*ncycle) % *nelt;
+ } else if (*(unsigned char *)dir == 'F' || *(unsigned char *)dir == 'f') {
+ k = *ncycle % *nelt;
+ } else {
+ setmsg_("Cycling direction was *.", (ftnlen)24);
+ errch_("*", dir, (ftnlen)1, (ftnlen)1);
+ sigerr_("SPICE(INVALIDDIRECTION)", (ftnlen)23);
+ chkout_("CYCLAC", (ftnlen)6);
+ return 0;
+ }
+ if (k < 0) {
+ k += *nelt;
+ } else if (k == 0) {
+ movec_(array, nelt, out, array_len, out_len);
+ chkout_("CYCLAC", (ftnlen)6);
+ return 0;
+ }
+
+/* The algorithm used to cycle arrays is identical to the one used */
+/* to cycle character strings in CYCLEC. We won't repeat the (rather */
+/* lengthy) description here. */
+
+/* The character version of CYCLAx differs from the other */
+/* versions in that a single character is cycled at a time. That */
+/* is, the first trip through the outermost loop cycles the first */
+/* characters of the array elements; the second trip cycles the */
+/* second characters; and so on. This allows the same algorithm to */
+/* be used for all the routines. The local storage required is just */
+/* a couple of characters. */
+
+
+/* Don't swap the ends of strings if they're just blank padded. */
+/* And don't overwrite the elements of the output array, if they */
+/* happen to be shorter thAn those in the input array. */
+
+ outlen = i_len(out, out_len);
+ widest = nbwid_(array, nelt, array_len);
+ limit = min(outlen,widest);
+
+/* The greatest common divisor need only be computed once. */
+
+ g = gcd_(&k, nelt);
+ m = *nelt / g;
+
+/* To make this a non-character routine, remove all references to C. */
+
+ i__1 = limit;
+ for (c__ = 1; c__ <= i__1; ++c__) {
+ i__2 = g;
+ for (i__ = 1; i__ <= i__2; ++i__) {
+ l = i__;
+ *(unsigned char *)last = *(unsigned char *)&array[(l - 1) *
+ array_len + (c__ - 1)];
+ i__3 = m;
+ for (j = 1; j <= i__3; ++j) {
+ l += k;
+ if (l > *nelt) {
+ l -= *nelt;
+ }
+ *(unsigned char *)temp = *(unsigned char *)&array[(l - 1) *
+ array_len + (c__ - 1)];
+ *(unsigned char *)&out[(l - 1) * out_len + (c__ - 1)] = *(
+ unsigned char *)last;
+ *(unsigned char *)last = *(unsigned char *)temp;
+ }
+ }
+ }
+
+/* If needed, pad the output array with blanks. */
+
+ if (outlen > limit) {
+ i__1 = *nelt;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ i__2 = limit;
+ s_copy(out + ((i__ - 1) * out_len + i__2), " ", out_len - i__2, (
+ ftnlen)1);
+ }
+ }
+ chkout_("CYCLAC", (ftnlen)6);
+ return 0;
+} /* cyclac_ */
+
diff --git a/ext/spice/src/cspice/cyclad.c b/ext/spice/src/cspice/cyclad.c
new file mode 100644
index 0000000000..45a1494d5d
--- /dev/null
+++ b/ext/spice/src/cspice/cyclad.c
@@ -0,0 +1,267 @@
+/* cyclad.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CYCLAD ( Cycle the elements of a DP array ) */
+/* Subroutine */ int cyclad_(doublereal *array, integer *nelt, char *dir,
+ integer *ncycle, doublereal *out, ftnlen dir_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ doublereal last, temp;
+ integer g, i__, j, k, l, m;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen), moved_(doublereal *, integer *, doublereal *),
+ sigerr_(char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *,
+ ftnlen);
+ extern logical return_(void);
+ extern integer gcd_(integer *, integer *);
+
+/* $ Abstract */
+
+/* Cycle the elements of a double precision array forward */
+/* or backward. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* ARRAY I Input array. */
+/* NELT I Number of elements. */
+/* DIR I Direction to cycle: 'F' or 'B'. */
+/* NCYCLE I Number of times to cycle. */
+/* OUT O Cycled array. */
+
+/* $ Detailed_Input */
+
+/* ARRAY is the array to be cycled. */
+
+/* NELT is the number of elements in the input array. */
+
+/* DIR is the direction in which the elements in the */
+/* array are to be cycled. */
+
+/* 'F' or 'f' to cycle forward. */
+/* 'B' or 'b' to cycle backward. */
+
+/* NCYCLE is the number of times the elements in the array */
+/* are to be cycled. */
+
+/* $ Detailed_Output */
+
+/* OUT is the input array after it has been cycled. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the value of DIR is not recognized, the error */
+/* SPICE(INVALIDDIRECTION) is signalled. */
+
+/* 2) If NELT is less than 1, the output array is not modified. */
+
+/* 3) If NCYCLE is negative, the array is cycled NCYCLE times in */
+/* the opposite direction of DIR. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* An array is cycled when its contents are shifted forward or */
+/* backward by one place. An element pushed off one end of the */
+/* array is brought around to the other end of the array instead */
+/* of disappearing. */
+
+/* $ Examples */
+
+/* Let the double precision A contain the following elements. */
+
+/* A(1) = 1.D0 */
+/* A(2) = 2.D0 */
+/* A(3) = 3.D0 */
+/* A(4) = 4.D0 */
+
+/* Cycling A forward once yields the array */
+
+/* A(1) = 4.D0 */
+/* A(2) = 1.D0 */
+/* A(3) = 2.D0 */
+/* A(4) = 3.D0 */
+
+/* Cycling A backward once yields the array */
+
+/* A(1) = 2.D0 */
+/* A(2) = 3.D0 */
+/* A(3) = 4.D0 */
+/* A(4) = 1.D0 */
+
+/* Cycling by any multiple of the number of elements in the array */
+/* yields the same array. */
+
+/* $ Restrictions */
+
+/* The memory used for the output array must be disjoint from the */
+/* memory used for the input array. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.3, 18-MAY-2010 (BVS) */
+
+/* Removed "C$" marker from text in the header. */
+
+/* - SPICELIB Version 1.0.2, 23-APR-2010 (NJB) */
+
+/* Header correction: assertions that the output */
+/* can overwrite the input have been removed. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cycle the elements of a d.p. array */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 2.0.0, 16-JAN-1989 (HAN) */
+
+/* Error handling was added to detect an invalid value for */
+/* the cycling direction. If the direction is not recognized */
+/* the error SPICE(INVALIDDIRECTION) is signalled and the */
+/* output array is not modified. (The routine used to copy the */
+/* input array into the output array if the direction was not */
+/* recognized.) */
+
+/* The "Exceptions" section was filled out in more detail. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CYCLAD", (ftnlen)6);
+ }
+
+/* Don't even screw around if there are no elements in the array. */
+
+ if (*nelt < 1) {
+ chkout_("CYCLAD", (ftnlen)6);
+ return 0;
+ }
+
+/* A backward cycle is the same as a forward cycle by the opposite */
+/* of NCYCLE. Moreover a cycle by K is the same as a cycle by */
+/* K + m*N for any integer m. Thus we compute the value of the */
+/* minimum forward right cycle that is equivalent to the inputs. */
+
+ if (*(unsigned char *)dir == 'B' || *(unsigned char *)dir == 'b') {
+ k = -(*ncycle) % *nelt;
+ } else if (*(unsigned char *)dir == 'F' || *(unsigned char *)dir == 'F') {
+ k = *ncycle % *nelt;
+ } else {
+ setmsg_("Cycling direction was *.", (ftnlen)24);
+ errch_("*", dir, (ftnlen)1, (ftnlen)1);
+ sigerr_("SPICE(INVALIDDIRECTION)", (ftnlen)23);
+ chkout_("CYCLAD", (ftnlen)6);
+ return 0;
+ }
+ if (k < 0) {
+ k += *nelt;
+ } else if (k == 0) {
+ moved_(array, nelt, out);
+ chkout_("CYCLAD", (ftnlen)6);
+ return 0;
+ }
+
+/* The algorithm used to cycle arrays is identical to the one used */
+/* to cycle character strings in CYCLEC. We won't repeat the (rather */
+/* lengthy) description here. */
+
+ g = gcd_(&k, nelt);
+ m = *nelt / g;
+ i__1 = g;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ l = i__;
+ last = array[l - 1];
+ i__2 = m;
+ for (j = 1; j <= i__2; ++j) {
+ l += k;
+ if (l > *nelt) {
+ l -= *nelt;
+ }
+ temp = array[l - 1];
+ out[l - 1] = last;
+ last = temp;
+ }
+ }
+ chkout_("CYCLAD", (ftnlen)6);
+ return 0;
+} /* cyclad_ */
+
diff --git a/ext/spice/src/cspice/cyclai.c b/ext/spice/src/cspice/cyclai.c
new file mode 100644
index 0000000000..7b2609342a
--- /dev/null
+++ b/ext/spice/src/cspice/cyclai.c
@@ -0,0 +1,265 @@
+/* cyclai.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CYCLAI ( Cycle the elements of an integer array ) */
+/* Subroutine */ int cyclai_(integer *array, integer *nelt, char *dir,
+ integer *ncycle, integer *out, ftnlen dir_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer last, temp, g, i__, j, k, l, m;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen), movei_(integer *, integer *, integer *),
+ sigerr_(char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *,
+ ftnlen);
+ extern logical return_(void);
+ extern integer gcd_(integer *, integer *);
+
+/* $ Abstract */
+
+/* Cycle the elements of an integer array forward or backward. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ARRAY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* ARRAY I Input array. */
+/* NELT I Number of elements. */
+/* DIR I Direction to cycle: 'F' or 'B'. */
+/* NCYCLE I Number of times to cycle. */
+/* OUT O Cycled array. */
+
+/* $ Detailed_Input */
+
+/* ARRAY is the array to be cycled. */
+
+/* NELT is the number of elements in the input array. */
+
+/* DIR is the direction in which the elements in the */
+/* array are to be cycled. */
+
+/* 'F' or 'f' to cycle forward. */
+/* 'B' or 'b' to cycle backward. */
+
+/* NCYCLE is the number of times the elements in the array */
+/* are to be cycled. */
+
+/* $ Detailed_Output */
+
+/* OUT is the input array after it has been cycled. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the value of DIR is not recognized, the error */
+/* SPICE(INVALIDDIRECTION) is signaled. */
+
+/* 2) If NELT is less than 1, the output array is not modified. */
+
+/* 3) If NCYCLE is negative, the array is cycled NCYCLE times in */
+/* the opposite direction of DIR. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* An array is cycled when its contents are shifted forward or */
+/* backward by one place. An element pushed off one end of the */
+/* array is brought around to the other end of the array instead */
+/* of disappearing. */
+
+/* $ Examples */
+
+/* Let the integer array A contain the following elements. */
+
+/* A(1) = 1 */
+/* A(2) = 2 */
+/* A(3) = 3 */
+/* A(4) = 4 */
+
+/* Cycling A forward once yields the array */
+
+/* A(1) = 4 */
+/* A(2) = 1 */
+/* A(3) = 2 */
+/* A(4) = 3 */
+
+/* Cycling A backward once yields the array */
+
+/* A(1) = 2 */
+/* A(2) = 3 */
+/* A(3) = 4 */
+/* A(4) = 1 */
+
+/* Cycling by any multiple of the number of elements in the array */
+/* yields the same array. */
+
+/* $ Restrictions */
+
+/* The memory used for the output array must be disjoint from the */
+/* memory used for the input array. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.3, 18-MAY-2010 (BVS) */
+
+/* Removed "C$" marker from text in the header. */
+
+/* - SPICELIB Version 1.0.2, 23-APR-2010 (NJB) */
+
+/* Header correction: assertions that the output */
+/* can overwrite the input have been removed. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cycle the elements of an integer array */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 2.0.0, 16-JAN-1989 (HAN) */
+
+/* Error handling was added to detect an invalid value for */
+/* the cycling direction. If the direction is not recognized */
+/* the error SPICE(INVALIDDIRECTION) is signalled and the */
+/* output array is not modified. (The routine used to copy the */
+/* input array into the output array if the direction was not */
+/* recognized.) */
+
+/* The "Exceptions" section was filled out in more detail. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CYCLAI", (ftnlen)6);
+ }
+
+/* Don't even screw around if there are no elements in the array. */
+
+ if (*nelt < 1) {
+ chkout_("CYCLAI", (ftnlen)6);
+ return 0;
+ }
+
+/* A backward cycle is the same as a forward cycle by the opposite */
+/* of NCYCLE. Moreover a cycle by K is the same as a cycle by */
+/* K + m*N for any integer m. Thus we compute the value of the */
+/* minimum forward right cycle that is equivalent to the inputs. */
+
+ if (*(unsigned char *)dir == 'B' || *(unsigned char *)dir == 'b') {
+ k = -(*ncycle) % *nelt;
+ } else if (*(unsigned char *)dir == 'F' || *(unsigned char *)dir == 'F') {
+ k = *ncycle % *nelt;
+ } else {
+ setmsg_("Cycling direction was *.", (ftnlen)24);
+ errch_("*", dir, (ftnlen)1, (ftnlen)1);
+ sigerr_("SPICE(INVALIDDIRECTION)", (ftnlen)23);
+ chkout_("CYCLAI", (ftnlen)6);
+ return 0;
+ }
+ if (k < 0) {
+ k += *nelt;
+ } else if (k == 0) {
+ movei_(array, nelt, out);
+ chkout_("CYCLAI", (ftnlen)6);
+ return 0;
+ }
+
+/* The algorithm used to cycle arrays is identical to the one used */
+/* to cycle character strings in CYCLEC. We won't repeat the (rather */
+/* lengthy) description here. */
+
+ g = gcd_(&k, nelt);
+ m = *nelt / g;
+ i__1 = g;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ l = i__;
+ last = array[l - 1];
+ i__2 = m;
+ for (j = 1; j <= i__2; ++j) {
+ l += k;
+ if (l > *nelt) {
+ l -= *nelt;
+ }
+ temp = array[l - 1];
+ out[l - 1] = last;
+ last = temp;
+ }
+ }
+ chkout_("CYCLAI", (ftnlen)6);
+ return 0;
+} /* cyclai_ */
+
diff --git a/ext/spice/src/cspice/cyclec.c b/ext/spice/src/cspice/cyclec.c
new file mode 100644
index 0000000000..b41f973d80
--- /dev/null
+++ b/ext/spice/src/cspice/cyclec.c
@@ -0,0 +1,325 @@
+/* cyclec.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CYCLEC ( Cycle a character string ) */
+/* Subroutine */ int cyclec_(char *instr, char *dir, integer *ncycle, char *
+ outstr, ftnlen instr_len, ftnlen dir_len, ftnlen outstr_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen);
+
+ /* Local variables */
+ char last[1], temp[1];
+ integer g, i__, j, k, l, m, n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen);
+ integer limit;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen);
+ extern logical return_(void);
+ extern integer gcd_(integer *, integer *);
+
+/* $ Abstract */
+
+/* Cycle the contents of a character string to the left or right. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CHARACTER, UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* INSTR I String to be cycled. */
+/* DIR I Direction to cycle. */
+/* NCYCLE I Number of times to cycle. */
+/* OUTSTR O Cycled string. */
+
+/* $ Detailed_Input */
+
+/* DIR is the direction in which the characters in the */
+/* string are to be cycled. */
+
+/* 'L' or 'l' to cycle left. */
+/* 'R' or 'r' to cycle right. */
+
+/* NCYCLE is the number of times the characters in the string */
+/* are to be cycled. */
+
+/* INSTR is the string to be cycled. */
+
+/* $ Detailed_Output */
+
+/* OUTSTR the input string after it has been cycled. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* A string is cycled when its contents are shifted to the left */
+/* or right by one place. A character pushed off one end of the */
+/* string is brought around to the other end of the string instead */
+/* of disappearing. */
+
+/* Leading and trailing blanks are treated just like any other */
+/* characters. */
+
+/* If the output string is not large enough to contain the input */
+/* string, the cycled string is truncated on the right. */
+
+/* $ Examples */
+
+/* 'abcde' cycled left twice becomes 'cdeab' */
+/* 'abcde ' cycled left twice becomes 'cde ab' */
+/* 'abcde' cycled right once becomes 'eabcd' */
+/* 'Apple ' cycled left six times becomes 'Apple ' */
+/* 'Apple ' cycled right twenty-four times becomes 'Apple ' */
+
+/* $ Restrictions */
+
+/* The memory used for the output string must be identical to that */
+/* used for the input string or be disjoint from the input string */
+/* memory. */
+
+/* That is: */
+
+/* CALL CYCLEN ( STRING, DIR, NCYCLE, STRING ) */
+
+/* will produce correct results with output overwriting input. */
+
+/* CALL CYCLEN ( STRING(4:20), DIR, NCYCLE, STRING(2:18) ) */
+
+/* will produce garbage results. */
+
+/* $ Exceptions */
+
+/* 1) If the direction flag is not one of the acceptable values */
+/* 'r', 'R', 'l', 'L', the error 'SPICE(INVALIDDIRECTION)' is */
+/* signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 18-JUN-1999 (WLT) */
+
+/* Fixed problem with unbalanced CHKIN/CHKOUT calls. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cycle a character_string */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.1.0, 6-FEB-1989 (WLT) */
+
+/* Error handling for bad direction flag added. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("CYCLEC", (ftnlen)6);
+ }
+
+/* Get the length of the input string. */
+
+ n = i_len(instr, instr_len);
+ limit = i_len(outstr, outstr_len);
+
+/* A left cycle is the same as a right cycle by the opposite of */
+/* NCYCLE. Moreover a cycle by K is the same as a cycle by */
+/* K + m*N for any integer m. Thus we compute the value of the */
+/* minimum positive right cycle that is equivalent to the inputs. */
+
+ if (*(unsigned char *)dir == 'L' || *(unsigned char *)dir == 'l') {
+ k = -(*ncycle) % n;
+ } else if (*(unsigned char *)dir == 'R' || *(unsigned char *)dir == 'r') {
+ k = *ncycle % n;
+ } else {
+ setmsg_("The direction flag should be one of the following: 'r', 'R'"
+ ", 'l', 'L'. It was #.", (ftnlen)81);
+ errch_("#", dir, (ftnlen)1, (ftnlen)1);
+ sigerr_("SPICE(INVALIDDIRECTION)", (ftnlen)23);
+ chkout_("CYCLEC", (ftnlen)6);
+ return 0;
+ }
+ if (k < 0) {
+ k += n;
+ } else if (k == 0) {
+ chkout_("CYCLEC", (ftnlen)6);
+ return 0;
+ }
+
+/* As to the method for performing the cycle in place, we need a */
+/* few preliminaries. */
+
+/* 1. Since we are performing a cycle on the input string we */
+/* can regard the letters of the string as being attached */
+/* to a circle at N equally spaced points. Thus a cycle */
+/* by K has the effect of moving the position of each letter */
+/* to the K'th point from its current position along the */
+/* circle. (The first point from its position is the */
+/* adjacent point.) */
+
+/* 2. If we start at some point on the circle and begin moves to */
+/* other points of the circle by always moving K points */
+/* at a time, how long will it take until we get back to */
+/* the starting point? Answer: N/gcd(K,N) */
+
+/* Justification of the above answer. */
+
+/* a. If we count all of the points that we move past or */
+/* onto in such a trip (counting second, third, ... */
+/* passes), we will find that we have */
+/* moved past or onto i*K points after i steps. */
+
+/* b. In order to get back to the starting point we will */
+/* have to move past or onto a multiple of N points. */
+
+/* c. The first time we will get back to the starting */
+/* point is the smallest value of i such that i*K */
+/* is a multiple of N. That value is N/g.c.d.(K,N) */
+/* where g.c.d stands for the greatest common divisor */
+/* of K and N. Lets call this number M. */
+
+/* i. To see that this is the smallest number we */
+/* first show that K*M is in fact a multiple of */
+/* N. The product K*M = K * ( N / gcd(K,N) ) */
+/* = N * ( K / gcd(K,N) ) */
+
+/* Since gcd(K,N) evenly divides K, K/gcd(K,N) */
+/* is an integer. Thus K*M = N*I for some */
+/* integer I ( = K / gcd(K,N) ). */
+
+/* ii. The least common multiple of K and N is: */
+/* K*N / gcd(K,N) thus the first multiple */
+/* of K that is also a multiple of N is the */
+/* N/ gcd(K,N) 'th multiple of K. */
+
+/* 3. The closest stopping point on the circle will be gcd(K,N) */
+/* points away from our starting point. To see this recall */
+/* that we make N/gcd(K,N) moves of size K inorder to get */
+/* back to the starting point. The stopping points must */
+/* be equally spaced around the circle since the set of */
+/* points must look the same from any one of the points */
+/* visited --- after all we could get the same set by just */
+/* starting at one of those visited and making N/gcd(K,N) */
+/* moves. But the set of N/gcd(K,N) equally space points */
+/* out of the original N must be gcd(K,N) points apart. */
+
+/* 4. To visit every point on the circle we could */
+
+/* a. Pick a starting point */
+/* b. Take N/gcd(K,N) steps of size K (bringing us back */
+/* to our starting point. */
+/* c. move forward 1 point */
+/* d. repeat steps a. b. and c. gcd(K,N) times. */
+
+/* 5. If in addition to moving around the circle by the */
+/* prescription of 4. above we: */
+/* a. pick up the letter at a position when we stop there */
+/* (starting being the same as stopping) */
+/* b. put down the letter we had picked up at a previous */
+/* point. */
+/* then we will cycle every letter by the prescribed value */
+/* of K. */
+
+/* In this case the code is much shorter than its explanation. */
+
+ g = gcd_(&k, &n);
+ m = n / g;
+ i__1 = g;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ l = i__;
+ *(unsigned char *)last = *(unsigned char *)&instr[l - 1];
+ i__2 = m;
+ for (j = 1; j <= i__2; ++j) {
+ l += k;
+
+/* Compute L mod N. */
+
+ if (l > n) {
+ l -= n;
+ }
+ *(unsigned char *)temp = *(unsigned char *)&instr[l - 1];
+
+/* Make sure there is someplace to put the letter picked up */
+/* in the previous pass through the loop. */
+
+ if (l <= limit) {
+ *(unsigned char *)&outstr[l - 1] = *(unsigned char *)last;
+ }
+ *(unsigned char *)last = *(unsigned char *)temp;
+ }
+ }
+ chkout_("CYCLEC", (ftnlen)6);
+ return 0;
+} /* cyclec_ */
+
diff --git a/ext/spice/src/cspice/cyllat.c b/ext/spice/src/cspice/cyllat.c
new file mode 100644
index 0000000000..4fac081cd7
--- /dev/null
+++ b/ext/spice/src/cspice/cyllat.c
@@ -0,0 +1,206 @@
+/* cyllat.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CYLLAT ( Cylindrical to latitudinal ) */
+/* Subroutine */ int cyllat_(doublereal *r__, doublereal *longc, doublereal *
+ z__, doublereal *radius, doublereal *long__, doublereal *lat)
+{
+ /* System generated locals */
+ doublereal d__1, d__2;
+
+ /* Builtin functions */
+ double sqrt(doublereal), atan2(doublereal, doublereal);
+
+ /* Local variables */
+ doublereal x, y, lattud, big, rho;
+
+/* $ Abstract */
+
+/* Convert from cylindrical to latitudinal coordinates. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CONVERSION, COORDINATES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* R I Distance of point from Z axis. */
+/* LONGC I Cylindrical angle of point from XZ plane(radians). */
+/* Z I Height of point above XY plane. */
+/* RADIUS O Distance of point from origin. */
+/* LONG O Longitude of point (radians). */
+/* LAT O Latitude of point (radians). */
+
+/* $ Detailed_Input */
+
+/* R Distance of the input point from Z axis. */
+
+/* LONGC Cylindrical angle of the point from XZ plane(radians). */
+
+/* Z Height of the point above XY plane. */
+
+/* $ Detailed_Output */
+
+/* RADIUS Distance of the input point from origin. */
+
+/* LONG Longitude (i.e. angle from the XZ plane) of the input */
+/* point. */
+
+/* LAT Latitude (i.e. angle above the XY plane) of the input */
+/* point (radians). */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine converts coordinates given in cylindrical */
+/* coordinates to coordinates in latitudinal coordinates. */
+
+/* Latitudinal coordinates are the same coordinates as use for */
+/* the earth. Latitude refers to angle above the equator, longitude */
+/* to angle east from a meridian, and radius to the distance from */
+/* an origin. */
+
+/* $ Examples */
+
+/* Below are two tables: The first is a set of input values */
+/* the second is the result of the following sequence of */
+/* calls to Spicelib routines. Note all input and output angular */
+/* quantities are in degrees. */
+
+/* CALL CONVRT ( LONGC, 'DEGREES', 'RADIANS', LONGC ) */
+
+/* CALL CYLLAT ( R, LONGC, Z, RADIUS, LONG, LAT ) */
+
+/* CALL CONVRT ( LONG, 'RADIANS', 'DEGREES', LONG ) */
+/* CALL CONVRT ( LAT, 'RADIANS', 'DEGREES', LAT ) */
+
+
+
+/* Inputs: Results: */
+
+/* R LONGC Z RADIUS LONG LAT */
+/* ------ ------ ------ ------ ------ ------ */
+/* 1.0000 0 0 1.0000 0 0 */
+/* 1.0000 90.00 0 1.0000 90.00 0 */
+/* 1.0000 180.00 1.000 1.4142 180.00 45.00 */
+/* 1.0000 180.00 -1.000 1.4142 180.00 -45.00 */
+/* 0.0000 180.00 1.000 1.0000 180.00 90.00 */
+/* 0.0000 33.00 0 0.0000 33.00 0.00 */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 22-AUG-2001 (EDW) */
+
+/* Corrected ENDIF to END IF. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cylindrical to latitudinal */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.0.1, 1-Feb-1989 (WLT) */
+
+/* Example section of header upgraded. */
+
+/* -& */
+
+/* Local Variables */
+
+
+/* Convert the input cylindrical coordinates to latitudinal */
+/* coordinates, storing in temporary variables. */
+
+/* Computing MAX */
+ d__1 = abs(*r__), d__2 = abs(*z__);
+ big = max(d__1,d__2);
+ if (big > 0.) {
+ x = *r__ / big;
+ y = *z__ / big;
+ rho = big * sqrt(x * x + y * y);
+ } else {
+ rho = 0.;
+ }
+ if (rho == 0.) {
+ lattud = 0.;
+ } else {
+ lattud = atan2(*z__, *r__);
+ }
+
+/* Move results to output variables */
+
+ *long__ = *longc;
+ *radius = rho;
+ *lat = lattud;
+
+ return 0;
+} /* cyllat_ */
+
diff --git a/ext/spice/src/cspice/cyllat_c.c b/ext/spice/src/cspice/cyllat_c.c
new file mode 100644
index 0000000000..9f9ad2113f
--- /dev/null
+++ b/ext/spice/src/cspice/cyllat_c.c
@@ -0,0 +1,211 @@
+/*
+
+-Procedure cyllat_c ( Cylindrical to latitudinal )
+
+-Abstract
+
+ Convert from cylindrical to latitudinal coordinates.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ CONVERSION, COORDINATES
+
+*/
+
+ #include
+ #include "SpiceUsr.h"
+ #include "SpiceZmc.h"
+
+ void cyllat_c ( SpiceDouble r,
+ SpiceDouble lonc,
+ SpiceDouble z,
+ SpiceDouble * radius,
+ SpiceDouble * lon,
+ SpiceDouble * lat )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ r I Distance of point from z axis.
+ lonc I Cylindrical angle of point from XZ plane(radians).
+ z I Height of point above XY plane.
+ radius O Distance of point from origin.
+ lon O Longitude of point (radians).
+ lat O Latitude of point (radians).
+
+-Detailed_Input
+
+ r Distance of the input point from z axis.
+
+ lonc Cylindrical angle of the point from XZ plane(radians).
+
+ z Height of the point above XY plane.
+
+-Detailed_Output
+
+ radius Distance of the input point from origin.
+
+ lon Longitude (i.e. angle from the XZ plane) of the input
+ point.
+
+ lat Latitude (i.e. angle above the XY plane) of the input
+ point (radians).
+
+-Parameters
+
+ None.
+
+-Particulars
+
+ This routine converts coordinates given in cylindrical
+ coordinates to coordinates in latitudinal coordinates.
+
+ Latitudinal coordinates are the same coordinates as use for
+ the earth. Latitude refers to angle above the equator, longitude
+ to angle east from a meridian, and radius to the distance from
+ an origin.
+
+-Examples
+
+ Below are two tables: The first is a set of input values
+ the second is the result of the following sequence of
+ calls to Spicelib routines. Note all input and output angular
+ quantities are in degrees.
+
+ convrt_c ( lonc , "DEGREES", "RADIANS", lonc );
+
+ cyllat_c ( r, lonc , z, &radius, &lon, &lat );
+
+ convrt_c ( lon, "RADIANS", "DEGREES", lon );
+ convrt_c ( lat, "RADIANS", "DEGREES", lat );
+
+
+ Inputs: Results:
+
+ r lonc z radius lon lat
+ ------ ------ ------ ------ ------ ------
+ 1.0000 0 0 1.0000 0 0
+ 1.0000 90.00 0 1.0000 90.00 0
+ 1.0000 180.00 1.000 1.4142 180.00 45.00
+ 1.0000 180.00 -1.000 1.4142 180.00 -45.00
+ 0.0000 180.00 1.000 1.0000 180.00 90.00
+ 0.0000 33.00 0 0.0000 33.00 0.00
+
+-Restrictions
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+-Files
+
+ None.
+
+-Author_and_Institution
+
+ E.D. Wright (JPL)
+ W.L. Taber (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.1.0, 23-JUL-2001 (NJB)
+
+ Removed tab characters from source file.
+
+ -CSPICE Version 1.0.1, 08-FEB-1998 (EDW)
+
+ Corrected and clarified header entries. Removed return call.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (EDW)
+
+-Index_Entries
+
+ cylindrical to latitudinal
+
+-&
+*/
+
+{ /* Begin cyllat_c */
+
+ /*
+ Local variables
+ */
+
+ SpiceDouble lattud;
+ SpiceDouble rho;
+ SpiceDouble x;
+ SpiceDouble y;
+ SpiceDouble big;
+
+
+ /* Computing biggest absolute value */
+
+ big = MaxAbs( r, z);
+
+ if (big > 0.)
+ {
+ x = r / big;
+ y = z / big;
+ rho = big * sqrt(x * x + y * y);
+ }
+ else
+ {
+ rho = 0.;
+ }
+
+ if (rho == 0.)
+ {
+ lattud = 0.;
+ }
+ else
+ {
+ lattud = atan2( z, r );
+ }
+
+
+ /* Move results to output variables */
+
+ *lon = lonc;
+ *radius = rho;
+ *lat = lattud;
+
+
+} /* End cyllat_c */
diff --git a/ext/spice/src/cspice/cylrec.c b/ext/spice/src/cspice/cylrec.c
new file mode 100644
index 0000000000..3ef7605691
--- /dev/null
+++ b/ext/spice/src/cspice/cylrec.c
@@ -0,0 +1,183 @@
+/* cylrec.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CYLREC ( Cylindrical to rectangular ) */
+/* Subroutine */ int cylrec_(doublereal *r__, doublereal *long__, doublereal *
+ z__, doublereal *rectan)
+{
+ /* Builtin functions */
+ double cos(doublereal), sin(doublereal);
+
+ /* Local variables */
+ doublereal x, y;
+
+/* $ Abstract */
+
+/* Convert from cylindrical to rectangular coordinates. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CONVERSION, COORDINATES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- ------------------------------------------------- */
+/* R I Distance of a point from Z axis. */
+/* LONG I Angle (radians) of a point from XZ plane */
+/* Z I Height of a point above XY plane. */
+/* RECTAN O Rectangular coordinates of the point. */
+
+/* $ Detailed_Input */
+
+/* R Distance of the point of interest from Z axis. */
+
+/* LONG Cylindrical angle (in radians) of the point of */
+/* interest from XZ plane. */
+
+/* Z Height of the point above XY plane. */
+
+/* $ Detailed_Output */
+
+/* RECTAN Rectangular coordinates of the point of interest. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine transforms the coordinates of a point from */
+/* cylindrical to rectangular coordinates. */
+
+/* $ Examples */
+
+/* Below are two tables. */
+
+/* Listed in the first table (under R, LONG and Z ) are */
+/* cylindrical coordinate triples that approximately represent */
+/* points whose rectangular coordinates are taken from the set */
+/* {-1, 0, 1}. (Angular quantities are given in degrees.) */
+
+/* The result of the code fragment */
+
+/* Use the SPICELIB routine CONVRT to convert the angular */
+/* quantities to radians */
+
+/* CALL CONVRT ( LONG, 'DEGREES', 'RADIANS', LONG ) */
+
+/* CALL CYLREC ( R, LONG, Z, X ) */
+
+
+/* are listed in the second parallel table under X(1), X(2) and X(3). */
+
+
+/* R LONG Z X(1) X(2) X(3) */
+/* ------------------------- -------------------------- */
+/* 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 */
+/* 1.0000 0.0000 0.0000 1.0000 0.0000 0.0000 */
+/* 1.0000 90.0000 0.0000 0.0000 1.0000 0.0000 */
+/* 0.0000 0.0000 1.0000 0.0000 0.0000 1.0000 */
+/* 1.0000 180.0000 0.0000 -1.0000 0.0000 0.0000 */
+/* 1.0000 270.0000 0.0000 0.0000 -1.0000 0.0000 */
+/* 0.0000 0.0000 -1.0000 0.0000 0.0000 -1.0000 */
+/* 1.4142 45.0000 0.0000 1.0000 1.0000 0.0000 */
+/* 1.0000 0.0000 1.0000 1.0000 0.0000 1.0000 */
+/* 1.0000 90.0000 1.0000 0.0000 1.0000 1.0000 */
+/* 1.4142 45.0000 1.0000 1.0000 1.0000 1.0000 */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cylindrical to rectangular */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.0.1, 1-Feb-1989 (WLT) */
+
+/* Example section of header upgraded. */
+
+/* -& */
+
+/* Local variables */
+
+
+/* Convert to rectangular coordinates, storing the results in */
+/* temporary variables. */
+
+ x = *r__ * cos(*long__);
+ y = *r__ * sin(*long__);
+
+/* Move the results to the output variables. */
+
+ rectan[0] = x;
+ rectan[1] = y;
+ rectan[2] = *z__;
+ return 0;
+} /* cylrec_ */
+
diff --git a/ext/spice/src/cspice/cylrec_c.c b/ext/spice/src/cspice/cylrec_c.c
new file mode 100644
index 0000000000..c22a66719b
--- /dev/null
+++ b/ext/spice/src/cspice/cylrec_c.c
@@ -0,0 +1,182 @@
+/*
+
+-Procedure cylrec_c ( Cylindrical to rectangular )
+
+-Abstract
+
+ Convert from cylindrical to rectangular coordinates.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ CONVERSION
+ COORDINATES
+
+*/
+
+ #include
+ #include "SpiceUsr.h"
+
+ void cylrec_c ( SpiceDouble r,
+ SpiceDouble lon,
+ SpiceDouble z,
+ SpiceDouble rectan[3] )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- -------------------------------------------------
+ r I Distance of a point from z axis.
+ lon I Angle (radians) of a point from xZ plane
+ z I Height of a point above xY plane.
+ rectan O Rectangular coordinates of the point.
+
+-Detailed_Input
+
+ r Distance of the point of interest from z axis.
+
+ lon Cylindrical angle (in radians) of the point of
+ interest from XZ plane.
+
+ z Height of the point above XY plane.
+
+-Detailed_Output
+
+ rectan Rectangular coordinates of the point of interest.
+
+-Parameters
+
+ None.
+
+-Particulars
+
+ This routine transforms the coordinates of a point from
+ cylindrical to rectangular coordinates.
+
+-Examples
+
+ Below are two tables.
+
+ Listed in the first table (under r, lon and z ) are
+ cylindrical coordinate triples that approximately represent
+ points whose rectangular coordinates are taken from the set
+ {-1, 0, 1}. (Angular quantities are given in degrees.)
+
+ The result of the code fragment
+
+ Use the CSPICE routine convrt_c to convert the angular
+ quantities to radians
+
+ convrt_c ( lon, "DEGREES", "RADIANS", lon );
+
+ cylrec_c ( r, lon, z, x );
+
+
+ are listed in the second parallel table under x(1), x(2) and x(3).
+
+
+ r lon z x(1) x(2) x(3)
+ ------------------------- --------------------------
+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
+ 1.0000 0.0000 0.0000 1.0000 0.0000 0.0000
+ 1.0000 90.0000 0.0000 0.0000 1.0000 0.0000
+ 0.0000 0.0000 1.0000 0.0000 0.0000 1.0000
+ 1.0000 180.0000 0.0000 -1.0000 0.0000 0.0000
+ 1.0000 270.0000 0.0000 0.0000 -1.0000 0.0000
+ 0.0000 0.0000 -1.0000 0.0000 0.0000 -1.0000
+ 1.4142 45.0000 0.0000 1.0000 1.0000 0.0000
+ 1.0000 0.0000 1.0000 1.0000 0.0000 1.0000
+ 1.0000 90.0000 1.0000 0.0000 1.0000 1.0000
+ 1.4142 45.0000 1.0000 1.0000 1.0000 1.0000
+
+
+-Restrictions
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+-Files
+
+ None.
+
+-Author_and_Institution
+
+ E.D. Wright (JPL)
+ W.L. Taber (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.1, 08-FEB-1998 (EDW)
+
+ Corrected and clarified header entries. Removed return call.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (EDW)
+
+-Index_Entries
+
+ cylindrical to rectangular
+
+-&
+*/
+
+{ /* Begin cylrec_c */
+
+ /*
+ Local variables
+ */
+
+ SpiceDouble x;
+ SpiceDouble y;
+
+
+ /* Function Body */
+
+ x = r * cos( lon );
+ y = r * sin( lon );
+
+
+ /* Move the results to the output variables. */
+
+ rectan[0] = x;
+ rectan[1] = y;
+ rectan[2] = z;
+
+
+} /* End cylrec_c */
diff --git a/ext/spice/src/cspice/cylsph.c b/ext/spice/src/cspice/cylsph.c
new file mode 100644
index 0000000000..bf84cfeca4
--- /dev/null
+++ b/ext/spice/src/cspice/cylsph.c
@@ -0,0 +1,190 @@
+/* cylsph.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure CYLSPH ( Cylindrical to spherical ) */
+/* Subroutine */ int cylsph_(doublereal *r__, doublereal *longc, doublereal *
+ z__, doublereal *radius, doublereal *colat, doublereal *long__)
+{
+ /* System generated locals */
+ doublereal d__1, d__2;
+
+ /* Builtin functions */
+ double sqrt(doublereal), atan2(doublereal, doublereal);
+
+ /* Local variables */
+ doublereal x, y, rh, th, big;
+
+/* $ Abstract */
+
+/* Convert from cylindrical to spherical coordinates. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CONVERSION, COORDINATES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- ------------------------------------------------- */
+/* R I Distance of point from Z axis. */
+/* LONGC I Angle (radians) of point from XZ plane. */
+/* Z I Height of point above XY plane. */
+/* RADIUS O Distance of point from origin. */
+/* COLAT O Polar angle (co-latitude in radians) of point. */
+/* LONG O Azimuthal angle (longitude) of point (radians). */
+
+/* $ Detailed_Input */
+
+/* R Distance of the point of interest from Z axis. */
+
+/* LONGC Cylindrical angle (radians) of the point from the */
+/* XZ plane. */
+
+/* Z Height of the point above XY plane. */
+
+/* $ Detailed_Output */
+
+/* RADIUS Distance of the point from origin. */
+
+/* COLAT Polar angle (co-latitude in radians) of the point. */
+
+/* LONG Azimuthal angle (longitude) of the point (radians). */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This returns the spherical coordinates of a point whose position */
+/* is input through cylindrical coordinates. */
+
+/* $ Examples */
+
+
+/* Below are two tables: The first is a set of input values */
+/* the second is the result of the following sequence of */
+/* calls to Spicelib routines. Note all input and output angular */
+/* quantities are in degrees. */
+
+/* CALL CONVRT ( LONGC, 'DEGREES', 'RADIANS', LONGC ) */
+
+/* CALL CYLSPH ( R, LONGC, Z, RADIUS, COLAT, LONG ) */
+
+/* CALL CONVRT ( LONG, 'RADIANS', 'DEGREES', LONG ) */
+/* CALL CONVRT ( LAT, 'RADIANS', 'DEGREES', LAT ) */
+
+
+
+/* Inputs: Results: */
+
+/* R LONGC Z RADIUS LONG COLAT */
+/* ------ ------ ------ ------ ------ ------ */
+/* 1.0000 0 0 1.0000 0 90.00 */
+/* 1.0000 90.00 0 1.0000 90.00 90.00 */
+/* 1.0000 180.00 1.000 1.4142 180.00 45.00 */
+/* 1.0000 180.00 -1.000 1.4142 180.00 135.00 */
+/* 0.0000 180.00 1.000 1.0000 180.00 0.00 */
+/* 0.0000 33.00 0 0.0000 33.00 0.00 */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 22-AUG-2001 (EDW) */
+
+/* Corrected ENDIF to END IF. Obsolete Revisions section */
+/* deleted. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* cylindrical to spherical */
+
+/* -& */
+
+/* Local variables */
+
+
+/* Convert to spherical, storing in temporary variables */
+
+/* Computing MAX */
+ d__1 = abs(*r__), d__2 = abs(*z__);
+ big = max(d__1,d__2);
+ if (big == 0.) {
+ th = 0.;
+ rh = 0.;
+ } else {
+ x = *r__ / big;
+ y = *z__ / big;
+ rh = big * sqrt(x * x + y * y);
+ th = atan2(*r__, *z__);
+ }
+
+/* Move the results to output variables */
+
+ *long__ = *longc;
+ *radius = rh;
+ *colat = th;
+ return 0;
+} /* cylsph_ */
+
diff --git a/ext/spice/src/cspice/cylsph_c.c b/ext/spice/src/cspice/cylsph_c.c
new file mode 100644
index 0000000000..86e9c4afb2
--- /dev/null
+++ b/ext/spice/src/cspice/cylsph_c.c
@@ -0,0 +1,197 @@
+/*
+
+-Procedure cylsph_c ( Cylindrical to spherical )
+
+-Abstract
+
+ Convert from cylindrical to spherical coordinates.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ CONVERSION
+ COORDINATES
+
+*/
+
+ #include
+ #include "SpiceUsr.h"
+ #include "SpiceZmc.h"
+
+ void cylsph_c ( SpiceDouble r,
+ SpiceDouble lonc,
+ SpiceDouble z,
+ SpiceDouble * radius,
+ SpiceDouble * colat,
+ SpiceDouble * lon )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- -------------------------------------------------
+ r I Distance of point from z axis.
+ lonc I Angle (radians) of point from XZ plane.
+ z I Height of point above XY plane.
+ radius O Distance of point from origin.
+ colat O Polar angle (co-latitude in radians) of point.
+ lon O Azimuthal angle (longitude) of point (radians).
+
+-Detailed_Input
+
+ r Distance of the point of interest from z axis.
+
+ lonc Cylindrical angle (radians) of the point from the
+ XZ plane.
+
+ z Height of the point above XY plane.
+
+-Detailed_Output
+
+ radius Distance of the point from origin.
+
+ colat Polar angle (co-latitude in radians) of the point.
+
+ lon Azimuthal angle (longitude) of the point (radians).
+
+-Parameters
+
+ None.
+
+-Particulars
+
+ This returns the spherical coordinates of a point whose position
+ is input through cylindrical coordinates.
+
+-Examples
+
+
+ Below are two tables: The first is a set of input values
+ the second is the result of the following sequence of
+ calls to Spicelib routines. Note all input and output angular
+ quantities are in degrees.
+
+ convrt_c ( lonc, "DEGREES", "RADIANS", lonc );
+
+ cylsph_c ( r, lonc, z, &radius, &colat, &lon );
+
+ convrt_c ( lon, "RADIANS", "DEGREES", lon );
+ convrt_c ( lat, "RADIANS", "DEGREES", lat );
+
+
+
+ Inputs: Results:
+
+ r lonc z radius lon colat
+ ------ ------ ------ ------ ------ ------
+ 1.0000 0 0 1.0000 0 90.00
+ 1.0000 90.00 0 1.0000 90.00 90.00
+ 1.0000 180.00 1.000 1.4142 180.00 45.00
+ 1.0000 180.00 -1.000 1.4142 180.00 135.00
+ 0.0000 180.00 1.000 1.0000 180.00 0.00
+ 0.0000 33.00 0 0.0000 33.00 0.00
+
+-Restrictions
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+-Files
+
+ None.
+
+-Author_and_Institution
+
+ E.D. Wright (JPL)
+ W.L. Taber (JPL)
+
+-Literature_References
+
+ None.
+
+-Version
+
+ -CSPICE Version 1.0.1, 08-FEB-1998 (EDW)
+
+ Corrected and clarified header entries.
+
+ -CSPICE Version 1.0.0, 25-OCT-1997 (EDW)
+
+-Index_Entries
+
+ cylindrical to spherical
+
+-&
+*/
+
+{ /* Begin cylsph_c */
+
+ /*
+ Local variables
+ */
+
+ SpiceDouble big;
+ SpiceDouble th;
+ SpiceDouble rh;
+ SpiceDouble x;
+ SpiceDouble y;
+
+
+ /* Computing biggest absolute value */
+
+ big = MaxAbs( r, z );
+
+ if (big == 0.)
+ {
+ th = 0.;
+ rh = 0.;
+ }
+ else
+ {
+ x = r / big;
+ y = z / big;
+ rh = big * sqrt( x * x + y * y);
+ th = atan2( r, z );
+ }
+
+
+ /* Move the results to output variables */
+
+ *lon = lonc;
+ *radius = rh;
+ *colat = th;
+
+
+} /* End cylsph_c */
diff --git a/ext/spice/src/cspice/d_abs.c b/ext/spice/src/cspice/d_abs.c
new file mode 100644
index 0000000000..cb157e067b
--- /dev/null
+++ b/ext/spice/src/cspice/d_abs.c
@@ -0,0 +1,12 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double d_abs(x) doublereal *x;
+#else
+double d_abs(doublereal *x)
+#endif
+{
+if(*x >= 0)
+ return(*x);
+return(- *x);
+}
diff --git a/ext/spice/src/cspice/d_acos.c b/ext/spice/src/cspice/d_acos.c
new file mode 100644
index 0000000000..ecb56e87f5
--- /dev/null
+++ b/ext/spice/src/cspice/d_acos.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double acos();
+double d_acos(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_acos(doublereal *x)
+#endif
+{
+return( acos(*x) );
+}
diff --git a/ext/spice/src/cspice/d_asin.c b/ext/spice/src/cspice/d_asin.c
new file mode 100644
index 0000000000..045e73301c
--- /dev/null
+++ b/ext/spice/src/cspice/d_asin.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double asin();
+double d_asin(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_asin(doublereal *x)
+#endif
+{
+return( asin(*x) );
+}
diff --git a/ext/spice/src/cspice/d_atan.c b/ext/spice/src/cspice/d_atan.c
new file mode 100644
index 0000000000..03530a1857
--- /dev/null
+++ b/ext/spice/src/cspice/d_atan.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double atan();
+double d_atan(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_atan(doublereal *x)
+#endif
+{
+return( atan(*x) );
+}
diff --git a/ext/spice/src/cspice/d_atn2.c b/ext/spice/src/cspice/d_atn2.c
new file mode 100644
index 0000000000..7c25ac0460
--- /dev/null
+++ b/ext/spice/src/cspice/d_atn2.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double atan2();
+double d_atn2(x,y) doublereal *x, *y;
+#else
+#undef abs
+#include "math.h"
+double d_atn2(doublereal *x, doublereal *y)
+#endif
+{
+return( atan2(*x,*y) );
+}
diff --git a/ext/spice/src/cspice/d_cnjg.c b/ext/spice/src/cspice/d_cnjg.c
new file mode 100644
index 0000000000..c778c38758
--- /dev/null
+++ b/ext/spice/src/cspice/d_cnjg.c
@@ -0,0 +1,12 @@
+#include "f2c.h"
+
+ VOID
+#ifdef KR_headers
+d_cnjg(r, z) doublecomplex *r, *z;
+#else
+d_cnjg(doublecomplex *r, doublecomplex *z)
+#endif
+{
+r->r = z->r;
+r->i = - z->i;
+}
diff --git a/ext/spice/src/cspice/d_cos.c b/ext/spice/src/cspice/d_cos.c
new file mode 100644
index 0000000000..45c4838bae
--- /dev/null
+++ b/ext/spice/src/cspice/d_cos.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double cos();
+double d_cos(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_cos(doublereal *x)
+#endif
+{
+return( cos(*x) );
+}
diff --git a/ext/spice/src/cspice/d_cosh.c b/ext/spice/src/cspice/d_cosh.c
new file mode 100644
index 0000000000..1181833cc1
--- /dev/null
+++ b/ext/spice/src/cspice/d_cosh.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double cosh();
+double d_cosh(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_cosh(doublereal *x)
+#endif
+{
+return( cosh(*x) );
+}
diff --git a/ext/spice/src/cspice/d_dim.c b/ext/spice/src/cspice/d_dim.c
new file mode 100644
index 0000000000..1d0ecb7bbb
--- /dev/null
+++ b/ext/spice/src/cspice/d_dim.c
@@ -0,0 +1,10 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double d_dim(a,b) doublereal *a, *b;
+#else
+double d_dim(doublereal *a, doublereal *b)
+#endif
+{
+return( *a > *b ? *a - *b : 0);
+}
diff --git a/ext/spice/src/cspice/d_exp.c b/ext/spice/src/cspice/d_exp.c
new file mode 100644
index 0000000000..3f2b6ffcc4
--- /dev/null
+++ b/ext/spice/src/cspice/d_exp.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double exp();
+double d_exp(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_exp(doublereal *x)
+#endif
+{
+return( exp(*x) );
+}
diff --git a/ext/spice/src/cspice/d_imag.c b/ext/spice/src/cspice/d_imag.c
new file mode 100644
index 0000000000..793a3f9c40
--- /dev/null
+++ b/ext/spice/src/cspice/d_imag.c
@@ -0,0 +1,10 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double d_imag(z) doublecomplex *z;
+#else
+double d_imag(doublecomplex *z)
+#endif
+{
+return(z->i);
+}
diff --git a/ext/spice/src/cspice/d_int.c b/ext/spice/src/cspice/d_int.c
new file mode 100644
index 0000000000..6c0e64215d
--- /dev/null
+++ b/ext/spice/src/cspice/d_int.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double floor();
+double d_int(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_int(doublereal *x)
+#endif
+{
+return( (*x>0) ? floor(*x) : -floor(- *x) );
+}
diff --git a/ext/spice/src/cspice/d_lg10.c b/ext/spice/src/cspice/d_lg10.c
new file mode 100644
index 0000000000..f03ff0043f
--- /dev/null
+++ b/ext/spice/src/cspice/d_lg10.c
@@ -0,0 +1,15 @@
+#include "f2c.h"
+
+#define log10e 0.43429448190325182765
+
+#ifdef KR_headers
+double log();
+double d_lg10(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_lg10(doublereal *x)
+#endif
+{
+return( log10e * log(*x) );
+}
diff --git a/ext/spice/src/cspice/d_log.c b/ext/spice/src/cspice/d_log.c
new file mode 100644
index 0000000000..d7a1941d56
--- /dev/null
+++ b/ext/spice/src/cspice/d_log.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double log();
+double d_log(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_log(doublereal *x)
+#endif
+{
+return( log(*x) );
+}
diff --git a/ext/spice/src/cspice/d_mod.c b/ext/spice/src/cspice/d_mod.c
new file mode 100644
index 0000000000..0d3ffbff9e
--- /dev/null
+++ b/ext/spice/src/cspice/d_mod.c
@@ -0,0 +1,40 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+#ifdef IEEE_drem
+double drem();
+#else
+double floor();
+#endif
+double d_mod(x,y) doublereal *x, *y;
+#else
+#ifdef IEEE_drem
+double drem(double, double);
+#else
+#undef abs
+#include "math.h"
+#endif
+double d_mod(doublereal *x, doublereal *y)
+#endif
+{
+#ifdef IEEE_drem
+ double xa, ya, z;
+ if ((ya = *y) < 0.)
+ ya = -ya;
+ z = drem(xa = *x, ya);
+ if (xa > 0) {
+ if (z < 0)
+ z += ya;
+ }
+ else if (z > 0)
+ z -= ya;
+ return z;
+#else
+ double quotient;
+ if( (quotient = *x / *y) >= 0)
+ quotient = floor(quotient);
+ else
+ quotient = -floor(-quotient);
+ return(*x - (*y) * quotient );
+#endif
+}
diff --git a/ext/spice/src/cspice/d_nint.c b/ext/spice/src/cspice/d_nint.c
new file mode 100644
index 0000000000..2ead3df200
--- /dev/null
+++ b/ext/spice/src/cspice/d_nint.c
@@ -0,0 +1,14 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double floor();
+double d_nint(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_nint(doublereal *x)
+#endif
+{
+return( (*x)>=0 ?
+ floor(*x + .5) : -floor(.5 - *x) );
+}
diff --git a/ext/spice/src/cspice/d_prod.c b/ext/spice/src/cspice/d_prod.c
new file mode 100644
index 0000000000..3d4cef7835
--- /dev/null
+++ b/ext/spice/src/cspice/d_prod.c
@@ -0,0 +1,10 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double d_prod(x,y) real *x, *y;
+#else
+double d_prod(real *x, real *y)
+#endif
+{
+return( (*x) * (*y) );
+}
diff --git a/ext/spice/src/cspice/d_sign.c b/ext/spice/src/cspice/d_sign.c
new file mode 100644
index 0000000000..514ff0bbff
--- /dev/null
+++ b/ext/spice/src/cspice/d_sign.c
@@ -0,0 +1,12 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double d_sign(a,b) doublereal *a, *b;
+#else
+double d_sign(doublereal *a, doublereal *b)
+#endif
+{
+double x;
+x = (*a >= 0 ? *a : - *a);
+return( *b >= 0 ? x : -x);
+}
diff --git a/ext/spice/src/cspice/d_sin.c b/ext/spice/src/cspice/d_sin.c
new file mode 100644
index 0000000000..0013af0349
--- /dev/null
+++ b/ext/spice/src/cspice/d_sin.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double sin();
+double d_sin(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_sin(doublereal *x)
+#endif
+{
+return( sin(*x) );
+}
diff --git a/ext/spice/src/cspice/d_sinh.c b/ext/spice/src/cspice/d_sinh.c
new file mode 100644
index 0000000000..1ccd02ead9
--- /dev/null
+++ b/ext/spice/src/cspice/d_sinh.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double sinh();
+double d_sinh(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_sinh(doublereal *x)
+#endif
+{
+return( sinh(*x) );
+}
diff --git a/ext/spice/src/cspice/d_sqrt.c b/ext/spice/src/cspice/d_sqrt.c
new file mode 100644
index 0000000000..bee10a3a55
--- /dev/null
+++ b/ext/spice/src/cspice/d_sqrt.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double sqrt();
+double d_sqrt(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_sqrt(doublereal *x)
+#endif
+{
+return( sqrt(*x) );
+}
diff --git a/ext/spice/src/cspice/d_tan.c b/ext/spice/src/cspice/d_tan.c
new file mode 100644
index 0000000000..23fa423188
--- /dev/null
+++ b/ext/spice/src/cspice/d_tan.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double tan();
+double d_tan(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_tan(doublereal *x)
+#endif
+{
+return( tan(*x) );
+}
diff --git a/ext/spice/src/cspice/d_tanh.c b/ext/spice/src/cspice/d_tanh.c
new file mode 100644
index 0000000000..0363a49b1b
--- /dev/null
+++ b/ext/spice/src/cspice/d_tanh.c
@@ -0,0 +1,13 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double tanh();
+double d_tanh(x) doublereal *x;
+#else
+#undef abs
+#include "math.h"
+double d_tanh(doublereal *x)
+#endif
+{
+return( tanh(*x) );
+}
diff --git a/ext/spice/src/cspice/dacosh.c b/ext/spice/src/cspice/dacosh.c
new file mode 100644
index 0000000000..8af1b8f926
--- /dev/null
+++ b/ext/spice/src/cspice/dacosh.c
@@ -0,0 +1,178 @@
+/* dacosh.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DACOSH ( Double precision arc hyperbolic cosine ) */
+doublereal dacosh_(doublereal *x)
+{
+ /* System generated locals */
+ doublereal ret_val;
+
+ /* Builtin functions */
+ double sqrt(doublereal), log(doublereal);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), sigerr_(char *,
+ ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Return the inverse hyperbolic cosine of a double */
+/* precision argument. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* HYPERBOLIC, MATH */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* X I Number whose inverse hyperbolic cosine is desired. */
+/* X must be >= 1. */
+
+/* $ Detailed_Input */
+
+/* X is any double precision number greater than or equal to 1. */
+
+/* $ Detailed_Output */
+
+/* DACOSH is the inverse hyperbolic cosine of X. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This function simply implements the definition of the inverse */
+/* hyperbolic cosine as follows: */
+
+/* DACOSH = DLOG (X + DSQRT (X*X-1.D0)) */
+
+/* If the input value is not valid, an error is signalled. */
+
+/* $ Examples */
+
+/* The following table gives a few values for X and the resulting */
+/* value of DACOSH. */
+
+/* X DACOSH(X) */
+/* ---------------------------------------------- */
+/* 1.000000000000000 0.0000000000000000E+00 */
+/* 10.00000000000000 2.993222846126381 */
+/* 100.0000000000000 5.298292365610485 */
+/* 1000.000000000000 7.600902209541989 */
+
+/* $ Restrictions */
+
+/* The value of the input variable X must be greater than or equal */
+/* to 1.0d0. */
+
+/* $ Exceptions */
+
+/* 1) If X is less than 1.0d0, the error SPICE(INVALIDARGUMENT) is */
+/* signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* H.A. Neilan (JPL) */
+/* W.M. Owen (JPL) */
+
+/* $ Literature_References */
+
+/* Any good book of mathematical tables and formulae, for example */
+/* the "Standard Mathematical Tables" published by the Chemical */
+/* Rubber Company. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 17-MAY-1994 (HAN) */
+
+/* Set the default function value to either 0, 0.0D0, .FALSE., */
+/* or blank depending on the type of the function. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WMO) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* d.p. arc hyperbolic_cosine */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Set up the error processing. */
+
+ if (return_()) {
+ ret_val = 0.;
+ return ret_val;
+ } else {
+ chkin_("DACOSH", (ftnlen)6);
+ ret_val = 0.;
+ }
+
+/* Check that X >= 1. */
+
+ if (*x < 1.) {
+ setmsg_("DACOSH: Invalid argument, X is less than one.", (ftnlen)45);
+ sigerr_("SPICE(INVALIDARGUMENT)", (ftnlen)22);
+ chkout_("DACOSH", (ftnlen)6);
+ return ret_val;
+ }
+
+/* Abiding by the order implied by the parentheses in the expression */
+/* (1.0D0/X)/X prevents floating point overflow that might occur for */
+/* large values of X if the equivalent expression, 1.0D0/(X*X), were */
+/* used. */
+
+ ret_val = log(*x + *x * sqrt(1. - 1. / *x / *x));
+ chkout_("DACOSH", (ftnlen)6);
+ return ret_val;
+} /* dacosh_ */
+
diff --git a/ext/spice/src/cspice/dacosn.c b/ext/spice/src/cspice/dacosn.c
new file mode 100644
index 0000000000..3a6a51974e
--- /dev/null
+++ b/ext/spice/src/cspice/dacosn.c
@@ -0,0 +1,176 @@
+/* dacosn.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DACOSN (arc cosine of bracketed argument) */
+doublereal dacosn_(doublereal *arg, doublereal *tol)
+{
+ /* System generated locals */
+ doublereal ret_val, d__1, d__2;
+
+ /* Builtin functions */
+ double acos(doublereal);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errdp_(char *,
+ doublereal *, ftnlen), sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen);
+
+/* $ Abstract */
+
+/* This routine produces a SPICE error if the |argument| exceeds */
+/* 1.D0 by more than TOL. If ARG exceeds 1.D0, the argument is */
+/* evaluated as if it equaled 1.D0, if ARG is less than -1., */
+/* the argument is evaluated as if it equaled -1.D0. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* INTERVALS, NUMBERS, UTILITY, INVERSE TRIGONOMETRIC FUNCTION */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* ARG I Argument to be evaluated. */
+/* TOL I Tolerance. */
+/* DACOSN O The function returns the arc cosine of ARG. */
+
+/* $ Detailed_Input */
+
+/* ARG is the arc cosine argument that is to be evaluated */
+/* such that if it is less than -1.D0 by more than TOL */
+/* or greater than 1.D0 by more than TOL, an error */
+/* results. */
+
+/* TOL is a tolerance such that |ARG| is considered to be */
+/* equal to 1.D0 if |ARG| <= 1.D0 + TOL. TOL must be */
+/* non-negative. */
+
+/* $ Detailed_Output */
+
+/* DACOSN The function returns the arc cosine of ARG. If |ARG| */
+/* >= 1.D0, it returns DACOS (1.D0) or DACOS (-1.D0) as */
+/* appropriate. Values range from 0 to PI. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If |ARG| > 1.D0 + TOL, the error SPICE(INPUTOUTOFBOUNDS) is */
+/* signaled. */
+
+/* 2) If TOL is less than zero, the error SPICE(VALUEOUTOFRANGE) is */
+/* signaled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine determines whether |ARG| > 1.D0 + TOL. If */
+/* it is, an error will be flagged. In addition, */
+/* the values of ARG are constrained to [-1.D0, 1.D0]. */
+
+/* $ Examples */
+
+/* The following illustrate the operation of DACOSN. */
+
+/* DACOSN ( -1.D0, 1.D-7 ) = PI */
+/* DACOSN ( -1.00001D0, 1.D-3 ) = PI */
+/* DACOSN ( -1.00001D0, 1.D-7 ) = PI (error flagged) */
+/* DACOSN ( 0.D0, 1.D-7 ) = PI/2 */
+/* DACOSN ( 1.00001D0, 1.D-3 ) = 0. */
+/* DACOSN ( 1.00001D0, 1.D-7 ) = 0. (error flagged) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* L.S. Elson (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 28-FEB-2006 (LSE) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* check a d.p. argument for ACOS before evaluation */
+
+/* -& */
+
+/* Bracket ARG. */
+
+/* Computing MAX */
+ d__1 = -1., d__2 = min(1.,*arg);
+ ret_val = acos((max(d__1,d__2)));
+
+/* Check that tolerance is non negative. */
+
+ if (*tol < 0.) {
+ chkin_("DACOSN", (ftnlen)6);
+ setmsg_("TOL was #; must be non-negative.", (ftnlen)32);
+ errdp_("#", tol, (ftnlen)1);
+ sigerr_("SPICE(VALUEOUTOFRANGE)", (ftnlen)22);
+ chkout_("DACOSN", (ftnlen)6);
+ return ret_val;
+ }
+
+/* Check to see if |ARG| is within TOL of 1.D0. Signal error if */
+/* appropriate. */
+
+ if (abs(*arg) - *tol > 1.) {
+ chkin_("DACOSN", (ftnlen)6);
+ setmsg_("The |argument| specified was greater than 1.D0 by more than"
+ " #. The value of the argument is #. ", (ftnlen)95);
+ errdp_("#", tol, (ftnlen)1);
+ errdp_("#", arg, (ftnlen)1);
+ sigerr_("SPICE(INPUTOUTOFBOUNDS)", (ftnlen)23);
+ chkout_("DACOSN", (ftnlen)6);
+ return ret_val;
+ }
+ return ret_val;
+} /* dacosn_ */
+
diff --git a/ext/spice/src/cspice/dafa2b.c b/ext/spice/src/cspice/dafa2b.c
new file mode 100644
index 0000000000..8fcb0cc506
--- /dev/null
+++ b/ext/spice/src/cspice/dafa2b.c
@@ -0,0 +1,271 @@
+/* dafa2b.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DAFA2B ( DAF, ASCII to binary ) */
+/* Subroutine */ int dafa2b_(char *ascii, char *binary, integer *resv, ftnlen
+ ascii_len, ftnlen binary_len)
+{
+ /* System generated locals */
+ cllist cl__1;
+
+ /* Builtin functions */
+ integer f_clos(cllist *);
+
+ /* Local variables */
+ integer unit;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), daft2b_(integer *,
+ char *, integer *, ftnlen);
+ extern logical failed_(void);
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int txtopr_(char *, integer *, ftnlen);
+
+/* $ Abstract */
+
+/* Convert an ASCII (text) DAF to an equivalent binary DAF. */
+/* (Obsolete, maintained for backward compatibility only.) */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* ASCII I Name of an existing ASCII (text) DAF. */
+/* BINARY I Name of a binary DAF to be created. */
+/* RESV I Number of records to reserve. */
+
+/* $ Detailed_Input */
+
+/* ASCII is the name of an existing ASCII (text) DAF. */
+
+/* BINARY is the name of the binary DAF to be created. */
+/* The binary DAF contains the same data as the */
+/* ASCII DAF, but in a form more suitable for use */
+/* by application programs. */
+
+/* RESV is the number of records to be reserved in the */
+/* binary DAF. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See arguments ASCII, BINARY. */
+
+/* $ Exceptions */
+
+/* None. */
+
+/* Errors are detected and signalled by routines called by this */
+/* routine. */
+
+/* $ Particulars */
+
+/* This routine has been made obsolete by the new DAF text to binary */
+/* conversion routine DAFTB. This routine remains available for */
+/* reasons of backward compatibility. We strongly recommend that the */
+/* conversion routine DAFTB be used for any new software development. */
+/* Please see the header of the routine DAFTB for details. */
+
+/* This routine is used for converting older DAF text files, which */
+/* use a decimal format for numbers, into their equivalent binary */
+/* formats. Note that the routine DAFTB makes use of a text file */
+/* format that is incompatible with the text file format expected by */
+/* the routines called by this routine. */
+
+/* Note that you must select the number of records to be reserved */
+/* in the binary DAF. The contents of reserved records are ignored */
+/* by the normal transfer process. */
+
+/* $ Examples */
+
+/* DAFB2A and DAFA2B are typically used to transfer files. */
+/* If file A.DAF is a binary DAF in environment 1, it */
+/* can be transferred to environment 2 in three steps. */
+
+/* 1) Convert it to ASCII, */
+
+/* CALL DAFB2A ( 'A.DAF', 'A.ASCII' ) */
+
+/* 2) Transfer the ASCII file, using FTP, Kermit, or some other */
+/* file transfer utility, */
+
+/* ftp> put a.ascii */
+
+/* 3) Convert it to binary on the new machine, */
+
+/* CALL DAFA2B ( 'A.ASCII', 'A.DAF', RESV ) */
+
+/* Note that DAFB2A and DAFA2B work in any standard Fortran-77 */
+/* environment. */
+
+/* $ Restrictions */
+
+/* DAFA2B cannot be executed while any other DAF is open */
+/* for writing. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 30-SEP-1993 (KRG) */
+
+/* This routine was completely rewritten to make use of the */
+/* routines DAFT2B and TXTOPR, for converting a text file to */
+/* binary and opening a text file. It now simply calls the */
+/* routine DAFT2B after opening the text file. */
+
+/* Added a statement to the $ Particulars section to the effect */
+/* that this routine has been made obsolete by the introduction of */
+/* the routine DAFTB, and that the use of the new routine is */
+/* strongly recommended for new software development. */
+
+/* Modified the $ Abstract section to reflect the fact that this */
+/* routine is obsolete. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* ascii daf to binary */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 30-SEP-1993 (KRG) */
+
+/* This routine was completely rewritten to make use of the */
+/* routines DAFT2B and TXTOPR, for converting a text file to */
+/* binary and opening a text file. It now simply calls the */
+/* routine DAFT2B after opening the text file. */
+
+/* Added a statement to the $ Particulars section to the effect */
+/* that this routine has been made obsolete by the introduction of */
+/* the routine DAFTB, and that the use of the new routine is */
+/* strongly recommended for new software development. */
+
+/* Modified the $ Abstract section to reflect the fact that this */
+/* routine is obsolete. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFA2B", (ftnlen)6);
+ }
+
+/* Open the ASCII file for reading. If an error occurs, then check */
+/* out and return. An appropriate error message will have already */
+/* been set. */
+
+ txtopr_(ascii, &unit, ascii_len);
+ if (failed_()) {
+ chkout_("DAFA2B", (ftnlen)6);
+ return 0;
+ }
+
+/* Call DAFT2B to perform the conversion. If it fails, then just */
+/* check out and return, as an appropriate error message should have */
+/* already been set. Also close the text file that we opened. */
+
+ daft2b_(&unit, binary, resv, binary_len);
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = unit;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DAFA2B", (ftnlen)6);
+ return 0;
+ }
+
+/* Close the file. */
+
+ cl__1.cerr = 0;
+ cl__1.cunit = unit;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DAFA2B", (ftnlen)6);
+ return 0;
+} /* dafa2b_ */
+
diff --git a/ext/spice/src/cspice/dafac.c b/ext/spice/src/cspice/dafac.c
new file mode 100644
index 0000000000..3bef869eb0
--- /dev/null
+++ b/ext/spice/src/cspice/dafac.c
@@ -0,0 +1,720 @@
+/* dafac.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static logical c_false = FALSE_;
+static integer c__1 = 1;
+
+/* $Procedure DAFAC ( DAF add comments ) */
+/* Subroutine */ int dafac_(integer *handle, integer *n, char *buffer, ftnlen
+ buffer_len)
+{
+ /* Initialized data */
+
+ static logical first = TRUE_;
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer s_rdue(cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_wdue(cilist *), e_wdue(void);
+
+ /* Local variables */
+ integer free;
+ extern integer cpos_(char *, char *, integer *, ftnlen, ftnlen);
+ extern /* Subroutine */ int zzddhhlu_(integer *, char *, logical *,
+ integer *, ftnlen);
+ integer i__, j, space;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc, bward, fward, recno;
+ logical found;
+ integer ncomr;
+ extern integer ncpos_(char *, char *, integer *, ftnlen, ftnlen);
+ logical empty;
+ integer nd;
+ extern logical failed_(void);
+ integer ni;
+ extern /* Subroutine */ int dafsih_(integer *, char *, ftnlen);
+ char ifname[60];
+ extern /* Subroutine */ int dafarr_(integer *, integer *);
+ char crecrd[1000];
+ extern /* Subroutine */ int dafrfr_(integer *, integer *, integer *, char
+ *, integer *, integer *, integer *, ftnlen);
+ integer daflun, nchars;
+ extern integer lastnb_(char *, ftnlen);
+ static char eocmrk[1];
+ integer length, newrec, eocpos;
+ static char eolmrk[1];
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen);
+ integer nelpos;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ integer rinuse, curpos, notusd;
+ extern logical return_(void);
+
+ /* Fortran I/O blocks */
+ static cilist io___21 = { 1, 0, 1, 0, 0 };
+ static cilist io___30 = { 1, 0, 0, 0, 0 };
+ static cilist io___31 = { 1, 0, 0, 0, 0 };
+ static cilist io___32 = { 1, 0, 0, 0, 0 };
+ static cilist io___33 = { 1, 0, 0, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Add comments from a buffer of character strings to the comment */
+/* area of a binary DAF file, appending them to any comments which */
+/* are already present in the file's comment area. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I handle of a DAF opened with write access. */
+/* N I Number of comments to put into the comment area. */
+/* BUFFER I Buffer of comments to put into the comment area. */
+
+/* $ Detailed_Input */
+
+/* HANDLE The file handle of a binary DAF which has been opened */
+/* with write access. */
+
+/* N The number of comments in BUFFER that are to be added to */
+/* the comment area of the binary DAF attached to HANDLE. */
+
+/* BUFFER A buffer containing comments which are to be added */
+/* to the comment area of the binary DAF attached to HANDLE. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the number of comments to be added is not positive, the */
+/* error SPICE(INVALIDARGUMENT) will be signalled. */
+
+/* 2) If a non printing ASCII character is encountered in the */
+/* comments, the error SPICE(ILLEGALCHARACTER) will be */
+/* signalled. */
+
+/* 3) If the binary DAF file attached to HANDLE is not open with */
+/* write access an error will be signalled by a routine called */
+/* by this routine. */
+
+/* 4) If the end of the comments cannot be found, i.e., the end of */
+/* comments marker is missing on the last comment record, the */
+/* error SPICE(BADCOMMENTAREA) will be signalled. */
+
+/* $ Files */
+
+/* See argument HANDLE in $ Detailed_Input. */
+
+/* $ Particulars */
+
+/* A binary DAF contains a data area which is reserved for storing */
+/* annotations or descriptive textual information about the data */
+/* contained in a file. This area is referred to as the ``comment */
+/* area'' of the file. The comment area of a DAF is a line oriented */
+/* medium for storing textual information. The comment area */
+/* preserves leading or embedded white space in the line(s) of text */
+/* which are stored so that the appearance of the information will */
+/* be unchanged when it is retrieved (extracted) at some other time. */
+/* Trailing blanks, however, are NOT preserved, due to the way that */
+/* character strings are represented in standard Fortran 77. */
+
+/* This routine will take a buffer of text lines and add (append) */
+/* them to the comment area of a binary DAF. If there are no */
+/* comments in the comment area of the file, then space will be */
+/* allocated and the text lines in BUFFER will be placed into the */
+/* comment area. The text lines may contain only printable ASCII */
+/* characters (decimal values 32 - 126). */
+
+/* There is NO maximum length imposed on the significant portion */
+/* of a text line that may be placed into the comment area of a */
+/* DAF. The maximum length of a line stored in the comment area */
+/* should be reasonable, however, so that they may be easily */
+/* extracted. A good maximum value for this would be 255 characters, */
+/* as this can easily accommodate ``screen width'' lines as well as */
+/* long lines which may contain some other form of information. */
+
+/* $ Examples */
+
+/* Let */
+
+/* HANDLE be the handle for a DAF which has been opened with */
+/* write access. */
+
+/* N be the number of lines of text to be added to the */
+/* comment area of the binary DAF attached to HANDLE. */
+
+/* BUFFER is a list of text lines to be added to the comment */
+/* area of the binary DAF attached to HANDLE. */
+
+/* The call */
+
+/* CALL DAFAC ( HANDLE, N, BUFFER ) */
+
+/* will append the first N line(s) in BUFFER to the comment area */
+/* of the binary DAF attached to HANDLE. */
+
+/* $ Restrictions */
+
+/* 1) This routine uses constants that are specific to the ASCII */
+/* character sequence. The results of using this routine with */
+/* a different character sequence are unpredictable. */
+
+/* 2) This routine is only used to extract records on environments */
+/* whose characters are a single byte in size. Updates to this */
+/* routine and routines in its call tree may be required to */
+/* properly handle other cases. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - Support Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* Updated this routine to utilize the new handle manager */
+/* interfaces. */
+
+/* - Beta Version 1.0.0, 26-JUL-1994 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* add comments to a binary daf file */
+/* append comments to a daf file comment area */
+
+/* -& */
+/* $ Revisions */
+
+/* - Support Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* The call to DAFHLU has been replaced with a call to ZZDDHHLU, */
+/* the handle manager interface for retrieving a logical unit. */
+/* DAFHLU is no longer used, since it locks the unit returned to */
+/* its HANDLE, tying up resources in the handle manager. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* Length of a DAF file internal filename. */
+
+
+/* Decimal value for the DAF comment area end-of-comment (EOC) */
+/* marker. */
+
+
+/* Decimal value for the DAF comment area end-of-line (EOL) marker. */
+
+
+/* Length of a DAF character record, in characters. */
+
+
+/* Maximum and minimum decimal values for the printable ASCII */
+/* characters. */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFAC", (ftnlen)5);
+ }
+
+/* The lines of text in BUFFER will be ``packed'' into DAF comment */
+/* records: the significant portion of each comment line from BUFFER */
+/* will be terminated using the special character EOLMRK to indicate */
+/* the end of the line. When a comment record is full or all of the */
+/* comments have been added, the comment record will be written to */
+/* the comment area of the binary DAF file. */
+
+/* If this is the first time that this routine has been called, */
+/* we need to initialize the character value for the end-of-line */
+/* marker and the character value for the end of comments marker. */
+
+ if (first) {
+ first = FALSE_;
+ *(unsigned char *)eocmrk = '\4';
+ *(unsigned char *)eolmrk = '\0';
+ }
+
+/* Verify that the DAF file attached to HANDLE is opened with write */
+/* access. */
+
+ dafsih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+ }
+
+/* Convert the DAF file handle to its corresponding Fortran logical */
+/* unit number for reading and writing comment records. */
+
+ zzddhhlu_(handle, "DAF", &c_false, &daflun, (ftnlen)3);
+ if (failed_()) {
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+ }
+
+/* Check for a nonpositive number of lines in the buffer. */
+
+ if (*n <= 0) {
+ setmsg_("The number of comment lines to be added to the binary DAF f"
+ "ile '#' was not positive: #.", (ftnlen)87);
+ errfnm_("#", &daflun, (ftnlen)1);
+ errint_("#", n, (ftnlen)1);
+ sigerr_("SPICE(INVALIDARGUMENT)", (ftnlen)22);
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+ }
+
+/* Count the number of characters in the buffer ignoring trailing */
+/* blanks on nonblank lines and blank lines. The count will be */
+/* modified to include the contribution of blank lines later. This */
+/* count is used to determine the number of character records to be */
+/* added to the binary DAF file attached to HANDLE. */
+
+ nchars = 0;
+ i__1 = *n;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+
+/* Get the length of the significant portion of a comment line. */
+
+ length = lastnb_(buffer + (i__ - 1) * buffer_len, buffer_len);
+
+/* Scan the comment line for non printing characters. */
+
+ i__2 = length;
+ for (j = 1; j <= i__2; ++j) {
+
+/* Check to see that the characters in the buffer are all */
+/* printing ASCII characters. The bounds for printing ASCII */
+/* characters are given by MINPCH and MAXPCH, which are */
+/* defined in the $ Local Parameters section of the header. */
+
+ if (*(unsigned char *)&buffer[(i__ - 1) * buffer_len + (j - 1)] >
+ 126 || *(unsigned char *)&buffer[(i__ - 1) * buffer_len +
+ (j - 1)] < 32) {
+ setmsg_("A nonprinting character was encountered in the comm"
+ "ent buffer. Value: #", (ftnlen)71);
+ i__3 = *(unsigned char *)&buffer[(i__ - 1) * buffer_len + (j
+ - 1)];
+ errint_("#", &i__3, (ftnlen)1);
+ sigerr_("SPICE(ILLEGALCHARACTER)", (ftnlen)23);
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Increment the number of characters by the length of the */
+/* significant portion of the current line in the buffer. */
+
+ nchars += length;
+ }
+
+/* We need to include the number of end of line markers in the */
+/* number of characters, so add the number of comment lines to */
+/* be added, N, to the number of characters, NCHARS. This is where */
+/* the contribution of any blank lines gets added to the character */
+/* count. We also need to have space for the end of comments marker. */
+
+ nchars = nchars + *n + 1;
+
+/* Get the current number of comment records and comment characters */
+/* from the DAF file attached to HANDLE. We will also get back some */
+/* extra stuff that we do not use. */
+
+ dafrfr_(handle, &nd, &ni, ifname, &fward, &bward, &free, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+ }
+
+/* Compute the number of comment records and the number of comment */
+/* characters. In order to perform these calculations, we assume */
+/* that we have a valid comment area in the DAF file attached to */
+/* HANDLE. */
+
+ ncomr = fward - 2;
+ if (ncomr > 0) {
+
+/* The starting record number is the number of comment records + 1 */
+/* where the 1 skips the file record. */
+
+ empty = TRUE_;
+ found = FALSE_;
+ notusd = 0;
+ while(ncomr > 0 && ! found && empty) {
+ recno = ncomr + 1;
+ io___21.ciunit = daflun;
+ io___21.cirec = recno;
+ iostat = s_rdue(&io___21);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, crecrd, (ftnlen)1000);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rdue();
+L100001:
+ if (iostat != 0) {
+ setmsg_("Error reading comment area of binary file named '#'"
+ ". IOSTAT = #.", (ftnlen)65);
+ errfnm_("#", &daflun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+ }
+
+/* Scan the comment record looking for the end of comments */
+/* marker. */
+
+ eocpos = cpos_(crecrd, eocmrk, &c__1, (ftnlen)1000, (ftnlen)1);
+ if (eocpos > 0) {
+ found = TRUE_;
+ } else {
+ nelpos = ncpos_(crecrd, eolmrk, &c__1, (ftnlen)1000, (ftnlen)
+ 1);
+ if (nelpos != 0) {
+ empty = FALSE_;
+ } else {
+ --ncomr;
+ ++notusd;
+ }
+ }
+ }
+
+/* If we do not find the end of comments marker and the comment */
+/* area is not empty, then it is an error. */
+
+ if (! found && ! empty) {
+ setmsg_("The comment area in the DAF file '#' may be damaged. Th"
+ "e end of the comments could not be found.", (ftnlen)96);
+ errfnm_("#", &daflun, (ftnlen)1);
+ sigerr_("SPICE(BADCOMMENTAREA)", (ftnlen)21);
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+ } else if (found) {
+ ncomc = (ncomr - 1) * 1000 + eocpos - 1;
+ } else if (empty) {
+ ncomc = 0;
+ }
+ } else {
+ ncomc = 0;
+ notusd = 0;
+ }
+
+/* Determine the amount of free space in the comment area. If */
+/* there are some comment records allocated, the space available */
+/* is the number of comment records allocated times the length of */
+/* a comment record, minus the number of comment characters already */
+/* used. Otherwise, the space available is zero. */
+
+ if (ncomr + notusd > 0) {
+ space = notusd * 1000 + ncomr * 1000 - ncomc;
+ } else {
+ space = 0;
+ }
+
+/* Determine the number of new comment records which are necessary */
+/* to store all of the comments from the buffer. */
+
+ if (nchars > space) {
+
+/* If there are more characters to store than available space */
+/* we need at least one new record. */
+
+ newrec = (nchars - space - 1) / 1000 + 1;
+ } else {
+
+/* Otherwise, we do not need any new records. */
+
+ newrec = 0;
+ }
+
+/* Now add the necessary number of comment records to the file, */
+/* if we need to add any. */
+
+ if (newrec > 0) {
+ dafarr_(handle, &newrec);
+ if (failed_()) {
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* At this point, we know that we have enough space to write all of */
+/* the comments in BUFFER to the comment area. Either there was */
+/* enough space already there, or we calculated how many new comment */
+/* records were needed, and we added them to the file. So, now we */
+/* begin ``packing'' the comments into DAF comment records and */
+/* writing them to the file. */
+
+/* We begin initializing the appropriate variables. */
+
+ if (ncomc == 0) {
+
+/* If there are no comments in the comment area, then we need */
+/* to skip the file record. The first available comment record */
+/* is therecord immediately after the file record, so we set */
+/* RECNO accordingly. We also initialize the current position in */
+/* the comment record, and the comment record itself. */
+
+ recno = 2;
+ curpos = 1;
+ s_copy(crecrd, " ", (ftnlen)1000, (ftnlen)1);
+ } else {
+
+/* If there are comments in the comment area, then we need to */
+/* skip the file record and any comment records which have been */
+/* filled. The first comment record with space available is the */
+/* record immediately following the last completely filled */
+/* comment record. So calculate the number of comment records */
+/* in use, and set RECNO appropriately. Finally calculate the */
+/* initial position. */
+
+ rinuse = ncomc / 1000 + 1;
+ recno = rinuse + 1;
+ curpos = ncomc - (rinuse - 1) * 1000 + 1;
+ }
+
+/* Begin ``packing'' the comments from the input buffer into the */
+/* comment records, writing the comment records to the file as they */
+/* become filled. */
+
+ i__1 = *n;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+
+/* Get the length of the significant portion of comment line I. */
+
+ length = lastnb_(buffer + (i__ - 1) * buffer_len, buffer_len);
+
+/* Process the comment line. */
+
+ i__2 = length;
+ for (j = 1; j <= i__2; ++j) {
+
+/* If we have filled the comment record while processing */
+/* comment line BUFFER(I), write out the comment record, */
+/* increment the record number, RECNO, and reset the values */
+/* of the current position and the comment record. */
+
+ if (curpos > 1000) {
+ io___30.ciunit = daflun;
+ io___30.cirec = recno;
+ iostat = s_wdue(&io___30);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, crecrd, (ftnlen)1000);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_wdue();
+L100002:
+ if (iostat != 0) {
+ setmsg_("Error writing to record # of the binary file na"
+ "med '#'. IOSTAT = #.", (ftnlen)67);
+ errint_("#", &recno, (ftnlen)1);
+ errfnm_("#", &daflun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+ }
+ ++recno;
+ curpos = 1;
+ s_copy(crecrd, " ", (ftnlen)1000, (ftnlen)1);
+ }
+ *(unsigned char *)&crecrd[curpos - 1] = *(unsigned char *)&buffer[
+ (i__ - 1) * buffer_len + (j - 1)];
+ ++curpos;
+ }
+
+/* Check to see if we happened to exactly fill the comment record */
+/* when we finished processing comment line BUFFER(I). If we */
+/* did, CURPOS will be 1 greater than MXCREC, and we will need */
+/* to write the comment record to the file, increment the record */
+/* number, RECNO, and reset the values of the current position */
+/* and the comment record. */
+
+ if (curpos > 1000) {
+ io___31.ciunit = daflun;
+ io___31.cirec = recno;
+ iostat = s_wdue(&io___31);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_uio(&c__1, crecrd, (ftnlen)1000);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = e_wdue();
+L100003:
+ if (iostat != 0) {
+ setmsg_("Error writing to record # of the binary file named "
+ "'#'. IOSTAT = #.", (ftnlen)67);
+ errint_("#", &recno, (ftnlen)1);
+ errfnm_("#", &daflun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+ }
+ ++recno;
+ curpos = 1;
+ s_copy(crecrd, " ", (ftnlen)1000, (ftnlen)1);
+ }
+
+/* Append the end-of-line marker to the comment line that we just */
+/* placed into the comment record. */
+
+ *(unsigned char *)&crecrd[curpos - 1] = *(unsigned char *)eolmrk;
+ ++curpos;
+ }
+
+/* We have now finished processing all of the comment lines in */
+/* BUFFER, so we need write the current record to the file. This */
+/* record will always contain something, so we always need to write */
+/* it. */
+
+ if (curpos > 1000) {
+
+/* If we have completely filled the comment record, the last */
+/* character of the last line n the buffer coincides with the */
+/* last character in the comment record, then we need to write */
+/* the record and get set up to add the end of comments mark on */
+/* the next record. */
+
+ io___32.ciunit = daflun;
+ io___32.cirec = recno;
+ iostat = s_wdue(&io___32);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_uio(&c__1, crecrd, (ftnlen)1000);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = e_wdue();
+L100004:
+ if (iostat != 0) {
+ setmsg_("Error writing to record # of the binary file named '#'."
+ " IOSTAT = #.", (ftnlen)67);
+ errint_("#", &recno, (ftnlen)1);
+ errfnm_("#", &daflun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+ }
+ ++recno;
+ curpos = 1;
+ s_copy(crecrd, " ", (ftnlen)1000, (ftnlen)1);
+ }
+
+/* Add the end of comments mark to the final comment record and */
+/* write it to the file. */
+
+ *(unsigned char *)&crecrd[curpos - 1] = *(unsigned char *)eocmrk;
+ io___33.ciunit = daflun;
+ io___33.cirec = recno;
+ iostat = s_wdue(&io___33);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_uio(&c__1, crecrd, (ftnlen)1000);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = e_wdue();
+L100005:
+ if (iostat != 0) {
+ setmsg_("Error writing to record # of the binary file named '#'. IOS"
+ "TAT = #.", (ftnlen)67);
+ errint_("#", &recno, (ftnlen)1);
+ errfnm_("#", &daflun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+ }
+
+/* Check out and leave DAFAC. */
+
+ chkout_("DAFAC", (ftnlen)5);
+ return 0;
+} /* dafac_ */
+
diff --git a/ext/spice/src/cspice/dafac_c.c b/ext/spice/src/cspice/dafac_c.c
new file mode 100644
index 0000000000..befadaff63
--- /dev/null
+++ b/ext/spice/src/cspice/dafac_c.c
@@ -0,0 +1,258 @@
+/*
+
+-Procedure dafac_c ( DAF add comments )
+
+-Abstract
+
+ Add comments from a buffer of character strings to the comment
+ area of a binary DAF file, appending them to any comments which
+ are already present in the file's comment area.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+ UTILITY
+
+*/
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+ #include "SpiceZst.h"
+ #undef dafac_c
+
+ void dafac_c ( SpiceInt handle,
+ SpiceInt n,
+ SpiceInt lenvals,
+ const void * buffer )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I handle of a DAF opened with write access.
+ n I Number of comments to put into the comment area.
+ lenvals I Length of elements
+ buffer I Buffer of comments to put into the comment area.
+
+-Detailed_Input
+
+ handle is the file handle of a binary DAF which has been opened
+ with write access.
+
+ n is the number of rows in the array `buffer'. This is
+ also the number of comment lines in `buffer' that are to be
+ added to the comment area of the binary DAF attached to
+ `handle'.
+
+ buffer A string buffer containing comments which are to be added
+ to the comment area of the binary DAF attached to `handle'.
+ buffer should be declared by the caller has follows:
+
+ SpiceChar buffer[n][lenvals];
+
+ Each row of the buffer should contain one comment line.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the number of comments to be added is not positive, the
+ error SPICE(INVALIDARGUMENT) will be signaled.
+
+ 2) If a non printing ASCII character is encountered in the
+ comments, the error SPICE(ILLEGALCHARACTER) will be signaled.
+
+ 3) If the binary DAF file attached to HANDLE is not open with
+ write access an error will be signalled by a routine called by
+ this routine.
+
+ 4) If the end of the comments cannot be found, i.e., the end of
+ comments marker is missing on the last comment record, the error
+ SPICE(BADCOMMENTAREA) will be signaled.
+
+ 5) If the input pointer `buffer' is null, the error
+ SPICE(NULLPOINTER) will be signaled.
+
+ 6) If the input buffer string length indicated by `lenvals'
+ is less than 2, the error SPICE(STRINGTOOSHORT) will be signaled.
+
+-Files
+
+ See argument `handle' in $ Detailed_Input.
+
+-Particulars
+
+ A binary DAF contains a data area which is reserved for storing
+ annotations or descriptive textual information about the data
+ contained in a file. This area is referred to as the ``comment
+ area'' of the file. The comment area of a DAF is a line oriented
+ medium for storing textual information. The comment area preserves
+ leading or embedded white space in the line(s) of text which are
+ stored so that the appearance of the information will be unchanged
+ when it is retrieved (extracted) at some other time. Trailing
+ blanks, however, are NOT preserved, due to the way that character
+ strings are represented in standard Fortran 77.
+
+ This routine will take a buffer of text lines and add (append) them
+ to the comment area of a binary DAF. If there are no comments in the
+ comment area of the file, then space will be allocated and the text
+ lines in `buffer' will be placed into the comment area. The text lines
+ may contain only printable ASCII characters (decimal values 32 -
+ 126).
+
+ There is NO maximum length imposed on the significant portion of a
+ text line that may be placed into the comment area of a DAF. The
+ maximum length of a line stored in the comment area should be
+ reasonable, however, so that they may be easily extracted. A good
+ maximum value for this would be 255 characters, as this can easily
+ accommodate ``screen width'' lines as well as long lines which may
+ contain some other form of information.
+
+-Examples
+
+ 1) Let
+
+ handle be the handle for a DAF which has been opened with
+ write access.
+
+ n be the number of lines of text to be added to the
+ comment area of the binary DAF attached to handle.
+
+ lenvals be the length of the rows of a string buffer.
+
+ buffer is an array of text lines to be added to the comment
+ area of the binary DAF attached to handle. `buffer'
+ normally is declared
+
+ SpiceChar buffer [n][lenvals];
+
+ The call
+
+ dafac_c ( handle, n, lenvals, buffer );
+
+ will append the first n line(s) in `buffer' to the comment area
+ of the binary DAF attached to `handle'.
+
+-Restrictions
+
+ 1) This routine uses constants that are specific to the ASCII
+ character sequence. The results of using this routine with
+ a different character sequence are unpredictable.
+
+ 2) This routine is only used to extract records on environments
+ whose characters are a single byte in size. Updates to this
+ routine and routines in its call tree may be required to
+ properly handle other cases.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 16-NOV-2006 (NJB) (KRG)
+
+-Index_Entries
+
+ add comments to a binary daf file
+ append comments to a daf file comment area
+
+-&
+*/
+
+{ /* Begin dafac_c */
+
+
+ /*
+ Local variables
+ */
+ SpiceChar * fCvalsArr;
+
+ SpiceInt fCvalsLen;
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafac_c" );
+
+
+ /*
+ Make sure the input string pointer for the `buffer' array is non-null
+ and that the length lenvals is sufficient.
+ */
+ CHKOSTR ( CHK_STANDARD, "dafac_c", buffer, lenvals );
+
+ /*
+ The input buffer contains C-style strings; we must pass a
+ Fortran-style buffer to dafac_.
+ */
+ C2F_MapStrArr ( "dafac_c",
+ n, lenvals, buffer, &fCvalsLen, &fCvalsArr );
+
+ if ( failed_c() )
+ {
+ chkout_c ( "dafac_c" );
+ return;
+ }
+
+
+ /*
+ Call the f2c'd routine.
+ */
+ dafac_ ( ( integer * ) &handle,
+ ( integer * ) &n,
+ ( char * ) fCvalsArr,
+ ( ftnlen ) fCvalsLen );
+
+ /*
+ Free the dynamically allocated array.
+ */
+ free ( fCvalsArr );
+
+
+ chkout_c ( "dafac_c" );
+
+} /* End dafac_c */
diff --git a/ext/spice/src/cspice/dafah.c b/ext/spice/src/cspice/dafah.c
new file mode 100644
index 0000000000..96ca0a9c60
--- /dev/null
+++ b/ext/spice/src/cspice/dafah.c
@@ -0,0 +1,4965 @@
+/* dafah.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1000 = 1000;
+static logical c_false = FALSE_;
+static integer c__2 = 2;
+static integer c__124 = 124;
+static integer c__250 = 250;
+static integer c__125 = 125;
+static integer c__128 = 128;
+static integer c__1 = 1;
+static logical c_true = TRUE_;
+
+/* $Procedure DAFAH ( DAF, assign handles ) */
+/* Subroutine */ int dafah_0_(int n__, char *fname, char *ftype, integer *nd,
+ integer *ni, char *ifname, integer *resv, integer *handle, integer *
+ unit, integer *fhset, char *access, ftnlen fname_len, ftnlen
+ ftype_len, ftnlen ifname_len, ftnlen access_len)
+{
+ /* Initialized data */
+
+ static logical first = TRUE_;
+ static integer nft = 0;
+
+ /* System generated locals */
+ address a__1[2];
+ integer i__1, i__2, i__3[2], i__4;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer), s_cmp(char *, char *,
+ ftnlen, ftnlen);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen), s_cat(char *,
+ char **, integer *, integer *, ftnlen);
+ integer s_wdue(cilist *), do_uio(integer *, char *, ftnlen), e_wdue(void);
+
+ /* Local variables */
+ static integer ibff;
+ static char crec[1000];
+ static doublereal drec[128];
+ static integer iarc, iamh, free, ftnd[1000], ftni[1000];
+ extern /* Subroutine */ int zzdafgfr_(integer *, char *, integer *,
+ integer *, char *, integer *, integer *, integer *, logical *,
+ ftnlen, ftnlen), zzddhfnh_(char *, integer *, logical *, ftnlen),
+ zzdafnfr_(integer *, char *, integer *, integer *, char *,
+ integer *, integer *, integer *, char *, ftnlen, ftnlen, ftnlen),
+ zzddhcls_(integer *, char *, logical *, ftnlen), zzddhnfo_(
+ integer *, char *, integer *, integer *, integer *, logical *,
+ ftnlen), zzddhhlu_(integer *, char *, logical *, integer *,
+ ftnlen), zzddhluh_(integer *, integer *, logical *), zzddhopn_(
+ char *, char *, char *, integer *, ftnlen, ftnlen, ftnlen),
+ zzplatfm_(char *, char *, ftnlen, ftnlen);
+ static integer i__;
+ extern logical elemi_(integer *, integer *);
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ static integer bward, fthan[1000];
+ extern /* Subroutine */ int ucase_(char *, char *, ftnlen, ftnlen);
+ static integer fward;
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
+ static logical found;
+ static integer ftlnk[1000];
+ extern /* Subroutine */ int copyi_(integer *, integer *);
+ extern integer ltrim_(char *, ftnlen), rtrim_(char *, ftnlen);
+ extern /* Subroutine */ int ljust_(char *, char *, ftnlen, ftnlen);
+ static char ttype[4];
+ extern logical failed_(void);
+ static char dafnam[255];
+ extern /* Subroutine */ int cleard_(integer *, doublereal *), dafrwa_(
+ integer *, integer *, integer *);
+ static integer findex;
+ extern integer isrchi_(integer *, integer *, integer *);
+ static char format[8], idword[8];
+ static integer fhlist[1006];
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), errfnm_(char *, integer *, ftnlen), removi_(integer *,
+ integer *), setmsg_(char *, ftnlen);
+ static integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen), ssizei_(
+ integer *, integer *), insrti_(integer *, integer *);
+ extern logical return_(void);
+ static char acc[10];
+ static integer fnb, fnd;
+ static char ifn[60];
+ static integer fni, lun;
+
+ /* Fortran I/O blocks */
+ static cilist io___25 = { 1, 0, 0, 0, 0 };
+ static cilist io___26 = { 1, 0, 0, 0, 0 };
+ static cilist io___27 = { 1, 0, 0, 0, 0 };
+ static cilist io___28 = { 1, 0, 0, 0, 0 };
+ static cilist io___29 = { 1, 0, 0, 0, 0 };
+ static cilist io___30 = { 1, 0, 0, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Assign handles to DAFs as they are opened. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* $ Abstract */
+
+/* Parameter declarations for the DAF/DAS handle manager. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF, DAS */
+
+/* $ Keywords */
+
+/* PRIVATE */
+
+/* $ Particulars */
+
+/* This include file contains parameters defining limits and */
+/* integer codes that are utilized in the DAF/DAS handle manager */
+/* routines. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* F.S. Turner (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.20.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL. */
+
+/* - SPICELIB Version 1.19.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL-CC_C. */
+
+/* - SPICELIB Version 1.18.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL-64BIT-CC_C. */
+
+/* - SPICELIB Version 1.17.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-64BIT-NATIVE_C. */
+
+/* - SPICELIB Version 1.16.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-WINDOWS-64BIT-IFORT. */
+
+/* - SPICELIB Version 1.15.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-LINUX-64BIT-GFORTRAN. */
+
+/* - SPICELIB Version 1.14.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-64BIT-MS_C. */
+
+/* - SPICELIB Version 1.13.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-INTEL_C. */
+
+/* - SPICELIB Version 1.12.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-IFORT. */
+
+/* - SPICELIB Version 1.11.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-GFORTRAN. */
+
+/* - SPICELIB Version 1.10.0, 18-MAR-2009 (BVS) */
+
+/* Updated for PC-LINUX-GFORTRAN. */
+
+/* - SPICELIB Version 1.9.0, 18-MAR-2009 (BVS) */
+
+/* Updated for MAC-OSX-GFORTRAN. */
+
+/* - SPICELIB Version 1.8.0, 19-FEB-2008 (BVS) */
+
+/* Updated for PC-LINUX-IFORT. */
+
+/* - SPICELIB Version 1.7.0, 14-NOV-2006 (BVS) */
+
+/* Updated for PC-LINUX-64BIT-GCC_C. */
+
+/* - SPICELIB Version 1.6.0, 14-NOV-2006 (BVS) */
+
+/* Updated for MAC-OSX-INTEL_C. */
+
+/* - SPICELIB Version 1.5.0, 14-NOV-2006 (BVS) */
+
+/* Updated for MAC-OSX-IFORT. */
+
+/* - SPICELIB Version 1.4.0, 14-NOV-2006 (BVS) */
+
+/* Updated for PC-WINDOWS-IFORT. */
+
+/* - SPICELIB Version 1.3.0, 26-OCT-2005 (BVS) */
+
+/* Updated for SUN-SOLARIS-64BIT-GCC_C. */
+
+/* - SPICELIB Version 1.2.0, 03-JAN-2005 (BVS) */
+
+/* Updated for PC-CYGWIN_C. */
+
+/* - SPICELIB Version 1.1.0, 03-JAN-2005 (BVS) */
+
+/* Updated for PC-CYGWIN. */
+
+/* - SPICELIB Version 1.0.1, 17-JUL-2002 */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 1.0.0, 07-NOV-2001 */
+
+/* -& */
+
+/* Unit and file table size parameters. */
+
+/* FTSIZE is the maximum number of files (DAS and DAF) that a */
+/* user may have open simultaneously. */
+
+
+/* RSVUNT is the number of units protected from being locked */
+/* to a particular handle by ZZDDHHLU. */
+
+
+/* SCRUNT is the number of units protected for use by scratch */
+/* files. */
+
+
+/* UTSIZE is the maximum number of logical units this manager */
+/* will utilize at one time. */
+
+
+/* Access method enumeration. These parameters are used to */
+/* identify which access method is associated with a particular */
+/* handle. They need to be synchronized with the STRAMH array */
+/* defined in ZZDDHGSD in the following fashion: */
+
+/* STRAMH ( READ ) = 'READ' */
+/* STRAMH ( WRITE ) = 'WRITE' */
+/* STRAMH ( SCRTCH ) = 'SCRATCH' */
+/* STRAMH ( NEW ) = 'NEW' */
+
+/* These values are used in the file table variable FTAMH. */
+
+
+/* Binary file format enumeration. These parameters are used to */
+/* identify which binary file format is associated with a */
+/* particular handle. They need to be synchronized with the STRBFF */
+/* array defined in ZZDDHGSD in the following fashion: */
+
+/* STRBFF ( BIGI3E ) = 'BIG-IEEE' */
+/* STRBFF ( LTLI3E ) = 'LTL-IEEE' */
+/* STRBFF ( VAXGFL ) = 'VAX-GFLT' */
+/* STRBFF ( VAXDFL ) = 'VAX-DFLT' */
+
+/* These values are used in the file table variable FTBFF. */
+
+
+/* Some random string lengths... more documentation required. */
+/* For now this will have to suffice. */
+
+
+/* Architecture enumeration. These parameters are used to identify */
+/* which file architecture is associated with a particular handle. */
+/* They need to be synchronized with the STRARC array defined in */
+/* ZZDDHGSD in the following fashion: */
+
+/* STRARC ( DAF ) = 'DAF' */
+/* STRARC ( DAS ) = 'DAS' */
+
+/* These values will be used in the file table variable FTARC. */
+
+
+/* For the following environments, record length is measured in */
+/* characters (bytes) with eight characters per double precision */
+/* number. */
+
+/* Environment: Sun, Sun FORTRAN */
+/* Source: Sun Fortran Programmer's Guide */
+
+/* Environment: PC, MS FORTRAN */
+/* Source: Microsoft Fortran Optimizing Compiler User's Guide */
+
+/* Environment: Macintosh, Language Systems FORTRAN */
+/* Source: Language Systems FORTRAN Reference Manual, */
+/* Version 1.2, page 12-7 */
+
+/* Environment: PC/Linux, g77 */
+/* Source: Determined by experiment. */
+
+/* Environment: PC, Lahey F77 EM/32 Version 4.0 */
+/* Source: Lahey F77 EM/32 Language Reference Manual, */
+/* page 144 */
+
+/* Environment: HP-UX 9000/750, FORTRAN/9000 Series 700 computers */
+/* Source: FORTRAN/9000 Reference-Series 700 Computers, */
+/* page 5-110 */
+
+/* Environment: NeXT Mach OS (Black Hardware), */
+/* Absoft Fortran Version 3.2 */
+/* Source: NAIF Program */
+
+
+/* The following parameter defines the size of a string used */
+/* to store a filenames on this target platform. */
+
+
+/* The following parameter controls the size of the character record */
+/* buffer used to read data from non-native files. */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Entry points */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I,O OPR, OPW, ONW, OPN (Obsolete), HFN, FNH */
+/* FTYPE I ONW */
+/* ND I,O ONW, OPN (Obsolete), HSF */
+/* NI I,O ONW, OPN (Obsolete), HSF */
+/* IFNAME I ONW, OPN (Obsolete) */
+/* RESV I ONW, OPN (Obsolete) */
+/* HANDLE I,O OPR, OPW, ONW, OPN (Obsolete), CLS, HLU, LUH, HFN, */
+/* FNH, SIH */
+/* UNIT I,O HLU, LUH */
+/* FHSET O HOF */
+/* ACCESS I SIH */
+/* RECL P OPR, OPW, ONW, OPN (Obsolete) */
+/* FTSIZE P OPR, OPW, ONW, OPN (Obsolete), CLS, HLU, LUH, HFN, */
+/* FNH */
+/* FILEN P SIH */
+
+/* $ Detailed_Input */
+
+/* FNAME on input is the name of a DAF to be opened, or */
+/* the name of a DAF about which some information */
+/* (handle, logical unit) is requested. */
+
+/* FTYPE on input is a code for the type of data that is */
+/* contained in the DAF file. This code has no meaning or */
+/* interpretation at the level of the DAF file */
+/* architecture, but is provided as a convenience for */
+/* higher level software. The maximum length for the file */
+/* type is four (4) characters. If the input string is */
+/* longer than four characters, the first nonblank */
+/* character and its three, or fewer, immediate nonblank */
+/* successors will be used as the file type. The file */
+/* type may not contain nonprinting characters, and it IS */
+/* case sensitive. */
+
+/* NAIF has reserved for its own use file types */
+/* consisting of the upper case letters (A-Z) and the */
+/* digits 0-9. NAIF recommends lower case or mixed case */
+/* file types be used by all others in order to avoid */
+/* any conflicts with NAIF file types. */
+
+/* ND on input is the number of double precision components */
+/* in each array summary of a new file. */
+
+/* NI on input is the number of integer components in each */
+/* array summary in a new file. */
+
+/* IFNAME is the internal file name for a DAF to be created. */
+
+/* RESV is the number of records to be reserved in a DAF */
+/* to be created. */
+
+/* HANDLE on input is the handle of a DAF about which some */
+/* information (file name, logical unit) is requested, */
+/* or the handle of a DAF to be closed. */
+
+/* UNIT on input is the logical unit connected to a DAF */
+/* about which some information (file name, handle) is */
+/* requested. */
+
+/* ACCESS is the type of access a DAF is open for, that is, */
+/* either reading or writing. The values of ACCESS */
+/* may be */
+
+/* 'READ' */
+/* 'WRITE' */
+
+/* Leading and trailing blanks are ignored, and case */
+/* is not significant. */
+
+/* $ Detailed_Output */
+
+/* FNAME on output is the name of a DAF for which */
+/* the corresponding handle or logical unit has been */
+/* supplied. */
+
+/* ND on output is the number of double precision */
+/* components in each array summary of an existing file. */
+
+/* NI on output is the number of integer components in */
+/* each array summary in an existing file. */
+
+/* HANDLE on output is the handle of a DAF for which */
+/* the corresponding file name or logical unit has been */
+/* supplied. */
+
+/* UNIT on output is the logical unit connected to a DAF */
+/* for which the corresponding file name or handle has */
+/* been supplied. */
+
+/* FHSET is a SPICELIB set containing the handles of the */
+/* currently open DAFs. */
+
+/* $ Parameters */
+
+/* RECL is the record length of a DAF. Each record */
+/* must be large enough to hold 128 double */
+/* precision numbers or 1000 characters, whichever */
+/* is greater. The units in which the record length */
+/* must be specified vary from environment to */
+/* environment. For example, VAX Fortran requires */
+/* record lengths to be specified in longwords, */
+/* where two longwords equal one double precision */
+/* number. See the include file 'zzddhman.inc' for */
+/* details. */
+
+/* FTSIZE is the size of the file table maintained internally */
+/* by DAFAH. In effect, FTSIZE is the maximum number */
+/* of DAFs that the DAF routines allow to be open */
+/* simultaneously. See the include file 'zzddhman.inc' */
+/* for details. */
+
+/* FILEN is the maximum filename length. See the include file */
+/* 'zzddhman.inc' for details. */
+
+
+/* INTEOC is the ASCII decimal integer code of the character */
+/* recognized by SPICE as representing the end of the */
+/* comment data in the reserved record area. */
+
+
+/* $ Files */
+
+/* All DAFs opened by this routine are specified by name. */
+
+/* $ Exceptions */
+
+/* 1) If DAFAH is called directly, the error SPICE(BOGUSENTRY) */
+/* is signalled. */
+
+/* 2) See entry points DAFOPR, DAFOPW, DAFONW, DAFOPN, DAFCLS, */
+/* DAFHSF, DAFHLU, DAFLUH, DAFHFN, DAFNFH, DAFHOF, and DAFSIH for */
+/* exceptions specific to those entry points. */
+
+/* $ Particulars */
+
+/* DAFAH serves as an umbrella, allowing data to be shared by its */
+/* entry points: */
+
+/* DAFOPR Open for read. */
+/* DAFOPW Open for write. */
+/* DAFONW Open new. */
+/* DAFOPN Open new. (Obsolete, use DAFONW ) */
+
+/* DAFCLS Close. */
+
+/* DAFHSF Handle to summary format. */
+
+/* DAFHLU Handle to logical unit. */
+/* DAFLUH Logical to handle. */
+
+/* DAFHFN Handle to name. */
+/* DAFFNH File name to handle. */
+
+/* DAFHOF Handles of open files. */
+/* DAFSIH Signal invalid handles. */
+
+/* Before a DAF can be used, it must be opened. Entry points */
+/* DAFOPR and DAFOPW provide the only means for opening an */
+/* existing DAF. */
+
+/* Several files may be opened for use simultaneously. (This makes */
+/* it convenient to combine data from several files to produce a */
+/* single result.) As each DAF is opened, it is assigned a file */
+/* handle, which is used to keep track of the file internally, and */
+/* which is used by the calling program to refer to the file in all */
+/* subsequent calls to DAF routines. */
+
+/* DAFs may be opened for two kinds of access: read, and write. */
+/* Files opened for read access may not be changed in any way. Files */
+/* opened for write access may be both read and written. */
+
+/* DAFONW is used to open a new DAF file. This routine extends the */
+/* functionality of DAFOPN by providing a mechanism for associating a */
+/* type with the data in the DAF file. The use of this entry over */
+/* DAFOPN is highly recommended. */
+
+/* Since the only reason for creating a new file is to write */
+/* something in it, all new files are opened for write access. */
+
+/* Entry point DAFOPN, for opening a new DAF file, has been rendered */
+/* obsolete by the new entry point DAFONW. The entry point DAFOPN */
+/* will continue to be supported for purposes of backward */
+/* compatibility, but its use in new software development is */
+/* discouraged. */
+
+/* Entry point DAFCLS provides the only official means of closing */
+/* a DAF that is currently open. Closing a DAF any other way (for */
+/* example, by determining its logical unit and using the Fortran */
+/* CLOSE statement directly) may affect your calling program in */
+/* mysterious ways. */
+
+/* Entry point DAFHSF allows you to determine the summary format */
+/* of any DAF that is currently open, without calling DAFRFR to */
+/* re-read the file record. */
+
+/* Entry point DAFHOF allows you to determine which DAFs are open */
+/* at any time. In particular, you can use DAFHOF to determine */
+/* whether any file handle points to an open DAF. */
+
+/* Entry point DAFSIH signals errors when it is supplied with invalid */
+/* handles, so it serves to centralize error handling associated */
+/* with invalid handles. */
+
+/* The remaining entry points exist mainly to translate between */
+/* alternative representations of DAFs. There are three ways to */
+/* identify any open DAF: by name, by handle, and by logical */
+/* unit. Given any one of these, you may use these entry points to */
+/* find the other two. */
+
+/* $ Examples */
+
+/* See entry points DAFOPR, DAFOPW, DAFONW, DAFOPN, DAFCLS, DAFHSF, */
+/* DAFHLU, DAFLUH, DAFHFN, DAFNFH, DAFHOF, and DAFSIH for examples */
+/* specific to those entry points. */
+
+/* $ Restrictions */
+
+/* 1) The value of parameter RECL may need to be changed when DAFAH */
+/* and its entry points are ported to a new environment (CPU and */
+/* compiler). */
+
+/* 2) An integer overflow may occur if the number of files opened */
+/* by a single program exceeds the maximum number that can be */
+/* stored in an integer variable. */
+
+/* $ Literature_References */
+
+/* 1) NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* 2) Sun Fortran Programmer's Guide */
+
+/* 3) Microsoft Fortran Optimizing Compiler User's Guide */
+
+/* 4) Lahey F77 EM/32 Language Reference Manual, page 144 */
+
+/* 5) Language Systems FORTRAN Reference Manual, Version 1.2, */
+/* page 12-7 */
+
+/* 6) "FORTRAN/9000 Reference HP 9000 Series 700 Computers", */
+/* First Edition, June 1991, Hewlett Packard Company, page 5-110. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* J.M. Lynch (JPL) */
+/* J.E. McLean (JPL) */
+/* H.A. Neilan (JPL) */
+/* M.J. Spencer (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 9.0.0, 09-NOV-2006 (NJB) */
+
+/* Updated the entry point DAFONW so that a non-empty reserved */
+/* record area will also be a valid empty comment area. DAFONW */
+/* now writes a EOC character to the first byte of the second */
+/* record when the input number of reserved records NRESV is */
+/* greater than zero. */
+
+/* - SPICELIB Version 8.1.0, 02-APR-2002 (FST) */
+
+/* Updated the following entry points in response to changes */
+/* to the handle manager interfaces: */
+
+/* DAFCLS */
+/* DAFOPR */
+/* DAFOPW */
+/* DAFONW */
+/* DAFOPN */
+
+/* See the Revisions section for details. */
+
+/* Minor bug fix to DAFFNH. An error was signaled but the */
+/* intended call to CHKOUT and RETURN statement were omitted. */
+
+/* - SPICELIB Version 8.0.0, 14-NOV-2000 (FST) */
+
+/* Cleaned up entry point headers by removing duplicate */
+/* entries from the Revisions section where appropriate. */
+
+/* Integrated the new handle manager code into this module. */
+/* The number of DAFs the system can load is now 1000, */
+/* and some supported environments can read non-native */
+/* binary DAFs. See the Convert User's Guide for details. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 22-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 7.0.0, 22-MAR-1999 (FST) */
+
+/* To accommodate the DAF FTP validation check, the following */
+/* entry points were modified: */
+
+/* DAFOPR, DAFOPW, DAFONW, DAFOPN. */
+
+/* See their headers and code for the details of the changes. */
+
+/* - SPICELIB Version 6.0.0, 05-APR-1998 (NJB) */
+
+/* Added references to the PC-LINUX environment. */
+
+/* - SPICELIB Version 5.1.0, 08-MAR-1996 (KRG) */
+
+/* The Following entry points have been modified: DAFONW and */
+/* DAFOPN. */
+
+/* The modifications support the notion of a DAF comment area, */
+/* and involve writing NULL filled reserved records when the */
+/* number of reserved records is greater than zero (0). */
+
+/* Some nested IF...THEN...ELSE IF...THEN...END IF constructs */
+/* were expanded to be independent IF...THEN...END IF tests. */
+/* The tests were for IOSTAT errors on cascading write statements */
+/* nested in the IF...ELSE IF... statements, and this was */
+/* confusing. These tests were restructured so that IOSTAT is */
+/* tested after each write statement which is equicalent to the */
+/* original intent and easier to read. */
+
+/* - SPICELIB Version 5.0.0, 27-SEP-1993 (KRG) */
+
+/* The following entry points have had code modifications: */
+/* DAFOPR, DAFOPW and DAFOPN. */
+
+/* A new entry point has been added: DAFONW. */
+
+/* The modifications are to allow a type to be associated with a */
+/* DAF file. */
+
+/* A new parameter has been added to this subroutine's parameter */
+/* list, FTYPE, so that type information may be passed to the */
+/* entry point DAFONW. Two new variables were added to the */
+/* routine as well, TARCH and TTYPE, which provide temporary */
+/* storage for the file architecture and type. */
+
+/* Several new parameters have been added to the declarations for */
+/* this routine: */
+
+/* ARCLEN The length of a file architecture. */
+
+/* MAXPC The maximum decimal value for the range of */
+/* printable characters. */
+
+/* MINPC The minimum decimal value for the range of */
+/* printable characters. */
+
+/* TYPLEN The length of a file type. */
+
+/* See the individual entry points for detailed descriptions of */
+/* their modifications. */
+
+/* Removed the variables MINHAN and NIL, as they were not used in */
+/* any of the entry points, yet they had values assigned to them */
+/* through DATA statements. */
+
+/* Made all occurrences of error message formatting of filenames */
+/* consistent. All filenames will be single quoted in the output */
+/* error message. */
+
+/* - SPICELIB Version 4.0.0, 25-FEB-1993 (JML) */
+
+/* In the entry points DAFOPR, DAFOPW, and DAFFNH, the INQUIRE */
+/* statement that checks if the file is already open now also */
+/* checks that the file exists. */
+
+/* IOSTAT is now checked after all INQUIRE statements. */
+
+/* A new variable LUN is used in DAFOPR, DAFOPW, and DAFOPN */
+/* for the logical unit number returned by GETLUN. */
+
+/* The IF-THEN statements in DAFOPR and DAFOPW were reorganized */
+/* to make the routines more readable. */
+
+/* In DAFOPR and DAFOPW, a long error message was added for the */
+/* case when the NAIF/DAF id word was not recognized. Also, the */
+/* file is closed when this error is signalled. */
+
+/* In DAFOPR and DAFOPW, IOSTAT is now checked after the file */
+/* record is read. */
+
+/* In DAFOPR, DAFOPW, DAFOPN, and DAFFNH, the file name is */
+/* checked to see if it is blank. */
+
+/* In DAFOPR, DAFOPW, DAFOPN, and DAFFNH, the file name passed */
+/* to the FORTRAN OPEN and INQUIRE statements has been chopped */
+/* at the last non-blank character. */
+
+/* A minor error in the particulars section of the header of */
+/* DAFCLS was corrected. It formerly stated that a file could be */
+/* open more than once for read or write access instead of just */
+/* read access. */
+
+/* - SPICELIB Version 3.2.0, 6-OCT-1992 (HAN) */
+
+/* Module was updated to include the record length and source */
+/* for the Hewlett Packard UX 9000/750 environment. Moved FILEN */
+/* to the Declarations section, and corrected Revisions section */
+/* to include the last code change description, 3.1.0. */
+
+/* - SPICELIB Version 3.1.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 3.1.0, 13-NOV-1991 (MJS) */
+
+/* Module was updated to operate in the Lahey F77 EM/32 */
+/* PC environment. */
+
+/* - SPICELIB Version 3.0.0, 03-SEP-1991 (NJB) (WLT) */
+
+/* DAFAH and its entry points were modified to permit multiple */
+/* DAFs to be open for writing at the same time. Also, the */
+/* entry points DAFHOF and DAFSIH were added. */
+
+/* - SPICELIB Version 2.0.0, 25-MAR-1991 (JEM) (MJS) */
+
+/* The variable MINHAN was initialized to zero and the variable */
+/* NEXT was saved. DAFOPW now accepts the ID word 'NAIF/NIP' */
+/* as well 'NAIF/DAF'. Spelling mistakes were corrected. */
+
+/* - SPICELIB Version 1.1.0, 5-NOV-1990 (HAN) */
+
+/* The parameter FTSIZE was increased from 4 to 20. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* assign daf handles */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 8.1.0, 02-APR-2002 (FST) */
+
+/* The entry point ZZDDHCLS in the handle manager (ZZDDHMAN) */
+/* had its argument list augmented to allow files to be */
+/* deleted on close. This allows the removal of a series */
+/* of "raw" CLOSE statements in a few of the entry points */
+/* of this routine. */
+
+/* - SPICELIB Version 8.0.0, 14-NOV-2001 (FST) */
+
+/* The DAF system now utilizes the handle manager umbrella */
+/* (ZZDDHMAN) and its entry points to provide most of the */
+/* handle and logical unit based operations that DAFAH */
+/* previously managed. */
+
+/* FTSIZE Files with UTSIZE Units: */
+
+/* In previous versions of the DAF system all files opened */
+/* through the DAFAH entry points were connected to logical */
+/* units. In contrast, the handle manager umbrella entry */
+/* points allow FTSIZE files to be loaded (opened), while */
+/* only utilizing UTSIZE (less than FTSIZE, see the include */
+/* file 'zzddhman.inc') logical units. The entry points in */
+/* the handle manager automatically connect and disconnect */
+/* loaded files from their logical units as new files are */
+/* loaded and accessed. */
+
+/* Previously, one could buffer a logical unit associated */
+/* with a particular handle and access the file directly */
+/* with Fortran I/O statements. To preserve this capability */
+/* invoking DAFHLU locks a handle to its assigned logical */
+/* unit, until that lock is removed (see ZZDDHUNL, an entry */
+/* point in ZZDDHMAN) or the file is closed. See the */
+/* Revisions section in the DAFHLU entry point for details. */
+
+/* Another consequence of the utilization of the handle */
+/* manager code is that the process of connecting a file */
+/* name to a HANDLE may require performing up to FTSIZE */
+/* INQUIRE statements. This is necessary to insure that */
+/* different names referring to the same file return the */
+/* same handle. This was the case previously with the DAF */
+/* system since an INQUIRE on a different, but equivalent, */
+/* file name would produce the same logical unit. */
+
+/* FTP Error Detection: */
+
+/* The FTP error detection software is now integrated into */
+/* the handle manager umbrella entry points, and as such */
+/* is no longer present in DAFAH. */
+
+/* Non-Native Files: */
+
+/* In addition to expanding the number of loaded files the */
+/* DAF system supports, the handle manager also detects and */
+/* tracks binary file formats. This allows a layer of */
+/* private code that has been inserted between DAF routines */
+/* and the Fortran I/O statements to provide translation */
+/* services for DAF. Some environments are now endowed with */
+/* the ability to read files created with certain non-native */
+/* binary file formats. See the Convert User's Guide for */
+/* details. */
+
+/* - SPICELIB Version 7.0.0, 22-MAR-1999 (FST) */
+
+/* Binary File Format Identification: */
+
+/* The file record now contains an 8 character string that */
+/* identifies the binary file format utilized by DAFs. */
+/* The purpose of this string's inclusion in the file record */
+/* is preparatory in nature, to accelerate the migration to */
+/* files that support the runtime translation update that */
+/* is scheduled. */
+
+/* FTP Validation: */
+
+/* The DAF system now employs a validation scheme to assist */
+/* users in detecting DAFs potentially corrupted via ASCII mode */
+/* FTP transfers. A string that contains sequences of */
+/* characters commonly corrupted by improper FTP transfers is */
+/* inserted into the unused portion of the file record. When any */
+/* DAFAH entry point attempts to open a file, this string is */
+/* located and examined. If the string indicates the file is */
+/* corrupted, the entry point signals an error. */
+
+/* Detection Scheme Implementation: */
+
+/* When a new DAF is created, the entry points DAFONW and */
+/* DAFOPN(obsolete) retrieve the FTP validation string from */
+/* the defining routine (ZZFTPSTR) and insert it into the */
+/* tail of the file record. A diagram illustrating the new */
+/* file record for 32-bit environments with single byte */
+/* characters follows: */
+
+/* +=============+ */
+/* | File Record | */
+/* | Data | */
+/* +=============+ */
+/* | */
+/* +=====|===+==========================+===+========+ */
+/* | | | 603 bytes of nulls | | | nulls | */
+/* +=========+==========================+=|=+========+ */
+/* Byte 1 | 1024 */
+/* +============+ */
+/* | FTP | */
+/* | Validation | */
+/* | String | */
+/* +============+ */
+
+/* As can be seen above, the file record is now null padded, */
+/* which was not the case previously. */
+
+/* When an existing DAF is opened, the entry points DAFOPR */
+/* and DAFOPW attempt to verify that the validation string is */
+/* intact. This is accomplished by reading the file */
+/* record into a character string, and then passing the last */
+/* half of this string into the validation subroutine */
+/* ZZFTPCHK. Only sending the latter half of the file record */
+/* into ZZFTPCHK is done to prevent other portions of the file */
+/* record from confusing the validation process. The following */
+/* three abnormal situations may arise during validation: */
+
+/* (1) Older DAFs without the FTP validation string are */
+/* not validated. As far as the DAF open routines */
+/* are concerned such files are valid by default. The */
+/* only notable exception is that the garbage that */
+/* resides in the unused portion of the file record may */
+/* confuse ZZFTPCHK into thinking the validation */
+/* string is present. (The probability of this event */
+/* is minimal and noted only for completeness.) */
+
+/* (2) Files with an older version of the validation */
+/* string are examined for errors supported by the */
+/* contemporaneous version of the Toolkit. */
+
+/* (3) Files with a newer version of the validation */
+/* string are examined for errors supported by the */
+/* current version of the Toolkit. */
+
+/* Updates to the FTP Validation String: */
+
+/* In the event that it becomes necessary to add additional */
+/* test characters to the validation string, refer to */
+/* ZZFTPSTR for the proper procedure. The instructions */
+/* provided there ensure that the above behavior is properly */
+/* adhered to by the modifications. */
+
+/* FTP Validation Issues in Code Portability: */
+
+/* The scheme as currently implemented will function */
+/* properly in any computing environment whose character data */
+/* conforms to the single byte ASCII standards with a word */
+/* size that is between 32 and 64 bits inclusive. Refer to */
+/* the above diagram that displays the new DAF file record */
+/* and the following discussion for details. */
+
+/* Since the DAF file record block contains integer data, */
+/* it may expand if the word size increases above the */
+/* currently supported 32 bits. However, the FTP validation */
+/* string is extracted by reading in 1000 bytes of character */
+/* data and examining bytes 500-1000. (See the parameters */
+/* FTPBLK and FTPSTR if you need to alter these numbers). */
+/* So as long as the alteration in word size does not cause */
+/* the FTP string information to shift out of bytes 500-1000 */
+/* in the file record, the existing code will function */
+/* properly. */
+
+/* - SPICELIB Version 3.2.0, 6-OCT-1992 (HAN) */
+
+/* The code was also reformatted so that a utility program can */
+/* create the source file for a specific environment given a */
+/* master source file. */
+
+/* - SPICELIB Version 3.0.0, 03-SEP-1991 (NJB) (WLT) */
+
+/* DAFAH and the entry point DAFOPW were modified to permit */
+/* multiple DAFs to be open for writing at the same time. */
+/* Also, the entry points DAFHOF and DAFSIH were added. DAFHOF */
+/* returns a set containing the handles of currently open DAFs. */
+/* To accommodate the addition of DAFHOF, the argument FHSET */
+/* was added to DAFAH's argument list, and local declarations */
+/* for DAFHOF were added to DAFAH's declaration section. DAFSIH */
+/* signals an error if the file indicated by the handle is not */
+/* open for the specified type of access. */
+
+/* - SPICELIB Version 2.0.0, 24-JAN-1991 (JEM) (MJS) */
+
+/* The entry point DAFOPW accepted only 'NAIF/DAF' as a valid */
+/* ID word. It now accepts 'NAIF/NIP' as well for */
+/* backwards compatibility. The entry point DAFOPR did not need */
+/* this fix because it already accepts both ID words. */
+
+/* - SPICELIB Version 1.1.0, 5-NOV-1990 (HAN) */
+
+/* The parameter FTSIZE was increased from 4 to 20. The number */
+/* 4 was chosen for testing purposes and was not removed. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* As each file is opened, it is assigned a handle, and the */
+/* internal file name is stored for comparison with other files. */
+/* All names in the file table begin with FT. */
+
+/* HAN Handle */
+/* LNK Number of links */
+/* ND, */
+/* NI Summary format */
+
+/* The columns are stored in no particular order. New files are */
+/* added to the end of the list; the list is repacked whenever a */
+/* file is removed from the list. */
+
+/* NFT is the number of files currently opened: this may not be */
+/* greater than FTSIZE. FINDEX refers to a file of interest within */
+/* the table. */
+
+/* NEXT is incremented each time a file is opened to become the */
+/* next file handle assigned. */
+
+
+/* Other local variables */
+
+
+/* Saved variables */
+
+
+/* Save everything between calls. */
+
+
+/* Initial values */
+
+ /* Parameter adjustments */
+ if (fhset) {
+ }
+
+ /* Function Body */
+ switch(n__) {
+ case 1: goto L_dafopr;
+ case 2: goto L_dafopw;
+ case 3: goto L_dafonw;
+ case 4: goto L_dafopn;
+ case 5: goto L_dafcls;
+ case 6: goto L_dafhsf;
+ case 7: goto L_dafhlu;
+ case 8: goto L_dafluh;
+ case 9: goto L_dafhfn;
+ case 10: goto L_daffnh;
+ case 11: goto L_dafhof;
+ case 12: goto L_dafsih;
+ }
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFAH", (ftnlen)5);
+ sigerr_("SPICE(BOGUSENTRY)", (ftnlen)17);
+ chkout_("DAFAH", (ftnlen)5);
+ }
+ return 0;
+/* $Procedure DAFOPR ( DAF, open for read ) */
+
+L_dafopr:
+/* $ Abstract */
+
+/* Open a DAF for subsequent read requests. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) FNAME */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I Name of DAF to be opened. */
+/* HANDLE O Handle assigned to DAF. */
+
+/* $ Detailed_Input */
+
+/* FNAME is the file name of a DAF to be opened for read */
+/* access. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the file handle associated with the file. This */
+/* handle is used to identify the file in subsequent */
+/* calls to other DAF routines. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See argument FNAME. */
+
+/* $ Exceptions */
+
+/* 1) If the specified file has already been opened for read */
+/* access, the handle already associated with the file is */
+/* returned. */
+
+/* 2) If the specified file has already been opened for write */
+/* access, an error is signaled by routines in the call */
+/* tree of this routine. */
+
+/* 3) If the specified file has already been opened by a non-DAF */
+/* routine, an error is signaled by routines in the call */
+/* tree of this routine. */
+
+/* 4) If the specified file cannot be opened without exceeding */
+/* the maximum number of files, the error SPICE(DAFFTFULL) */
+/* is signaled. */
+
+/* 5) If the attempt to read the file's file record fails, */
+/* the error SPICE(FILEREADFAILED) is signaled. */
+
+/* 6) If the specified file is not a DAF file, an error is */
+/* signaled by routines in the call tree of this routine. */
+
+/* 7) If no logical units are available, an error is */
+/* signaled by routines called by this routine. */
+
+/* 8) If the file does not exist, the error SPICE(FILENOTFOUND) */
+/* is signaled by routines in the call tree of this routine. */
+
+/* 9) If an I/O error occurs in the process of opening the file, */
+/* routines in the call tree of this routine signal an error. */
+
+/* 10) If the file name is blank or otherwise inappropriate */
+/* routines in the call tree of this routine signal an error. */
+
+/* 11) If the file was transferred improperly via FTP, routines */
+/* in the call tree of this routine signal an error. */
+
+/* 12) If the file utilizes a binary file format that is not */
+/* currently supported on this platform, an error is signaled */
+/* by routines in the call tree of this routine. */
+
+/* $ Particulars */
+
+/* Most DAFs require only read access. If you do not need to */
+/* change the contents of a file, you should open it with DAFOPR. */
+
+/* $ Examples */
+
+/* In the following code fragment, DAFOPR is used to open a file, */
+/* which is then searched for DAFs containing data for a particular */
+/* object. */
+
+/* CALL DAFOPR ( FNAME, HANDLE ) */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+/* CALL DAFGS ( SUM ) */
+/* CALL DAFUS ( SUM, ND, NI, DC, IC ) */
+
+/* IF ( IC(1) .EQ. TARGET_OBJECT ) THEN */
+/* . */
+/* . */
+
+/* END IF */
+
+/* CALL DAFFNA ( FOUND ) */
+/* END DO */
+
+/* $ Restrictions */
+
+/* 1) Files opened using this routine must be closed with DAFCLS. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* J.M. Lynch (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 8.1.0, 02-APR-2002 (FST) */
+
+/* This routine was updated to accomodate changes to the */
+/* handle manager interface. See DAFAH's Revision section */
+/* for details. */
+
+/* - SPICELIB Version 8.0.0, 13-NOV-2001 (FST) */
+
+/* This routine was updated to utilize the new handle manager */
+/* software to manage binary file formats and consolidated */
+/* I/O code. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 5.0.0, 03-MAR-1999 (FST) */
+
+/* This entry point now attempts to locate and validate the */
+/* FTP validation string contained in the file record. */
+
+/* - SPICELIB Version 4.0.0, 27-SEP-1993 (KRG) */
+
+/* This routine was modified to use a subroutine to obtain the */
+/* architecture of the file rather than using hard coded values */
+/* for comparison with the file ID word. This was done in order to */
+/* isolate the code which checks to determine a file architecture */
+/* and to make the identification of file types easier through a */
+/* change to the file ID word. */
+
+/* In particular, the changes to this routine support the change */
+/* of the file ID word from 'NAIF/DAF' or 'NAIF/NIP' to 'DAF/xxxx' */
+/* where 'xxxx' represents a four character mnemonic code for the */
+/* type of data in the file. */
+
+/* Removed the error SPICE(DAFNOIDWORD) as it was no longer */
+/* relevant. */
+
+/* Added the error SPICE(NOTADAFFILE) if this routine is called */
+/* with a file that does not contain an ID word identifying the */
+/* file as a DAF file. */
+
+/* Changed the long error message when the error */
+/* SPICE(NOTADAFFILE) is signalled to suggest that a common error */
+/* is attempting to load a text version of the desired file rather */
+/* than the binary version. */
+
+/* - SPICELIB Version 3.0.0, 25-FEB-1993 (JML) */
+
+/* The INQUIRE statement that checks if the file is already open */
+/* now also checks that the file exists. */
+
+/* A new variable LUN is used for the logical unit number */
+/* returned by GETLUN. */
+
+/* The IF-THEN statements were reorganized to improve readability. */
+
+/* A long error message is now set when the DAF id word is not */
+/* recognized. Also, the file is closed when this error is */
+/* signalled. */
+
+/* IOSTAT is checked after the file record is read. */
+
+/* The file name is checked to see if it is blank. */
+
+/* The file name string that is passed to the FORTRAN OPEN and */
+/* INQUIRE statements has been chopped at the last non-blank */
+/* character. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 03-SEP-1991 (NJB) (WLT) */
+
+/* This routine was updated so that it now keeps current the set */
+/* of DAF handles returned by DAFHOF. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* open daf for read */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 5.0.0, 03-MAR-1999 (FST) */
+
+/* See the Revisions section under DAFAH for a discussion */
+/* of the impact of the changes made for this version. */
+
+/* - SPICELIB Version 2.0.0, 03-SEP-1991 (NJB) (WLT) */
+
+/* This routine was updated so that it now keeps current the set */
+/* of DAF handles returned by DAFHOF. */
+
+/* Some error messages were changed so that they specify */
+/* names of relevant DAFs. */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFOPR", (ftnlen)6);
+ }
+
+/* Initialize the handle list, if necessary. */
+
+ if (first) {
+ ssizei_(&c__1000, fhlist);
+ first = FALSE_;
+ }
+
+/* Attempt to open the file; perform any appropriate checks. */
+
+ zzddhopn_(fname, "READ", "DAF", handle, fname_len, (ftnlen)4, (ftnlen)3);
+
+/* Check FAILED(); return if an error has occurred. */
+
+ if (failed_()) {
+ chkout_("DAFOPR", (ftnlen)6);
+ return 0;
+ }
+
+/* See if this file is already present in the file table. If it */
+/* is simply increment its link count by one, check out and */
+/* return. */
+
+ findex = isrchi_(handle, &nft, fthan);
+ if (findex != 0) {
+ ftlnk[(i__1 = findex - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftlnk",
+ i__1, "dafah_", (ftnlen)1221)] = ftlnk[(i__2 = findex - 1) <
+ 1000 && 0 <= i__2 ? i__2 : s_rnge("ftlnk", i__2, "dafah_", (
+ ftnlen)1221)] + 1;
+ chkout_("DAFOPR", (ftnlen)6);
+ return 0;
+ }
+
+/* Retrieve ND and NI from the file record. */
+
+ zzdafgfr_(handle, idword, &fnd, &fni, ifn, &fward, &bward, &free, &found,
+ (ftnlen)8, (ftnlen)60);
+ if (! found) {
+ zzddhcls_(handle, "DAF", &c_false, (ftnlen)3);
+ setmsg_("Error reading the file record from the binary DAF file '#'.",
+ (ftnlen)59);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DAFOPR", (ftnlen)6);
+ return 0;
+ }
+
+/* At this point, we know that we have a valid DAF file, and we're */
+/* set up to read from it, so ... */
+
+/* Update the file table to include information about our newly */
+/* opened DAF. */
+
+ ++nft;
+ fthan[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("fthan", i__1,
+ "dafah_", (ftnlen)1259)] = *handle;
+ ftnd[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftnd", i__1,
+ "dafah_", (ftnlen)1260)] = fnd;
+ ftni[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftni", i__1,
+ "dafah_", (ftnlen)1261)] = fni;
+ ftlnk[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftlnk", i__1,
+ "dafah_", (ftnlen)1262)] = 1;
+
+/* Insert the new handle into our handle set. */
+
+ insrti_(handle, fhlist);
+ chkout_("DAFOPR", (ftnlen)6);
+ return 0;
+/* $Procedure DAFOPW ( DAF, open for write ) */
+
+L_dafopw:
+/* $ Abstract */
+
+/* Open a DAF for subsequent write requests. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) FNAME */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I Name of DAF to be opened. */
+/* HANDLE O Handle assigned to DAF. */
+
+/* $ Detailed_Input */
+
+/* FNAME is the name of a DAF to be opened with write */
+/* access. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the file handle associated with the file. This */
+/* handle is used to identify the file in subsequent */
+/* calls to other DAF routines. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See argument FNAME. */
+
+/* $ Exceptions */
+
+/* 1) If the specified file has already been opened, either by */
+/* the DAF routines or by other code, an error is signaled by */
+/* routines in the call tree of this routine. Note that this */
+/* response is not paralleled by DAFOPR, which allows you */
+/* to open a DAF for reading even if it is already open for */
+/* reading. */
+
+/* 2) If the specified file cannot be opened without exceeding */
+/* the maximum number of files, the error SPICE(DAFFTFULL) */
+/* is signaled. */
+
+/* 3) If the attempt to read the file's file record fails, the */
+/* error SPICE(FILEREADFAILED) will be signalled. */
+
+/* 4) If the specified file is not a DAF file, an error is */
+/* signaled by routines in the call tree of this routine. */
+
+/* 5) If no logical units are available, an error is */
+/* signaled by routines called by this routine. */
+
+/* 6) If the file does not exist, the error SPICE(FILENOTFOUND) */
+/* is signaled by routines in the call tree of this routine. */
+
+/* 7) If an I/O error occurs in the process of opening the file, */
+/* routines in the call tree of this routine signal an error. */
+
+/* 8) If the file name is blank or otherwise inappropriate */
+/* routines in the call tree of this routine signal an error. */
+
+/* 9) If the file was transferred improperly via FTP, routines */
+/* in the call tree of this routine signal an error. */
+
+/* 10) If the file utilizes a non-native binary file format, an */
+/* error is signaled by routines in the call tree of this */
+/* routine. */
+
+/* $ Particulars */
+
+/* Most DAFs require only read access. If you do not need to */
+/* change the contents of a file, you should open it with DAFOPR. */
+/* Use DAFOPW when you need to */
+
+/* -- change (update) one or more summaries, names, or */
+/* arrays within a file; or */
+
+/* -- add new arrays to a file. */
+
+/* $ Examples */
+
+/* In the following code fragment, DAFOPW is used to open a */
+/* file, which is then searched for arrays containing data for */
+/* a particular object. The code for the object is then changed */
+/* (perhaps to reflect some new convention). */
+
+/* CALL DAFOPW ( FNAME, HANDLE ) */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+/* CALL DAFGS ( SUM ) */
+/* CALL DAFUS ( SUM, ND, NI, DC, IC ) */
+
+/* IF ( IC(1) .EQ. OLD_CODE ) THEN */
+/* IC(1) = NEW_CODE */
+
+/* CALL DAFPS ( ND, NI, DC, IC, SUM ) */
+/* CALL DAFRS ( SUM ) */
+/* END IF */
+
+/* CALL DAFFNA ( FOUND ) */
+/* END DO */
+
+/* $ Restrictions */
+
+/* 1) Only file of the native binary file format may be opened */
+/* with this routine. */
+
+/* 2) Files opened using this routine must be closed with DAFCLS. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* J.M. Lynch (JPL) */
+/* J.E. McLean (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 8.1.0, 02-APR-2002 (FST) */
+
+/* This routine was updated to accomodate changes to the */
+/* handle manager interface. See DAFAH's Revision section */
+/* for details. */
+
+/* - SPICELIB Version 8.0.0, 13-NOV-2001 (FST) */
+
+/* This routine was updated to utilize the new handle manager */
+/* software to manage binary file formats and consolidated */
+/* I/O code. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 6.0.0, 03-MAR-1999 (FST) */
+
+/* This entry point now attempts to locate and validate the */
+/* FTP validation string contained in the file record. */
+
+/* - SPICELIB Version 5.0.0, 27-SEP-1993 (KRG) */
+
+/* This routine was modified to use a subroutine to obtain the */
+/* architecture of the file rather than using hard coded values */
+/* for comparing to the file ID word. This was done in order to */
+/* isolate the code which checks to determine a file architecture, */
+/* and to make the identification of file types easier through a */
+/* change to the file ID word. */
+
+/* In particular, the changes to this routine support the change */
+/* of the file ID word from 'NAIF/DAF' or 'NAIF/NIP' to 'DAF/xxxx' */
+/* where 'xxxx' represents a four character mnemonic code for the */
+/* type of data in the file. */
+
+/* Removed the error SPICE(DAFNOIDWORD) as it was no longer */
+/* relevant. */
+
+/* Added the error SPICE(NOTADAFFILE) if this routine is called */
+/* with a file that does not contain an ID word identifying the */
+/* file as a DAF file. */
+
+/* Changed the long error message when the error */
+/* SPICE(NOTADAFFILE) is signalled to suggest that a common error */
+/* is attempting to load a text version of the desired file rather */
+/* than the binary version. */
+
+/* - SPICELIB Version 4.0.0, 25-FEB-1993 (JML) */
+
+/* The INQUIRE statement that checks if the file is already open */
+/* now also checks that the file exists. */
+
+/* A new variable LUN is used for the logical unit number */
+/* returned by GETLUN. */
+
+/* The IF-THEN statements were reorganized to improve readability. */
+
+/* A long error message is now set when the DAF id word is not */
+/* recognized. Also, the file is closed when this error is */
+/* signalled. */
+
+/* IOSTAT is now checked after the file record is read. */
+
+/* The file name is checked to see if it is blank. */
+
+/* The file name string that is passed to the FORTRAN OPEN and */
+/* INQUIRE statements has been chopped at the last non-blank */
+/* character. */
+
+/* - SPICELIB Version 3.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 3.0.0, 03-SEP-1991 (NJB) (WLT) */
+
+/* DAFOPW now allows multiple files to be open for writing. */
+
+/* This routine was updated so that it now keeps current the set */
+/* of DAF handles returned by DAFHOF. */
+
+/* - SPICELIB Version 2.0.0, 24-JAN-1991 (JEM) */
+
+/* DAFOPW now accepts the ID word 'NAIF/NIP' as well 'NAIF/DAF'. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* open daf for write */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 6.0.0, 03-MAR-1999 (FST) */
+
+/* See the Revisions section under DAFAH for a discussion */
+/* of the impact of the changes made for this version. */
+
+/* - SPICELIB Version 2.0.0, 03-SEP-1991 (NJB) (WLT) */
+
+/* DAFOPW now allows multiple files to be open for writing. */
+
+/* This routine was updated so that it now keeps current the set */
+/* of DAF handles returned by DAFHOF. */
+
+/* Some error messages were changed so that they specify */
+/* names of relevant DAFs. */
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFOPW", (ftnlen)6);
+ }
+
+/* Initialize the handle list, if necessary. */
+
+ if (first) {
+ ssizei_(&c__1000, fhlist);
+ first = FALSE_;
+ }
+
+/* Check to see if there is room in the file table. */
+
+ if (nft == 1000) {
+ setmsg_("The file table is full, with # entries. Could not open '#'.",
+ (ftnlen)59);
+ errint_("#", &c__1000, (ftnlen)1);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(DAFFTFULL)", (ftnlen)16);
+ chkout_("DAFOPW", (ftnlen)6);
+ return 0;
+ }
+
+/* Attempt to open the file; perform any appropriate checks. */
+
+ zzddhopn_(fname, "WRITE", "DAF", handle, fname_len, (ftnlen)5, (ftnlen)3);
+
+/* Check FAILED(); return if an error has occurred. */
+
+ if (failed_()) {
+ chkout_("DAFOPW", (ftnlen)6);
+ return 0;
+ }
+
+/* Retrieve ND and NI from the file record. */
+
+ zzdafgfr_(handle, idword, &fnd, &fni, ifn, &fward, &bward, &free, &found,
+ (ftnlen)8, (ftnlen)60);
+ if (! found) {
+ zzddhcls_(handle, "DAF", &c_false, (ftnlen)3);
+ setmsg_("Error reading the file record from the binary DAF file '#'.",
+ (ftnlen)59);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DAFOPW", (ftnlen)6);
+ return 0;
+ }
+
+/* At this point, we know that we have a valid DAF file, and we're */
+/* set up to write to it or read from it, so ... */
+
+/* Update the file table to include information about our */
+/* newly opened DAF. */
+
+ ++nft;
+ fthan[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("fthan", i__1,
+ "dafah_", (ftnlen)1663)] = *handle;
+ ftnd[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftnd", i__1,
+ "dafah_", (ftnlen)1664)] = fnd;
+ ftni[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftni", i__1,
+ "dafah_", (ftnlen)1665)] = fni;
+ ftlnk[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftlnk", i__1,
+ "dafah_", (ftnlen)1666)] = 1;
+
+/* Insert the new handle into our handle set. */
+
+ insrti_(handle, fhlist);
+ chkout_("DAFOPW", (ftnlen)6);
+ return 0;
+/* $Procedure DAFONW ( DAF, open new ) */
+
+L_dafonw:
+/* $ Abstract */
+
+/* Open a new DAF for subsequent write requests. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) FNAME */
+/* CHARACTER*(*) FTYPE */
+/* INTEGER ND */
+/* INTEGER NI */
+/* CHARACTER*(*) IFNAME */
+/* INTEGER RESV */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I Name of DAF to be opened. */
+/* FTYPE I Mnemonic code for type of data in the DAF file. */
+/* ND I Number of double precision components in summaries. */
+/* NI I Number of integer components in summaries. */
+/* IFNAME I Internal file name. */
+/* RESV I Number of records to reserve. */
+/* HANDLE O Handle assigned to DAF. */
+
+/* $ Detailed_Input */
+
+/* FNAME is the name of a new DAF to be created (and */
+/* consequently opened for write access). */
+
+/* FTYPE is a code for type of data placed into a DAF file. */
+/* The first nonblank character and the three (3) */
+/* characters immediately following it, giving four (4) */
+/* characters, are used to represent the type of the data */
+/* placed in the DAF file. This is provided as a */
+/* convenience for higher level software. It is an error */
+/* if this string is blank. When written to the DAF file, */
+/* the value for the type IS case sensitive; what you put */
+/* in is what you get out, so be careful. */
+
+/* NAIF has reserved for its own use file types */
+/* consisting of the upper case letters (A-Z) and the */
+/* digits 0-9. NAIF recommends lower case or mixed case */
+/* file types be used by all others in order to avoid */
+/* any conflicts with NAIF file types. */
+
+/* ND is the number of double precision components */
+/* in each array summary of the new file. */
+
+/* NI is the number of integer components in each */
+/* array summary in the new file. */
+
+/* IFNAME is the internal file name (containing as many as 60 */
+/* characters) for the new file. This should uniquely */
+/* identify the file. */
+
+/* RESV is the number of records in the new file to be */
+/* reserved; these records will not be used to store any */
+/* data belonging to DAF arrays subsequently written to */
+/* the file. The user may reserve records 2 through (2 + */
+/* RESV - 1) in the file. SPICE kernels based on the DAF */
+/* format use the reserved record area to store optional */
+/* textual information; for these kernels, the reserved */
+/* records contain the file's "comment area." */
+
+/* When RESV is non-zero, this routine writes an */
+/* end-of-comments character into the first byte of */
+/* record 2, and fills the rest of the allocated records */
+/* will null (ASCII code 0) characters. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the file handle associated with the file. This */
+/* handle is used to identify the file in subsequent */
+/* calls to other DAF routines. */
+
+/* $ Parameters */
+
+/* INTEOC is the ASCII decimal integer code of the character */
+/* recognized by SPICE as representing the end of the */
+/* comment data in the reserved record area. */
+
+/* $ Files */
+
+/* See argument FNAME. */
+
+/* $ Exceptions */
+
+/* 1) If the specified file cannot be opened without exceeding */
+/* the maximum number of files, the error SPICE(DAFFTFULL) */
+/* is signalled. */
+
+/* 2) If the input argument ND is out of the range [0, 124] */
+/* or if NI is out of the range [2, 250], the error */
+/* SPICE(DAFINVALIDPARAMS) is signalled. */
+
+/* 3) If */
+
+/* ND + ( NI + 1 ) / 2 > 125 */
+
+/* the error SPICE(DAFINVALIDPARAMS) is signalled. */
+
+/* 4) If the number of records to be reserved is not zero or */
+/* positive, the error SPICE(DAFNORESV) is signalled. */
+
+/* 5) If an I/O error occurs in the process of creating the file, */
+/* routines in the call tree of this routine signal an error. */
+
+/* 6) If (for some reason) the initial records in the file cannot */
+/* be written, the error SPICE(DAFWRITEFAIL) is signalled. */
+
+/* 7) If no logical units are available, the error is */
+/* signaled by routines called by this routine. */
+
+/* 8) If the file name is blank or otherwise inappropriate */
+/* routines in the call tree of this routine signal an error. */
+
+/* 9) If the file type is blank, the error SPICE(BLANKFILETYPE) */
+/* is signalled. */
+
+/* 10) If the file type contains nonprinting characters, decimal */
+/* 0-31 and 127-255, the error SPICE(ILLEGALCHARACTER) is */
+/* signalled. */
+
+/* $ Particulars */
+
+/* This routine supersedes DAFOPN as the method for opening a new DAF */
+/* file. It includes a data type identifier as part of the ID word of */
+/* a DAF file it creates. */
+
+/* The DAFs created by DAFONW have initialized file records but */
+/* do not yet contain any arrays. See the DAF Required Reading */
+/* for a discussion of file records. */
+
+/* $ Examples */
+
+/* In the following code fragment, DAFONW is used to open a file, */
+/* to which a new array is then added. This file will have the data */
+/* type 'TEST' which may be used to distinguish production data from */
+/* test data at a user subroutine level. */
+
+/* FNAME = 'test.bin' */
+/* FTYPE = 'TEST' */
+
+/* CALL DAFONW ( FNAME, FTYPE, ND, NI, IFNAME, 0, HANDLE ) */
+
+/* CALL DAFBNA ( HANDLE, SUM, NAME ) */
+/* CALL GET_DATA ( DATA, N, FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+/* CALL DAFADA ( DATA, N ) */
+/* CALL GET_DATA ( DATA, N, FOUND ) */
+/* END DO */
+
+/* CALL DAFENA */
+
+/* $ Restrictions */
+
+/* 1) Files opened using this routine must be closed with DAFCLS. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* J.M. Lynch (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 9.0.0, 09-NOV-2006 (NJB) */
+
+/* DAFONW now writes a EOC character to the first byte */
+/* of the second record when NRESV > 0. */
+
+/* - SPICELIB Version 8.1.0, 02-APR-2002 (FST) */
+
+/* This routine was updated to accomodate changes to the */
+/* handle manager interface. See DAFAH's Revision section */
+/* for details. */
+
+/* - SPICELIB Version 8.0.0, 13-NOV-2001 (FST) */
+
+/* This routine was updated to utilize the new handle manager */
+/* software to manage binary file formats and consolidated */
+/* I/O code. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 2.0.0, 03-MAR-1999 (FST) */
+
+/* The entry point was modified to insert the FTP validation */
+/* string, as well as the binary file format into the file record. */
+
+/* - SPICELIB Version 1.1.0, 08-MAR-1996 (KRG) */
+
+/* The modifications support the notion of a DAF comment area, */
+/* and involve writing NULL filled reserved records when the */
+/* number of reserved records is greater than zero (0). */
+
+/* Some nested IF...THEN...ELSE IF...THEN...END IF constructs */
+/* were expanded to be independent IF...THEN...END IF tests. */
+/* The tests were for IOSTAT errors on cascading write statements */
+/* nested in the IF...ELSE IF... statements, and this was */
+/* confusing. These tests were restructured so that IOSTAT is */
+/* tested after each write statement which is equicalent to the */
+/* original intent and easier to read. */
+
+/* - SPICELIB Version 1.0.0, 29-SEP-1993 (KRG) */
+
+/* This routine implements the notion of a file type for DAF */
+/* files. It allows type information to be added to the file ID */
+/* word. */
+
+/* This routine is a modified version of DAFOPN. See the revision */
+/* history of that entry point for details of changes before the */
+/* creation of this entry point. */
+
+/* -& */
+/* $ Index_Entries */
+
+/* open new daf with type */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 03-MAR-1999 (FST) */
+
+/* See the Revisions section under DAFAH for a discussion */
+/* of the impact of the changes made for this version. */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFONW", (ftnlen)6);
+ }
+
+/* Initialize the handle list, if necessary. */
+
+ if (first) {
+ ssizei_(&c__1000, fhlist);
+ first = FALSE_;
+ }
+
+/* Check to see if there is room in the file table. */
+
+ if (nft == 1000) {
+ setmsg_("The file table is full, with # entries. Could not open '#'.",
+ (ftnlen)59);
+ errint_("#", &c__1000, (ftnlen)1);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(DAFFTFULL)", (ftnlen)16);
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+
+/* Check if the file type is blank. */
+
+ if (s_cmp(ftype, " ", ftype_len, (ftnlen)1) == 0) {
+ setmsg_("The file type is blank.", (ftnlen)23);
+ sigerr_("SPICE(BLANKFILETYPE)", (ftnlen)20);
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+
+/* Check for nonprinting characters in the file type. */
+
+ fnb = ltrim_(ftype, ftype_len);
+ i__1 = rtrim_(ftype, ftype_len);
+ for (i__ = fnb; i__ <= i__1; ++i__) {
+ if (*(unsigned char *)&ftype[i__ - 1] > 126 || *(unsigned char *)&
+ ftype[i__ - 1] < 32) {
+ setmsg_("The file type contains nonprinting characters.", (ftnlen)
+ 46);
+ sigerr_("SPICE(ILLEGALCHARACTER)", (ftnlen)23);
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* Set the value the file type in a temporary variable to be sure of */
+/* its length and then set the value of the ID word. Only 4 */
+/* characters are allowed for the file type, and they are the first */
+/* nonblank character and its three (3), or fewer, immediate */
+/* successors in the input string FTYPE. */
+
+ s_copy(ttype, ftype + (fnb - 1), (ftnlen)4, ftype_len - (fnb - 1));
+/* Writing concatenation */
+ i__3[0] = 4, a__1[0] = "DAF/";
+ i__3[1] = 4, a__1[1] = ttype;
+ s_cat(idword, a__1, i__3, &c__2, (ftnlen)8);
+
+/* Make sure ND and NI are in range. */
+
+ if (*nd < 0 || *nd > 124) {
+ setmsg_("ND was #, should be in range [0,#].", (ftnlen)35);
+ errint_("#", nd, (ftnlen)1);
+ errint_("#", &c__124, (ftnlen)1);
+ sigerr_("SPICE(DAFINVALIDPARAMS)", (ftnlen)23);
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+ if (*ni < 2 || *ni > 250) {
+ setmsg_("NI was #, should be in range [2,#].", (ftnlen)35);
+ errint_("#", ni, (ftnlen)1);
+ errint_("#", &c__250, (ftnlen)1);
+ sigerr_("SPICE(DAFINVALIDPARAMS)", (ftnlen)23);
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+ if (*nd + (*ni + 1) / 2 > 125) {
+ setmsg_("Summary size was #, should not exceed #.", (ftnlen)40);
+ i__1 = *nd + (*ni + 1) / 2;
+ errint_("#", &i__1, (ftnlen)1);
+ errint_("#", &c__125, (ftnlen)1);
+ sigerr_("SPICE(DAFINVALIDPARAMS)", (ftnlen)23);
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+
+/* The user must reserve some non-negative number of records. */
+
+ if (*resv < 0) {
+ setmsg_("An attempt was made to reserve a negative number (#) of rec"
+ "ords.", (ftnlen)64);
+ errint_("#", resv, (ftnlen)1);
+ sigerr_("SPICE(DAFNORESV)", (ftnlen)16);
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+
+/* Attempt to create the file; perform any appropriate checks. */
+
+ zzddhopn_(fname, "NEW", "DAF", handle, fname_len, (ftnlen)3, (ftnlen)3);
+
+/* Check FAILED(); return if an error has occurred. */
+
+ if (failed_()) {
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+ s_copy(ifn, ifname, (ftnlen)60, ifname_len);
+ fnd = *nd;
+ fni = *ni;
+ fward = *resv + 2;
+ bward = fward;
+ s_copy(crec, " ", (ftnlen)1000, (ftnlen)1);
+ cleard_(&c__128, drec);
+ i__1 = fward + 2;
+ dafrwa_(&i__1, &c__1, &free);
+
+/* Fetch a logical unit for HANDLE. */
+
+ zzddhhlu_(handle, "DAF", &c_false, &lun, (ftnlen)3);
+
+/* Check FAILED(); return if an error has occurred. */
+
+ if (failed_()) {
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+
+/* Fetch the system file format. */
+
+ zzplatfm_("FILE_FORMAT", format, (ftnlen)11, (ftnlen)8);
+
+/* Write the new file record to the logical unit, LUN. */
+
+ zzdafnfr_(&lun, idword, &fnd, &fni, ifn, &fward, &bward, &free, format, (
+ ftnlen)8, (ftnlen)60, (ftnlen)8);
+
+/* Check to see whether or not ZZDAFNFR generated an error writing */
+/* the file record to the logical unit. In the event an error */
+/* occurs, checkout and return. */
+
+ if (failed_()) {
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+
+/* Write NULL filled reserved records. */
+
+ if (*resv > 0) {
+ for (i__ = 1; i__ <= 1000; ++i__) {
+ *(unsigned char *)&crec[i__ - 1] = '\0';
+ }
+ i__1 = *resv + 1;
+ for (i__ = 2; i__ <= i__1; ++i__) {
+
+/* Place an end-of-comments marker in the first byte */
+/* of the first record. */
+
+ if (i__ == 2) {
+ *(unsigned char *)crec = '\4';
+ } else {
+ *(unsigned char *)crec = '\0';
+ }
+ io___25.ciunit = lun;
+ io___25.cirec = i__;
+ iostat = s_wdue(&io___25);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, crec, (ftnlen)1000);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_wdue();
+L100001:
+ if (iostat != 0) {
+ zzddhcls_(handle, "DAF", &c_true, (ftnlen)3);
+ setmsg_("Attempt to write file '#' failed. Value of IOSTAT w"
+ "as #.", (ftnlen)56);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+ }
+ }
+ io___26.ciunit = lun;
+ io___26.cirec = fward;
+ iostat = s_wdue(&io___26);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__128, (char *)&drec[0], (ftnlen)sizeof(doublereal));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_wdue();
+L100002:
+ if (iostat != 0) {
+ zzddhcls_(handle, "DAF", &c_true, (ftnlen)3);
+ setmsg_("Attempt to write file '#' failed. Value of IOSTAT was #.", (
+ ftnlen)56);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+ io___27.ciunit = lun;
+ io___27.cirec = fward + 1;
+ iostat = s_wdue(&io___27);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_uio(&c__1, crec, (ftnlen)1000);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = e_wdue();
+L100003:
+ if (iostat != 0) {
+ zzddhcls_(handle, "DAF", &c_true, (ftnlen)3);
+ setmsg_("Attempt to write file '#' failed. Value of IOSTAT was #.", (
+ ftnlen)56);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+ }
+
+/* Update the file table to include information about our newly */
+/* opened DAF. */
+
+ ++nft;
+ fthan[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("fthan", i__1,
+ "dafah_", (ftnlen)2243)] = *handle;
+ ftnd[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftnd", i__1,
+ "dafah_", (ftnlen)2244)] = fnd;
+ ftni[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftni", i__1,
+ "dafah_", (ftnlen)2245)] = fni;
+ ftlnk[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftlnk", i__1,
+ "dafah_", (ftnlen)2246)] = 1;
+
+/* Insert the new handle into our handle set. */
+
+ insrti_(handle, fhlist);
+ chkout_("DAFONW", (ftnlen)6);
+ return 0;
+/* $Procedure DAFOPN ( DAF, open new ) */
+
+L_dafopn:
+/* $ Abstract */
+
+/* Open a new DAF for subsequent write requests. */
+/* Obsolete: This routine has been superceded by DAFONW. It is */
+/* supported for purposes of backward compatibility only. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) FNAME */
+/* INTEGER ND */
+/* INTEGER NI */
+/* CHARACTER*(*) IFNAME */
+/* INTEGER RESV */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I Name of DAF to be opened. */
+/* ND I Number of double precision components in summaries. */
+/* NI I Number of integer components in summaries. */
+/* IFNAME I Internal file name. */
+/* RESV I Number of records to reserve. */
+/* HANDLE O Handle assigned to DAF. */
+
+/* $ Detailed_Input */
+
+/* FNAME is the name of a new DAF to be created (and */
+/* consequently open for write access). */
+
+/* ND is the number of double precision components */
+/* in each array summary of the new file. */
+
+/* NI is the number of integer components in each */
+/* array summary in the new file. */
+
+/* IFNAME is the internal file name (containing as many as 60 */
+/* characters) for the new file. This should uniquely */
+/* identify the file. */
+
+/* RESV is the number of records in the new file to be */
+/* reserved for non-DAF use. The user may reserve */
+/* records 2 through (2 + RESV - 1) in the file. */
+/* These records are not used to store DAF data, */
+/* and are in fact invisible to all DAF routines. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the file handle associated with the file. This */
+/* handle is used to identify the file in subsequent */
+/* calls to other DAF routines. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See argument FNAME. */
+
+/* $ Exceptions */
+
+/* 1) If the specified file cannot be opened without exceeding */
+/* the maximum number of files, the error SPICE(DAFFTFULL) */
+/* is signalled. */
+
+/* 2) If the input argument ND is out of the range [0, 124] */
+/* or if NI is out of the range [2, 250], the error */
+/* SPICE(DAFINVALIDPARAMS) is signalled. */
+
+/* 3) If */
+
+/* ND + ( NI + 1 ) / 2 > 125 */
+
+/* the error SPICE(DAFINVALIDPARAMS) is signalled. */
+
+/* 4) If the number of records to be reserved is not zero or */
+/* positive, the error SPICE(DAFNORESV) is signalled. */
+
+/* 5) If an I/O error occurs in the process of creating the file, */
+/* routines in the call tree of this routine signal an error. */
+
+/* 6) If (for some reason) the initial records in the file cannot */
+/* be written, the error SPICE(DAFWRITEFAIL) is signalled. */
+
+/* 7) If no logical units are available, the error is */
+/* signaled by routines called by this routine. */
+
+/* 8) If the file name is blank, or otherwise inappropriate */
+/* routines in the call tree of this routine signal an error. */
+
+/* $ Particulars */
+
+/* The DAFs created by DAFOPN have initialized file records but */
+/* do not yet contain any arrays. See the DAF Required Reading */
+/* for a discussion of file records. */
+
+/* This entry point has been made obsolete by the entry point DAFONW. */
+/* It is supported for reasons of backward compatibility only. New */
+/* software development should use the entry point DAFONW. */
+
+/* $ Examples */
+
+/* In the following code fragment, DAFOPN is used to open a file, */
+/* to which a new array is then added. */
+
+/* CALL DAFOPN ( FNAME, ND, NI, IFNAME, 0, HANDLE ) */
+
+/* CALL DAFBNA ( HANDLE, SUM, NAME ) */
+/* CALL GET_DATA ( DATA, N, FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+/* CALL DAFADA ( DATA, N ) */
+/* CALL GET_DATA ( DATA, N, FOUND ) */
+/* END DO */
+
+/* CALL DAFENA */
+
+/* $ Restrictions */
+
+/* 1) Files opened using this routine must be closed with DAFCLS. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* J.M. Lynch (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 8.1.0, 02-APR-2002 (FST) */
+
+/* This routine was updated to accomodate changes to the */
+/* handle manager interface. See DAFAH's Revision section */
+/* for details. */
+
+/* - SPICELIB Version 8.0.0, 13-NOV-2001 (FST) */
+
+/* This routine was updated to utilize the new handle manager */
+/* software to manage binary file formats and consolidated */
+/* I/O code. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 4.0.0, 03-MAR-1999 (FST) */
+
+/* The entry point was modified to insert the FTP validation */
+/* string, as well as the binary file format into the file record. */
+
+/* - SPICELIB Version 3.1.0, 08-MAR-1996 (KRG) */
+
+/* The modifications support the notion of a DAF comment area, */
+/* and involve writing NULL filled reserved records when the */
+/* number of reserved records is greater than zero (0). */
+
+/* Some nested IF...THEN...ELSE IF...THEN...END IF constructs */
+/* were expanded to be independent IF...THEN...END IF tests. */
+/* The tests were for IOSTAT errors on cascading write statements */
+/* nested in the IF...ELSE IF... statements, and this was */
+/* confusing. These tests were restructured so that IOSTAT is */
+/* tested after each write statement which is equicalent to the */
+/* original intent and easier to read. */
+
+/* - SPICELIB Version 3.0.0, 29-SEP-1993 (KRG) */
+
+/* Modified the logical structure of some */
+/* IF ... THEN ... ELSE IF... END IF */
+/* statements which were testing different items in each ELSE IF */
+/* clause for failure into separate IF ... END IF statements. This */
+/* improved the readability and supportability of the code. */
+
+/* - SPICELIB Version 2.1.0, 25-FEB-1993 (JML) */
+
+/* A new variable LUN is used for the logical unit number */
+/* returned by GETLUN. */
+
+/* The file name is checked to see if it is blank. */
+
+/* The file name string that is passed to the FORTRAN OPEN and */
+/* INQUIRE statements has been chopped at the last non-blank */
+/* character. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 03-SEP-1991 (NJB) (HAN) (WLT) */
+
+/* Updated to allow multiple DAFs to be open for write */
+/* access simultaneously. An error in a calling sequence */
+/* shown in the Examples section was corrected. */
+
+/* This routine was updated so that it now keeps current the set */
+/* of DAF handles returned by DAFHOF. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* open new daf */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 4.0.0, 03-MAR-1999 (FST) */
+
+/* See the Revisions section under DAFAH for a discussion */
+/* of the impact of the changes made for this version. */
+
+/* - SPICELIB Version 2.0.0, 03-SEP-1991 (NJB) (HAN) (WLT) */
+
+/* Updated to allow multiple DAFs to be open for write */
+/* access simultaneously. */
+
+/* This routine was updated so that it now keeps current the set */
+/* of DAF handles returned by DAFHOF. */
+
+/* Invalid values of ND and NI are now screened; two new */
+/* exceptions were added to the $Exceptions header section. */
+
+/* The calling sequence of DAFADA shown in the first example */
+/* in the Examples section was reversed; this was fixed. */
+
+/* Some error messages were changed so that they specify */
+/* names of relevant DAFs. */
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFOPN", (ftnlen)6);
+ }
+
+/* Initialize the handle list, if necessary. */
+
+ if (first) {
+ ssizei_(&c__1000, fhlist);
+ first = FALSE_;
+ }
+
+/* Check to see if there is room in the file table. */
+
+ if (nft == 1000) {
+ setmsg_("The file table is full, with # entries. Could not open '#'.",
+ (ftnlen)59);
+ errint_("#", &c__1000, (ftnlen)1);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(DAFFTFULL)", (ftnlen)16);
+ chkout_("DAFOPN", (ftnlen)6);
+ return 0;
+ }
+
+/* Make sure ND and NI are in range. */
+
+ if (*nd < 0 || *nd > 124) {
+ setmsg_("ND was #, should be in range [0,#].", (ftnlen)35);
+ errint_("#", nd, (ftnlen)1);
+ errint_("#", &c__124, (ftnlen)1);
+ sigerr_("SPICE(DAFINVALIDPARAMS)", (ftnlen)23);
+ chkout_("DAFOPN", (ftnlen)6);
+ return 0;
+ }
+ if (*ni < 2 || *ni > 250) {
+ setmsg_("NI was #, should be in range [2,#].", (ftnlen)35);
+ errint_("#", ni, (ftnlen)1);
+ errint_("#", &c__250, (ftnlen)1);
+ sigerr_("SPICE(DAFINVALIDPARAMS)", (ftnlen)23);
+ chkout_("DAFOPN", (ftnlen)6);
+ return 0;
+ }
+ if (*nd + (*ni + 1) / 2 > 125) {
+ setmsg_("Summary size was #, should not exceed #.", (ftnlen)40);
+ i__1 = *nd + (*ni + 1) / 2;
+ errint_("#", &i__1, (ftnlen)1);
+ errint_("#", &c__125, (ftnlen)1);
+ sigerr_("SPICE(DAFINVALIDPARAMS)", (ftnlen)23);
+ chkout_("DAFOPN", (ftnlen)6);
+ return 0;
+ }
+
+/* The user must reserve some non-negative number of records. */
+
+ if (*resv < 0) {
+ setmsg_("An attempt was made to reserve a negative number (#) of rec"
+ "ords.", (ftnlen)64);
+ errint_("#", resv, (ftnlen)1);
+ sigerr_("SPICE(DAFNORESV)", (ftnlen)16);
+ chkout_("DAFOPN", (ftnlen)6);
+ return 0;
+ }
+
+/* Attempt to create the file; perform any appropriate checks. */
+
+ zzddhopn_(fname, "NEW", "DAF", handle, fname_len, (ftnlen)3, (ftnlen)3);
+
+/* Check FAILED(); return if an error has occurred. */
+
+ if (failed_()) {
+ chkout_("DAFOPN", (ftnlen)6);
+ return 0;
+ }
+ s_copy(ifn, ifname, (ftnlen)60, ifname_len);
+ fnd = *nd;
+ fni = *ni;
+ fward = *resv + 2;
+ bward = fward;
+ s_copy(crec, " ", (ftnlen)1000, (ftnlen)1);
+ cleard_(&c__128, drec);
+ i__1 = fward + 2;
+ dafrwa_(&i__1, &c__1, &free);
+
+/* Fetch a logical unit for HANDLE. */
+
+ zzddhhlu_(handle, "DAF", &c_false, &lun, (ftnlen)3);
+
+/* Check FAILED(); return if an error has occurred. */
+
+ if (failed_()) {
+ chkout_("DAFOPN", (ftnlen)6);
+ return 0;
+ }
+
+/* Fetch the system file format. */
+
+ zzplatfm_("FILE_FORMAT", format, (ftnlen)11, (ftnlen)8);
+
+/* Write the new file record to the logical unit, LUN. */
+
+ zzdafnfr_(&lun, "NAIF/DAF", &fnd, &fni, ifn, &fward, &bward, &free,
+ format, (ftnlen)8, (ftnlen)60, (ftnlen)8);
+
+/* Check to see whether or not ZZDAFNFR generated an error writing */
+/* the file record to the logical unit. In the event an error */
+/* occurs, checkout and return. */
+
+ if (failed_()) {
+ chkout_("DAFOPN", (ftnlen)6);
+ return 0;
+ }
+
+/* Write NULL filled reserved records. */
+
+ if (*resv > 0) {
+ for (i__ = 1; i__ <= 1000; ++i__) {
+ *(unsigned char *)&crec[i__ - 1] = '\0';
+ }
+ i__1 = *resv + 1;
+ for (i__ = 2; i__ <= i__1; ++i__) {
+ io___28.ciunit = lun;
+ io___28.cirec = i__;
+ iostat = s_wdue(&io___28);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_uio(&c__1, crec, (ftnlen)1000);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = e_wdue();
+L100004:
+ if (iostat != 0) {
+ zzddhcls_(handle, "DAF", &c_true, (ftnlen)3);
+ setmsg_("Attempt to write file '#' failed. Value of IOSTAT w"
+ "as #.", (ftnlen)56);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFOPN", (ftnlen)6);
+ return 0;
+ }
+ }
+ }
+ io___29.ciunit = lun;
+ io___29.cirec = fward;
+ iostat = s_wdue(&io___29);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_uio(&c__128, (char *)&drec[0], (ftnlen)sizeof(doublereal));
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = e_wdue();
+L100005:
+ if (iostat != 0) {
+ zzddhcls_(handle, "DAF", &c_true, (ftnlen)3);
+ setmsg_("Attempt to write file '#' failed. Value of IOSTAT was #.", (
+ ftnlen)56);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFOPN", (ftnlen)6);
+ return 0;
+ }
+ io___30.ciunit = lun;
+ io___30.cirec = fward + 1;
+ iostat = s_wdue(&io___30);
+ if (iostat != 0) {
+ goto L100006;
+ }
+ iostat = do_uio(&c__1, crec, (ftnlen)1000);
+ if (iostat != 0) {
+ goto L100006;
+ }
+ iostat = e_wdue();
+L100006:
+ if (iostat != 0) {
+ zzddhcls_(handle, "DAF", &c_true, (ftnlen)3);
+ setmsg_("Attempt to write file '#' failed. Value of IOSTAT was #.", (
+ ftnlen)56);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFOPN", (ftnlen)6);
+ return 0;
+ }
+
+/* Update the file table to include information about */
+/* our newly opened DAF. */
+
+ ++nft;
+ fthan[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("fthan", i__1,
+ "dafah_", (ftnlen)2776)] = *handle;
+ ftnd[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftnd", i__1,
+ "dafah_", (ftnlen)2777)] = fnd;
+ ftni[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftni", i__1,
+ "dafah_", (ftnlen)2778)] = fni;
+ ftlnk[(i__1 = nft - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftlnk", i__1,
+ "dafah_", (ftnlen)2779)] = 1;
+
+/* Insert the new handle into our handle set. */
+
+ insrti_(handle, fhlist);
+ chkout_("DAFOPN", (ftnlen)6);
+ return 0;
+/* $Procedure DAFCLS ( DAF, close ) */
+
+L_dafcls:
+/* $ Abstract */
+
+/* Close the DAF associated with a given handle. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAF to be closed. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the file handle of a previously opened DAF file. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified handle does not belong to a DAF */
+/* that is currently open, nothing happens. */
+
+/* 2) If this routine is used to close an HANDLE not associated */
+/* with a DAF, routines called by this routine signal an error. */
+
+/* $ Particulars */
+
+/* Because DAFAH and its entry points must keep track of what */
+/* files are open at any given time, it is important that DAF */
+/* files be closed only with DAFCLS, to prevent the remaining */
+/* DAF routines from failing, sometimes mysteriously. */
+
+/* Note that when a file is opened more than once for read access, */
+/* DAFOPR returns the same handle each time it is re-opened. */
+/* Each time the file is closed, DAFCLS checks to see if any other */
+/* claims on the file are still active before physically closing */
+/* the file. */
+
+/* $ Examples */
+
+/* In the following code fragment, the arrays in a file are */
+/* examined in order to determine whether the file contains */
+/* any arrays whose names begin with the word TEST. */
+/* The complete names for these arrays are printed to */
+/* the screen. The file is closed at the end of the search. */
+
+/* CALL DAFOPR ( FNAME, HANDLE ) */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+/* CALL DAFGN ( NAME ) */
+
+/* IF ( NAME(1:5) .EQ. 'TEST ' ) THEN */
+/* WRITE (*,*) NAME */
+/* END IF */
+
+/* CALL DAFFNA ( FOUND ) */
+/* END DO */
+
+/* CALL DAFCLS ( HANDLE ) */
+
+/* Note that if the file has been opened already by a DAF routine */
+/* at some other place in the calling program, it remains open. */
+/* This makes it possible to examine files that have been opened for */
+/* use by other modules without interfering with the operation of */
+/* those routines. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 8.1.0, 02-APR-2002 (FST) */
+
+/* This routine was updated to accomodate changes to the */
+/* handle manager interface. See DAFAH's Revision section */
+/* for details. */
+
+/* - SPICELIB Version 8.0.0, 13-NOV-2001 (FST) */
+
+/* This routine was updated to utilize the new handle manager */
+/* software to manage binary file formats and consolidated */
+/* I/O code. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 2.0.3, 29-SEP-1993 (KRG) */
+
+/* Removed references to specific DAF file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 2.0.2, 25-FEB-1993 (JML) */
+
+/* A minor error in the particulars section of the header was */
+/* corrected. It formerly stated that a file could be open more */
+/* than once for read or write access instead of just read access. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 03-SEP-1991 (NJB) (WLT) */
+
+/* This routine was updated so that it now keeps current the set */
+/* of DAF handles returned by DAFHOF. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* close daf */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 03-SEP-1991 (NJB) (WLT) */
+
+/* Upgraded to support file handle checking routines */
+/* DAFHOF and DAFSIH. DAFCLS now initializes the file */
+/* handle list if necessary, and removes from the list */
+/* the handles of files it closes. */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFCLS", (ftnlen)6);
+ }
+
+/* Initialize the handle list, if necessary. */
+
+ if (first) {
+ ssizei_(&c__1000, fhlist);
+ first = FALSE_;
+ }
+
+/* Is this file even open? If so, decrement the number of links */
+/* to the file. If the number of links drops to zero, physically */
+/* close the file and remove it from the file buffer. */
+
+/* If the file is not open: no harm, no foul. */
+
+ findex = isrchi_(handle, &nft, fthan);
+ if (findex > 0) {
+ ftlnk[(i__1 = findex - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("ftlnk",
+ i__1, "dafah_", (ftnlen)3042)] = ftlnk[(i__2 = findex - 1) <
+ 1000 && 0 <= i__2 ? i__2 : s_rnge("ftlnk", i__2, "dafah_", (
+ ftnlen)3042)] - 1;
+ if (ftlnk[(i__1 = findex - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftlnk", i__1, "dafah_", (ftnlen)3044)] == 0) {
+ zzddhcls_(handle, "DAF", &c_false, (ftnlen)3);
+ i__1 = nft - 1;
+ for (i__ = findex; i__ <= i__1; ++i__) {
+ fthan[(i__2 = i__ - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "fthan", i__2, "dafah_", (ftnlen)3049)] = fthan[(i__4
+ = i__) < 1000 && 0 <= i__4 ? i__4 : s_rnge("fthan",
+ i__4, "dafah_", (ftnlen)3049)];
+ ftlnk[(i__2 = i__ - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "ftlnk", i__2, "dafah_", (ftnlen)3050)] = ftlnk[(i__4
+ = i__) < 1000 && 0 <= i__4 ? i__4 : s_rnge("ftlnk",
+ i__4, "dafah_", (ftnlen)3050)];
+ ftnd[(i__2 = i__ - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "ftnd", i__2, "dafah_", (ftnlen)3051)] = ftnd[(i__4 =
+ i__) < 1000 && 0 <= i__4 ? i__4 : s_rnge("ftnd", i__4,
+ "dafah_", (ftnlen)3051)];
+ ftni[(i__2 = i__ - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "ftni", i__2, "dafah_", (ftnlen)3052)] = ftni[(i__4 =
+ i__) < 1000 && 0 <= i__4 ? i__4 : s_rnge("ftni", i__4,
+ "dafah_", (ftnlen)3052)];
+ }
+ --nft;
+
+/* Delete the handle from our handle set. */
+
+ removi_(handle, fhlist);
+ }
+ }
+ chkout_("DAFCLS", (ftnlen)6);
+ return 0;
+/* $Procedure DAFHSF ( DAF, handle to summary format ) */
+
+L_dafhsf:
+/* $ Abstract */
+
+/* Return the summary format associated with a handle. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER ND */
+/* INTEGER NI */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of a DAF file. */
+/* ND O Number of double precision components in summaries. */
+/* NI O Number of integer components in summaries. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a previously opened */
+/* DAF file. */
+
+/* $ Detailed_Output */
+
+/* ND, */
+/* NI are the numbers of double precision and integer */
+/* components, respectively, in each array summary */
+/* in the specified file. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified handle does not belong to any file that is */
+/* currently known to be open, the error SPICE(DAFNOSUCHHANDLE) */
+/* is signalled. */
+
+/* $ Particulars */
+
+/* The summary format must be known in order to pack or unpack */
+/* an array summary. See the DAF Required Reading for a discussion */
+/* of summary formats. */
+
+/* $ Examples */
+
+/* 1) Find the number of d.p. `words' in a DAF having an */
+/* arbitrary summary format. */
+
+
+/* PROGRAM NWORDS */
+/* C */
+/* C Count the number of d.p. words of data in a */
+/* C DAF. Exclude array summaries, reserved records, */
+/* C the file record, and character records. */
+/* C */
+/* INTEGER FILEN */
+/* PARAMETER ( FILEN = 128 ) */
+
+/* INTEGER MAXND */
+/* PARAMETER ( MAXND = 124 ) */
+
+/* INTEGER MAXNI */
+/* PARAMETER ( MAXNI = 250 ) */
+
+/* INTEGER MAXSUM */
+/* PARAMETER ( MAXSUM = 125 ) */
+
+/* CHARACTER*(FILEN) DAF */
+
+/* DOUBLE PRECISION DC ( MAXND ) */
+/* DOUBLE PRECISION SUM ( MAXSUM ) */
+
+/* INTEGER FA */
+/* INTEGER HANDLE */
+/* INTEGER IA */
+/* INTEGER IC ( MAXNI ) */
+/* INTEGER N */
+/* INTEGER ND */
+/* INTEGER NI */
+
+/* LOGICAL FOUND */
+
+/* DATA N / 0 / */
+
+/* WRITE (*,*) 'Enter file name' */
+/* READ (*,FMT='(A)') DAF */
+
+/* C */
+/* C Open the DAF and find the summary format. */
+/* C */
+/* CALL DAFOPR ( DAF, HANDLE ) */
+/* CALL DAFHSF ( HANDLE, ND, NI ) */
+
+/* C */
+/* C Start a forward search and examine each array in */
+/* C turn. */
+/* C */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+/* C */
+/* C Obtain the array summary, unpack it, and get */
+/* C the initial and final array addresses from */
+/* C the integer descriptor component. */
+/* C */
+/* CALL DAFGS ( SUM ) */
+/* CALL DAFUS ( SUM, ND, NI, DC, IC ) */
+
+/* IA = IC ( NI - 1 ) */
+/* FA = IC ( NI ) */
+
+/* N = FA - IA + 1 + N */
+
+/* CALL DAFFNA ( FOUND ) */
+
+/* END DO */
+
+/* WRITE (*,*) 'Number of d.p. words is ', N */
+
+/* END */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 8.0.0, 13-NOV-2001 (FST) */
+
+/* This routine was updated to utilize the new handle manager */
+/* software to manage binary file formats and consolidated */
+/* I/O code. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.4, 29-SEP-1993 (KRG) */
+
+/* Removed references to specific DAF file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.3, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.2, 03-SEP-1990 (NJB) */
+
+/* Example added to the $Examples section. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* handle to daf summary format */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFHSF", (ftnlen)6);
+ }
+ findex = isrchi_(handle, &nft, fthan);
+ if (findex > 0) {
+ *nd = ftnd[(i__1 = findex - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftnd", i__1, "dafah_", (ftnlen)3331)];
+ *ni = ftni[(i__1 = findex - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftni", i__1, "dafah_", (ftnlen)3332)];
+ } else {
+ setmsg_("There is no DAF open with handle = #", (ftnlen)36);
+ errint_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(DAFNOSUCHHANDLE)", (ftnlen)22);
+ }
+ chkout_("DAFHSF", (ftnlen)6);
+ return 0;
+/* $Procedure DAFHLU ( DAF, handle to logical unit ) */
+
+L_dafhlu:
+/* $ Abstract */
+
+/* Return the logical unit associated with a handle. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER UNIT */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of a DAF file. */
+/* UNIT O Corresponding logical unit. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a previously opened */
+/* DAF file. */
+
+/* $ Detailed_Output */
+
+/* UNIT is the Fortran logical unit to which the file is */
+/* connected. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If an error occurs while attempting to fetch a logical */
+/* unit, routines in the call tree process and signal any */
+/* appropriate errors. The value of UNIT in this case is */
+/* undefined. */
+
+/* $ Particulars */
+
+/* The best reason for knowing the logical unit to which a DAF */
+/* is connected is to read or write from the records reserved in a */
+/* file. Since these records are by definition invisible to the DAF */
+/* routines, you must read and write them directly. */
+
+/* $ Examples */
+
+/* In the following code fragment, the first reserved record in */
+/* a newly created DAF is used to store the name and address */
+/* of the person who created it. */
+
+/* FTYPE = 'TEST' */
+/* CALL DAFONW ( FNAME, FTYPE, 3, 6, IFNAME, 5, HANDLE ) */
+/* CALL DAFHLU ( HANDLE, UNIT ) */
+
+/* WRITE (UNIT,REC=2) 'Ellis Wyatt, JPL ', */
+/* . '4800 Oak Grove Drive ', */
+/* . 'Room 301-125A ', */
+/* . 'Pasadena, CA 91109' */
+
+/* $ Restrictions */
+
+/* 1) This routine may only be used to retrieve logical units */
+/* for DAFs loaded or created using the interfaces available */
+/* in this entry point umbrella. Using this entry point to */
+/* retrieve units for files not loaded through these interfaces */
+/* may result in unexpected behavior. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* R.E. Thurman (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 8.0.0, 13-NOV-2001 (FST) */
+
+/* This routine was updated to utilize the new handle manager */
+/* software to manage binary file formats and consolidated */
+/* I/O code. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.3, 29-SEP-1993 (KRG) */
+
+/* Removed references to specific DAF file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* Changed the example to use the new entry point DAFONW. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* daf handle to logical unit */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 8.0.0, 15-NOV-2000 (FST) */
+
+/* Successfully invoking this module has the side effect of */
+/* locking UNIT to HANDLE. This 'lock' guarentees until */
+/* HANDLE is closed (or unlocked) that the file associated */
+/* with HANDLE is always open and attached to logical unit */
+/* UNIT. To unlock a handle without closing the file, use */
+/* ZZDDHUNL, an entry point in the handle manager umbrella, */
+/* ZZDDHMAN. */
+
+/* The system can lock at most UTSIZE-SCRUNT-RSVUNT */
+/* simultaneously (see the include file 'zzddhman.inc' for */
+/* specific values of these parameters), but unnecessarily */
+/* locking handles to their logical units may cause performance */
+/* degradation. The handle manager will have less logical */
+/* units to utilize when disconnecting and reconnecting */
+/* loaded files. */
+
+/* - Beta Version 1.1.0, 1-NOV-1989 (RET) */
+
+/* DAFHLU now only checks in and checks out if the one exception */
+/* occurs. The purpose of this change was to help speed up a */
+/* routine that gets called constantly by higher level DAF */
+/* routines. */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFHLU", (ftnlen)6);
+ }
+ zzddhhlu_(handle, "DAF", &c_true, unit, (ftnlen)3);
+ chkout_("DAFHLU", (ftnlen)6);
+ return 0;
+/* $Procedure DAFLUH ( DAF, logical unit to handle ) */
+
+L_dafluh:
+/* $ Abstract */
+
+/* Return the handle associated with a logical unit. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER UNIT */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* UNIT I Logical unit connected to a DAF. */
+/* HANDLE O Corresponding DAF file handle. */
+
+/* $ Detailed_Input */
+
+/* UNIT is the logical unit to which a DAF has been */
+/* connected after it has been opened. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the handle associated with the file. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified unit is not connected to any file that is */
+/* currently loaded as a DAF, the error SPICE(DAFNOSUCHUNIT) */
+/* is signaled. The value of HANDLE returned is undefined in */
+/* this case. */
+
+/* $ Particulars */
+
+/* It is unlikely, but possible, that a calling program would know */
+/* the logical unit to which a file is connected without knowing the */
+/* handle associated with the file. DAFLUH is provided mostly for */
+/* completeness. */
+
+/* $ Examples */
+
+/* In the following code fragment, the handle associated with */
+/* a DAF is retrieved using the logical unit to which the */
+/* file is connected. The handle is then used to determine the */
+/* name of the file. */
+
+/* CALL DAFLUH ( UNIT, HANDLE ) */
+/* CALL DAFHFN ( HANDLE, FNAME ) */
+
+/* $ Restrictions */
+
+/* 1) This routine may only be used to retrieve handles for logical */
+/* units connected to DAFs loaded or created using the interfaces */
+/* available in this entry point umbrella. Using this entry point */
+/* to retrieve handles for files not loaded through these */
+/* interfaces may result in unexpected behavior. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 8.0.0, 13-NOV-2001 (FST) */
+
+/* This routine was updated to utilize the new handle manager */
+/* software to manage binary file formats and consolidated */
+/* I/O code. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.3, 29-SEP-1993 (KRG) */
+
+/* Removed references to specific DAF file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* logical unit to daf handle */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFLUH", (ftnlen)6);
+ }
+ zzddhluh_(unit, handle, &found);
+ if (! found) {
+ *handle = 0;
+ setmsg_("There is no file open with unit = #", (ftnlen)35);
+ errint_("#", unit, (ftnlen)1);
+ sigerr_("SPICE(DAFNOSUCHUNIT)", (ftnlen)20);
+ chkout_("DAFLUH", (ftnlen)6);
+ return 0;
+ }
+
+/* Now make certain that the HANDLE is associated with a DAF. */
+
+ zzddhnfo_(handle, dafnam, &iarc, &ibff, &iamh, &found, (ftnlen)255);
+ if (iarc != 1) {
+ *handle = 0;
+ setmsg_("The file, '#', connected to unit # is not a DAF.", (ftnlen)
+ 48);
+ errfnm_("#", unit, (ftnlen)1);
+ errint_("#", unit, (ftnlen)1);
+ sigerr_("SPICE(DAFNOSUCHUNIT)", (ftnlen)20);
+ chkout_("DAFLUH", (ftnlen)6);
+ return 0;
+ }
+ chkout_("DAFLUH", (ftnlen)6);
+ return 0;
+/* $Procedure DAFHFN ( DAF, handle to file name ) */
+
+L_dafhfn:
+/* $ Abstract */
+
+/* Return the name of the file associated with a handle. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* CHARACTER*(*) FNAME */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of a DAF file. */
+/* FNAME O Corresponding file name. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a previously opened */
+/* DAF file. */
+
+/* $ Detailed_Output */
+
+/* UNIT is the name of the file. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified handle does not belong to any file that is */
+/* currently known to be loaded as a DAF, the error */
+/* SPICE(DAFNOSUCHHANDLE) is signaled. */
+
+/* $ Particulars */
+
+/* It may be desirable to recover the names of one or more DAF */
+/* files in a different part of the program from the one in which */
+/* they were opened. Note that the names returned by DAFHFN may */
+/* not be identical to the names used to open the files. Under */
+/* most operating systems, a particular file can be accessed using */
+/* many different names. DAFHFN returns one of them. */
+
+/* $ Examples */
+
+/* In the following code fragment, the name of a DAF is */
+/* recovered using the handle associated with the file. */
+
+/* CALL DAFOPR ( 'sample.DAF', HANDLE ) */
+/* . */
+/* . */
+
+/* CALL DAFHFN ( HANDLE, FNAME ) */
+
+/* Depending on the circumstances (operating system, compiler, */
+/* default directory) the value of FNAME might resemble any of */
+/* the following: */
+
+/* 'USER$DISK:[WYATT.IMAGES]SAMPLE.DAF;4' */
+
+/* '/wyatt/images/sample.DAF' */
+
+/* 'A:\IMAGES\SAMPLE.DAF' */
+
+/* On the other hand, it might not. */
+
+/* $ Restrictions */
+
+/* 1) This routine may only be used to retrieve the names of DAFs */
+/* loaded or created using the interfaces available in this entry */
+/* point umbrella. Using this entry point to retrieve names for */
+/* files not loaded through these interfaces may result in */
+/* unexpected behavior. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* J.M. Lynch (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 8.0.0, 13-NOV-2001 (FST) */
+
+/* This routine was updated to utilize the new handle manager */
+/* software to manage binary file formats and consolidated */
+/* I/O code. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.1.1, 29-SEP-1993 (KRG) */
+
+/* Removed references to specific DAF file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.1.0, 25-FEB-1993 (JML) */
+
+/* IOSTAT is checked after the INQUIRE statement. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* daf handle to file name */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFHFN", (ftnlen)6);
+ }
+ zzddhnfo_(handle, dafnam, &iarc, &ibff, &iamh, &found, (ftnlen)255);
+ if (! found || iarc != 1) {
+ setmsg_("There is no file open with handle = #", (ftnlen)37);
+ errint_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(DAFNOSUCHHANDLE)", (ftnlen)22);
+ chkout_("DAFHFN", (ftnlen)6);
+ return 0;
+ }
+ s_copy(fname, dafnam, fname_len, (ftnlen)255);
+ chkout_("DAFHFN", (ftnlen)6);
+ return 0;
+/* $Procedure DAFFNH ( DAF, file name to handle ) */
+
+L_daffnh:
+/* $ Abstract */
+
+/* Return handle associated with a file name. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) FNAME */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I Name of a DAF file. */
+/* HANDLE O Corresponding DAF file handle. */
+
+/* $ Detailed_Input */
+
+/* FNAME is the name of a previously opened DAF file. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the handle associated with the file. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified name does not specify any file currently known */
+/* to be loaded as a DAF the error SPICE(DAFNOSUCHFILE) is */
+/* signaled. The value of HANDLE is undefined in this case. */
+
+/* 2) If the file does not exist, an error is signaled by routines */
+/* in the call tree of this routine. The value of HANDLE is */
+/* undefined in this case. */
+
+/* 3) Any I/O errors generated in the process of connecting the */
+/* specified name with a handle cause errors to be signaled */
+/* by routines in the call tree of this routine. The value of */
+/* HANDLE is undefined in this case. */
+
+/* $ Particulars */
+
+/* It is sometimes easier to work with file names (which are */
+/* meaningful, and often predictable) than with file handles */
+/* (which are neither), especially in interactive situations. */
+/* However, nearly every DAF routines requires that you use file */
+/* handles to refer to files. DAFFNH is provided to bridge the gap */
+/* between the two representations. */
+
+/* $ Examples */
+
+/* In the following code fragment, the handle associated with a */
+/* DAF is recovered using the name of the file. */
+
+/* CALL DAFOPR ( 'sample.DAF', HANDLE ) */
+/* . */
+/* . */
+
+/* CALL DAFFNH ( 'sample.DAF', HANDLE ) */
+
+/* $ Restrictions */
+
+/* 1) Only file names of DAFs loaded with interfaces present in */
+/* this entry point umbrella should be passed into this routine. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* J.M. Lynch (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 8.1.0, 02-APR-2002 (FST) */
+
+/* Fixed a bug, where an error was signaled but the call to */
+/* CHKOUT and the RETURN statement were omitted. */
+
+/* - SPICELIB Version 8.0.0, 13-NOV-2001 (FST) */
+
+/* This routine was updated to utilize the new handle manager */
+/* software to manage binary file formats and consolidated */
+/* I/O code. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 2.0.1, 29-SEP-1993 (KRG) */
+
+/* Removed references to specific DAF file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 2.0.0, 25-FEB-1993 (JML) */
+
+/* The INQUIRE statement that checks if the file is open now also */
+/* checks that the file exists. Two new exceptions were added as */
+/* a result of this change. */
+
+/* A RETURN statement was added after the error signalled when */
+/* the file is not open. */
+
+/* The file name is checked to see if it is blank. */
+
+/* The file name string that is passed to the FORTRAN INQUIRE */
+/* statement has been chopped at the last non-blank character. */
+
+/* - SPICELIB Version 1.1.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.1.1, 18-SEP-1991 (HAN) */
+
+/* The Revisions section was incorrectly named Version. This has */
+/* been fixed. */
+
+/* - SPICELIB Version 1.1.0, 5-NOV-1990 (HAN) */
+
+/* Call to CHKIN was corrected. The module was checking in */
+/* as 'DAFFHN'. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* file name to daf handle */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 8.0.0, 15-NOV-2000 (FST) */
+
+/* In previous version of DAFAH, this module simply */
+/* performed an INQUIRE on FNAME and looked in the */
+/* file table for the logical unit returned. */
+
+/* The integration of the new handle manager interfaces */
+/* into this entry point has the possibility of increasing */
+/* the complexity of this routine when more than UTSIZE */
+/* files are loaded. Essentially, when given an arbitrary */
+/* name, a total of FTSIZE INQUIRE statements may be executed */
+/* to accurately connect FNAME with HANDLE. See ZZDDHFNH and */
+/* ZZDDHF2H for details. */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFFNH", (ftnlen)6);
+ }
+ zzddhfnh_(fname, handle, &found, fname_len);
+ if (! found) {
+ *handle = 0;
+ setmsg_("There is no file in the DAF table with file name = '#'", (
+ ftnlen)54);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(DAFNOSUCHFILE)", (ftnlen)20);
+ chkout_("DAFFNH", (ftnlen)6);
+ return 0;
+ }
+
+/* Now make certain that HANDLE is associated with a DAF. */
+
+ zzddhnfo_(handle, dafnam, &iarc, &ibff, &iamh, &found, (ftnlen)255);
+ if (iarc != 1) {
+ *handle = 0;
+ setmsg_("The file, '#', is not a DAF.", (ftnlen)28);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(DAFNOSUCHFILE)", (ftnlen)20);
+ chkout_("DAFFNH", (ftnlen)6);
+ return 0;
+ }
+ chkout_("DAFFNH", (ftnlen)6);
+ return 0;
+/* $Procedure DAFHOF ( DAF, handles of open files ) */
+
+L_dafhof:
+/* $ Abstract */
+
+/* Return a SPICELIB set containing the handles of all currently */
+/* open DAFS. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+/* SETS */
+
+/* $ Keywords */
+
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER LBCELL */
+/* PARAMETER ( LBCELL = -5 ) */
+
+/* INTEGER FHSET ( LBCELL : * ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FHSET O A set containing handles of currently open DAFS. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* FHSET is a SPICELIB set containing the file handles of */
+/* all currently open DAFs. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the set FHSET is not initialized, the error will be */
+/* diagnosed by routines called by this routine. */
+
+/* 2) If the set FHSET is too small to accommodate the set of */
+/* handles to be returned, the error will be diagnosed by */
+/* routines called by this routine. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine allows subroutines to test file handles for */
+/* validity before performing operations on them, such as */
+/* finding the name of the file designated by a handle. Many */
+/* DAF operations on handles cause errors to be signalled if */
+/* the handles are invalid. */
+
+/* $ Examples */
+
+/* 1) Find out how may DAFs are open for writing. */
+
+/* C */
+/* C Find out which DAFs are open. */
+/* C */
+/* CALL DAFHOF ( FHSET ) */
+
+/* C */
+/* C Count the ones open for writing. These have */
+/* C negative file handles. */
+/* C */
+/* COUNT = 0 */
+
+/* DO I = 1, CARDC(FHSET) */
+
+/* IF ( FHSET(I) .LT. 0 ) THEN */
+/* COUNT = COUNT + 1 */
+/* END IF */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 8.0.0, 13-NOV-2001 (FST) */
+
+/* This routine was updated to utilize the new handle manager */
+/* software to manage binary file formats and consolidated */
+/* I/O code. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 03-SEP-1991 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* return the set of handles for open daf files */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFHOF", (ftnlen)6);
+ }
+
+/* Initialize the handle list, if necessary. */
+
+ if (first) {
+ ssizei_(&c__1000, fhlist);
+ first = FALSE_;
+ }
+
+/* Just stuff our local list into the set. */
+
+ copyi_(fhlist, fhset);
+ chkout_("DAFHOF", (ftnlen)6);
+ return 0;
+/* $Procedure DAFSIH ( DAF, signal invalid handles ) */
+
+L_dafsih:
+/* $ Abstract */
+
+/* Signal an error if a DAF file handle does not designate a DAF */
+/* that is open for a specified type of access. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+/* ERROR */
+/* SETS */
+
+/* $ Keywords */
+
+/* DAF */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* CHARACTER*(*) ACCESS */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I HANDLE to be validated. */
+/* ACCESS I String indicating access type. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a DAF handle to validate. For HANDLE to be */
+/* considered valid, it must specify a DAF that is */
+/* open for the type of access specified by the input */
+/* argument ACCESS. */
+
+
+/* ACCESS is a string indicating the type of access that */
+/* the DAF specified by the input argument HANDLE */
+/* must be open for. The values of ACCESS may be */
+
+
+/* 'READ' File must be open for read access */
+/* by DAF routines. All open DAFs */
+/* may be read. */
+
+/* 'WRITE' File must be open for write access */
+/* by DAF routines. */
+
+/* Note that files open for write */
+/* access may be read as well as */
+/* written. */
+
+
+/* Leading and trailing blanks in ACCESS are ignored, */
+/* and case is not significant. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input argument ACCESS has an unrecognized value, */
+/* the error SPICE(INVALIDOPTION) is signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine signals the error SPICE(DAFINVALIDACCESS) if the */
+/* DAF designated by the input argument HANDLE is not open */
+/* for the specified type of access. If HANDLE does not designate */
+/* an open DAF, the error SPICE(DAFNOSUCHHANDLE) is signalled. */
+
+/* This routine allows subroutines to test file handles for */
+/* validity before performing operations on them, such as */
+/* finding the name of the file designated by a handle. Many */
+/* DAF operations on handles may cause unpredictable program */
+/* behavior if the handles are invalid. This routine should */
+/* be used in situations where the appropriate action to take upon */
+/* determining that a handle is invalid is to signal an error. */
+/* DAFSIH centralizes the error response for this type of error in a */
+/* single routine. */
+
+/* In cases where it is necessary to determine the validity of a */
+/* file handle, but it is not an error for the handle to refer */
+/* to a closed file, the entry point DAFHOF should be used instead */
+/* of DAFSIH. */
+
+/* $ Examples */
+
+/* 1) Add data to a DAF specified by a file handle. Signal an */
+/* error if the file is not open for writing. Check the */
+/* SPICELIB error status function FAILED after calling */
+/* DAFSIH, so that the routine will return if DAFSIH */
+/* signalled an error (we're presuming that this code */
+/* fragment would be used in a subroutine). */
+
+/* C */
+/* C Check that HANDLE is valid, then add data to the */
+/* C file specified by HANDLE. */
+/* C */
+/* CALL DAFSIH ( HANDLE, 'WRITE' ) */
+
+/* IF ( FAILED() ) THEN */
+/* RETURN */
+/* END IF */
+
+/* CALL DAFBNA ( HANDLE, SUM, NAME ) */
+/* CALL DAFADA ( DATA, N ) */
+/* CALL DAFENA */
+
+/* 2) Find the size of an array in a DAF specified by a file */
+/* handle. Signal an error if the file is not open for reading. */
+
+/* C */
+/* C Check that HANDLE is valid, then obtain the */
+/* C current array summary and compute the size of */
+/* C the current array. */
+/* C */
+/* CALL DAFSIH ( HANDLE, 'READ' ) */
+
+/* IF ( FAILED() ) THEN */
+/* RETURN */
+/* END IF */
+
+/* C */
+/* C Obtain the summary format, then the integer and d.p. */
+/* C components of the summary. Finally, compute the */
+/* C array length. */
+/* C */
+/* CALL DAFHSF ( HANDLE, ND, NI ) */
+/* CALL DAFGS ( SUMMRY ) */
+/* CALL DAFUS ( SUMMRY, ND, NI, DC, IC ) */
+
+/* IA = IC( NI - 1 ) */
+/* FA = IC( NI ) */
+/* LENGTH = FA - IA + 1 */
+
+/* 3) Make sure that a file handle designates an open DAF. Signal */
+/* an error if it does not. */
+
+/* Note that if a DAF is open at all, read access is allowed. */
+
+/* CALL DAFSIH ( HANDLE, 'READ' ) */
+
+/* IF ( FAILED() ) THEN */
+/* RETURN */
+/* END IF */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* J.M. Lynch (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 8.0.0, 13-NOV-2001 (FST) */
+
+/* This routine was updated to utilize the new handle manager */
+/* software to manage binary file formats and consolidated */
+/* I/O code. */
+
+/* - SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.2.1, 29-SEP-1993 (KRG) */
+
+/* Removed references to specific DAF file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.2.0, 25-FEB-1993 (JML) */
+
+/* IOSTAT is now checked after the INQUIRE statement. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 03-SEP-1991 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* signal an error for invalid daf handles */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFSIH", (ftnlen)6);
+ }
+
+/* Initialize the handle list, if necessary. */
+
+ if (first) {
+ ssizei_(&c__1000, fhlist);
+ first = FALSE_;
+ }
+
+/* Get an upper case, left-justified copy of ACCESS. */
+
+ ljust_(access, acc, access_len, (ftnlen)10);
+ ucase_(acc, acc, (ftnlen)10, (ftnlen)10);
+
+/* Make sure we recognize the access type specified by the caller. */
+
+ if (s_cmp(acc, "READ", (ftnlen)10, (ftnlen)4) != 0 && s_cmp(acc, "WRITE",
+ (ftnlen)10, (ftnlen)5) != 0) {
+ setmsg_("Unrecognized access type. Type was #. ", (ftnlen)39);
+ errch_("#", access, (ftnlen)1, access_len);
+ sigerr_("SPICE(INVALIDOPTION)", (ftnlen)20);
+ chkout_("DAFSIH", (ftnlen)6);
+ return 0;
+ }
+
+/* Retrieve information about this HANDLE. */
+
+ zzddhnfo_(handle, dafnam, &iarc, &ibff, &iamh, &found, (ftnlen)255);
+
+/* See whether the input handle is in our list at all. It's */
+/* unlawful for the handle to be absent. All open DAFs are */
+/* readable, so in the case that ACC is 'READ', we're done if */
+/* the DAF is open. */
+
+ if (! found || ! elemi_(handle, fhlist)) {
+ setmsg_("There is no file open with handle = #", (ftnlen)37);
+ errint_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(DAFNOSUCHHANDLE)", (ftnlen)22);
+ chkout_("DAFSIH", (ftnlen)6);
+ return 0;
+
+/* If the access type is 'WRITE', the DAF must be open for writing. */
+/* This is not the case if the value of IAMH returned from the handle */
+/* manager is not READ. */
+
+ } else if (s_cmp(acc, "WRITE", (ftnlen)10, (ftnlen)5) == 0 && iamh == 1) {
+ setmsg_("DAF not open for write. Handle = #, file = '#'", (ftnlen)47)
+ ;
+ errint_("#", handle, (ftnlen)1);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(DAFINVALIDACCESS)", (ftnlen)23);
+ chkout_("DAFSIH", (ftnlen)6);
+ return 0;
+ }
+
+/* The DAF's handle is o.k. */
+
+ chkout_("DAFSIH", (ftnlen)6);
+ return 0;
+} /* dafah_ */
+
+/* Subroutine */ int dafah_(char *fname, char *ftype, integer *nd, integer *
+ ni, char *ifname, integer *resv, integer *handle, integer *unit,
+ integer *fhset, char *access, ftnlen fname_len, ftnlen ftype_len,
+ ftnlen ifname_len, ftnlen access_len)
+{
+ return dafah_0_(0, fname, ftype, nd, ni, ifname, resv, handle, unit,
+ fhset, access, fname_len, ftype_len, ifname_len, access_len);
+ }
+
+/* Subroutine */ int dafopr_(char *fname, integer *handle, ftnlen fname_len)
+{
+ return dafah_0_(1, fname, (char *)0, (integer *)0, (integer *)0, (char *)
+ 0, (integer *)0, handle, (integer *)0, (integer *)0, (char *)0,
+ fname_len, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dafopw_(char *fname, integer *handle, ftnlen fname_len)
+{
+ return dafah_0_(2, fname, (char *)0, (integer *)0, (integer *)0, (char *)
+ 0, (integer *)0, handle, (integer *)0, (integer *)0, (char *)0,
+ fname_len, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dafonw_(char *fname, char *ftype, integer *nd, integer *
+ ni, char *ifname, integer *resv, integer *handle, ftnlen fname_len,
+ ftnlen ftype_len, ftnlen ifname_len)
+{
+ return dafah_0_(3, fname, ftype, nd, ni, ifname, resv, handle, (integer *)
+ 0, (integer *)0, (char *)0, fname_len, ftype_len, ifname_len, (
+ ftnint)0);
+ }
+
+/* Subroutine */ int dafopn_(char *fname, integer *nd, integer *ni, char *
+ ifname, integer *resv, integer *handle, ftnlen fname_len, ftnlen
+ ifname_len)
+{
+ return dafah_0_(4, fname, (char *)0, nd, ni, ifname, resv, handle, (
+ integer *)0, (integer *)0, (char *)0, fname_len, (ftnint)0,
+ ifname_len, (ftnint)0);
+ }
+
+/* Subroutine */ int dafcls_(integer *handle)
+{
+ return dafah_0_(5, (char *)0, (char *)0, (integer *)0, (integer *)0, (
+ char *)0, (integer *)0, handle, (integer *)0, (integer *)0, (char
+ *)0, (ftnint)0, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dafhsf_(integer *handle, integer *nd, integer *ni)
+{
+ return dafah_0_(6, (char *)0, (char *)0, nd, ni, (char *)0, (integer *)0,
+ handle, (integer *)0, (integer *)0, (char *)0, (ftnint)0, (ftnint)
+ 0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dafhlu_(integer *handle, integer *unit)
+{
+ return dafah_0_(7, (char *)0, (char *)0, (integer *)0, (integer *)0, (
+ char *)0, (integer *)0, handle, unit, (integer *)0, (char *)0, (
+ ftnint)0, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dafluh_(integer *unit, integer *handle)
+{
+ return dafah_0_(8, (char *)0, (char *)0, (integer *)0, (integer *)0, (
+ char *)0, (integer *)0, handle, unit, (integer *)0, (char *)0, (
+ ftnint)0, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dafhfn_(integer *handle, char *fname, ftnlen fname_len)
+{
+ return dafah_0_(9, fname, (char *)0, (integer *)0, (integer *)0, (char *)
+ 0, (integer *)0, handle, (integer *)0, (integer *)0, (char *)0,
+ fname_len, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int daffnh_(char *fname, integer *handle, ftnlen fname_len)
+{
+ return dafah_0_(10, fname, (char *)0, (integer *)0, (integer *)0, (char *)
+ 0, (integer *)0, handle, (integer *)0, (integer *)0, (char *)0,
+ fname_len, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dafhof_(integer *fhset)
+{
+ return dafah_0_(11, (char *)0, (char *)0, (integer *)0, (integer *)0, (
+ char *)0, (integer *)0, (integer *)0, (integer *)0, fhset, (char *
+ )0, (ftnint)0, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dafsih_(integer *handle, char *access, ftnlen access_len)
+{
+ return dafah_0_(12, (char *)0, (char *)0, (integer *)0, (integer *)0, (
+ char *)0, (integer *)0, handle, (integer *)0, (integer *)0,
+ access, (ftnint)0, (ftnint)0, (ftnint)0, access_len);
+ }
+
diff --git a/ext/spice/src/cspice/dafana.c b/ext/spice/src/cspice/dafana.c
new file mode 100644
index 0000000000..499bc3fdc6
--- /dev/null
+++ b/ext/spice/src/cspice/dafana.c
@@ -0,0 +1,2457 @@
+/* dafana.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1000 = 1000;
+static integer c__20 = 20;
+static integer c__1 = 1;
+static integer c__128 = 128;
+
+/* $Procedure DAFANA ( DAF, add new array ) */
+/* Subroutine */ int dafana_0_(int n__, integer *handle, doublereal *sum,
+ char *name__, doublereal *data, integer *n, ftnlen name_len)
+{
+ /* Initialized data */
+
+ static logical first = TRUE_;
+ static integer sthead = -1;
+ static integer stfptr = -1;
+
+ /* System generated locals */
+ integer i__1, i__2, i__3, i__4, i__5;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ static integer cloc, dloc, free, stfh[20], word, prev, next, i__, p;
+ extern logical elemi_(integer *, integer *);
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafps_(integer *,
+ integer *, doublereal *, integer *, doublereal *);
+ static integer bward;
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *);
+ static integer fward;
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen),
+ moved_(doublereal *, integer *, doublereal *);
+ static logical found;
+ static integer nextp;
+ static doublereal dc[124];
+ static integer ic[250], nd;
+ extern logical failed_(void);
+ static char dafnam[255];
+ static integer ni;
+ extern /* Subroutine */ int dafhof_(integer *), dafhfn_(integer *, char *,
+ ftnlen), dafwda_(integer *, integer *, integer *, doublereal *),
+ dafhsf_(integer *, integer *, integer *), dafsih_(integer *, char
+ *, ftnlen);
+ static char ifname[60];
+ extern /* Subroutine */ int cleard_(integer *, doublereal *), dafrcr_(
+ integer *, integer *, char *, ftnlen), dafrdr_(integer *, integer
+ *, integer *, integer *, doublereal *, logical *), dafrfr_(
+ integer *, integer *, integer *, char *, integer *, integer *,
+ integer *, ftnlen);
+ static char namrec[1000];
+ static logical staddg[20];
+ extern /* Subroutine */ int dafwdr_(integer *, integer *, doublereal *),
+ dafwcr_(integer *, integer *, char *, ftnlen), dafarw_(integer *,
+ integer *, integer *), dafrwa_(integer *, integer *, integer *),
+ errhan_(char *, integer *, ftnlen);
+ static integer stbegn[20];
+ extern /* Subroutine */ int dafwfr_(integer *, integer *, integer *, char
+ *, integer *, integer *, integer *, ftnlen);
+ static integer stfree[20];
+ static char stname[1000*20];
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ static integer narray;
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ static doublereal sumrec[128];
+ static char stifnm[60*20];
+ static integer namsiz, opnset[1006];
+ extern /* Subroutine */ int ssizei_(integer *, integer *);
+ static integer stlast[20];
+ extern /* Subroutine */ int setmsg_(char *, ftnlen);
+ extern logical return_(void);
+ static integer stpool[20];
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ static integer stfrst[20];
+ static doublereal stlsum[2500] /* was [125][20] */;
+ static integer sumsiz;
+
+/* $ Abstract */
+
+/* Add a new array to an existing DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* $ Abstract */
+
+/* Parameter declarations for the DAF/DAS handle manager. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF, DAS */
+
+/* $ Keywords */
+
+/* PRIVATE */
+
+/* $ Particulars */
+
+/* This include file contains parameters defining limits and */
+/* integer codes that are utilized in the DAF/DAS handle manager */
+/* routines. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* F.S. Turner (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.20.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL. */
+
+/* - SPICELIB Version 1.19.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL-CC_C. */
+
+/* - SPICELIB Version 1.18.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL-64BIT-CC_C. */
+
+/* - SPICELIB Version 1.17.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-64BIT-NATIVE_C. */
+
+/* - SPICELIB Version 1.16.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-WINDOWS-64BIT-IFORT. */
+
+/* - SPICELIB Version 1.15.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-LINUX-64BIT-GFORTRAN. */
+
+/* - SPICELIB Version 1.14.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-64BIT-MS_C. */
+
+/* - SPICELIB Version 1.13.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-INTEL_C. */
+
+/* - SPICELIB Version 1.12.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-IFORT. */
+
+/* - SPICELIB Version 1.11.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-GFORTRAN. */
+
+/* - SPICELIB Version 1.10.0, 18-MAR-2009 (BVS) */
+
+/* Updated for PC-LINUX-GFORTRAN. */
+
+/* - SPICELIB Version 1.9.0, 18-MAR-2009 (BVS) */
+
+/* Updated for MAC-OSX-GFORTRAN. */
+
+/* - SPICELIB Version 1.8.0, 19-FEB-2008 (BVS) */
+
+/* Updated for PC-LINUX-IFORT. */
+
+/* - SPICELIB Version 1.7.0, 14-NOV-2006 (BVS) */
+
+/* Updated for PC-LINUX-64BIT-GCC_C. */
+
+/* - SPICELIB Version 1.6.0, 14-NOV-2006 (BVS) */
+
+/* Updated for MAC-OSX-INTEL_C. */
+
+/* - SPICELIB Version 1.5.0, 14-NOV-2006 (BVS) */
+
+/* Updated for MAC-OSX-IFORT. */
+
+/* - SPICELIB Version 1.4.0, 14-NOV-2006 (BVS) */
+
+/* Updated for PC-WINDOWS-IFORT. */
+
+/* - SPICELIB Version 1.3.0, 26-OCT-2005 (BVS) */
+
+/* Updated for SUN-SOLARIS-64BIT-GCC_C. */
+
+/* - SPICELIB Version 1.2.0, 03-JAN-2005 (BVS) */
+
+/* Updated for PC-CYGWIN_C. */
+
+/* - SPICELIB Version 1.1.0, 03-JAN-2005 (BVS) */
+
+/* Updated for PC-CYGWIN. */
+
+/* - SPICELIB Version 1.0.1, 17-JUL-2002 */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 1.0.0, 07-NOV-2001 */
+
+/* -& */
+
+/* Unit and file table size parameters. */
+
+/* FTSIZE is the maximum number of files (DAS and DAF) that a */
+/* user may have open simultaneously. */
+
+
+/* RSVUNT is the number of units protected from being locked */
+/* to a particular handle by ZZDDHHLU. */
+
+
+/* SCRUNT is the number of units protected for use by scratch */
+/* files. */
+
+
+/* UTSIZE is the maximum number of logical units this manager */
+/* will utilize at one time. */
+
+
+/* Access method enumeration. These parameters are used to */
+/* identify which access method is associated with a particular */
+/* handle. They need to be synchronized with the STRAMH array */
+/* defined in ZZDDHGSD in the following fashion: */
+
+/* STRAMH ( READ ) = 'READ' */
+/* STRAMH ( WRITE ) = 'WRITE' */
+/* STRAMH ( SCRTCH ) = 'SCRATCH' */
+/* STRAMH ( NEW ) = 'NEW' */
+
+/* These values are used in the file table variable FTAMH. */
+
+
+/* Binary file format enumeration. These parameters are used to */
+/* identify which binary file format is associated with a */
+/* particular handle. They need to be synchronized with the STRBFF */
+/* array defined in ZZDDHGSD in the following fashion: */
+
+/* STRBFF ( BIGI3E ) = 'BIG-IEEE' */
+/* STRBFF ( LTLI3E ) = 'LTL-IEEE' */
+/* STRBFF ( VAXGFL ) = 'VAX-GFLT' */
+/* STRBFF ( VAXDFL ) = 'VAX-DFLT' */
+
+/* These values are used in the file table variable FTBFF. */
+
+
+/* Some random string lengths... more documentation required. */
+/* For now this will have to suffice. */
+
+
+/* Architecture enumeration. These parameters are used to identify */
+/* which file architecture is associated with a particular handle. */
+/* They need to be synchronized with the STRARC array defined in */
+/* ZZDDHGSD in the following fashion: */
+
+/* STRARC ( DAF ) = 'DAF' */
+/* STRARC ( DAS ) = 'DAS' */
+
+/* These values will be used in the file table variable FTARC. */
+
+
+/* For the following environments, record length is measured in */
+/* characters (bytes) with eight characters per double precision */
+/* number. */
+
+/* Environment: Sun, Sun FORTRAN */
+/* Source: Sun Fortran Programmer's Guide */
+
+/* Environment: PC, MS FORTRAN */
+/* Source: Microsoft Fortran Optimizing Compiler User's Guide */
+
+/* Environment: Macintosh, Language Systems FORTRAN */
+/* Source: Language Systems FORTRAN Reference Manual, */
+/* Version 1.2, page 12-7 */
+
+/* Environment: PC/Linux, g77 */
+/* Source: Determined by experiment. */
+
+/* Environment: PC, Lahey F77 EM/32 Version 4.0 */
+/* Source: Lahey F77 EM/32 Language Reference Manual, */
+/* page 144 */
+
+/* Environment: HP-UX 9000/750, FORTRAN/9000 Series 700 computers */
+/* Source: FORTRAN/9000 Reference-Series 700 Computers, */
+/* page 5-110 */
+
+/* Environment: NeXT Mach OS (Black Hardware), */
+/* Absoft Fortran Version 3.2 */
+/* Source: NAIF Program */
+
+
+/* The following parameter defines the size of a string used */
+/* to store a filenames on this target platform. */
+
+
+/* The following parameter controls the size of the character record */
+/* buffer used to read data from non-native files. */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Entry */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAFBNA, DAFCAD */
+/* SUM I DAFBNA */
+/* NAME I DAFBNA */
+/* DATA I DAFADA */
+/* N I DAFADA */
+/* TBSIZE P DAFANA */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAF opened for write access */
+/* by a previous call to DAFOPW or DAFOPN. */
+
+/* SUM is the summary for the array being added. */
+
+/* NAME is the name of the array being added. */
+
+/* DATA contains all or part of the data in the array. */
+
+/* N is the number of elements in DATA. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* TBSIZE is the size of the file table maintained internally */
+/* by DAFANA, TBSIZE is the maximum number of DAFs */
+/* that can be in use simultaneously by this routine. */
+
+/* $ Files */
+
+/* See argument HANDLE, above. */
+
+/* $ Exceptions */
+
+/* 1) If DAFANA is called directly, the error SPICE(BOGUSENTRY) */
+/* is signalled. */
+
+/* 2) See entry points DAFBNA, DAFADA, DAFENA, and DAFCAD */
+/* for exceptions specific to those entry points. */
+
+/* $ Particulars */
+
+/* DAFANA serves as an umbrella, allowing data to be shared by its */
+/* entry points: */
+
+/* DAFBNA Begin new array. */
+/* DAFADA Add data to array. */
+/* DAFCAD Continue adding data. */
+/* DAFENA End new array. */
+
+/* The main function of these entry points is to simplify the */
+/* addition of new arrays to existing DAFs. */
+
+/* An application can add data to a single DAF, or to multiple DAFs, */
+/* simultaneously. In the case of writing to a single DAF, the */
+/* creation of a new array requires four steps: */
+
+/* 1) Open a DAF for write access, using either DAFOPW */
+/* (if the file already exists) or DAFOPN (if it does not). */
+
+/* CALL DAFOPW ( FNAME, HANDLE ) */
+
+/* 2) Begin the new DAF by calling DAFBNA, */
+
+/* CALL DAFBNA ( HANDLE, SUM, NAME ) */
+
+/* 3) Add data to the array by calling DAFADA as many times */
+/* as necessary, */
+
+/* CALL GET_DATA ( DATA, N, FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+/* CALL DAFADA ( DATA, N ) */
+/* CALL GET_DATA ( DATA, N, FOUND ) */
+/* END DO */
+
+/* 4) End the array by calling DAFENA, */
+
+/* CALL DAFENA */
+
+/* Note that the data can be added in chunks of any size, so long */
+/* as the chunks are ordered correctly. */
+
+/* In applications that add data to multiple DAFs simultaneously, it */
+/* is necessary to specify which DAF to add data to. The DAFANA */
+/* entry points that allow specification of a DAF via a file handle */
+/* argument are DAFBNA (DAF, begin new array) and DAFCAD (DAF, */
+/* continue adding data). As in the single-DAF case, arrays are */
+/* started by calls to DAFBNA, and data is added to arrays by calls */
+/* to DAFADA. The last DAF designated by the input file handle */
+/* supplied to DAFBNA or DAFCAD is the `current DAF'. If a */
+/* DAF contains an array started by a call to DAFBNA but not yet */
+/* completed by a call to DAFENA, we call this array the `current */
+/* array' for that DAF. Each call to DAFADA will add data to the */
+/* current array in the current DAF. A call to DAFENA will make the */
+/* current array in the current DAF a permanent addition to that DAF. */
+
+/* The notion of `current DAF' as discussed here applies only to */
+/* DAFs acted upon by entry points of DAFANA. In DAFFA, there is a */
+/* DAF that is treated as the `current DAF' for searching; there is */
+/* no connection between the DAFs regarded as current by DAFANA and */
+/* DAFFA. */
+
+/* In the following example, we write data obtained from the routine */
+/* GET_DATA into two separate DAFs. The first N/2 elements of the */
+/* array DATA will be written to the first DAF; the rest of the */
+/* array will be written to the second DAF. */
+
+
+/* 1) Open the DAFs for write access, using either DAFOPW */
+/* (if the files already exist) or DAFOPN (if they do not). */
+
+/* CALL DAFOPW ( FNAME1, HANDL1 ) */
+/* CALL DAFOPW ( FNAME2, HANDL2 ) */
+
+/* 2) Begin the new DAFs by calling DAFBNA, */
+
+/* CALL DAFBNA ( HANDL1, SUM1, NAME1 ) */
+/* CALL DAFBNA ( HANDL2, SUM2, NAME2 ) */
+
+/* 3) Add data to the arrays by calling DAFCAD and DAFADA as many */
+/* times as necessary, selecting the file to add data to by */
+/* calling DAFCAD: */
+
+/* CALL GET_DATA ( DATA, N, FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+
+/* CALL DAFCAD ( HANDL1 ) */
+/* CALL DAFADA ( DATA, N/2 ) */
+
+/* CALL DAFCAD ( HANDL2 ) */
+/* CALL DAFADA ( DATA( N/2 + 1 ), N - N/2 ) */
+
+/* CALL GET_DATA ( DATA, N, FOUND ) */
+
+/* END DO */
+
+/* 4) End each array by calling DAFENA, selecting the file */
+/* in which to end the array by calling DAFCAD: */
+
+/* CALL DAFCAD ( HANDL1 ) */
+/* CALL DAFENA */
+
+/* CALL DAFCAD ( HANDL2 ) */
+/* CALL DAFENA */
+
+
+/* $ Examples */
+
+/* 1) The following code fragment illustrates one possible way */
+/* to copy an array from one DAF (with handle ORIGIN) to another */
+/* (with handle COPY), SIZE words at a time. */
+
+/* CALL DAFGS ( SUM ) */
+/* CALL DAFGN ( NAME ) */
+/* CALL DAFHSF ( ORIGIN, ND, NI ) */
+/* CALL DAFUS ( SUM, ND, NI, DC, IC ) */
+
+/* BEGIN = IC(NI-1) */
+/* END = IC(NI ) */
+
+/* CALL DAFBNA ( COPY, SUM, NAME ) */
+
+/* DO WHILE ( BEGIN .LE. END ) */
+/* CHUNK = MIN ( BEGIN + SIZE - 1, END ) */
+
+/* CALL DAFRDA ( ORIGIN, BEGIN, CHUNK, DATA ) */
+/* CALL DAFADA ( DATA, SIZE ) */
+
+/* BEGIN = BEGIN + SIZE */
+/* END DO */
+
+/* CALL DAFENA */
+
+
+/* 2) A simple example demonstrating simultaneous addition */
+/* of data to multiple DAFs. We read data from a text */
+/* file containing three columns of numbers, and we write */
+/* the data from each column out to a separate DAF. The */
+/* format of the input text file is as follows: */
+
+/* +- -+ */
+/* | n11 n12 n13 | */
+/* | n21 n22 n23 | */
+/* | . . . | */
+/* | . . . | */
+/* | . . . | */
+/* +- -+ */
+
+/* Here the symbol nij indicates the jth number on the ith line */
+/* of the file. */
+
+/* The delimiters between the numbers in each column may be */
+/* commas or blanks. */
+
+/* The input file is called NUMBERS.TXT. The output files are */
+/* called */
+
+/* COLUMN1.DAF */
+/* COLUMN2.DAF */
+/* COLUMN3.DAF */
+
+/* To confirm that the DAFs created by this program contain the */
+/* correct contents, we will read the data from each DAF and */
+/* combine it to create a new text file call RESULT.TXT. This */
+/* file should contain the same data as NUMBERS.TXT. If */
+/* RESULT.TXT is copied as NUMBERS.TXT and used as the input for */
+/* a second run of this program, the output file RESULT.TXT */
+/* from the second program run should match, up to round-off */
+/* error in the numbers, the input file NUMBERS.TXT containing */
+/* the output of the first program run. If the numbers in */
+/* NUMBERS.TXT are integers, the match should be exact. */
+
+
+/* PROGRAM WRTDAF */
+/* C */
+/* C Read columns of d.p. numbers from a text file */
+/* C and write the data from each column into a */
+/* C separate DAF. Read these DAFs and create a */
+/* C second text file containing the same data as */
+/* C the input text file. */
+/* C */
+/* C Since we do not need to retain any descriptive */
+/* C information about the DAFs inside of the files */
+/* C themselves, we'll use a summary format having */
+/* C two integer components (the minimum--these are */
+/* C reserved for use by the DAF routines) and zero */
+/* C double precision components. */
+/* C */
+/* C The internal file names and array names will */
+/* C simply indicate the data sources. */
+/* C */
+
+/* C */
+/* C Local parameters */
+/* C */
+/* INTEGER FNMLEN */
+/* PARAMETER ( FNMLEN = 20 ) */
+
+/* INTEGER LINLEN */
+/* PARAMETER ( LINLEN = 80 ) */
+
+/* INTEGER MAXCOL */
+/* PARAMETER ( MAXCOL = 3 ) */
+
+/* INTEGER ND */
+/* PARAMETER ( ND = 0 ) */
+
+/* INTEGER NDAF */
+/* PARAMETER ( NDAF = 3 ) */
+
+/* INTEGER NI */
+/* PARAMETER ( NI = 2 ) */
+
+/* INTEGER NUMLEN */
+/* PARAMETER ( NUMLEN = 30 ) */
+
+/* INTEGER SIG */
+/* PARAMETER ( SIG = 14 ) */
+
+/* C */
+/* C Local variables */
+/* C */
+/* CHARACTER*(FNMLEN) DAF ( NDAF ) */
+/* CHARACTER*(FNMLEN) INFILE */
+/* CHARACTER*(LINLEN) LINE */
+/* CHARACTER*(NUMLEN) NUMCH ( MAXCOL ) */
+/* CHARACTER*(LINLEN) PRSERR */
+/* CHARACTER*(FNMLEN) RESULT */
+
+/* DOUBLE PRECISION DC ( 1 ) */
+/* DOUBLE PRECISION NUMBER ( MAXCOL ) */
+/* DOUBLE PRECISION SUMMRY ( 1 ) */
+
+/* INTEGER FA */
+/* INTEGER HAN ( NDAF ) */
+/* INTEGER I */
+/* INTEGER IA */
+/* INTEGER IC ( NI ) */
+/* INTEGER J */
+/* INTEGER LENGTH */
+/* INTEGER NCOLS */
+/* INTEGER PTR */
+
+/* LOGICAL EOF */
+/* LOGICAL FOUND */
+
+/* C */
+/* C Initial values */
+/* C */
+/* DATA DAF / 'COLUMN1.DAF', */
+/* . 'COLUMN2.DAF', */
+/* . 'COLUMN3.DAF' / */
+
+/* DATA INFILE / 'NUMBERS.TXT' / */
+/* DATA RESULT / 'RESULT.TXT' / */
+
+
+/* C */
+/* C Use SPICELIB call tracing. */
+/* C */
+/* CALL CHKIN ( 'WRTDAF' ) */
+
+/* C */
+/* C Create the new DAFs, and start a new array in each */
+/* C one. Just use the file name for the internal file */
+/* C name and array name, for each DAF. No assignments */
+/* C are required for the array summaries. */
+/* C */
+/* DO I = 1, 3 */
+/* CALL DAFOPN ( DAF(I), ND, NI, DAF(I), 0, HAN(I) ) */
+/* CALL DAFBNA ( HAN(I), SUMMRY, DAF(I) ) */
+/* END DO */
+
+/* C */
+/* C Now read numbers from the text file, line by line, */
+/* C and add the numbers from each column to the */
+/* C corresponding DAF. */
+/* C */
+/* CALL RDTEXT ( INFILE, LINE, EOF ) */
+
+/* DO WHILE ( .NOT. EOF ) */
+/* C */
+/* C Parse the numbers in the input line. They */
+/* C may be separated by commas or blanks (the second */
+/* C argument of LPARSM is a list of allowed */
+/* C delimiters). Parse the strings found by LPARSM. */
+/* C */
+/* C For brevity, we won't check the number of columns */
+/* C found, or the parse error flag. */
+/* C */
+/* CALL LPARSM ( LINE, ' ,', MAXCOL, NCOLS, NUMCH ) */
+
+/* DO I = 1, NCOLS */
+/* CALL NPARSD ( NUMCH(I), NUMBER(I), PRSERR, PTR) */
+/* END DO */
+
+/* C */
+/* C Add the number from the ith column to the array */
+/* C in the ith DAF. We'll use DAFCAD to select */
+/* C the correct DAF to add data to. */
+/* C */
+/* DO I = 1, NDAF */
+/* CALL DAFCAD ( HAN(I) ) */
+/* CALL DAFADA ( NUMBER(I), 1 ) */
+/* END DO */
+
+/* C */
+/* C Get the next line. */
+/* C */
+/* CALL RDTEXT ( INFILE, LINE, EOF ) */
+
+/* END DO */
+
+/* C */
+/* C Finish (`end') the arrays. Again, we'll use DAFCAD */
+/* C to select the DAFs in which the arrays are to be */
+/* C finished. After finishing each array, close the DAF */
+/* C containing it. */
+/* C */
+/* DO I = 1, NDAF */
+/* CALL DAFCAD ( HAN(I) ) */
+/* CALL DAFENA */
+/* CALL DAFCLS ( HAN(I) ) */
+/* END DO */
+
+/* C */
+/* C Now for the verification step. We'll try to */
+/* C build a text file containing the same data as */
+/* C the orginal input file. The format of the numbers, */
+/* C the delimiters separating the numbers, spacing, and */
+/* C non-printing characters may differ. However, if this */
+/* C file is used as the input file, and if the numbers */
+/* C used in the file are integers, WRTDAF will create an */
+/* C exact copy of it. */
+/* C */
+
+/* C */
+/* C Open the DAFs for reading. */
+/* C */
+/* DO I = 1, NDAF */
+/* CALL DAFOPR ( DAF(I), HAN(I) ) */
+/* END DO */
+
+/* C */
+/* C Obtain the start and end addresses of the */
+/* C data in each DAF. To do this, we'll need to */
+/* C obtain and unpack the array summaries. */
+/* C */
+/* C If all went well, the addresses should be the */
+/* C same for each DAF. We'll assume that the initial */
+/* C and final addresses in the first DAF are correct */
+/* C for all three. */
+/* C */
+/* CALL DAFBFS ( HAN(1) ) */
+/* CALL DAFFNA ( FOUND ) */
+/* CALL DAFGS ( SUMMRY ) */
+/* CALL DAFUS ( SUMMRY, ND, NI, DC, IC ) */
+
+/* IA = IC( NI-1 ) */
+/* FA = IC( NI ) */
+/* LENGTH = FA - IA + 1 */
+
+/* C */
+/* C Now read numbers from the DAFs and build up */
+/* C lines of text. Write these lines out to our */
+/* C output text file. */
+/* C */
+/* DO I = 0, LENGTH - 1 */
+
+/* LINE = ' ' */
+
+/* DO J = 1, NDAF */
+/* CALL DAFRDA ( HAN(J), IA+I, IA+I, NUMBER(J)) */
+/* CALL DPSTR ( NUMBER(J), SIG, NUMCH(J) ) */
+/* CALL SUFFIX ( NUMCH(J), 5, LINE ) */
+/* END DO */
+
+/* CALL WRLINE ( RESULT, LINE ) */
+
+/* END DO */
+
+/* C */
+/* C Close the output text file and the DAFs. */
+/* C */
+/* CALL CLLINE ( RESULT ) */
+
+/* DO I = 1, NDAF */
+/* CALL DAFCLS( HAN(I) ) */
+/* END DO */
+
+/* END */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 16-NOV-2001 (FST) */
+
+/* Updated the entry points of DAFANA to enable its */
+/* internal state table size, TBSIZE, to be smaller */
+/* than the file table maintained by DAFAH: FTSIZE. */
+
+/* - SPICELIB Version 2.1.0, 11-JUL-1995 (KRG) */
+
+/* Updated to remove potential compiler warnings from the */
+/* truncation of double precision numbers to integers. */
+
+/* Also changed was a numeric constant from 1.D0 to the */
+/* equivalent, but more aesthetically pleasing 1.0D0. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous writes to multiple DAFs. */
+/* The $Examples section of this routine now illustrates */
+/* usage of the routine DAFCAD. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* add new daf array */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 3.0.0, 16-NOV-2001 (FST) */
+
+/* This umbrella and its entry points were updated to */
+/* work properly with the changes in the DAF system as */
+/* a result of its utilization of the new handle manager. */
+
+/* Since DAFAH now tracks FTSIZE files as defined in */
+/* the include file 'zzddhman.inc', it was decided that */
+/* in the interest of releasing the toolkit this module */
+/* would undergo simple changes. As such most previous */
+/* references to FTSIZE in this umbrella have been replaced */
+/* with TBSIZE where appropriate. DAFBNA now signals an */
+/* error if there is not enough room to add a new DAF's */
+/* dossier to the state table. Also, after attempting to */
+/* clean up all files listed in the state table that are */
+/* not currently open, DAFBNA attempts to locate the */
+/* first dossier with STADDG set to FALSE. This is then */
+/* freed to make room for the new DAF. If DAFBNA fails */
+/* to locate such a dossier in the state table, it */
+/* signals the error SPICE(STFULL). */
+
+/* The parameter FILEN was removed, as it is defined */
+/* on an environmental basis in the include file */
+/* 'zzddhman.inc'. */
+
+
+/* - SPICELIB Version 2.1.0, 11-JUL-1995 (KRG) */
+
+/* Updated to remove potential compiler warnings from the */
+/* truncation of double precision numbers to integers. Two */
+/* assignments to NARRAY were updated, being changed from: */
+
+/* NARRAY = SUMREC(ARYCNT) */
+
+/* to */
+
+/* NARRAY = IDINT ( SUMREC(ARYCNT) ) */
+
+/* Also changed was a numeric constant from 1.D0 to the */
+/* equivalent, but more aesthetically pleasing 1.0D0. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous writes to multiple DAFs. */
+
+/* In previous versions of DAFANA, data could be added to only */
+/* one DAF array at a time. In fact, DAFAH allowed only one */
+/* DAF to be open for writing at any time. Therefore, there was */
+/* no question about which DAF was being operated on by either of */
+/* the DAFANA entry points that don't accept file handles as */
+/* input arguments: DAFADA and DAFENA. In the current version */
+/* of DAFANA, the entry points that don't accept file handles as */
+/* inputs operate on the `current DAF'. The current DAF is the */
+/* last one in which a new array was started by DAFBNA, or in */
+/* which addition of data to an array was continued by the new */
+/* entry point DAFCAD. DAFCAD was added to allow users to set */
+/* the current DAF, so that additions of data to arrays in */
+/* multiple DAFs can be interleaved. */
+
+/* Note that the notion of `current DAF' as discussed here applies */
+/* only to DAFs acted upon by entry points of DAFANA. In DAFFA, */
+/* there is a DAF that is treated as the `current DAF' for */
+/* searching; there is no connection between the DAFs regarded */
+/* as current by DAFANA and DAFFA. */
+
+/* The two principal changes to DAFANA are the addition of the */
+/* new entry point DAFCAD, and the addition of a data structure */
+/* called the `state table'. The state table is a collection of */
+/* parallel arrays that maintain information about the state */
+/* of each data addition that is currently in progress. The */
+/* state table arrays are indexed by a singly linked list pool; */
+/* this mechanism allows addition and deletion of information */
+/* about data additions without requiring movement of data */
+/* already in the state table. */
+
+/* The linked list pool contains an `active' list and a `free' */
+/* list. Nodes in the active list are used to index elements of */
+/* the state table where information about additions in progress */
+/* is stored. The head node of the active list is of particular */
+/* significance: the state information pointed to by this node */
+/* is that of the current DAF. Nodes in the free list index */
+/* elements of the state table that are available for use. */
+
+/* When an array is started in a DAF that is not already `known' */
+/* to DAFANA, information about the DAF is added to the state */
+/* table. If there are no free elements in the state table, */
+/* the routine starting the array (DAFBNA) will perform garbage */
+/* collection: the routine will test the handles of each file */
+/* about which information in stored in the state table to see */
+/* whether that file is still open. Nodes containing information */
+/* about DAFs that are no longer open will be moved to the free */
+/* list. */
+
+/* Whenever a DAF becomes the current DAF, the linked list */
+/* that indexes the state table is adjusted so that the node */
+/* pointing to information about the current DAF is at the head */
+/* of the active list. This way, a slight efficiency is gained */
+/* when repeated data additions are made to the same DAF, since */
+/* the linear search through the state table for information on */
+/* that DAF will be shortened. */
+
+/* Since the algorithms for maintenance of linked lists are well */
+/* known, they are not documented here. However, see the */
+/* internals of the SPICELIB routine SPKBSR for a nice diagram */
+/* describing a similar data structure. */
+
+/* The state table contains two arrays that are quite large: */
+/* there are buffers that contain the name and array summary for */
+/* each array under construction. A parallel situation exists */
+/* in DAFFA, where there are buffers that contain the last */
+/* character record and summary record read from each DAF. The */
+/* total storage required for these arrays (in DAFANA and DAFFA */
+/* together) is 4000 * TBSIZE bytes. For this reason, it may be */
+/* a good idea to reduce the value of TBSIZE in SPICELIB versions */
+/* for machines where memory is scarce. */
+
+/* On a completely different topic: the local declarations in */
+/* DAFANA have been alphabetized and separated by type, except */
+/* for those relating to the state table. Several hard-coded */
+/* constants have been replaced by parameters. */
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* State variables. */
+
+/* These variables define the state of each DAF to which data */
+/* is currently being added. For each DAF that we're writing to, we */
+/* maintain a copy of: */
+
+/* STFH File handle. */
+
+/* STIFNM Internal file name. */
+
+/* STADDG (`State table: adding') Flag indicating */
+/* whether addition of data to an array is in */
+/* progress. */
+
+/* STFRST Record number of initial summary record. */
+
+/* STLAST Record number of final summary record. */
+
+/* STBEGN Beginning address of new array. */
+
+/* STFREE Address of next free word. */
+
+/* STLSUM Local copy of the array summary for the current */
+/* array. */
+
+/* STNAME Local copy of the array name for the current */
+/* array. */
+
+
+/* These variables are maintained in a table of parallel arrays; */
+/* the size of the table is TBSIZE. */
+
+
+
+/* The table of state variables is indexed by a singly linked list */
+/* of pointers. This mechanism avoids the work of moving */
+/* the state variable data about as information about DAFs is */
+/* added to or deleted from the table. */
+
+/* The structure containing the linked list pointers is called a */
+/* `pool.' The pool contains a list of `active' nodes and a list */
+/* of free nodes. The head nodes of the active and free lists are */
+/* maintained as the variables STHEAD (`state table head') and */
+/* STFPTR (`state table free pointer'), respectively. Every node in */
+/* the pool is on exactly one of these lists. */
+
+
+/* The pool starts out with all of the nodes on the free list. */
+/* DAFBNA initializes the pool. As new DAFs are written to, */
+/* DAFBNA adds information about them to the state table. Every */
+/* time a DAF array is started by DAFBNA, or selected for */
+/* continuation by DAFCAD, the routine in question `moves' the */
+/* DAF's state information to the head of the active list, if the */
+/* state information is not already there. This re-organization is */
+/* accomplished by deleting the node for the DAF from its current */
+/* position in the active list and inserting the node at the head of */
+/* the list. Thus, the change is made merely by setting pointers, */
+/* not by moving chunks of data in the state table. */
+
+/* It may happen that there is no room left in the state table */
+/* to accommodate information about a new DAF. In this case, */
+/* garbage collection must be performed: DAFBNA frees all nodes in */
+/* the table that index DAFs that are not currently open. */
+
+/* Note that the routine DAFADA does not modify the state table; it */
+/* merely adds data to the DAF that is at the head of the active */
+/* list. */
+
+
+/* Other local variables */
+
+
+/* Save everything between calls */
+
+
+/* Initial values */
+
+ /* Parameter adjustments */
+ if (sum) {
+ }
+ if (data) {
+ }
+
+ /* Function Body */
+ switch(n__) {
+ case 1: goto L_dafbna;
+ case 2: goto L_dafada;
+ case 3: goto L_dafena;
+ case 4: goto L_dafcad;
+ }
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFANA", (ftnlen)6);
+ sigerr_("SPICE(BOGUSENTRY)", (ftnlen)17);
+ chkout_("DAFANA", (ftnlen)6);
+ }
+ return 0;
+/* $Procedure DAFBNA ( DAF, begin new array ) */
+
+L_dafbna:
+/* $ Abstract */
+
+/* Begin a new array in a DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* DOUBLE PRECISION SUM ( * ) */
+/* CHARACTER*(*) NAME */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Entry */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAF. */
+/* SUM I Summary of new array. */
+/* NAME I Name of new array. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAF opened for write access */
+/* by a previous call to DAFOPW or DAFOPN. */
+
+/* SUM is the summary of a new array to be added to the */
+/* specified file. The addresses (the final two integer */
+/* components) need not be filled in. */
+
+/* NAME is the name of the new array. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See argument HANDLE, above. */
+
+/* $ Exceptions */
+
+/* 1) If the input handle is not that of a DAF that is open */
+/* for writing, the error is diagnosed by routines called by */
+/* this routine. These files are implicitly of the native */
+/* binary file format. */
+
+/* 2) If the input array name is too long to fit in the number */
+/* of characters allowed by the summary format of the DAF */
+/* designated by HANDLE, the excess characters are truncated. */
+/* No error is signalled. */
+
+/* 3) If there is not enough room in the state table to add */
+/* the DAF associated with HANDLE, the error SPICE(STFULL) */
+/* is signaled. */
+
+/* $ Particulars */
+
+/* Only one array can be added to a DAF at any one time, so */
+/* calling DAFBNA cancels any addition to the file specified */
+/* by HANDLE that may be in progress. No warning is issued. */
+
+/* $ Examples */
+
+/* See DAFANA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 16-NOV-2001 (FST) */
+
+/* Updated DAFBNA to support changes made to the DAF */
+/* system that utilize the new handle manager. See */
+/* the Revisions section of DAFANA for a detailed */
+/* discussion of the changes. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Modified to support simultaneous writes to multiple DAFs. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* begin new daf array */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Modified to support simultaneous writes to multiple DAFs. */
+/* DAFBNA now adds information about DAFs to the state table, */
+/* deletes information about closed DAFs from the state table, */
+/* and intializes the state pool. */
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFBNA", (ftnlen)6);
+ }
+
+/* Check out the file handle before going any further. */
+
+ dafsih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DAFBNA", (ftnlen)6);
+ return 0;
+ }
+
+/* Initialize the state table pool, if this hasn't been done yet. */
+/* Also initialize the cell used to obtain the set of handles of */
+/* open DAFs. */
+
+ if (first) {
+ ssizei_(&c__1000, opnset);
+ for (i__ = 1; i__ <= 19; ++i__) {
+ stpool[(i__1 = i__ - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stpool"
+ , i__1, "dafana_", (ftnlen)1067)] = i__ + 1;
+ }
+ stpool[19] = -1;
+ stfptr = 1;
+ sthead = -1;
+ first = FALSE_;
+ }
+
+/* We know that the beginning of the array will be the first */
+/* free address in the file. We also need the summary format. */
+/* Get both items from the file record. */
+
+/* We won't use the information we're obtaining now until */
+/* after we've placed the state information for the current */
+/* DAF at the head of the active list, but we want to make sure */
+/* that we can actually read the file record first. So, we */
+/* do the read now and avoid modifying the active list if the */
+/* read fails. */
+
+ dafrfr_(handle, &nd, &ni, ifname, &fward, &bward, &free, (ftnlen)60);
+
+/* If we couldn't read the file record, bail out now. */
+
+ if (failed_()) {
+ chkout_("DAFBNA", (ftnlen)6);
+ return 0;
+ }
+
+/* See whether we already have an entry for this DAF in the */
+/* state table. Find the previous node if possible. */
+
+ p = sthead;
+ prev = -1;
+ found = FALSE_;
+ while(p != -1 && ! found) {
+ if (stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1109)] == *handle) {
+ found = TRUE_;
+ } else {
+ prev = p;
+ p = stpool[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stp"
+ "ool", i__1, "dafana_", (ftnlen)1113)];
+ }
+ }
+
+/* At this point, either FOUND is false, or P points to a */
+/* state table entry describing the DAF indicated by HANDLE. */
+/* In the latter case, PREV is the predecessor of P. */
+
+
+ if (found) {
+
+/* We already have a dossier on this DAF. We already have */
+/* the information on the summary format, but we must re-set */
+/* the rest of our state information. */
+
+/* Rather than doing the update here, we do it outside of this */
+/* IF block. That way, the update gets done in just one place. */
+/* This just makes life easier: if the collection of state */
+/* variables is changed, there are fewer places to forget to */
+/* make the required code changes. */
+
+/* Move the node for this DAF to the head of the active list, */
+/* if it is not already there: */
+
+/* - Make the predecessor of P point to the successor of P. */
+
+/* - Make P point to the head of the active list. */
+
+/* - Make P the active list head node. */
+
+
+ if (p != sthead) {
+
+/* P is in the active list, but is not at the head. So, */
+/* the predecessor of P is not NIL. */
+
+ stpool[(i__1 = prev - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stpo"
+ "ol", i__1, "dafana_", (ftnlen)1151)] = stpool[(i__2 = p -
+ 1) < 20 && 0 <= i__2 ? i__2 : s_rnge("stpool", i__2,
+ "dafana_", (ftnlen)1151)];
+ stpool[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stpool",
+ i__1, "dafana_", (ftnlen)1152)] = sthead;
+ sthead = p;
+ }
+ } else {
+
+/* We don't yet have any information on this DAF. Make a new */
+/* state table entry for the DAF. We may need to make room for */
+/* the new information by freeing space allocated to DAFs that */
+/* are no longer open. */
+
+ if (stfptr == -1) {
+
+/* Oops, we're out of space. Time for garbage collection. */
+/* Test each file handle to see whether it designates a DAF */
+/* that is still open. DAFHOF will tell us which handles */
+/* point to open DAFs. */
+
+ dafhof_(opnset);
+ p = sthead;
+ prev = -1;
+
+/* For every DAF file represented in the state table, we'll */
+/* delete the corresponding state information if the DAF is */
+/* now closed. We traverse the active list, examining each */
+/* file handle as we go. */
+
+ while(p != -1) {
+ if (elemi_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 :
+ s_rnge("stfh", i__1, "dafana_", (ftnlen)1185)],
+ opnset)) {
+
+/* The file is open. Have a look at the next node. */
+
+ prev = p;
+ p = stpool[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 :
+ s_rnge("stpool", i__1, "dafana_", (ftnlen)1190)];
+ } else {
+
+/* This file handle is not on the list, so free the */
+/* node pointing to the information about the DAF it */
+/* designated: */
+
+/* - Save the successor of P. */
+
+/* - Link the predecessor of node P to the successor */
+/* of P, if the predecessor is not NIL. */
+
+/* - If it happens that P is the head node of the */
+/* active list, set the head equal to the */
+/* successor of P. */
+
+/* - Link P into the free list. */
+
+/* - Set P equal to its saved successor. */
+
+/* - (PREV remains unchanged.) */
+
+
+ nextp = stpool[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 :
+ s_rnge("stpool", i__1, "dafana_", (ftnlen)1214)];
+ if (p == sthead) {
+
+/* Re-assign STHEAD so that we don't lose the head */
+/* of the active list. P has no predecessor in this */
+/* case, so there's no need to set the forward pointer */
+/* of node PREV. */
+
+ sthead = nextp;
+ } else {
+
+/* Since P is not the head node of the active list, */
+/* PREV is not NIL, so we'll need to set the forward */
+/* pointer of node PREV. */
+
+ stpool[(i__1 = prev - 1) < 20 && 0 <= i__1 ? i__1 :
+ s_rnge("stpool", i__1, "dafana_", (ftnlen)
+ 1231)] = nextp;
+ }
+ stpool[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge(
+ "stpool", i__1, "dafana_", (ftnlen)1236)] =
+ stfptr;
+ stfptr = p;
+ p = nextp;
+ }
+ }
+
+/* At this point, we've freed all nodes from the active */
+/* list that were used to index information about DAFs that */
+/* are no longer open. Now see if we still need to make */
+/* room. If so, locate the first dossier with STADDG(P) */
+/* set to FALSE. We know then that this file is not */
+/* currently involved in an array addition. */
+
+ if (stfptr == -1) {
+ found = FALSE_;
+ p = sthead;
+ prev = -1;
+ while(p != -1 && ! found) {
+
+/* If STADDG(P) is TRUE, then we must continue */
+/* searching. */
+
+ if (staddg[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 :
+ s_rnge("staddg", i__1, "dafana_", (ftnlen)1264)])
+ {
+ prev = p;
+ p = stpool[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 :
+ s_rnge("stpool", i__1, "dafana_", (ftnlen)
+ 1267)];
+ } else {
+ found = TRUE_;
+
+/* No array is presently being added to the DAF */
+/* associated with this dossier, so free the */
+/* node pointing to the information about the DAF it */
+/* designated: */
+
+/* - Save the successor of P. */
+
+/* - Link the predecessor of node P to the successor */
+/* of P, if the predecessor is not NIL. */
+
+/* - If it happens that P is the head node of the */
+/* active list, set the head equal to the */
+/* successor of P. */
+
+/* - Link P into the free list. */
+
+/* - Set P equal to its saved successor. */
+
+/* - (PREV remains unchanged.) */
+
+
+ nextp = stpool[(i__1 = p - 1) < 20 && 0 <= i__1 ?
+ i__1 : s_rnge("stpool", i__1, "dafana_", (
+ ftnlen)1294)];
+ if (p == sthead) {
+
+/* Re-assign STHEAD so that we don't lose the head */
+/* of the active list. P has no predecessor in */
+/* this case, so there's no need to set the */
+/* forward pointer of node PREV. */
+
+ sthead = nextp;
+ } else {
+
+/* Since P is not the head node of the active list, */
+/* PREV is not NIL, so we'll need to set the */
+/* forward pointer of node PREV. */
+
+ stpool[(i__1 = prev - 1) < 20 && 0 <= i__1 ? i__1
+ : s_rnge("stpool", i__1, "dafana_", (
+ ftnlen)1311)] = nextp;
+ }
+ stpool[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 :
+ s_rnge("stpool", i__1, "dafana_", (ftnlen)
+ 1316)] = stfptr;
+ stfptr = p;
+ p = nextp;
+ }
+ }
+ }
+
+/* Now, check to see if there is now room to add the dossier */
+/* for the new DAF to the state table. If not signal an error. */
+
+ if (stfptr == -1) {
+ setmsg_("Attempt to initiate create a new array in DAF '#' h"
+ "as failed. DAFANA's state table has room to manage w"
+ "riting to # new arrays simultaneously, but there is "
+ "no room left in the table for this DAF.", (ftnlen)194)
+ ;
+ errhan_("#", handle, (ftnlen)1);
+ errint_("#", &c__20, (ftnlen)1);
+ sigerr_("SPICE(STFULL)", (ftnlen)13);
+ chkout_("DAFBNA", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* If we reach here, then we have room in the state table for */
+/* the new DAF. The first free node is indicated by SFTPTR. */
+/* Allocate this node and use it to index the state information */
+/* for the new DAF. */
+
+ p = stfptr;
+
+/* Update the free list pointer, link P to the previous head */
+/* of the active list, and make P the head of the active list. */
+
+ stfptr = stpool[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge(
+ "stpool", i__1, "dafana_", (ftnlen)1360)];
+ stpool[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stpool",
+ i__1, "dafana_", (ftnlen)1361)] = sthead;
+ sthead = p;
+ }
+
+/* At this point, P is the head node of the active list, and P is */
+/* the index in the state table of the information for the current */
+/* DAF. */
+
+
+/* Set the state information for the current array. */
+
+ stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh", i__1, "daf"
+ "ana_", (ftnlen)1375)] = *handle;
+ s_copy(stifnm + ((i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stifnm"
+ , i__1, "dafana_", (ftnlen)1376)) * 60, ifname, (ftnlen)60, (
+ ftnlen)60);
+ staddg[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("staddg", i__1,
+ "dafana_", (ftnlen)1377)] = TRUE_;
+ stfrst[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfrst", i__1,
+ "dafana_", (ftnlen)1378)] = fward;
+ stlast[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stlast", i__1,
+ "dafana_", (ftnlen)1379)] = bward;
+ stbegn[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stbegn", i__1,
+ "dafana_", (ftnlen)1380)] = free;
+ stfree[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfree", i__1,
+ "dafana_", (ftnlen)1381)] = free;
+
+/* Find out how big the array summary is supposed to be. */
+
+ dafhsf_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1386)], &nd, &ni);
+ sumsiz = nd + (ni + 1) / 2;
+
+/* Set the local copies of the array's summary and name. */
+
+ moved_(sum, &sumsiz, &stlsum[(i__1 = p * 125 - 125) < 2500 && 0 <= i__1 ?
+ i__1 : s_rnge("stlsum", i__1, "dafana_", (ftnlen)1393)]);
+ s_copy(stname + ((i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stname"
+ , i__1, "dafana_", (ftnlen)1395)) * 1000, name__, (ftnlen)1000,
+ name_len);
+ chkout_("DAFBNA", (ftnlen)6);
+ return 0;
+/* $Procedure DAFADA ( DAF, add data to array ) */
+
+L_dafada:
+/* $ Abstract */
+
+/* Add one or more double precision words of data to the newest */
+/* array in the current DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* DOUBLE PRECISION DATA ( * ) */
+/* INTEGER N */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Entry */
+/* -------- --- -------------------------------------------------- */
+/* DATA I Elements of the new array. */
+/* N I Number of elements in DATA. */
+
+/* $ Detailed_Input */
+
+/* DATA is an arbitrary number of double precision words to */
+/* be added to the data in the array being created. */
+
+/* N is the number of double precision words in DATA. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If there are no DAFs to which data is currently being added, */
+/* the error SPICE(DAFNOWRITE) is signalled. */
+
+/* 2) If a new array has not been started in the current DAF (by a */
+/* call to DAFBNA), the error SPICE(DAFNEWCONFLICT) is signalled. */
+
+/* 3) If N is less than one, no data are added to the file. */
+
+/* $ Particulars */
+
+/* DAFADA adds data to the last array begun by DAFBNA or selected */
+/* by DAFCAD. */
+
+/* Data can be added to a DAF in chunks of any size, so long */
+/* as the chunks are added in the proper order. */
+
+/* $ Examples */
+
+/* See example for DAFADA in the header of DAFANA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 16-NOV-2001 (FST) */
+
+/* Updated entry points to support changes made to the DAF */
+/* system that utilize the new handle manager. See */
+/* the Revisions section of DAFANA for a detailed */
+/* discussion of the changes. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to work with new DAF routines that allow writing */
+/* to multiple DAFs simultaneously. Functionality for */
+/* applications that write to one DAF at a time is unchanged. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* add data to daf array */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to work with new DAF routines that allow writing */
+/* to multiple DAFs simultaneously. Functionality for */
+/* applications that write to one DAF at a time is unchanged. */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFADA", (ftnlen)6);
+ }
+
+/* This routine operates on the DAF at the head of the active list. */
+
+ p = sthead;
+
+/* We must make sure that the requested addition can be performed. */
+/* We don't validate the file handle here because this is one place */
+/* where we are concerned about speed. The low-level writer routine */
+/* DAFWDR will handle the check. */
+
+ if (p == -1) {
+ setmsg_("No DAF is currently being written.", (ftnlen)34);
+ sigerr_("SPICE(DAFNOWRITE)", (ftnlen)17);
+ chkout_("DAFADA", (ftnlen)6);
+ return 0;
+
+/* An array cannot be extended unless begun first. */
+
+ } else if (! staddg[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge(
+ "staddg", i__1, "dafana_", (ftnlen)1592)]) {
+
+/* Validate the current handle, then get the name of the DAF. */
+
+ dafsih_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1596)], "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DAFADA", (ftnlen)6);
+ return 0;
+ }
+ dafhfn_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1603)], dafnam, (ftnlen)255);
+ setmsg_("An attempt was made to add data to an array that has not ye"
+ "t been begun, in file #.", (ftnlen)83);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(DAFNEWCONFLICT)", (ftnlen)21);
+ chkout_("DAFADA", (ftnlen)6);
+ return 0;
+
+/* Start adding data at the first free address, then update that */
+/* address to get ready for the next addition. */
+
+ } else if (*n >= 1) {
+ i__4 = stfree[(i__3 = p - 1) < 20 && 0 <= i__3 ? i__3 : s_rnge("stfr"
+ "ee", i__3, "dafana_", (ftnlen)1617)] + *n - 1;
+ dafwda_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1617)], &stfree[(i__2 = p - 1) < 20
+ && 0 <= i__2 ? i__2 : s_rnge("stfree", i__2, "dafana_", (
+ ftnlen)1617)], &i__4, data);
+ stfree[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfree",
+ i__1, "dafana_", (ftnlen)1618)] = stfree[(i__2 = p - 1) < 20
+ && 0 <= i__2 ? i__2 : s_rnge("stfree", i__2, "dafana_", (
+ ftnlen)1618)] + *n;
+ }
+ chkout_("DAFADA", (ftnlen)6);
+ return 0;
+/* $Procedure DAFENA ( DAF, end new array ) */
+
+L_dafena:
+/* $ Abstract */
+
+/* End the addition of data to the newest array in the current DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* None. */
+
+/* $ Brief_I/O */
+
+/* None. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If there are no DAFs to which data is currently being added, */
+/* the error SPICE(DAFNOWRITE) is signalled, or the error will */
+/* be detected by routines called by this routine. */
+
+/* 2) If a new array has not been started in the current DAF (by a */
+/* call to DAFBNA), the error SPICE(DAFNEWCONFLICT) is signalled. */
+
+/* $ Particulars */
+
+/* DAFENA makes the current array a permanent addition to the */
+/* current DAF. */
+
+/* The pointers within the file are not changed until an array */
+/* is ended successfully. If an error occurs or if the current */
+/* DAF is closed before DAFENA is called, the last array will */
+/* not be visible to the DAF reader routines. */
+
+/* $ Examples */
+
+/* See DAFANA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 16-NOV-2001 (FST) */
+
+/* Updated entry points to support changes made to the DAF */
+/* system that utilize the new handle manager. See */
+/* the Revisions section of DAFANA for a detailed */
+/* discussion of the changes. */
+
+/* - SPICELIB Version 2.1.0, 11-JUL-1995 (KRG) */
+
+/* Updated to remove potential compiler warnings from the */
+/* truncation of double precision numbers to integers. */
+
+/* Also changed was a numeric constant from 1.D0 to the */
+/* equivalent, but more aesthetically pleasing 1.0D0. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to work with new DAF routines that allow writing */
+/* to multiple DAFs simultaneously. Functionality for */
+/* applications that write to one DAF at a time is unchanged. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* end new daf array */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.1.0, 11-JUL-1995 (KRG) */
+
+/* Updated to remove potential compiler warnings from the */
+/* truncation of double precision numbers to integers. Two */
+/* assignments to NARRAY were updated, being changed from: */
+
+/* NARRAY = SUMREC(ARYCNT) */
+
+/* to */
+
+/* NARRAY = IDINT ( SUMREC(ARYCNT) ) */
+
+/* Also changed was a numeric constant from 1.D0 to the */
+/* equivalent, but more aesthetically pleasing 1.0D0. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to work with new DAF routines that allow writing */
+/* to multiple DAFs simultaneously. Functionality for */
+/* applications that write to one DAF at a time is unchanged. */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFENA", (ftnlen)6);
+ }
+
+/* This routine operates on the DAF at the head of the active list. */
+
+ p = sthead;
+ if (p == -1) {
+ setmsg_("No DAF is currently being written.", (ftnlen)34);
+ sigerr_("SPICE(DAFNOWRITE)", (ftnlen)17);
+ chkout_("DAFENA", (ftnlen)6);
+ return 0;
+
+/* A new array cannot be ended unless begun first. */
+
+ } else if (! staddg[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge(
+ "staddg", i__1, "dafana_", (ftnlen)1832)]) {
+
+/* Validate the current handle, then get the name of the DAF. */
+
+ dafsih_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1836)], "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DAFENA", (ftnlen)6);
+ return 0;
+ }
+ dafhfn_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1843)], dafnam, (ftnlen)255);
+ setmsg_("An attempt was made to end an array that has not yet been b"
+ "egun, in file #.", (ftnlen)75);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(DAFNEWCONFLICT)", (ftnlen)21);
+ chkout_("DAFENA", (ftnlen)6);
+ return 0;
+ }
+
+/* No more data. The array ends just before the next free */
+/* address. The summary should be complete except for the */
+/* initial and final addresses of the data, of which we */
+/* have been keeping track. */
+
+ dafhsf_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1859)], &nd, &ni);
+ dafus_(&stlsum[(i__1 = p * 125 - 125) < 2500 && 0 <= i__1 ? i__1 : s_rnge(
+ "stlsum", i__1, "dafana_", (ftnlen)1861)], &nd, &ni, dc, ic);
+ ic[(i__1 = ni - 2) < 250 && 0 <= i__1 ? i__1 : s_rnge("ic", i__1, "dafan"
+ "a_", (ftnlen)1863)] = stbegn[(i__2 = p - 1) < 20 && 0 <= i__2 ?
+ i__2 : s_rnge("stbegn", i__2, "dafana_", (ftnlen)1863)];
+ ic[(i__1 = ni - 1) < 250 && 0 <= i__1 ? i__1 : s_rnge("ic", i__1, "dafan"
+ "a_", (ftnlen)1864)] = stfree[(i__2 = p - 1) < 20 && 0 <= i__2 ?
+ i__2 : s_rnge("stfree", i__2, "dafana_", (ftnlen)1864)] - 1;
+ dafps_(&nd, &ni, dc, ic, &stlsum[(i__1 = p * 125 - 125) < 2500 && 0 <=
+ i__1 ? i__1 : s_rnge("stlsum", i__1, "dafana_", (ftnlen)1866)]);
+
+/* The summary should be stored in the final summary record (the */
+/* one at the end of the file). Get that entire record, and the */
+/* corresponding name record. */
+
+ dafrdr_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1873)], &stlast[(i__2 = p - 1) < 20 && 0
+ <= i__2 ? i__2 : s_rnge("stlast", i__2, "dafana_", (ftnlen)1873)],
+ &c__1, &c__128, sumrec, &found);
+ i__3 = stlast[(i__2 = p - 1) < 20 && 0 <= i__2 ? i__2 : s_rnge("stlast",
+ i__2, "dafana_", (ftnlen)1874)] + 1;
+ dafrcr_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1874)], &i__3, namrec, (ftnlen)1000);
+ narray = (integer) sumrec[2];
+
+/* The number of arrays determines where the summary and name */
+/* are stored within the summary record. Adding this array increases */
+/* the number of arrays by one. */
+
+ sumsiz = nd + (ni + 1) / 2;
+ dloc = narray * sumsiz + 4;
+ moved_(&stlsum[(i__1 = p * 125 - 125) < 2500 && 0 <= i__1 ? i__1 : s_rnge(
+ "stlsum", i__1, "dafana_", (ftnlen)1885)], &sumsiz, &sumrec[(i__2
+ = dloc - 1) < 128 && 0 <= i__2 ? i__2 : s_rnge("sumrec", i__2,
+ "dafana_", (ftnlen)1885)]);
+ namsiz = sumsiz << 3;
+ cloc = narray * namsiz + 1;
+ s_copy(namrec + (cloc - 1), stname + ((i__1 = p - 1) < 20 && 0 <= i__1 ?
+ i__1 : s_rnge("stname", i__1, "dafana_", (ftnlen)1890)) * 1000,
+ cloc + namsiz - 1 - (cloc - 1), (ftnlen)1000);
+ sumrec[2] += 1.;
+ narray = (integer) sumrec[2];
+
+/* Usually, adding an array does not fill the final summary */
+/* record, and it can simply be replaced. */
+
+ if (narray < 125 / sumsiz) {
+ dafwdr_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1901)], &stlast[(i__2 = p - 1) < 20
+ && 0 <= i__2 ? i__2 : s_rnge("stlast", i__2, "dafana_", (
+ ftnlen)1901)], sumrec);
+ i__3 = stlast[(i__2 = p - 1) < 20 && 0 <= i__2 ? i__2 : s_rnge("stla"
+ "st", i__2, "dafana_", (ftnlen)1902)] + 1;
+ dafwcr_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1902)], &i__3, namrec, (ftnlen)1000)
+ ;
+
+/* When the record becomes full, a new one must be written. */
+/* However, this fact should be transparent to the user. */
+
+ } else {
+
+/* The new summary record will be stored in the next free record */
+/* in the file. This summary record should point to it. */
+
+/* To find out which record the next free address is in, we use */
+/* DAFARW (`address to record and word'). */
+
+ i__2 = stfree[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfr"
+ "ee", i__1, "dafana_", (ftnlen)1917)] - 1;
+ dafarw_(&i__2, &next, &word);
+ ++next;
+ sumrec[0] = (doublereal) next;
+ dafwdr_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1921)], &stlast[(i__2 = p - 1) < 20
+ && 0 <= i__2 ? i__2 : s_rnge("stlast", i__2, "dafana_", (
+ ftnlen)1921)], sumrec);
+ i__3 = stlast[(i__2 = p - 1) < 20 && 0 <= i__2 ? i__2 : s_rnge("stla"
+ "st", i__2, "dafana_", (ftnlen)1922)] + 1;
+ dafwcr_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1922)], &i__3, namrec, (ftnlen)1000)
+ ;
+
+/* The new summary record should point backwards to the one just */
+/* written, and should point forwards to nothing. Of course, */
+/* it contains no summaries, and no names. */
+
+ cleard_(&c__128, sumrec);
+ sumrec[0] = 0.;
+ sumrec[1] = (doublereal) stlast[(i__1 = p - 1) < 20 && 0 <= i__1 ?
+ i__1 : s_rnge("stlast", i__1, "dafana_", (ftnlen)1931)];
+ sumrec[2] = 0.;
+ s_copy(namrec, " ", (ftnlen)1000, (ftnlen)1);
+ dafwdr_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1935)], &next, sumrec);
+ i__2 = next + 1;
+ dafwcr_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1936)], &i__2, namrec, (ftnlen)1000)
+ ;
+
+/* If a new summary record was added, the first free address */
+/* lies just beyond the end of the matching character record. */
+
+/* We use DAFRWA (`record and word to address') to calculate */
+/* the next free address. */
+
+ stlast[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stlast",
+ i__1, "dafana_", (ftnlen)1945)] = next;
+ i__3 = stlast[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stla"
+ "st", i__1, "dafana_", (ftnlen)1946)] + 2;
+ dafrwa_(&i__3, &c__1, &stfree[(i__2 = p - 1) < 20 && 0 <= i__2 ? i__2
+ : s_rnge("stfree", i__2, "dafana_", (ftnlen)1946)]);
+ }
+
+/* The new value STFREE(P) must be rewritten in the file record each */
+/* time a new array is added. If a new record was added, the new */
+/* value of STLAST(P) will be rewritten as well. */
+
+ dafwfr_(&stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)1955)], &nd, &ni, stifnm + ((i__2 = p -
+ 1) < 20 && 0 <= i__2 ? i__2 : s_rnge("stifnm", i__2, "dafana_", (
+ ftnlen)1955)) * 60, &stfrst[(i__3 = p - 1) < 20 && 0 <= i__3 ?
+ i__3 : s_rnge("stfrst", i__3, "dafana_", (ftnlen)1955)], &stlast[(
+ i__4 = p - 1) < 20 && 0 <= i__4 ? i__4 : s_rnge("stlast", i__4,
+ "dafana_", (ftnlen)1955)], &stfree[(i__5 = p - 1) < 20 && 0 <=
+ i__5 ? i__5 : s_rnge("stfree", i__5, "dafana_", (ftnlen)1955)], (
+ ftnlen)60);
+
+/* Ready for another array. */
+
+ staddg[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("staddg", i__1,
+ "dafana_", (ftnlen)1966)] = FALSE_;
+ chkout_("DAFENA", (ftnlen)6);
+ return 0;
+/* $Procedure DAFCAD ( DAF, continue adding data ) */
+
+L_dafcad:
+/* $ Abstract */
+
+/* Select a DAF that already has a new array in progress as the */
+/* one to continue adding data to. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAF to continue adding data to. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAF that is open for write */
+/* access and in which a new array has been */
+/* started by a call to DAFBNA. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input handle is not that of a DAF that is open */
+/* for writing, the error will be diagnosed by routines called */
+/* by this routine. */
+
+/* 2) If no array is currently being added to in the file indicated */
+/* by HANDLE, the error will be diagnosed by this routine or */
+/* routines called by this routine. If DAFCAD can detect the */
+/* problem, the error SPICE(NOARRAYSTARTED) will be signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* DAFCAD supports simultaneous addition of data to arrays in */
+/* multiple DAFs. In applications that use this capability, */
+/* DAFCAD should be called prior to each call to DAFADA or DAFENA */
+/* to specify which DAF is to be acted upon. */
+
+/* Here is a code fragment that adds a new array to each of N */
+/* existing DAFs, simultaneously. The data to be added to each */
+/* is broken up into M chunks; one chunk is written to each DAF */
+/* at a time. The data is contained in the array CHUNK, dimensioned */
+
+/* DOUBLE PRECISION CHUNK ( MAXDAT, M, N ) */
+
+/* The actual amount of data in the Jth chunk for the Ith file is */
+/* given by */
+
+/* AMOUNT (J,I) */
+
+
+
+/* DO I = 1, N */
+/* CALL DAFOPW ( HANDLE(I) ) */
+/* CALL DAFBNA ( HANDLE(I) ) */
+/* END DO */
+
+/* DO J = 1, M */
+
+/* DO I = 1, N */
+/* CALL DAFCAD ( HANDLE(I) ) */
+/* CALL DAFADA ( CHUNK(1,J,I), AMOUNT(J,I) ) */
+/* END DO */
+
+/* END DO */
+
+/* DO I = 1, N */
+/* CALL DAFCAD ( HANDLE(I) ) */
+/* CALL DAFENA */
+/* END DO */
+
+
+/* Note that if we write all of the data for each array to just one */
+/* DAF at a time, we don't need to use DAFCAD: */
+
+/* DO I = 1, N */
+
+/* CALL DAFOPW ( HANDLE(I) ) */
+/* CALL DAFBNA ( HANDLE(I) ) */
+
+/* DO J = 1, M */
+/* CALL DAFADA ( CHUNK(1,J,I), AMOUNT(J,I) ) */
+/* END DO */
+
+/* CALL DAFENA */
+
+/* END DO */
+
+
+/* $ Examples */
+
+/* See DAFANA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 16-NOV-2001 (FST) */
+
+/* Updated entry points to support changes made to the DAF */
+/* system that utilize the new handle manager. See */
+/* the Revisions section of DAFANA for a detailed */
+/* discussion of the changes. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* continue adding data to a daf */
+/* select a daf to continue adding data to */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFCAD", (ftnlen)6);
+ }
+
+/* Check out the file handle before going any further. */
+
+ dafsih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DAFCAD", (ftnlen)6);
+ return 0;
+ }
+
+/* See whether we already have an entry for this DAF in the */
+/* state table. Find the previous node if possible. */
+
+ p = sthead;
+ prev = -1;
+ found = FALSE_;
+ while(p != -1 && ! found) {
+ if (stfh[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "dafana_", (ftnlen)2189)] == *handle) {
+ found = TRUE_;
+ } else {
+ prev = p;
+ p = stpool[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stp"
+ "ool", i__1, "dafana_", (ftnlen)2193)];
+ }
+ }
+
+/* Either FOUND is false, or P is the index in the state table of */
+/* the DAF specified by HANDLE, and PREV is the predecessor of P. */
+
+
+/* You can't continue writing to a DAF that you're not */
+/* already writing to. */
+
+ if (! found) {
+ dafhfn_(handle, dafnam, (ftnlen)255);
+ setmsg_("No write in progress to #. (Handle was #.) ", (ftnlen)43);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ errint_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(NOARRAYSTARTED)", (ftnlen)21);
+ chkout_("DAFCAD", (ftnlen)6);
+ return 0;
+ } else if (! staddg[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge(
+ "staddg", i__1, "dafana_", (ftnlen)2217)]) {
+ dafhfn_(handle, dafnam, (ftnlen)255);
+ setmsg_("No write in progress to #. (Handle was #.) ", (ftnlen)43);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ errint_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(NOARRAYSTARTED)", (ftnlen)21);
+ chkout_("DAFCAD", (ftnlen)6);
+ return 0;
+ }
+
+/* Move the node for this DAF to the head of the active list, */
+/* if it is not already there: */
+
+/* - Make the predecessor of P point to the successor of P. */
+
+/* - Make P point to the head of the active list. */
+
+/* - Make P the active list head node. */
+
+
+ if (p != sthead) {
+
+/* P is in the active list, but is not at the head. So, */
+/* the predecessor of P is not NIL. */
+
+ stpool[(i__1 = prev - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stpool",
+ i__1, "dafana_", (ftnlen)2246)] = stpool[(i__2 = p - 1) < 20
+ && 0 <= i__2 ? i__2 : s_rnge("stpool", i__2, "dafana_", (
+ ftnlen)2246)];
+ stpool[(i__1 = p - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge("stpool",
+ i__1, "dafana_", (ftnlen)2247)] = sthead;
+ sthead = p;
+ }
+ chkout_("DAFCAD", (ftnlen)6);
+ return 0;
+} /* dafana_ */
+
+/* Subroutine */ int dafana_(integer *handle, doublereal *sum, char *name__,
+ doublereal *data, integer *n, ftnlen name_len)
+{
+ return dafana_0_(0, handle, sum, name__, data, n, name_len);
+ }
+
+/* Subroutine */ int dafbna_(integer *handle, doublereal *sum, char *name__,
+ ftnlen name_len)
+{
+ return dafana_0_(1, handle, sum, name__, (doublereal *)0, (integer *)0,
+ name_len);
+ }
+
+/* Subroutine */ int dafada_(doublereal *data, integer *n)
+{
+ return dafana_0_(2, (integer *)0, (doublereal *)0, (char *)0, data, n, (
+ ftnint)0);
+ }
+
+/* Subroutine */ int dafena_(void)
+{
+ return dafana_0_(3, (integer *)0, (doublereal *)0, (char *)0, (doublereal
+ *)0, (integer *)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dafcad_(integer *handle)
+{
+ return dafana_0_(4, handle, (doublereal *)0, (char *)0, (doublereal *)0, (
+ integer *)0, (ftnint)0);
+ }
+
diff --git a/ext/spice/src/cspice/dafarr.c b/ext/spice/src/cspice/dafarr.c
new file mode 100644
index 0000000000..bf8935bbf3
--- /dev/null
+++ b/ext/spice/src/cspice/dafarr.c
@@ -0,0 +1,477 @@
+/* dafarr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static integer c__128 = 128;
+
+/* $Procedure DAFARR ( DAF, add reserved records ) */
+/* Subroutine */ int dafarr_(integer *handle, integer *resv)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ char crec[1000];
+ doublereal drec[128];
+ integer free, incr, word, next, i__;
+ extern /* Subroutine */ int dafgs_(doublereal *), chkin_(char *, ftnlen),
+ dafps_(integer *, integer *, doublereal *, integer *, doublereal *
+ );
+ integer bward;
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *);
+ integer fward;
+ extern /* Subroutine */ int dafws_(doublereal *);
+ integer recno;
+ logical found;
+ doublereal dc[125];
+ integer ic[250];
+ extern /* Subroutine */ int daffna_(logical *);
+ integer nd;
+ extern logical failed_(void);
+ extern /* Subroutine */ int dafbfs_(integer *);
+ integer begblk, ni;
+ extern /* Subroutine */ int dafsih_(integer *, char *, ftnlen);
+ char ifname[60];
+ integer endblk;
+ extern /* Subroutine */ int dafrdr_(integer *, integer *, integer *,
+ integer *, doublereal *, logical *), dafrcr_(integer *, integer *,
+ char *, ftnlen), dafrfr_(integer *, integer *, integer *, char *,
+ integer *, integer *, integer *, ftnlen), dafarw_(integer *,
+ integer *, integer *), dafwcr_(integer *, integer *, char *,
+ ftnlen), dafwdr_(integer *, integer *, doublereal *), dafwfr_(
+ integer *, integer *, integer *, char *, integer *, integer *,
+ integer *, ftnlen), chkout_(char *, ftnlen);
+ extern logical return_(void);
+ doublereal sum[125];
+
+/* $ Abstract */
+
+/* Add a specified number of reserved records to a Double Precision */
+/* Array File (DAF). */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of a DAF file opened for writing. */
+/* RESV I Number of records to reserve. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a DAF file that has */
+/* been opened with write access. */
+
+/* RESV is the number of reserved records to be added */
+/* to the specified file. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If RESV is less than one, the file is not changed. */
+
+/* $ Files */
+
+/* See argument HANDLE. */
+
+/* $ Particulars */
+
+/* Normally, the reserved records in an array file are reserved */
+/* when the file is created. However, it may occasionally become */
+/* necessary to add reserved records---when the contents of one */
+/* file are appended to another, for example. (In this case, any */
+/* information in the reserved records of either file should */
+/* be included in the resulting file.) */
+
+/* The new reserved records are appended to the old ones. The new */
+/* reserved records are also NULL filled. */
+
+/* $ Examples */
+
+/* In the following call to DAFARR, assume that HANDLE is the file */
+/* handle for a DAF file that has been opened for write access, and */
+/* that the DAF file already contains 12 reserved records (located in */
+/* records 2-13 of the physical file). */
+
+/* CALL DAFARR ( HANDLE, 7 ) */
+
+/* After this call, the DAF file attached to HANDLE will contain 19 */
+/* reserved records. The new reserved records are located in */
+/* records 14-20 of the physical file. */
+
+/* $ Restrictions */
+
+/* 1) This routine will only add reserved records to DAFs open for */
+/* write. These files are implicitly of the native binary file */
+/* format. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.5.0, 16-NOV-2001 (FST) */
+
+/* Added a call to DAFSIH to prevent this routine from */
+/* attempting to write to non-native binary file formats. */
+/* This will provide a more useful error diagnostic with */
+/* little impact on performance. */
+
+/* - SPICELIB Version 1.4.0, 08-MAR-1996 (KRG) */
+
+/* Added code to write NULL filled records to the file for the */
+/* new reserved records. */
+
+/* - SPICELIB Version 1.3.0, 12-MAY-1994 (KRG) */
+
+/* Added a missing call to CHKOUT before the RETURN statement in */
+/* the test */
+
+/* IF ( RESV .LT. 1 ) THEN */
+/* RETURN */
+/* END IF */
+
+/* - SPICELIB Version 1.2.0, 30-SEP-1993 (KRG) */
+
+/* Detailed_Input and Examples section of the header were */
+/* modified. */
+
+/* Added calls to the FORTRAN intrinsic functions INT and */
+/* DBLE in the code that updates the summary record. */
+
+/* Modified an IF loop to make logic clearer. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 17-JUL-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* add daf reserved records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.4.0, 08-MAR-1996 (KRG) */
+
+/* Added code to write NULL filled records to the file for the */
+/* new reserved records. */
+
+/* - SPICELIB Version 1.3.0, 12-MAY-1994 (KRG) */
+
+/* Added a missing call to CHKOUT before the RETURN statement in */
+/* the test */
+
+/* IF ( RESV .LT. 1 ) THEN */
+/* RETURN */
+/* END IF */
+
+/* - SPICELIB Version 1.2.0, 30-SEP-1993 (KRG) */
+
+/* $ Detailed_Input section was modified. References to any */
+/* specific routines by name as a method for opening a DAF file */
+/* for write access were removed. The assumption is that a person */
+/* using DAF files would already know something about opening and */
+/* closing the files. */
+
+/* $ Examples section was modified. References to any specific */
+/* routines by name as a method for opening a DAF file for writing */
+/* were removed, and the example was reworded in such a way that */
+/* the use of the subroutine remained clear. */
+
+/* Added calls to the INT intrinsic function to convert a DP */
+/* number to an integer before assigning it to NEXT, which is an */
+/* integer variable. Also added calls to INT in IF statements */
+/* where comparisons were made between DP numbers and INTEGERs, */
+/* when integral values were actually being compared. */
+
+/* Added calls to the intrinsic function DBLE to convert an */
+/* integer, RESV, into a DP number when doing some arithmetic. */
+
+/* Took an ELSE IF clause out of the initial IF return ELSE */
+/* check in END IF at the beginning of the routine. Replaced the */
+/* code: */
+
+/* IF ( RETURN () ) THEN */
+/* RETURN */
+
+/* ELSE IF ( RESV .LT. 1 ) THEN */
+/* RETURN */
+
+/* ELSE */
+/* CALL CHKIN ( 'DAFARR' ) */
+/* END IF */
+
+/* with the eqivalent code: */
+
+/* IF ( RETURN () ) THEN */
+/* RETURN */
+/* ELSE */
+/* CALL CHKIN ( 'DAFARR' ) */
+/* END IF */
+
+/* C */
+/* C Check to see if the number of records to be reserved is */
+/* C less than one. If so, just return without changing */
+/* C anything. */
+/* C */
+/* IF ( RESV .LT. 1 ) THEN */
+/* RETURN */
+/* END IF */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 17-JUL-1990 (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* IFNLEN is the length of a DAF internal file name. */
+
+
+/* WPR is the maximum number of double precision numbers */
+/* (words) per record. */
+
+/* MAXD, are the maximum number of double precision */
+/* MAXI, numbers, integers, and characters, respectively, */
+/* MAXC per record, not including space reserved for */
+/* control information (3 dp numbers are reserved). */
+/* There are two integers per double precision word, */
+/* and eight characters per word. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFARR", (ftnlen)6);
+ }
+
+
+/* Check to see if the number of records to be reserved is less than */
+/* one. If so, just return without changing anything. */
+
+ if (*resv < 1) {
+ chkout_("DAFARR", (ftnlen)6);
+ return 0;
+ }
+
+/* Before proceeding any further, check that the DAF associated */
+/* with HANDLE is available for write access. */
+
+ dafsih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DAFARR", (ftnlen)6);
+ return 0;
+ }
+
+/* Get the contents of the file record. If it fails, then just check */
+/* out and return, as an appropriate error message should have */
+/* already been set. */
+
+ dafrfr_(handle, &nd, &ni, ifname, &fward, &bward, &free, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DAFARR", (ftnlen)6);
+ return 0;
+ }
+
+/* Okay, here's the plan. We are just going to move records */
+/* in the direction of the end of the file, starting */
+/* with the last record in the file and ending with the first */
+/* summary record. */
+
+/* After everything has been moved, the initial and final */
+/* addresses of all the arrays have to be incremented by the */
+/* same amount: the number of words per record (128) times */
+/* the number of new records. */
+
+ incr = *resv << 7;
+
+/* Before we do that, however, we should write some bogus records */
+/* to the end of the file, to make sure we don't run out of space */
+/* later on. If this doesn't work, we will leave the logical */
+/* contents of the file uncorrupted (although it may get larger). */
+
+ dafarw_(&free, &recno, &word);
+ i__1 = *resv;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ i__2 = recno + i__;
+ dafwdr_(handle, &i__2, drec);
+ }
+ if (failed_()) {
+ chkout_("DAFARR", (ftnlen)6);
+ return 0;
+ }
+
+/* Records will be moved in `blocks', where each block contains */
+
+/* -- a summary record */
+
+/* -- a name record */
+
+/* -- one or more data records */
+
+/* The first block to be moved (that is, the last block in */
+/* the file) lies between the final summary record (BWARD) and */
+/* whatever record contains the first free address in the file. */
+
+ begblk = bward;
+ dafarw_(&free, &endblk, &word);
+ while(begblk > 0 && ! failed_()) {
+
+/* Move the data records first. */
+
+ i__1 = begblk + 2;
+ for (recno = endblk; recno >= i__1; --recno) {
+ dafrdr_(handle, &recno, &c__1, &c__128, drec, &found);
+ i__2 = recno + *resv;
+ dafwdr_(handle, &i__2, drec);
+ }
+
+/* Then the name record. */
+
+ recno = begblk + 1;
+ dafrcr_(handle, &recno, crec, (ftnlen)1000);
+ i__1 = recno + *resv;
+ dafwcr_(handle, &i__1, crec, (ftnlen)1000);
+
+/* Finally, the summary record. */
+
+/* To find the beginning of the next block, look at the backward */
+/* pointer from the summary record of the current block. */
+
+/* Be sure to adjust the forward and backward pointers; */
+/* otherwise, we won't be able to find the summaries again. */
+
+ recno = begblk;
+ dafrdr_(handle, &recno, &c__1, &c__128, drec, &found);
+ next = (integer) drec[1];
+ if ((integer) drec[0] > 0) {
+ drec[0] += (doublereal) (*resv);
+ }
+ if ((integer) drec[1] > 0) {
+ drec[1] += (doublereal) (*resv);
+ }
+ i__1 = recno + *resv;
+ dafwdr_(handle, &i__1, drec);
+
+/* The next block ends just before the current block begins. */
+
+ endblk = begblk - 1;
+ begblk = next;
+ }
+
+/* Rewrite the file record, to reflect the new organization of */
+/* the file. */
+
+ fward += *resv;
+ bward += *resv;
+ free += incr;
+ dafwfr_(handle, &nd, &ni, ifname, &fward, &bward, &free, (ftnlen)60);
+
+/* Get the summary for each array, increment the addresses (stored */
+/* in the final two integer components), and replace the summary. */
+
+ dafbfs_(handle);
+ daffna_(&found);
+ while(found && ! failed_()) {
+ dafgs_(sum);
+ dafus_(sum, &nd, &ni, dc, ic);
+ ic[(i__1 = ni - 2) < 250 && 0 <= i__1 ? i__1 : s_rnge("ic", i__1,
+ "dafarr_", (ftnlen)474)] = ic[(i__2 = ni - 2) < 250 && 0 <=
+ i__2 ? i__2 : s_rnge("ic", i__2, "dafarr_", (ftnlen)474)] +
+ incr;
+ ic[(i__1 = ni - 1) < 250 && 0 <= i__1 ? i__1 : s_rnge("ic", i__1,
+ "dafarr_", (ftnlen)475)] = ic[(i__2 = ni - 1) < 250 && 0 <=
+ i__2 ? i__2 : s_rnge("ic", i__2, "dafarr_", (ftnlen)475)] +
+ incr;
+ dafps_(&nd, &ni, dc, ic, sum);
+ dafws_(sum);
+ daffna_(&found);
+ }
+
+/* Write NULL filled records to the reserved record area. */
+
+ for (i__ = 1; i__ <= 1000; ++i__) {
+ *(unsigned char *)&crec[i__ - 1] = '\0';
+ }
+ i__ = fward - *resv;
+ i__1 = i__ + *resv - 1;
+ for (recno = i__; recno <= i__1; ++recno) {
+ dafwcr_(handle, &recno, crec, (ftnlen)1000);
+ }
+ chkout_("DAFARR", (ftnlen)6);
+ return 0;
+} /* dafarr_ */
+
diff --git a/ext/spice/src/cspice/dafb2a.c b/ext/spice/src/cspice/dafb2a.c
new file mode 100644
index 0000000000..682bb106ca
--- /dev/null
+++ b/ext/spice/src/cspice/dafb2a.c
@@ -0,0 +1,263 @@
+/* dafb2a.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DAFB2A ( DAF, binary to ASCII ) */
+/* Subroutine */ int dafb2a_(char *binary, char *ascii, ftnlen binary_len,
+ ftnlen ascii_len)
+{
+ /* System generated locals */
+ cllist cl__1;
+
+ /* Builtin functions */
+ integer f_clos(cllist *);
+
+ /* Local variables */
+ integer unit;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafb2t_(char *,
+ integer *, ftnlen);
+ extern logical failed_(void);
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int txtopn_(char *, integer *, ftnlen);
+
+/* $ Abstract */
+
+/* Convert a binary DAF to an equivalent ASCII (text) DAF. */
+/* (Obsolete, maintained for backward compatibility only.) */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* BINARY I Name of an existing binary DAF. */
+/* ASCII I Name of an ASCII (text) DAF to be created. */
+
+/* $ Detailed_Input */
+
+/* BINARY is the name of an existing binary DAF. */
+
+/* ASCII is the name of an ASCII (text) DAF to be created. */
+/* The ASCII file contains the same data as the binary */
+/* file, but in a form more suitable for transfer */
+/* between heterogeneous computing environments. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See arguments BINARY, ASCII. */
+
+/* $ Exceptions */
+
+/* None. */
+
+/* Errors are detected and signalled by routines called by this */
+/* routine. */
+
+/* $ Particulars */
+
+/* This routine has been made obsolete by the new DAF binary to text */
+/* conversion routine DAFBT. This routine remains available for */
+/* reasons of backward compatibility. We strongly recommend that the */
+/* conversion routine DAFBT be used for any new software development. */
+/* Please see the header of the routine DAFBT for details. */
+
+/* Note that the contents of reserved records in the binary file */
+/* are not stored in the ASCII file. */
+
+/* $ Examples */
+
+/* DAFB2A and DAFA2B are typically used to transfer files. */
+/* If file A.DAF is a binary DAF in environment 1, it can be */
+/* transferred to environment 2 in three steps. */
+
+/* 1) Convert it to ASCII, */
+
+/* CALL DAFB2A ( 'A.DAF', 'A.ASCII' ) */
+
+/* 2) Transfer the ASCII file, using FTP, Kermit, or some other */
+/* file transfer utility, */
+
+/* ftp> put a.ascii */
+
+/* 3) Convert it to binary on the new machine, */
+
+/* CALL DAFA2B ( 'A.ASCII', 'A.DAF', RESV ) */
+
+/* Note that DAFB2A and DAFA2B work in any standard Fortran-77 */
+/* environment. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.1.0, 18-JUN-1999 (WLT) */
+
+/* Fixed call to CHKOUT with wrong name. */
+
+/* - SPICELIB Version 2.0.0, 04-OCT-1993 (KRG) */
+
+/* This routine was completely rewritten to make use of the */
+/* routines DAFB2T and TXTOPN, for converting a text file to */
+/* binary and opening a text file. It now simply calls the */
+/* routine DAFT2B after opening the text file with TXTOPN. */
+
+/* Added a statement to the $ Particulars section to the effect */
+/* that this routine has been made obsolete by the introduction of */
+/* the routine DAFBT, and that we strongly recommend the use of */
+/* the new routine. */
+
+/* Modified the $ Abstract section to reflect the fact that this */
+/* routine is obsolete. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* binary daf to ascii */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-OCT-1993 (KRG) */
+
+/* This routine was completely rewritten to make use of the */
+/* routines DAFB2T and TXTOPN, for converting a text file to */
+/* binary and opening a text file. It now simply calls the */
+/* routine DAFT2B after opening the text file with TXTOPN. */
+
+/* Added a statement to the $ Particulars section to the effect */
+/* that this routine has been made obsolete by the introduction of */
+/* the routine DAFBT, and that we strongly recommend the use of */
+/* the new routine. */
+
+/* Modified the $ Abstract section to reflect the fact that this */
+/* routine is obsolete. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFB2A", (ftnlen)6);
+ }
+
+/* Open the ASCII file for writing. If an error occurs, then check */
+/* out and return. An appropriate error message will have already */
+/* been set. */
+
+ txtopn_(ascii, &unit, ascii_len);
+ if (failed_()) {
+ chkout_("DAFB2A", (ftnlen)6);
+ return 0;
+ }
+
+/* Attempt to perform the file conversion. If it fails, close the */
+/* text file with STATUS = 'DELETE', check out and return, as an */
+/* appropriate error message should have already been set. */
+
+ dafb2t_(binary, &unit, binary_len);
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = unit;
+ cl__1.csta = "DELETE";
+ f_clos(&cl__1);
+ chkout_("DAFB2A", (ftnlen)6);
+ return 0;
+ }
+
+/* Close the text file. */
+
+ cl__1.cerr = 0;
+ cl__1.cunit = unit;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DAFB2A", (ftnlen)6);
+ return 0;
+} /* dafb2a_ */
+
diff --git a/ext/spice/src/cspice/dafb2t.c b/ext/spice/src/cspice/dafb2t.c
new file mode 100644
index 0000000000..0dab9dafb5
--- /dev/null
+++ b/ext/spice/src/cspice/dafb2t.c
@@ -0,0 +1,864 @@
+/* dafb2t.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static logical c_false = FALSE_;
+static integer c__1 = 1;
+static integer c__3 = 3;
+static integer c__9 = 9;
+static integer c__5 = 5;
+
+/* $Procedure DAFB2T ( DAF, binary to text ) */
+/* Subroutine */ int dafb2t_(char *binary, integer *text, ftnlen binary_len)
+{
+ /* System generated locals */
+ address a__1[3];
+ integer i__1[3], i__2, i__3;
+ char ch__1[10], ch__2[62], ch__3[1002];
+
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_rdue(cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void),
+ s_wsle(cilist *);
+ /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
+ integer do_lio(integer *, integer *, char *, ftnlen), e_wsle(void),
+ s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ char name__[1000];
+ integer free;
+ extern /* Subroutine */ int zzddhhlu_(integer *, char *, logical *,
+ integer *, ftnlen);
+ integer i__;
+ extern /* Subroutine */ int dafgn_(char *, ftnlen);
+ integer begin;
+ extern /* Subroutine */ int dafgs_(doublereal *), chkin_(char *, ftnlen);
+ integer bward;
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *);
+ integer fward;
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
+ integer chunk;
+ logical found;
+ integer csize, isize, lsize;
+ extern /* Subroutine */ int dafgda_(integer *, integer *, integer *,
+ doublereal *);
+ doublereal dc[125];
+ integer ic[250];
+ extern /* Subroutine */ int daffna_(logical *);
+ integer nd;
+ extern logical failed_(void);
+ extern /* Subroutine */ int dafbfs_(integer *);
+ integer ni, handle;
+ extern /* Subroutine */ int dafcls_(integer *);
+ char ifname[60];
+ extern /* Subroutine */ int dafrfr_(integer *, integer *, integer *, char
+ *, integer *, integer *, integer *, ftnlen);
+ doublereal buffer[100];
+ integer daflun;
+ extern /* Subroutine */ int dafopr_(char *, integer *, ftnlen);
+ char idword[8];
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+ integer end;
+ doublereal sum[125];
+
+ /* Fortran I/O blocks */
+ static cilist io___5 = { 1, 0, 1, 0, 1 };
+ static cilist io___12 = { 1, 0, 0, 0, 0 };
+ static cilist io___13 = { 1, 0, 0, 0, 0 };
+ static cilist io___14 = { 1, 0, 0, 0, 0 };
+ static cilist io___15 = { 1, 0, 0, 0, 0 };
+ static cilist io___23 = { 1, 0, 0, 0, 0 };
+ static cilist io___24 = { 1, 0, 0, 0, 0 };
+ static cilist io___25 = { 1, 0, 0, 0, 0 };
+ static cilist io___27 = { 1, 0, 0, 0, 0 };
+ static cilist io___33 = { 1, 0, 0, 0, 0 };
+ static cilist io___34 = { 1, 0, 0, 0, 0 };
+ static cilist io___35 = { 1, 0, 0, 0, 0 };
+ static cilist io___36 = { 1, 0, 0, 0, 0 };
+ static cilist io___37 = { 1, 0, 0, 0, 0 };
+ static cilist io___38 = { 1, 0, 0, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Write the contents of a binary DAF to a text file opened by */
+/* the calling program. (Obsolete, maintained for backward */
+/* compatibility only.) */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* BINARY I Name of an existing binary DAF. */
+/* TEXT I Logical unit connected to text file. */
+
+/* $ Detailed_Input */
+
+/* BINARY is the name of an existing binary DAF. */
+
+/* TEXT is a logical unit number, to which a text file has */
+/* been connected by the calling program, and into */
+/* which the contents of BINARY are to be written */
+/* (in a form more suitable for transfer between */
+/* heterogeneous computing environments). */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See arguments BINARY, TEXT. */
+
+/* $ Exceptions */
+
+/* 1) If for some reason the text file cannot be written, */
+/* the error SPICE(DAFWRITEFAIL) is signalled. */
+
+/* 2) If for some reason the ID word cannot be read from the DAF */
+/* file, the error SPICE(DAFREADFAIL) will be signalled. */
+
+/* $ Particulars */
+
+/* This routine has been made obsolete by the new DAF binary to text */
+/* conversion routine DAFBT. This routine remains available for */
+/* reasons of backward compatibility. We strongly recommend that you */
+/* use the new conversion routines for any new software development. */
+/* Please see the header of the routine DAFBT for details. */
+
+/* Any binary DAF may be transferred between heterogeneous */
+/* Fortran environments by converting it to an equivalent file */
+/* containing only ASCII characters. Such a file can be transferred */
+/* almost universally, using any number of established protocols */
+/* (Kermit, FTP, and so on). Once transferred, the ASCII file can */
+/* be converted to a binary file, using the representations */
+/* native to the new host environment. */
+
+/* There are two pairs of routines that can be used to convert */
+/* DAFs between binary and text. The first pair, DAFB2A */
+/* and DAFA2B, works with complete files. That is, DAFB2A creates */
+/* a complete ASCII file containing all of the information in */
+/* a particular binary file, and nothing else; this file can */
+/* be fed directly into DAFA2B to produce a complete binary file. */
+/* In each case, the names of the files are specified. */
+
+/* A related pair of routines, DAFB2T and DAFT2B, assume that */
+/* the ASCII data are to be stored in the midst of a text file. */
+/* This allows the calling program to surround the data with */
+/* standardized labels, to append several binary files into a */
+/* single text file, and so on. */
+
+/* Note that the contents of reserved records in the binary file */
+/* are not written by this routine (although they may be stored */
+/* in the ASCII file by the calling program). */
+
+/* $ Examples */
+
+/* DAFB2A and DAFA2B are typically used for simple file transfers. */
+/* If file A.DAF is a binary DAF in environment 1, it can be */
+/* transferred to environment 2 in three steps. */
+
+/* 1) Convert it to ASCII: */
+
+/* CALL DAFB2A ( 'A.DAF', 'A.ASCII' ) */
+
+/* 2) Transfer the ASCII file, using FTP, Kermit, or some other */
+/* file transfer utility: */
+
+/* ftp> put a.ascii */
+
+/* 3) Convert it to binary on the new machine, */
+
+/* CALL DAFA2B ( 'A.ASCII', 'A.DAF', RESV ) */
+
+/* Note that DAFB2A and DAFA2B work in any standard Fortran-77 */
+/* environment. */
+
+/* If the file needs to contain other information---a standard */
+/* label, for instance---the first and third steps must be modified */
+/* to use DAFB2T and DAFT2B. The first step becomes */
+
+/* (Open a text file) */
+/* (Write the label) */
+/* CALL DAFB2T ( BINARY, UNIT ) */
+/* (Close the text file) */
+
+/* The third step becomes */
+
+/* (Open the text file) */
+/* (Read the label) */
+/* CALL DAFT2B ( UNIT, BINARY, RESV ) */
+/* (Close the text file) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 16-NOV-2001 (FST) */
+
+/* Updated this routine to utilize the new handle manager */
+/* interfaces. */
+
+/* - SPICELIB Version 2.0.0, 04-OCT-1993 (KRG) */
+
+/* Added the variable IDWORD to the routine for storing the ID */
+/* word from the file being converted. This replaces a hard coded */
+/* value of 'NAIF/DAF', and supports the new interpretation of the */
+/* ID word. */
+
+/* Removed the error SPICE(DAFNOIDWORD) as it was no longer */
+/* relevant. */
+
+/* There were no checks of the IOSTAT variable after attempting to */
+/* write to the text file, a single test of the IOSTAT variable */
+/* was made at the end of the routine. This was not adequate to */
+/* detect errors when writing to the text file. So after all of */
+/* these write statements, an IF ... END IF block was added to */
+/* signal an error if IOSTAT .NE. 0. */
+
+/* Added the following error message to the routine: */
+
+/* C 2) If for some reason the ID word cannot be read from */
+/* C the DAF file, the error SPICE(DAFREADFAIL) will be */
+/* C signalled. */
+
+/* because the file ID word is now read from the binary DAF file */
+/* rather than being hard coded as 'NAIF/DAF' in this routine. */
+
+/* Added a statement to the $ Particulars section to the effect */
+/* that this routine has been made obsolete by the introduction of */
+/* the routine DAFBT, and that we strongly recommend the use of */
+/* the new routine. */
+
+/* Modified the $ Abstract section to reflect the fact that this */
+/* routine is obsolete. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* binary daf to text */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 3.0.0, 16-NOV-2001 (FST) */
+
+/* This routine still uses a naked READ to retrieve the */
+/* file IDWORD from the first 8 characters stored in the */
+/* file record. It may be that future environments */
+/* will have characters whose storage exceeds 1 byte, */
+/* in which case this routine will require modification. */
+/* One possibility is to call the private file record */
+/* reader ZZDAFGFR, which must address the translation */
+/* for all supported non-native binary file formats on this */
+/* platform. */
+
+/* The existing call to DAFHLU was replaced with ZZDDHHLU. */
+/* The call to DAFRDA was replaced with a call to the new, */
+/* translation-aware routine DAFGDA. */
+
+/* - SPICELIB Version 2.0.0, 04-OCT-1993 (KRG) */
+
+/* Added the variable IDWORD to the routine for storing the ID */
+/* word from the file being converted. This replaces a hard coded */
+/* value of 'NAIF/DAF', and supports the new interpretation of the */
+/* ID word. */
+
+/* Removed the error SPICE(DAFNOIDWORD) as it was no longer */
+/* relevant. */
+
+/* There were no checks of the IOSTAT variable after attempting to */
+/* write to the text file, a single test of the IOSTAT variable */
+/* was made at the end of the routine. This was not adequate to */
+/* detect errors when writing to the text file. So after all of */
+/* these write statements, an IF ... END IF block was added to */
+/* signal an error if IOSTAT .NE. 0. */
+
+/* IF ( IOSTAT .NE. 0 ) THEN */
+
+/* CALL DAFCLS ( HANDLE ) */
+/* CALL SETMSG ( 'The attempt to write to file ''#''' // */
+/* . ' failed. IOSTAT = #.' ) */
+/* CALL ERRFNM ( '#', TEXT ) */
+/* CALL SIGERR ( 'SPICE(DAFWRITEFAIL)' ) */
+/* CALL CHKOUT ( 'DAFB2T' ) */
+/* RETURN */
+
+/* END IF */
+
+/* Removed the code from the end of the routine that purported to */
+/* check for read errors: */
+
+/* C */
+/* C If any write screws up, they should all screw up. Why */
+/* C make a billion separate checks? */
+/* C */
+/* IF ( IOSTAT .NE. 0 ) THEN */
+/* CALL SETMSG ( 'Value of IOSTAT was: #. ' ) */
+/* CALL ERRINT ( '#', IOSTAT ) */
+/* CALL SIGERR ( 'SPICE(DAFWRITEFAIL)' ) */
+/* END IF */
+
+/* The answer to the question is: */
+
+/* You have to do a billion separate checks because the IOSTAT */
+/* value is only valid for the most recently executed write. */
+
+/* Added the following error message to the routine: */
+
+/* C 2) If for some reason the ID word cannot be read from */
+/* C the DAF file, the error SPICE(DAFREADFAIL) will be */
+/* C signalled. */
+
+/* because the file ID word is now read from the binary DAF file */
+/* rather than being hard coded as 'NAIF/DAF' in this routine. */
+
+/* Added a statement to the $ Particulars section to the effect */
+/* that this routine has been made obsolete by the introduction of */
+/* the routine DAFBT, and that we strongly recommend the use of */
+/* the new routine. */
+
+/* Modified the $ Abstract section to reflect the fact that this */
+/* routine is obsolete. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFB2T", (ftnlen)6);
+ }
+
+/* Initialize the IDWORD. */
+
+ s_copy(idword, " ", (ftnlen)8, (ftnlen)1);
+
+/* Open the binary file for reading and read the ID word from the */
+/* first record of the file. */
+
+ dafopr_(binary, &handle, binary_len);
+ if (failed_()) {
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+
+/* At this point, we know that we have a DAF file, because we were */
+/* able to successfully open it, so we will attempt to proceed with */
+/* the file conversion process. */
+
+/* Convert the DAF file handle to its equivalent Fortran logical */
+/* unit. We need to do this in order to accurately move the file */
+/* ID word to the text file. */
+
+ zzddhhlu_(&handle, "DAF", &c_false, &daflun, (ftnlen)3);
+ if (failed_()) {
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___5.ciunit = daflun;
+ iostat = s_rdue(&io___5);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, idword, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rdue();
+L100001:
+ if (iostat != 0) {
+ setmsg_("Could not read ID word from file '#'. IOSTAT = #.", (ftnlen)
+ 49);
+ errch_("#", binary, (ftnlen)1, binary_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+
+/* Get the contents of the file record. The ASCII file begins */
+/* with the ID word which is followed by the summary format, */
+/* which is followed by the internal file name. */
+
+ dafrfr_(&handle, &nd, &ni, ifname, &fward, &bward, &free, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___12.ciunit = *text;
+ iostat = s_wsle(&io___12);
+ if (iostat != 0) {
+ goto L100002;
+ }
+/* Writing concatenation */
+ i__1[0] = 1, a__1[0] = "'";
+ i__1[1] = 8, a__1[1] = idword;
+ i__1[2] = 1, a__1[2] = "'";
+ s_cat(ch__1, a__1, i__1, &c__3, (ftnlen)10);
+ iostat = do_lio(&c__9, &c__1, ch__1, (ftnlen)10);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_wsle();
+L100002:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #.", (
+ ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___13.ciunit = *text;
+ iostat = s_wsle(&io___13);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_lio(&c__3, &c__1, (char *)&nd, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = e_wsle();
+L100003:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #.", (
+ ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___14.ciunit = *text;
+ iostat = s_wsle(&io___14);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_lio(&c__3, &c__1, (char *)&ni, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = e_wsle();
+L100004:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #.", (
+ ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___15.ciunit = *text;
+ iostat = s_wsle(&io___15);
+ if (iostat != 0) {
+ goto L100005;
+ }
+/* Writing concatenation */
+ i__1[0] = 1, a__1[0] = "'";
+ i__1[1] = 60, a__1[1] = ifname;
+ i__1[2] = 1, a__1[2] = "'";
+ s_cat(ch__2, a__1, i__1, &c__3, (ftnlen)62);
+ iostat = do_lio(&c__9, &c__1, ch__2, (ftnlen)62);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = e_wsle();
+L100005:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #.", (
+ ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+
+/* Each array is preceded by a '1', which indicates that more */
+/* arrays are to come. The array itself begins with the name */
+/* and the summary components, and ends with the name again. */
+/* The elements are written in arbitrary chunks. The final */
+/* chunk is followed by a '0', which indicates that no chunks */
+/* remain. */
+
+/* Write the arrays in forward order. */
+
+ lsize = nd + (ni - 1) / 2 + 1;
+ isize = lsize << 3;
+ dafbfs_(&handle);
+ daffna_(&found);
+ if (failed_()) {
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ while(found) {
+ dafgs_(sum);
+ dafgn_(name__, (ftnlen)1000);
+ dafus_(sum, &nd, &ni, dc, ic);
+ if (failed_()) {
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___23.ciunit = *text;
+ iostat = s_wsle(&io___23);
+ if (iostat != 0) {
+ goto L100006;
+ }
+ iostat = do_lio(&c__9, &c__1, "1", (ftnlen)1);
+ if (iostat != 0) {
+ goto L100006;
+ }
+ iostat = e_wsle();
+L100006:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #.", (
+ ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___24.ciunit = *text;
+ iostat = s_wsle(&io___24);
+ if (iostat != 0) {
+ goto L100007;
+ }
+/* Writing concatenation */
+ i__1[0] = 1, a__1[0] = "'";
+ i__1[1] = isize, a__1[1] = name__;
+ i__1[2] = 1, a__1[2] = "'";
+ s_cat(ch__3, a__1, i__1, &c__3, (ftnlen)1002);
+ iostat = do_lio(&c__9, &c__1, ch__3, isize + 2);
+ if (iostat != 0) {
+ goto L100007;
+ }
+ iostat = e_wsle();
+L100007:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #.", (
+ ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___25.ciunit = *text;
+ iostat = s_wsle(&io___25);
+ if (iostat != 0) {
+ goto L100008;
+ }
+ i__2 = nd;
+ for (i__ = 1; i__ <= i__2; ++i__) {
+ iostat = do_lio(&c__5, &c__1, (char *)&dc[(i__3 = i__ - 1) < 125
+ && 0 <= i__3 ? i__3 : s_rnge("dc", i__3, "dafb2t_", (
+ ftnlen)558)], (ftnlen)sizeof(doublereal));
+ if (iostat != 0) {
+ goto L100008;
+ }
+ }
+ iostat = e_wsle();
+L100008:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #.", (
+ ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___27.ciunit = *text;
+ iostat = s_wsle(&io___27);
+ if (iostat != 0) {
+ goto L100009;
+ }
+ i__3 = ni - 2;
+ for (i__ = 1; i__ <= i__3; ++i__) {
+ iostat = do_lio(&c__3, &c__1, (char *)&ic[(i__2 = i__ - 1) < 250
+ && 0 <= i__2 ? i__2 : s_rnge("ic", i__2, "dafb2t_", (
+ ftnlen)573)], (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100009;
+ }
+ }
+ iostat = e_wsle();
+L100009:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #.", (
+ ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ begin = ic[(i__2 = ni - 2) < 250 && 0 <= i__2 ? i__2 : s_rnge("ic",
+ i__2, "dafb2t_", (ftnlen)588)];
+ end = ic[(i__2 = ni - 1) < 250 && 0 <= i__2 ? i__2 : s_rnge("ic",
+ i__2, "dafb2t_", (ftnlen)589)];
+ while(begin <= end) {
+/* Computing MIN */
+ i__2 = begin + 99;
+ chunk = min(i__2,end);
+ csize = chunk - begin + 1;
+ dafgda_(&handle, &begin, &chunk, buffer);
+ if (failed_()) {
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___33.ciunit = *text;
+ iostat = s_wsle(&io___33);
+ if (iostat != 0) {
+ goto L100010;
+ }
+ iostat = do_lio(&c__3, &c__1, (char *)&csize, (ftnlen)sizeof(
+ integer));
+ if (iostat != 0) {
+ goto L100010;
+ }
+ iostat = e_wsle();
+L100010:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #."
+ , (ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___34.ciunit = *text;
+ iostat = s_wsle(&io___34);
+ if (iostat != 0) {
+ goto L100011;
+ }
+ i__2 = csize;
+ for (i__ = 1; i__ <= i__2; ++i__) {
+ iostat = do_lio(&c__5, &c__1, (char *)&buffer[(i__3 = i__ - 1)
+ < 100 && 0 <= i__3 ? i__3 : s_rnge("buffer", i__3,
+ "dafb2t_", (ftnlen)620)], (ftnlen)sizeof(doublereal));
+ if (iostat != 0) {
+ goto L100011;
+ }
+ }
+ iostat = e_wsle();
+L100011:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #."
+ , (ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ begin += 100;
+ }
+ io___35.ciunit = *text;
+ iostat = s_wsle(&io___35);
+ if (iostat != 0) {
+ goto L100012;
+ }
+ iostat = do_lio(&c__9, &c__1, "0", (ftnlen)1);
+ if (iostat != 0) {
+ goto L100012;
+ }
+ iostat = e_wsle();
+L100012:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #.", (
+ ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___36.ciunit = *text;
+ iostat = s_wsle(&io___36);
+ if (iostat != 0) {
+ goto L100013;
+ }
+/* Writing concatenation */
+ i__1[0] = 1, a__1[0] = "'";
+ i__1[1] = isize, a__1[1] = name__;
+ i__1[2] = 1, a__1[2] = "'";
+ s_cat(ch__3, a__1, i__1, &c__3, (ftnlen)1002);
+ iostat = do_lio(&c__9, &c__1, ch__3, isize + 2);
+ if (iostat != 0) {
+ goto L100013;
+ }
+ iostat = e_wsle();
+L100013:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #.", (
+ ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ daffna_(&found);
+ if (failed_()) {
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* A final '0' indicates that no arrays remain. The first shall be */
+/* last: the internal file name brings up the rear. */
+
+ io___37.ciunit = *text;
+ iostat = s_wsle(&io___37);
+ if (iostat != 0) {
+ goto L100014;
+ }
+ iostat = do_lio(&c__9, &c__1, "0", (ftnlen)1);
+ if (iostat != 0) {
+ goto L100014;
+ }
+ iostat = e_wsle();
+L100014:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #.", (
+ ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+ io___38.ciunit = *text;
+ iostat = s_wsle(&io___38);
+ if (iostat != 0) {
+ goto L100015;
+ }
+/* Writing concatenation */
+ i__1[0] = 1, a__1[0] = "'";
+ i__1[1] = 60, a__1[1] = ifname;
+ i__1[2] = 1, a__1[2] = "'";
+ s_cat(ch__2, a__1, i__1, &c__3, (ftnlen)62);
+ iostat = do_lio(&c__9, &c__1, ch__2, (ftnlen)62);
+ if (iostat != 0) {
+ goto L100015;
+ }
+ iostat = e_wsle();
+L100015:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to write to file '#' failed. IOSTAT = #.", (
+ ftnlen)52);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+ }
+
+/* Close only the binary file. */
+
+ dafcls_(&handle);
+ chkout_("DAFB2T", (ftnlen)6);
+ return 0;
+} /* dafb2t_ */
+
diff --git a/ext/spice/src/cspice/dafbbs_c.c b/ext/spice/src/cspice/dafbbs_c.c
new file mode 100644
index 0000000000..7143dae6f2
--- /dev/null
+++ b/ext/spice/src/cspice/dafbbs_c.c
@@ -0,0 +1,246 @@
+/*
+
+-Procedure dafbbs_c ( DAF, begin backward search )
+
+-Abstract
+
+ Begin a backward search for arrays in a DAF.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+ void dafbbs_c ( SpiceInt handle )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of DAF to be searched.
+
+-Detailed_Input
+
+ handle is the handle of a DAF on which a backward
+ search is to be conducted.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Files
+
+ See argument handle.
+
+-Exceptions
+
+ 1) If the input handle is invalid, the error will be diagnosed
+ by routines called by this routine.
+
+-Particulars
+
+
+ The DAF search routines are:
+
+ dafbfs_c Begin forward search.
+ daffna Find next array.
+
+ dafbbs_c Begin backward search.
+ daffpa_c Find previous array.
+
+ dafgs_c Get summary.
+ dafgn_c Get name.
+ dafgh_c Get handle.
+
+ dafcs_c Continue search.
+
+ The main function of these entry points is to allow the
+ contents of any DAF to be examined on an array-by-array
+ basis.
+
+ Conceptually, the arrays in a DAF form a doubly linked list,
+ which can be searched in either of two directions: forward or
+ backward. It is possible to search multiple DAFs simultaneously.
+
+ dafbfs_c (begin forward search) and daffna are used to search the
+ arrays in a DAF in forward order. In applications that search a
+ single DAF at a time, the normal usage is
+
+ dafbfs_c ( handle );
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffna_c ( &found );
+ }
+
+
+ dafbbs_c (begin backward search) and daffpa_c are used to search the
+ arrays in a DAF in backward order. In applications that search
+ a single DAF at a time, the normal usage is
+
+ dafbbs_c ( handle );
+ daffpa_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffpa_c ( &found );
+ }
+
+
+ In applications that conduct multiple searches simultaneously,
+ the above usage must be modified to specify the handle of the
+ file to operate on, in any case where the file may not be the
+ last one specified by dafbfs_c or dafbbs_c. The routine dafcs_c
+ (DAF, continue search) is used for this purpose. Below, we
+ give an example of an interleaved search of two files specified
+ by the handles handl1 and handl2. The directions of searches
+ in different DAFs are independent; here we conduct a forward
+ search on one file and a backward search on the other.
+ Throughout, we use dafcs to specify which file to operate on,
+ before calling daffna_c, daffpa_c, dafgs_c, or dafgn_c.
+
+
+ dafbfs_c ( handl1 );
+ dafbbs_c ( handl2 );
+
+ dafcs_c ( handl1 );
+ daffna_c ( &found1 );
+
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+
+ while ( found1 || found2 )
+ {
+ if ( found1 )
+ {
+ dafcs_c ( handl1 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( &handl1 );
+ daffna_c ( &found1 );
+ }
+
+ if ( found2 )
+ {
+ dafcs_c ( handl2 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+ }
+ }
+
+
+ At any time, the latest array found (whether by daffna_c or daffpa_c)
+ is regarded as the "current" array for the file in which the
+ array was found. The last DAF in which a search was started,
+ executed, or continued by any of dafbfs_c, dafbbs_c, daffna_c,
+ daffpa_c or dafcs_c is regarded as the "current" DAF. The summary
+ and name for the current array in the current DAF can be obtained
+ separately, as shown above, by calls to DAFGS (get summary) and
+ dafgn_c (get name). The handle of the current DAF can also be
+ obtained by calling dafgh_c (get handle).
+
+ Once a search has been begun, it may be continued in either
+ direction. That is, daffpa_c may be used to back up during a
+ forward search, and daffna_c may be used to advance during a
+ backward search.
+
+-Examples
+
+ 1) See Particulars.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ NAIF Document 167.0, "Double Precision Array Files (DAF)
+ Specification and User's Guide"
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 31-JUL-1999 (NJB) (WLT) (IMU)
+
+-Index_Entries
+
+ begin daf backward search
+
+-&
+*/
+
+{ /* Begin dafbbs_c */
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafbbs_c" );
+
+
+ dafbbs_ ( ( integer * ) &handle );
+
+
+ chkout_c ( "dafbbs_c" );
+
+} /* End dafbbs_c */
diff --git a/ext/spice/src/cspice/dafbfs_c.c b/ext/spice/src/cspice/dafbfs_c.c
new file mode 100644
index 0000000000..baab761422
--- /dev/null
+++ b/ext/spice/src/cspice/dafbfs_c.c
@@ -0,0 +1,247 @@
+/*
+
+-Procedure dafbfs_c ( DAF, begin forward search )
+
+-Abstract
+
+ Begin a forward search for arrays in a DAF.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+
+ void dafbfs_c ( SpiceInt handle )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of file to be searched.
+
+-Detailed_Input
+
+ handle is the handle of a DAF on which a forward
+ search is to be conducted.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Files
+
+ See argument handle.
+
+-Exceptions
+
+ 1) If the input handle is invalid, the error will be diagnosed
+ by routines called by this routine.
+
+-Particulars
+
+ The DAF search routines are:
+
+ dafbfs_c Begin forward search.
+ daffna Find next array.
+
+ dafbbs_c Begin backward search.
+ daffpa_c Find previous array.
+
+ dafgs_c Get summary.
+ dafgn_c Get name.
+ dafgh_c Get handle.
+
+ dafcs_c Continue search.
+
+ The main function of these entry points is to allow the
+ contents of any DAF to be examined on an array-by-array
+ basis.
+
+ Conceptually, the arrays in a DAF form a doubly linked list,
+ which can be searched in either of two directions: forward or
+ backward. It is possible to search multiple DAFs simultaneously.
+
+ dafbfs_c (begin forward search) and daffna are used to search the
+ arrays in a DAF in forward order. In applications that search a
+ single DAF at a time, the normal usage is
+
+ dafbfs_c ( handle );
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffna_c ( &found );
+ }
+
+
+ dafbbs_c (begin backward search) and daffpa_c are used to search the
+ arrays in a DAF in backward order. In applications that search
+ a single DAF at a time, the normal usage is
+
+ dafbbs_c ( handle );
+ daffpa_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffpa_c ( &found );
+ }
+
+
+ In applications that conduct multiple searches simultaneously,
+ the above usage must be modified to specify the handle of the
+ file to operate on, in any case where the file may not be the
+ last one specified by dafbfs_c or dafbbs_c. The routine dafcs_c
+ (DAF, continue search) is used for this purpose. Below, we
+ give an example of an interleaved search of two files specified
+ by the handles handl1 and handl2. The directions of searches
+ in different DAFs are independent; here we conduct a forward
+ search on one file and a backward search on the other.
+ Throughout, we use dafcs to specify which file to operate on,
+ before calling daffna_c, daffpa_c, dafgs_c, or dafgn_c.
+
+
+ dafbfs_c ( handl1 );
+ dafbbs_c ( handl2 );
+
+ dafcs_c ( handl1 );
+ daffna_c ( &found1 );
+
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+
+ while ( found1 || found2 )
+ {
+ if ( found1 )
+ {
+ dafcs_c ( handl1 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( &handl1 );
+ daffna_c ( &found1 );
+ }
+
+ if ( found2 )
+ {
+ dafcs_c ( handl2 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+ }
+ }
+
+
+ At any time, the latest array found (whether by daffna_c or daffpa_c)
+ is regarded as the "current" array for the file in which the
+ array was found. The last DAF in which a search was started,
+ executed, or continued by any of dafbfs_c, dafbbs_c, daffna_c,
+ daffpa_c or dafcs_c is regarded as the "current" DAF. The summary
+ and name for the current array in the current DAF can be obtained
+ separately, as shown above, by calls to DAFGS (get summary) and
+ dafgn_c (get name). The handle of the current DAF can also be
+ obtained by calling dafgh_c (get handle).
+
+ Once a search has been begun, it may be continued in either
+ direction. That is, daffpa_c may be used to back up during a
+ forward search, and daffna_c may be used to advance during a
+ backward search.
+
+-Examples
+
+ 1) See Particulars.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ NAIF Document 167.0, "Double Precision Array Files (DAF)
+ Specification and User's Guide"
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 31-JUL-1999 (NJB) (WLT) (IMU)
+
+-Index_Entries
+
+ begin daf forward search
+
+-&
+*/
+
+{ /* Begin dafbfs_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafbfs_c" );
+
+
+ dafbfs_ ( ( integer * ) &handle );
+
+
+ chkout_c ( "dafbfs_c" );
+
+} /* End dafbfs_c */
diff --git a/ext/spice/src/cspice/dafbt.c b/ext/spice/src/cspice/dafbt.c
new file mode 100644
index 0000000000..97a1e5ff71
--- /dev/null
+++ b/ext/spice/src/cspice/dafbt.c
@@ -0,0 +1,917 @@
+/* dafbt.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static logical c_false = FALSE_;
+static integer c__1 = 1;
+static integer c__3 = 3;
+static integer c__2 = 2;
+
+/* $Procedure DAFBT ( DAF, convert binary file to transfer file ) */
+/* Subroutine */ int dafbt_(char *binfil, integer *xfrlun, ftnlen binfil_len)
+{
+ /* System generated locals */
+ address a__1[3];
+ integer i__1[3], i__2, i__3;
+ char ch__1[10], ch__2[62], ch__3[1002];
+ cilist ci__1;
+
+ /* Builtin functions */
+ integer s_rdue(cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void),
+ s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void)
+ ;
+ /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
+ integer s_rnge(char *, integer, char *, integer);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ char name__[1000];
+ integer free;
+ char line[80];
+ extern /* Subroutine */ int zzddhhlu_(integer *, char *, logical *,
+ integer *, ftnlen), dafgn_(char *, ftnlen), dafgs_(doublereal *),
+ chkin_(char *, ftnlen);
+ integer bward;
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *);
+ integer fward;
+ logical found;
+ extern /* Subroutine */ int repmi_(char *, char *, integer *, char *,
+ ftnlen, ftnlen, ftnlen);
+ extern integer rtrim_(char *, ftnlen);
+ extern /* Subroutine */ int dafgda_(integer *, integer *, integer *,
+ doublereal *), daffna_(logical *);
+ integer nd;
+ extern logical failed_(void);
+ extern /* Subroutine */ int dafbfs_(integer *);
+ integer dtabeg, ni;
+ extern /* Subroutine */ int dafcls_(integer *);
+ char ifname[60];
+ integer binhdl;
+ extern /* Subroutine */ int dafrfr_(integer *, integer *, integer *, char
+ *, integer *, integer *, integer *, ftnlen);
+ doublereal buffer[1024];
+ integer dtacnt;
+ extern /* Subroutine */ int dafopr_(char *, integer *, ftnlen), wrencd_(
+ integer *, integer *, doublereal *);
+ integer binlun;
+ char idword[8];
+ integer numdta;
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen), sigerr_(
+ char *, ftnlen);
+ integer snmlen;
+ extern /* Subroutine */ int chkout_(char *, ftnlen), wrenci_(integer *,
+ integer *, integer *);
+ integer iostat, numarr, numlft;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ extern logical return_(void);
+ doublereal dsumry[125];
+ integer isumry[250];
+ doublereal summry[125];
+
+ /* Fortran I/O blocks */
+ static cilist io___4 = { 1, 0, 1, 0, 1 };
+
+
+/* $ Abstract */
+
+/* Convert the contents of a binary DAF file to an equivalent DAF */
+/* transfer file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* BINFIL I The name of a binary DAF file to be converted. */
+/* XFRLUN I Logical unit of a previously opened file. */
+
+/* $ Detailed_Input */
+
+/* BINFIL The name of a binary DAF file which is to be converted */
+/* to an equivalent DAF transfer file. */
+
+/* XFRLUN The Fortran logical unit number of a previously opened */
+/* file. The DAF transfer file will be written to the */
+/* file attached to this logical unit beginning at the */
+/* current position in the file. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See arguments BINFIL, XFRLUN. */
+
+/* $ Exceptions */
+
+
+/* 1) If the binary DAF file specified by the filename BINFIL */
+/* cannot be opened for read access, an appropriate error */
+/* message will be signalled by a DAF file access routine that */
+/* is called. */
+
+/* 2) If for some reason the DAF transfer file cannot be written */
+/* to, the error SPICE(FILEWRITEFAILED) is signalled. */
+
+/* 3) If, for any reason, the DAF file cannot be read, a DAF file */
+/* access routine will signal an error with appropriate error */
+/* message. */
+
+/* 4) If the ID word cannot be read from the binary file, the error */
+/* SPICE(FILEREADFAILED) will be signalled. */
+
+/* 5) The binary DAF file opened by this routine, BINFIL, is only */
+/* GUARANTEED to be closed upon successful completion of the */
+/* conversion process. In the event of an error, the caller of */
+/* this routine is required to close the binary DAF file BINFIL. */
+
+/* $ Particulars */
+
+/* Any binary DAF file may be transferred between heterogeneous */
+/* Fortran environments by converting it to an equivalent file */
+/* containing only ASCII characters. Such a file can be transferred */
+/* almost universally, using any number of established protocols. */
+/* Once transferred, the ASCII file can be converted to a binary */
+/* file, using the representations native to the new host */
+/* environment. */
+
+/* This routine provides a mechanism for converting a binary DAF */
+/* file into an equivalent encoded ASCII file called a DAF transfer */
+/* file. It is one of a pair of routines for performing conversions */
+/* between the binary format of a DAF file and the DAF transfer file. */
+/* The inverse of this routine is the routine DAFTB. */
+
+/* The contents of the reserved records in a binary DAF file are */
+/* ignored by this routine. They are not written to the DAF transfer */
+/* file. The reserved records must be dealt with separately from the */
+/* data in a DAF file. */
+
+/* Upon successful completion, the DAF transfer file attached to */
+/* Fortran logical unit XFRLUN will contain the same data as the */
+/* binary DAF file BINFIL. The binary DAF file BINFIL will be closed */
+/* when this routine exits. The DAF transfer file will remain open, */
+/* as it was on entry, and it will be positioned to write on the */
+/* first line following the encoded DAF data. */
+
+/* $ Examples */
+
+/* Let */
+
+/* BINFIL be the name of a binary DAF file which is to be */
+/* converted to an equivalent DAF transfer file. */
+
+/* XFRLUN be the Fortran logical unit to which the DAF transfer */
+/* file is to be written. */
+
+/* The following subroutine call would read the binary DAF */
+/* file with the name BINFIL, convert its data into an encoded */
+/* format, and write that data to the DAF transfer file attached */
+/* to the Fortran logical unit XFRLUN, beginning at the current */
+/* position in the file. */
+
+/* CALL DAFBT( BINFIL, XFRLUN ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.0.0, 16-NOV-2001 (FST) */
+
+/* Updated the routine to utilize the new handle manager */
+/* interfaces. */
+
+/* - SPICELIB Version 3.0.0, 25-JAN-1995 (KRG) */
+
+/* Updated the header and in line comments to reflect the change */
+/* from calling files text files to calling them transfer files. */
+
+/* Changed the variable name TXTLUN to XFRLUN to make it */
+/* compatible with the change in terminology. */
+
+/* - SPICELIB Version 2.0.0, 04-OCT-1993 (KRG) */
+
+/* No changes to this routine were necessary to incorporate the */
+/* new file ID word format. This routine already read and copied */
+/* the ID word to the text file being created. */
+
+/* Also, all list directed writes in this routine were replaced by */
+/* formatted writes with FMT = '(A)'. This routine only writes */
+/* character data. */
+
+/* Added a test of FAILED() after the call to DAFHLU for */
+/* completeness. */
+
+/* - SPICELIB Version 1.0.1, 24-JUN-1993 (KRG) */
+
+/* Modified the description of the DAF encoded text file format */
+/* appearing before the program code. */
+
+/* - SPICELIB Version 1.0.0, 29-OCT-1992 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* convert binary daf into a daf transfer file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 4.0.0, 16-NOV-2001 (FST) */
+
+/* This routine still uses a naked READ to retrieve the */
+/* file IDWORD from the first 8 characters stored in the */
+/* file record. It may be that future environments */
+/* will have characters whose storage exceeds 1 byte, */
+/* in which case this routine will require modification. */
+/* One possibility is to call the private file record */
+/* reader ZZDAFGFR, which must address the translation */
+/* for all supported non-native binary file formats on this */
+/* platform. */
+
+/* The existing call to DAFHLU was replaced with ZZDDHHLU. */
+/* The call to DAFRDA was replaced with a call to the new, */
+/* translation-aware routine DAFGDA. */
+
+/* - SPICELIB Version 2.0.0, 04-OCT-1993 (KRG) */
+
+/* No changes to this routine were necessary to incorporate the */
+/* new file ID word format. This routine already read and copied */
+/* the ID word to the text file being created. */
+
+/* Also, all list directed writes in this routine were replaced by */
+/* formatted writes with FMT = '(A)'. This routine only writes */
+/* character data. */
+
+/* Added a test of FAILED() after the call to DAFHLU for */
+/* completeness. */
+
+/* - SPICELIB Version 1.0.1, 24-JUN-1993 (KRG) */
+
+/* Modified the description of the DAF encoded text file format */
+/* appearing before the program code. Changed the line: */
+
+/* C < DAF ND value > < DAF NI value > */
+
+/* to the lines: */
+
+/* C < DAF ND value > */
+/* C < DAF NI value > */
+
+/* This change was necessary because the output format for the */
+/* low level routines which encode and write the data were */
+/* modified to fix a problem. See the routines WRENCD and WRENCI */
+/* for details of the modification. */
+
+/* - SPICELIB Version 1.0.0, 29-OCT-1992 (KRG) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFBT", (ftnlen)5);
+ }
+
+/* A brief description of the DAF transfer file format and its */
+/* intended use follows. This description is intended to provide a */
+/* simple ``picture'' of the DAF transfer file format to aid in the */
+/* understanding of this routine. This description is NOT intended to */
+/* be a detailed specification of the file format. */
+
+/* A DAF transfer file contains all of the data from a binary */
+/* DAF file, except for the reserved record area, in an encoded */
+/* ASCII format. The file also contains some bookkeeping information */
+/* for maintaining the integrity of the data. The DAF transfer file */
+/* format allows the full precision of both integer and floating */
+/* point numeric data to be maintained in a portable fashion. The DAF */
+/* transfer file format is intended to provide a reliable and */
+/* accurate means for porting data among multiple computer systems */
+/* and for the archival storage of data. */
+
+/* A DAF transfer file is not intended to be used directly to */
+/* provide data to a program, the equivalent binary DAF file is */
+/* to be used for this purpose. In no way should any program, other */
+/* than a DAF binary <-> transfer conversion program, rely on the DAF */
+/* encoded transfer file format. */
+
+/* To correctly understand the DAF transfer file description */
+/* the reader should be familiar with the DAF file architecture. */
+/* Items enclosed in angle brackets, '<' and '>', are used to */
+/* represent the data which is to be placed at that position in */
+/* the file. The bookkeeping information is represented exactly */
+/* as it would appear in a DAF transfer file. */
+
+/* Let */
+
+/* BOF denote the beginning of the file */
+/* EOF denote the end of the file */
+
+/* and */
+
+/* n denote the total number of arrays in a DAF file */
+/* NA(i) denote the number of double precision numbers in array i */
+/* m(i) denote the number of blocks of encoded data for array i */
+/* N(i,j) denote the number of encoded double precision numbers */
+/* in block j of array i */
+
+/* and */
+
+/* m(i) */
+/* ----- */
+/* \ */
+/* > N(i,k) = NA(i), i = 1, ..., n. */
+/* / */
+/* ----- */
+/* k=1 */
+
+/* A DAF encoded transfer file has the following format: */
+
+/* */
+/* < Information line > */
+/* < DAF file ID word > */
+/* < DAF ND value > */
+/* < DAF NI value > */
+/* < DAF internal file name > */
+/* BEGIN_ARRAY 1 NA(1) */
+/* < Name for array 1 > */
+/* < ND double precision summary values > */
+/* < NI-2 integer summary values > */
+/* N(1,1) */
+/* < N(1,1) Encoded double precision numbers > */
+/* N(1,2) */
+/* < N(1,2) Encoded double precision numbers > */
+/* . */
+/* . */
+/* . */
+/* N(1,m(1)) */
+/* < N(1,m(1)) Encoded double precision numbers > */
+/* END_ARRAY 1 NA(1) */
+/* BEGIN_ARRAY 2 NA(2) */
+/* < Name for array 2 > */
+/* < ND double precision summary values > */
+/* < NI-2 integer summary values > */
+/* N(2,1) */
+/* < N(2,1) Encoded double precision numbers > */
+/* N(2,2) */
+/* < N(2,2) Encoded double precision numbers > */
+/* . */
+/* . */
+/* . */
+/* N(2,m(2)) */
+/* < N(2,m(2)) Encoded double precision numbers > */
+/* END_ARRAY 2 NA(2) */
+/* . */
+/* . */
+/* . */
+/* BEGIN_ARRAY n NA(n) */
+/* < Name for array n > */
+/* < ND double precision summary values > */
+/* < NI-2 integer summary values > */
+/* N(n,1) */
+/* < N(n,1) Encoded double precision numbers > */
+/* N(n,2) */
+/* < N(n,2) Encoded double precision numbers > */
+/* . */
+/* . */
+/* . */
+/* N(n,m(n)) */
+/* < N(n,m(n)) Encoded double precision numbers > */
+/* END_ARRAY n NA(n) */
+/* TOTAL_ARRAYS n */
+/* */
+
+/* This routine will check the SPICELIB function FAILED() after */
+/* each call, or consecutive sequence of calls, to data encoding */
+/* routines, and if an error was signalled it will simply check out */
+/* and return to the caller. */
+
+/* This routine will check the SPICELIB function FAILED() after */
+/* each DAF file access call, and if an error was signalled it will */
+/* simply check out and return to the caller. */
+
+/* We begin by opening the binary DAF file specified by BINFIL for */
+/* read access, obtaining a DAF file handle. */
+
+ dafopr_(binfil, &binhdl, binfil_len);
+
+/* If the open failed, check out and return, as an appropriate error */
+/* message should have already been set. */
+
+ if (failed_()) {
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* At this point, we know that we have a DAF file, because we were */
+/* able to successfully open it, so we will attempt to proceed with */
+/* the file conversion process. */
+
+/* Convert the DAF file handle to its equivalent Fortran logical */
+/* unit. We need to do this in order to accurately move the file */
+/* ID word to the DAF transfer file. */
+
+ zzddhhlu_(&binhdl, "DAF", &c_false, &binlun, (ftnlen)3);
+
+/* If the translation failed, checkout and return, as an appropriate */
+/* error message should have already been set. */
+
+ if (failed_()) {
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Read the ID word from the binary file. It should be the first 8 */
+/* characters on the first record in the file. */
+
+ io___4.ciunit = binlun;
+ iostat = s_rdue(&io___4);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, idword, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rdue();
+L100001:
+ if (iostat != 0) {
+ setmsg_("Error reading the file ID word from the binary DAF file '#'"
+ ". IOSTAT = #.", (ftnlen)72);
+ errfnm_("#", &binlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Get the contents of the file record: the number of double */
+/* precision numbers in the summary (ND), the number of integers */
+/* in the summary (NI), the internal filename (IFNAME), and some */
+/* data pointer information (FWARD, BWARD, FREE). */
+
+ dafrfr_(&binhdl, &nd, &ni, ifname, &fward, &bward, &free, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write the information line containing the file type information */
+/* for the DAF transfer file format to the current position in the */
+/* DAF transfer file. The file type information must be the first */
+/* ``word'' on the information line. The rest of the line may be used */
+/* for other purposes. Right now, it simply contains an expanded */
+/* description of the file type information ``word.'' */
+
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_fio(&c__1, "DAFETF NAIF DAF ENCODED TRANSFER FILE", (ftnlen)
+ 37);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_wsfe();
+L100002:
+ if (iostat != 0) {
+ setmsg_("Error writing to the DAF transfer file '#'.IOSTAT = #.", (
+ ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write the ID word to the DAF transfer file. */
+
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100003;
+ }
+/* Writing concatenation */
+ i__1[0] = 1, a__1[0] = "'";
+ i__1[1] = 8, a__1[1] = idword;
+ i__1[2] = 1, a__1[2] = "'";
+ s_cat(ch__1, a__1, i__1, &c__3, (ftnlen)10);
+ iostat = do_fio(&c__1, ch__1, (ftnlen)10);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = e_wsfe();
+L100003:
+ if (iostat != 0) {
+ setmsg_("Error writing to the DAF transfer file '#'. IOSTAT = #.", (
+ ftnlen)55);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write out the ND and NI values for the DAF file architecture. */
+
+ isumry[0] = nd;
+ isumry[1] = ni;
+ wrenci_(xfrlun, &c__2, isumry);
+ if (failed_()) {
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write out the internal file name. */
+
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100004;
+ }
+/* Writing concatenation */
+ i__1[0] = 1, a__1[0] = "'";
+ i__1[1] = 60, a__1[1] = ifname;
+ i__1[2] = 1, a__1[2] = "'";
+ s_cat(ch__2, a__1, i__1, &c__3, (ftnlen)62);
+ iostat = do_fio(&c__1, ch__2, (ftnlen)62);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = e_wsfe();
+L100004:
+ if (iostat != 0) {
+ setmsg_("Error writing to the DAF transfer file '#'. IOSTAT = #.", (
+ ftnlen)55);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Calculate the length of the segment names. */
+
+ snmlen = nd + (ni + 1) / 2 << 3;
+
+/* Get ready to begin a forward search through the DAF file for the */
+/* data. */
+
+ dafbfs_(&binhdl);
+ if (failed_()) {
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Initialize the number of arrays processed to zero. */
+
+ numarr = 0;
+
+/* We'll assume that we will find some data, until proven otherwise. */
+
+ found = TRUE_;
+
+/* Begin looking for and processing the arrays in the binary DAF */
+/* file. */
+
+ while(found) {
+
+/* Look for a DAF array. */
+
+ daffna_(&found);
+ if (failed_()) {
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* If we found an array, then we need to process it. Start */
+/* by incrementing the number of arrays processed. If not, */
+/* we just skip to the bottom of the loop. */
+
+ if (found) {
+ ++numarr;
+
+/* Get and unpack the summary information for the current */
+/* array. */
+
+ dafgs_(summry);
+ dafus_(summry, &nd, &ni, dsumry, isumry);
+
+/* Get the name of the current array. */
+
+ dafgn_(name__, (ftnlen)1000);
+ if (failed_()) {
+
+/* If an error occurred on any of the DAF system calls */
+/* above, return to the caller. An appropriate error */
+/* message will have already been set by the routine which */
+/* signalled the error. */
+
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Get the beginning address for the data in the current array. */
+
+ dtabeg = isumry[(i__2 = ni - 2) < 250 && 0 <= i__2 ? i__2 :
+ s_rnge("isumry", i__2, "dafbt_", (ftnlen)657)];
+
+/* Set the number of double precision numbers in the current */
+/* array. */
+
+ dtacnt = isumry[(i__2 = ni - 1) < 250 && 0 <= i__2 ? i__2 :
+ s_rnge("isumry", i__2, "dafbt_", (ftnlen)662)] - isumry[(
+ i__3 = ni - 2) < 250 && 0 <= i__3 ? i__3 : s_rnge("isumry"
+ , i__3, "dafbt_", (ftnlen)662)] + 1;
+ s_copy(line, "BEGIN_ARRAY # #", (ftnlen)80, (ftnlen)15);
+ repmi_(line, "#", &numarr, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ repmi_(line, "#", &dtacnt, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = e_wsfe();
+L100005:
+ if (iostat != 0) {
+ setmsg_("Error writing to the DAF transfer file '#'. IOSTAT "
+ "= #.", (ftnlen)55);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write the name of the current array. */
+
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100006;
+ }
+/* Writing concatenation */
+ i__1[0] = 1, a__1[0] = "'";
+ i__1[1] = snmlen, a__1[1] = name__;
+ i__1[2] = 1, a__1[2] = "'";
+ s_cat(ch__3, a__1, i__1, &c__3, (ftnlen)1002);
+ iostat = do_fio(&c__1, ch__3, snmlen + 2);
+ if (iostat != 0) {
+ goto L100006;
+ }
+ iostat = e_wsfe();
+L100006:
+ if (iostat != 0) {
+ setmsg_("Error writing to the DAF transfer file '#'. IOSTAT "
+ "= #.", (ftnlen)55);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write out the double precision part of the summary. */
+
+ wrencd_(xfrlun, &nd, dsumry);
+
+/* Write out the integer part of the summary, excluding the */
+/* beginning and ending addresses of the data in the array, */
+/* ISUMRY(NI-1) and ISUMRY(NI), since these values vary with */
+/* the number of reserved records allocated. */
+
+ i__2 = ni - 2;
+ wrenci_(xfrlun, &i__2, isumry);
+ if (failed_()) {
+
+/* If an error occurred on any of the data encoding calls */
+/* above, return to the caller. An appropriate error message */
+/* will have already been set by the routine which signalled */
+/* the error. */
+
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+ numlft = dtacnt;
+ while(numlft > 0) {
+ if (numlft >= 1024) {
+ numdta = 1024;
+ } else {
+ numdta = numlft;
+ }
+
+/* Read in NUMDTA numbers from the current array. The */
+/* desired data are specified by beginning and ending */
+/* indices into the array, inclusive: thus the subtraction */
+/* of 1 in the call. */
+
+ i__2 = dtabeg + numdta - 1;
+ dafgda_(&binhdl, &dtabeg, &i__2, buffer);
+ if (failed_()) {
+
+/* We want to check failed here because were in a loop. */
+/* We should exit the loop, and the routine, as soon as */
+/* an error is detected, so we don't continue doing */
+/* things for a long time. */
+
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write out the count of double precision numbers which are */
+/* in the buffer. */
+
+ s_copy(line, "#", (ftnlen)80, (ftnlen)1);
+ repmi_(line, "#", &numdta, line, (ftnlen)80, (ftnlen)1, (
+ ftnlen)80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100007;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100007;
+ }
+ iostat = e_wsfe();
+L100007:
+ if (iostat != 0) {
+ setmsg_("Error writing to the DAF transfer file '#'. IOS"
+ "TAT = #.", (ftnlen)55);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Encode and write out a buffer of double precision */
+/* numbers. */
+
+ wrencd_(xfrlun, &numdta, buffer);
+ if (failed_()) {
+
+/* We want to check failed here because were in a loop. */
+/* We should exit the loop, and the routine, as soon as */
+/* an error is detected, so we don't continue doing */
+/* things for a long time. */
+
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+ numlft -= numdta;
+ dtabeg += numdta;
+ }
+ s_copy(line, "END_ARRAY # #", (ftnlen)80, (ftnlen)13);
+ repmi_(line, "#", &numarr, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ repmi_(line, "#", &dtacnt, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100008;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100008;
+ }
+ iostat = e_wsfe();
+L100008:
+ if (iostat != 0) {
+ setmsg_("Error writing to the DAF transfer file '#'. IOSTAT "
+ "= #.", (ftnlen)55);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* At this point, one complete DAF array has been written to the */
+/* DAF transfer file. */
+
+ }
+
+/* Write out the number of arrays processed. */
+
+ s_copy(line, "TOTAL_ARRAYS #", (ftnlen)80, (ftnlen)14);
+ repmi_(line, "#", &numarr, line, (ftnlen)80, (ftnlen)1, (ftnlen)80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100009;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100009;
+ }
+ iostat = e_wsfe();
+L100009:
+ if (iostat != 0) {
+ setmsg_("Error writing to the DAF transfer file '#'. IOSTAT = #.", (
+ ftnlen)55);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Close only the binary file. */
+
+ dafcls_(&binhdl);
+ chkout_("DAFBT", (ftnlen)5);
+ return 0;
+} /* dafbt_ */
+
diff --git a/ext/spice/src/cspice/dafcls_c.c b/ext/spice/src/cspice/dafcls_c.c
new file mode 100644
index 0000000000..04717f7b03
--- /dev/null
+++ b/ext/spice/src/cspice/dafcls_c.c
@@ -0,0 +1,180 @@
+/*
+
+-Procedure dafcls_c ( DAF, close )
+
+-Abstract
+
+ Close the DAF associated with a given handle.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ DAF
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+ void dafcls_c ( SpiceInt handle )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of DAF to be closed.
+
+-Detailed_Input
+
+ handle is the file handle of a previously opened DAF file.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Files
+
+ None.
+
+-Exceptions
+
+ 1) If the specified handle is not known to the DAF subsystem
+ (because it does not belong to a file opened via the DAF
+ API), nothing happens.
+
+ 2) If this routine is used to close a file whose handle is
+ known to the DAF subsystem, and if the file handle is
+ attached to a non-DAF file, routines called by this
+ routine signal an error.
+
+-Particulars
+
+ Because the DAF subsystem must keep track of what files are open at
+ any given time, it is important that DAF files be closed only with
+ dafcls_c, to prevent the remaining DAF routines from failing,
+ sometimes mysteriously.
+
+ Note that when a file is opened more than once for read access,
+ dafopr_c returns the same handle each time it is re-opened.
+ Each time the file is closed, dafcls_c checks to see if any other
+ claims on the file are still active before physically closing
+ the file.
+
+-Examples
+
+ In the following code fragment, the arrays in a file are examined in
+ order to determine whether the file contains any arrays whose names
+ begin with the word TEST. The complete names for these arrays are
+ printed to the screen. The file is closed at the end of the search.
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ dafopr_c ( fname, &handle );
+ dafbfs_c ( handle );
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ dafgn_c ( name );
+
+ if ( strncmp( name, "TEST", 4 ) == 0 )
+ {
+ printf ( "%s\n", name );
+ }
+ daffna_c ( &found );
+ }
+
+ dafcls_c ( handle );
+
+
+ Note that if the file has been opened already by a DAF routine
+ at some other place in the calling program, it remains open.
+ This makes it possible to examine files that have been opened for
+ use by other modules without interfering with the operation of
+ those routines.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ NAIF Document 167.0, "Double Precision Array Files (DAF)
+ Specification and User's Guide"
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.1, 28-JAN-2004 (NJB)
+
+ Header update: the exceptions section now lists the
+ case of attempting to close a non-DAF file using this
+ routine.
+
+ -CSPICE Version 1.0.0, 01-AUG-1999 (NJB) (KRG) (WLT) (IMU)
+
+-Index_Entries
+
+ close daf
+
+-&
+*/
+
+{ /* Begin dafcls_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafcls_c" );
+
+
+ dafcls_ ( ( integer * ) &handle );
+
+
+ chkout_c ( "dafcls_c" );
+
+} /* End dafcls_c */
diff --git a/ext/spice/src/cspice/dafcs_c.c b/ext/spice/src/cspice/dafcs_c.c
new file mode 100644
index 0000000000..b5125ecfdb
--- /dev/null
+++ b/ext/spice/src/cspice/dafcs_c.c
@@ -0,0 +1,256 @@
+/*
+
+-Procedure dafcs_c ( DAF, continue search )
+
+-Abstract
+
+ Select a DAF that already has a search in progress as the
+ one to continue searching.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+
+ void dafcs_c ( SpiceInt handle )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of DAF to continue searching.
+
+-Detailed_Input
+
+ handle is the handle of a DAF in which either a forward
+ or backward search has already been started by
+ dafbfs_c or dafbbs_c. The DAF may be open for read
+ or write access.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the input handle is invalid, the error will be diagnosed
+ by routines called by this routine.
+
+ 2) If this routine is called when no search is in progress in the
+ the current DAF, the error SPICE(DAFNOSEARCH) is signalled.
+
+-Files
+
+ None.
+
+-Particulars
+
+ dafcs_c supports simultaneous searching of multiple DAFs. In
+ applications that use this capability, dafcs_c should be called
+ prior to each call to daffna_c, daffpa_c, dafgn_c, or dafgs_c to
+ specify which DAF is to be acted upon.
+
+ The DAF search routines are:
+
+ dafbfs_c Begin forward search.
+ daffna Find next array.
+
+ dafbbs_c Begin backward search.
+ daffpa_c Find previous array.
+
+ dafgs_c Get summary.
+ dafgn_c Get name.
+ dafgh_c Get handle.
+
+ dafcs_c Continue search.
+
+ The main function of these entry points is to allow the
+ contents of any DAF to be examined on an array-by-array
+ basis.
+
+ Conceptually, the arrays in a DAF form a doubly linked list,
+ which can be searched in either of two directions: forward or
+ backward. It is possible to search multiple DAFs simultaneously.
+
+ dafbfs_c (begin forward search) and daffna are used to search the
+ arrays in a DAF in forward order. In applications that search a
+ single DAF at a time, the normal usage is
+
+ dafbfs_c ( handle );
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffna_c ( &found );
+ }
+
+
+ dafbbs_c (begin backward search) and daffpa_c are used to search the
+ arrays in a DAF in backward order. In applications that search
+ a single DAF at a time, the normal usage is
+
+ dafbbs_c ( handle );
+ daffpa_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffpa_c ( &found );
+ }
+
+
+ In applications that conduct multiple searches simultaneously,
+ the above usage must be modified to specify the handle of the
+ file to operate on, in any case where the file may not be the
+ last one specified by dafbfs_c or dafbbs_c. The routine dafcs_c
+ (DAF, continue search) is used for this purpose. Below, we
+ give an example of an interleaved search of two files specified
+ by the handles handl1 and handl2. The directions of searches
+ in different DAFs are independent; here we conduct a forward
+ search on one file and a backward search on the other.
+ Throughout, we use dafcs to specify which file to operate on,
+ before calling daffna_c, daffpa_c, dafgs_c, or dafgn_c.
+
+
+ dafbfs_c ( handl1 );
+ dafbbs_c ( handl2 );
+
+ dafcs_c ( handl1 );
+ daffna_c ( &found1 );
+
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+
+ while ( found1 || found2 )
+ {
+ if ( found1 )
+ {
+ dafcs_c ( handl1 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( &handl1 );
+ daffna_c ( &found1 );
+ }
+
+ if ( found2 )
+ {
+ dafcs_c ( handl2 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+ }
+ }
+
+
+ At any time, the latest array found (whether by daffna_c or daffpa_c)
+ is regarded as the "current" array for the file in which the
+ array was found. The last DAF in which a search was started,
+ executed, or continued by any of dafbfs_c, dafbbs_c, daffna_c,
+ daffpa_c or dafcs_c is regarded as the "current" DAF. The summary
+ and name for the current array in the current DAF can be obtained
+ separately, as shown above, by calls to DAFGS (get summary) and
+ dafgn_c (get name). The handle of the current DAF can also be
+ obtained by calling dafgh_c (get handle).
+
+ Once a search has been begun, it may be continued in either
+ direction. That is, daffpa_c may be used to back up during a
+ forward search, and daffna_c may be used to advance during a
+ backward search.
+
+-Examples
+
+ 1) See Particulars.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 31-JUL-1999 (NJB) (WLT)
+
+-Index_Entries
+
+ select a daf to continue searching
+
+-&
+*/
+
+{ /* Begin dafcs_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafcs_c" );
+
+
+ dafcs_ ( ( integer * ) &handle );
+
+
+ chkout_c ( "dafcs_c" );
+
+} /* End dafcs_c */
diff --git a/ext/spice/src/cspice/dafdc.c b/ext/spice/src/cspice/dafdc.c
new file mode 100644
index 0000000000..bd4d89edc4
--- /dev/null
+++ b/ext/spice/src/cspice/dafdc.c
@@ -0,0 +1,206 @@
+/* dafdc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DAFDC ( DAF delete comments ) */
+/* Subroutine */ int dafdc_(integer *handle)
+{
+ integer free;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer bward, fward, ncomr, nd;
+ extern logical failed_(void);
+ integer ni;
+ extern /* Subroutine */ int dafsih_(integer *, char *, ftnlen);
+ char ifname[60];
+ extern /* Subroutine */ int dafrfr_(integer *, integer *, integer *, char
+ *, integer *, integer *, integer *, ftnlen), dafrrr_(integer *,
+ integer *), chkout_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Delete the entire comment area of a previously opened binary */
+/* DAF attached to HANDLE. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* None. */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of a binary DAF opened for writing. */
+
+/* $ Detailed_Input */
+
+/* HANDLE The handle of a binary DAF that is to have its entire */
+/* comment area deleted. The DAF must have been opened */
+/* with write access. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the binary DAF attached to HANDLE is not open with write */
+/* access, an error will be signalled by a routine called by */
+/* this routine. */
+
+/* $ Files */
+
+/* See argument HANDLE in $ Detailed_Input. */
+
+/* $ Particulars */
+
+/* A binary DAF contains an area which is reserved for storing */
+/* annotations or descriptive textual information about the data */
+/* contained in a file. This area is referred to as the ``comment */
+/* area'' of the file. The comment area of a DAF is a line */
+/* oriented medium for storing textual information. The comment */
+/* area preserves any leading or embedded white space in the line(s) */
+/* of text which are stored, so that the appearance of the of */
+/* information will be unchanged when it is retrieved (extracted) at */
+/* some other time. Trailing blanks, however, are NOT preserved, */
+/* due to the way that character strings are represented in */
+/* standard Fortran 77. */
+
+/* This routine will delete the entire comment area from the binary */
+/* DAF attached to HANDLE. The size of the binary DAF will remain */
+/* unchanged. The space that was used by the comment records */
+/* is reclaimed. */
+
+/* $ Examples */
+
+/* Let */
+
+/* HANDLE be the handle of a DAF which has been opened */
+/* with write access. */
+
+/* The call */
+
+/* CALL DAFDC ( HANDLE ) */
+
+/* deletes the entire comment area of the binary DAF attached to */
+/* HANDLE. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - Beta Version 1.0.0, 23-SEP-1994 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* delete DAF comment area */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* Length of a DAF file internal filename. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFDC", (ftnlen)5);
+ }
+
+/* Verify that the DAF attached to HANDLE was opened with write */
+/* access. */
+
+ dafsih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DAFDC", (ftnlen)5);
+ return 0;
+ }
+
+/* Read the file record to obtain the current number of comment */
+/* records in the DAF attached to HANDLE. We will also get back some */
+/* extra stuff that we do not use. */
+
+ dafrfr_(handle, &nd, &ni, ifname, &fward, &bward, &free, (ftnlen)60);
+ ncomr = fward - 2;
+ if (failed_()) {
+ chkout_("DAFDC", (ftnlen)5);
+ return 0;
+ }
+
+/* Now we will attempt to remove the comment records, if there are */
+/* any, otherwise we do nothing. */
+
+ if (ncomr > 0) {
+
+/* We have some comment records, so remove them. */
+
+ dafrrr_(handle, &ncomr);
+ if (failed_()) {
+ chkout_("DAFDC", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* We're done now, so goodbye. */
+
+ chkout_("DAFDC", (ftnlen)5);
+ return 0;
+} /* dafdc_ */
+
diff --git a/ext/spice/src/cspice/dafdc_c.c b/ext/spice/src/cspice/dafdc_c.c
new file mode 100644
index 0000000000..0b4e47546d
--- /dev/null
+++ b/ext/spice/src/cspice/dafdc_c.c
@@ -0,0 +1,156 @@
+/*
+
+-Procedure dafdc_c ( DAF delete comments )
+
+-Abstract
+
+ Delete the entire comment area of a specified DAF file.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ None.
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+
+ void dafdc_c ( SpiceInt handle )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I The handle of a binary DAF opened for writing.
+
+-Detailed_Input
+
+ handle is the handle of a binary DAF that is to have its entire
+ comment area deleted. The DAF must have been opened
+ with write access.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the binary DAF attached to `handle' is not open with write
+ access, an error will be signaled by a routine called by
+ this routine.
+
+-Files
+
+ See argument `handle' in $ Detailed_Input.
+
+-Particulars
+
+ A binary DAF contains an area which is reserved for storing
+ annotations or descriptive textual information about the data
+ contained in a file. This area is referred to as the ``comment
+ area'' of the file. The comment area of a DAF is a line oriented
+ medium for storing textual information. The comment area preserves
+ any leading or embedded white space in the line(s) of text which are
+ stored, so that the appearance of the of information will be
+ unchanged when it is retrieved (extracted) at some other time.
+ Trailing blanks, however, are NOT preserved, due to the way that
+ character strings are represented in standard Fortran 77.
+
+ This routine will delete the entire comment area from the binary DAF
+ attached to `handle'. The size of the binary DAF will remain
+ unchanged. The space that was used by the comment records is
+ reclaimed: the data area of the DAF is shifted toward the beginning
+
+
+-Examples
+
+ Let
+
+ handle be the handle of a DAF which has been opened
+ with write access.
+
+ The call
+
+ dafdc_c ( handle );
+
+ deletes the entire comment area of the binary DAF attached to
+ `handle'.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 16-NOV-2006 (NJB) (KRG)
+
+-Index_Entries
+
+ delete DAF comment area
+
+-&
+*/
+
+{ /* Begin dafdc_c */
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafdc_c" );
+
+
+ /*
+ Hand off the task to the f2c'd routine.
+ */
+ dafdc_ ( (integer *) &handle );
+
+
+
+ chkout_c ( "dafdc_c" );
+
+} /* End dafdc_c */
diff --git a/ext/spice/src/cspice/dafec.c b/ext/spice/src/cspice/dafec.c
new file mode 100644
index 0000000000..1cb61173d6
--- /dev/null
+++ b/ext/spice/src/cspice/dafec.c
@@ -0,0 +1,846 @@
+/* dafec.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static logical c_false = FALSE_;
+static integer c__1 = 1;
+static integer c__1000 = 1000;
+
+/* $Procedure DAFEC ( DAF extract comments ) */
+/* Subroutine */ int dafec_(integer *handle, integer *bufsiz, integer *n,
+ char *buffer, logical *done, ftnlen buffer_len)
+{
+ /* Initialized data */
+
+ static logical first = TRUE_;
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer), i_len(char *, ftnlen),
+ s_rdue(cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer free;
+ extern integer cpos_(char *, char *, integer *, ftnlen, ftnlen);
+ extern /* Subroutine */ int zzddhhlu_(integer *, char *, logical *,
+ integer *, ftnlen);
+ integer i__, j, k;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc, bward, fward, recno, index;
+ logical found;
+ integer ncomr;
+ extern integer ncpos_(char *, char *, integer *, ftnlen, ftnlen);
+ logical empty;
+ char ch[1];
+ integer nd;
+ extern logical failed_(void);
+ integer ni;
+ extern /* Subroutine */ int dafsih_(integer *, char *, ftnlen);
+ char ifname[60];
+ static integer filhan[1000];
+ static char crecrd[1000];
+ extern /* Subroutine */ int dafrfr_(integer *, integer *, integer *, char
+ *, integer *, integer *, integer *, ftnlen);
+ static integer filchr[1000];
+ integer daflun, nchars;
+ static integer filcnt[1000];
+ static char eocmrk[1];
+ extern integer isrchi_(integer *, integer *, integer *);
+ integer linlen;
+ static integer nfiles;
+ integer eocpos;
+ static char eolmrk[1];
+ static integer lsthan, lstrec[1000];
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ integer numcom;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ integer nelpos;
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ integer curpos;
+ extern logical return_(void);
+ static integer lstpos[1000];
+ logical eol;
+
+ /* Fortran I/O blocks */
+ static cilist io___29 = { 1, 0, 1, 0, 0 };
+ static cilist io___33 = { 1, 0, 1, 0, 0 };
+ static cilist io___38 = { 1, 0, 1, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Extract comments from the comment area of a binary DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of binary DAF opened with read access. */
+/* BUFSIZ I Maximum size, in lines, of BUFFER. */
+/* N O Number of extracted comment lines. */
+/* BUFFER O Buffer where extracted comment lines are placed. */
+/* DONE O Indicates whether all comments have been extracted. */
+
+/* $ Detailed_Input */
+
+/* HANDLE The file handle of a binary DAF which has been opened */
+/* with read access. */
+
+/* BUFSIZ The maximum number of comments that may be placed into */
+/* BUFFER. This would typically be the declared array size */
+/* for the Fortran character string array passed into this */
+/* routine. */
+
+/* $ Detailed_Output */
+
+/* N The number of comment lines extracted from the comment */
+/* area of the binary DAF attached to HANDLE. This number */
+/* will be <= BUFSIZ on output. If N = BUFSIZ and DONE <> */
+/* .TRUE., then there are more comments left to to extract. */
+/* If N = 0, then DONE = .TRUE., i.e., there were no */
+/* comments in the comment area or we have extracted all */
+/* of the comments. If there are comments in the comment */
+/* area, or comments remaining after the extraction process */
+/* has begun, N > 0, always. */
+
+/* BUFFER A array of at most BUFSIZ comments which have been */
+/* extracted from the comment area of the binary DAF */
+/* attached to HANDLE. */
+
+/* DONE A logical flag indicating whether or not all of the */
+/* comment lines from the comment area of the DAF have */
+/* been read. This variable has the value .TRUE. after the */
+/* last comment line has been read. It will have the value */
+/* .FALSE. otherwise. */
+
+/* If there are no comments in the comment area, this */
+/* variable will have the value .TRUE., and N = 0. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the size of the output line buffer is is not positive, */
+/* the error SPICE(INVALIDARGUMENT) will be signaled. */
+
+/* 3) If a comment line in a DAF is longer than the length */
+/* of a character string array element of BUFFER, the error */
+/* SPICE(COMMENTTOOLONG) will be signaled. */
+
+/* 3) If the end of the comments cannot be found, i.e., the end of */
+/* comments marker is missing on the last comment record, the */
+/* error SPICE(BADCOMMENTAREA) will be signaled. */
+
+/* 4) If the number of comment characters scanned exceeds the */
+/* number of comment characters computed, the error */
+/* SPICE(BADCOMMENTAREA) will be signaled. */
+
+/* 5) If the binary DAF attached to HANDLE is not open for */
+/* reading,an error will be signaled by a routine called by */
+/* this routine. */
+
+/* $ Files */
+
+/* See argument HANDLE in $ Detailed_Input. */
+
+/* $ Particulars */
+
+/* A binary DAF contains an area which is reserved for storing */
+/* annotations or descriptive textual information describing the data */
+/* contained in a file. This area is referred to as the ``comment */
+/* area'' of the file. The comment area of a DAF is a line */
+/* oriented medium for storing textual information. The comment */
+/* area preserves any leading or embedded white space in the line(s) */
+/* of text which are stored, so that the appearance of the of */
+/* information will be unchanged when it is retrieved (extracted) at */
+/* some other time. Trailing blanks, however, are NOT preserved, */
+/* due to the way that character strings are represented in */
+/* standard Fortran 77. */
+
+/* This routine will read the comments from the comment area of */
+/* a binary DAF, placing them into a line buffer. If the line */
+/* buffer is not large enough to hold the entire comment area, */
+/* the portion read will be returned to the caller, and the DONE */
+/* flag will be set to .FALSE.. This allows the comment area to be */
+/* read in ``chunks,'' a buffer at a time. After all of the comment */
+/* lines have been read, the DONE flag will be set to .TRUE.. */
+
+/* This routine can be used to ``simultaneously'' extract comments */
+/* from the comment areas of multiple binary DAFs. See Example */
+/* 2 in the $ Examples section. */
+
+/* $ Examples */
+
+/* Example 1 */
+/* --------- */
+
+/* The following example will extract the entire comment area of a */
+/* binary DAF attached to HANDLE, displaying the comments on the */
+/* terminal screen. */
+
+/* Let */
+
+/* BUFFER have the following declaration: */
+
+/* CHARACTER*(80) BUFFER(25) */
+
+/* HANDLE be the handle of an open binary DAF file. */
+
+/* then */
+
+/* BUFSIZ = 25 */
+/* DONE = .FALSE. */
+
+/* DO WHILE ( .NOT. DONE ) */
+
+/* CALL DAFEC( HANDLE, BUFSIZ, N, BUFFER, DONE ) */
+
+/* DO I = 1, N */
+
+/* WRITE (*,*) BUFFER(I) */
+
+/* END DO */
+
+/* END DO */
+
+/* Example 2 */
+/* --------- */
+
+/* The following example demonstrates the use of this routine to */
+/* simultaneously read the comment areas of multiple DAFs. For each */
+/* file, the comments will be displayed on the screen as they are */
+/* extracted. */
+
+/* Let */
+
+/* BUFFER have the following declaration: */
+
+/* CHARACTER*(80) BUFFER(25) */
+
+/* NUMFIL be the number of binary DAFs that are to have their */
+/* comment areas displayed. */
+
+/* DAFNAM(I) Be a list of filenames for the DAFs which are to */
+/* have their comment areas displayed. */
+
+/* HANDLE(I) be a list of handles for the DAFs which are to have */
+/* their comment areas displayed. */
+
+/* DONE(I) be a list of logical flags indicating whether */
+/* we are done extracting the comment area from the */
+/* DAF attached to HANDLE(I) */
+
+/* then */
+
+/* BUFSIZ = 25 */
+
+/* DO I = 1, NUMFIL */
+
+/* DONE(I) = .FALSE. */
+/* HANDLE(I) = 0 */
+
+/* END DO */
+/* C */
+/* C Open the DAFs. */
+/* C */
+/* DO I = 1, NUMFIL */
+
+/* CALL DAFOPR ( DAFNAM(I), HANDLE(I) ) */
+
+/* END DO */
+/* C */
+/* C While there are still some comments left to read in at */
+/* C least one of the files, read them and display them. */
+/* C */
+/* DO WHILE ( .NOT. ALLTRU( DONE, NUMFIL ) ) */
+
+/* DO I = 1, NUMFIL */
+
+/* IF ( .NOT. DONE(I) ) THEN */
+
+/* WRITE (*,*) */
+/* WRITE (*,*) 'File: ', DAFNAM(I)(:RTRIM(DAFNAM(I))) */
+/* WRITE (*,*) */
+/* N = 0 */
+
+/* CALL DAFEC ( HANDLE(I), */
+/* . BUFSIZ, */
+/* . N, */
+/* . BUFFER, */
+/* . DONE(I) ) */
+
+/* DO J = 1, N */
+
+/* WRITE (*,*) BUFFER(J)(:RTRIM(BUFFER(J))) */
+
+/* END DO */
+
+/* END IF */
+
+/* END DO */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* 1) The comment area may consist only of printing ASCII characters, */
+/* decimal values 32 - 126. */
+
+/* 2) There is NO maximum length imposed on the significant portion */
+/* of a text line that may be placed into the comment area of a */
+/* DAF. The maximum length of a line stored in the comment area */
+/* should be kept reasonable, so that they may be easily */
+/* extracted. A good value for this would be 1000 characters, as */
+/* this can easily accomodate ``screen width'' lines as well as */
+/* long lines which may contain some other form of information. */
+
+/* 3) This routine is only used to read records on environments */
+/* whose characters are a single byte in size. Updates */
+/* to this routine and routines in its call tree may be */
+/* required to properly handle other cases. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0 08-NOV-2006 (NJB) (KRG) (FST) */
+
+/* Based on Support Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* extract comments from a DAF */
+
+/* -& */
+/* $ Revisions */
+
+
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* Length of a DAF internal filename. */
+
+
+/* Decimal value for the DAF comment area end-of-comment (EOC) */
+/* marker. */
+
+
+/* Decimal value for the DAF comment area end-of-line (EOL) marker. */
+
+
+/* The maximum number of DAFs that may be open simultaneously. */
+
+
+/* Length of a DAF character record, in characters. */
+
+
+/* Local variables */
+
+
+/* The file table declarations for keeping track of which files */
+/* are currently in the process of having comments extracted. */
+
+
+/* Saved variables */
+
+
+/* Save all of the file table information. */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFEC", (ftnlen)5);
+ }
+
+/* If this is the first time that this routine has been called, */
+/* we need to initialize the character value of the end-of-line */
+/* marker, and the file table variables. */
+
+ if (first) {
+ first = FALSE_;
+ nfiles = 0;
+ lsthan = 0;
+ *(unsigned char *)eocmrk = '\4';
+ *(unsigned char *)eolmrk = '\0';
+ for (i__ = 1; i__ <= 1000; ++i__) {
+ filchr[(i__1 = i__ - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("fil"
+ "chr", i__1, "dafec_", (ftnlen)445)] = 0;
+ filcnt[(i__1 = i__ - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("fil"
+ "cnt", i__1, "dafec_", (ftnlen)446)] = 0;
+ filhan[(i__1 = i__ - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("fil"
+ "han", i__1, "dafec_", (ftnlen)447)] = 0;
+ lstpos[(i__1 = i__ - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("lst"
+ "pos", i__1, "dafec_", (ftnlen)448)] = 0;
+ lstrec[(i__1 = i__ - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("lst"
+ "rec", i__1, "dafec_", (ftnlen)449)] = 0;
+ }
+ }
+
+/* Verify that the DAF attached to HANDLE is opened for reading */
+/* by calling the routine to signal an invalid access mode on a */
+/* handle. */
+
+ dafsih_(handle, "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+ }
+
+/* Check for a nonpositive BUFFER size. */
+
+ if (*bufsiz <= 0) {
+ setmsg_("The output buffer size was not positive: #.", (ftnlen)43);
+ errint_("#", bufsiz, (ftnlen)1);
+ sigerr_("SPICE(INVALIDARGUMENT)", (ftnlen)22);
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+ }
+
+/* Convert the DAF handle to its corresponding Fortran logical */
+/* unit number for reading the comment records. */
+
+ zzddhhlu_(handle, "DAF", &c_false, &daflun, (ftnlen)3);
+ if (failed_()) {
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+ }
+
+/* Get the length of a single character string in the buffer. */
+
+ linlen = i_len(buffer, buffer_len);
+
+/* If we have extracted comments from at least one file and we */
+/* didn't finish, check to see if HANDLE is in the file table. */
+
+ if (nfiles > 0) {
+ index = isrchi_(handle, &nfiles, filhan);
+ } else {
+ index = 0;
+ }
+
+/* Check to see if we found HANDLE in the file handle table. If */
+/* we did, INDEX will be > 0. */
+
+ if (index > 0) {
+
+/* Set the record number and the starting position accordingly, */
+/* i.e., where we left off when we last read from that file. */
+
+ recno = lstrec[(i__1 = index - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "lstrec", i__1, "dafec_", (ftnlen)515)];
+ curpos = lstpos[(i__1 = index - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("lstpos", i__1, "dafec_", (ftnlen)516)];
+ nchars = filchr[(i__1 = index - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("filchr", i__1, "dafec_", (ftnlen)517)];
+ ncomc = filcnt[(i__1 = index - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "filcnt", i__1, "dafec_", (ftnlen)518)];
+ } else {
+
+/* We have not yet read any comments from this file, so start at */
+/* the start. To get to the first comment record, we need to skip */
+/* the file record. We also need to count the number of comment */
+/* characters. */
+
+/* Read the file record from the DAF attached to HANDLE. We will */
+/* get back some stuff that we do not use. */
+
+ dafrfr_(handle, &nd, &ni, ifname, &fward, &bward, &free, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+ }
+
+/* Compute the number of comment records and the number of */
+/* comment characters. In order to perform these calculations, */
+/* we assume that we have a valid comment area in the DAF */
+/* attached to HANDLE. */
+
+ ncomr = fward - 2;
+ if (ncomr > 0) {
+
+/* The starting record number is the number of comment records */
+/* + 1 where the 1 skips the file record. */
+
+ empty = TRUE_;
+ found = FALSE_;
+ while(ncomr > 0 && ! found && empty) {
+ recno = ncomr + 1;
+ io___29.ciunit = daflun;
+ io___29.cirec = recno;
+ iostat = s_rdue(&io___29);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, crecrd, (ftnlen)1000);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rdue();
+L100001:
+ if (iostat != 0) {
+ setmsg_("Error reading comment area of binary file named"
+ " '#'. IOSTAT = #.", (ftnlen)64);
+ errfnm_("#", &daflun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+ }
+
+/* Scan the comment record looking for the end of comments */
+/* marker. */
+
+ eocpos = cpos_(crecrd, eocmrk, &c__1, (ftnlen)1000, (ftnlen)1)
+ ;
+ if (eocpos > 0) {
+ found = TRUE_;
+ } else {
+ nelpos = ncpos_(crecrd, eolmrk, &c__1, (ftnlen)1000, (
+ ftnlen)1);
+ if (nelpos != 0) {
+ empty = FALSE_;
+ } else {
+ --ncomr;
+ }
+ }
+ }
+
+/* If we do not find the end of comments marker and the */
+/* comment area is not empty, then it is an error. */
+
+ if (! found && ! empty) {
+ setmsg_("The comment area in the DAF file '#' may be damaged"
+ ". The end of the comments could not be found.", (
+ ftnlen)96);
+ errfnm_("#", &daflun, (ftnlen)1);
+ sigerr_("SPICE(BADCOMMENTAREA)", (ftnlen)21);
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+ } else if (found) {
+ ncomc = (ncomr - 1) * 1000 + eocpos - 1;
+ } else if (empty) {
+ ncomc = 0;
+ }
+ } else {
+ ncomc = 0;
+ }
+
+/* If the number of comment characters, NCOMC, is equal to zero, */
+/* then we have no comments to read, so set the number of comments */
+/* to zero, set DONE to .TRUE., check out, and return. */
+
+ if (ncomc == 0) {
+ *n = 0;
+ *done = TRUE_;
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+ }
+
+/* Otherwise, set the initial position in the comment area. */
+
+ recno = 2;
+ curpos = 1;
+ nchars = 0;
+ }
+
+/* Begin reading the comment area into the buffer. */
+
+ if (*handle != lsthan) {
+
+/* If the current DAF handle is not the same as the handle on */
+/* the last call, then we need to read in the appropriate record */
+/* from the DAF comment area. Otherwise the record was saved and */
+/* so we don't need to read it in. */
+
+ io___33.ciunit = daflun;
+ io___33.cirec = recno;
+ iostat = s_rdue(&io___33);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, crecrd, (ftnlen)1000);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_rdue();
+L100002:
+ if (iostat != 0) {
+ setmsg_("Error reading comment area of binary file named FILE. "
+ "IOSTAT = *.", (ftnlen)66);
+ errint_("*", &iostat, (ftnlen)1);
+ errfnm_("FILE", &daflun, (ftnlen)4);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Initialize the BUFFER line counter, I, and the line position */
+/* counter, J. */
+
+ i__ = 1;
+ j = 1;
+
+/* Start filling up the BUFFER. */
+
+ numcom = 0;
+ *done = FALSE_;
+ while(i__ <= *bufsiz && ! (*done)) {
+ eol = FALSE_;
+ while(! eol) {
+ ++nchars;
+ *(unsigned char *)ch = *(unsigned char *)&crecrd[curpos - 1];
+ if (*(unsigned char *)ch == 0) {
+ eol = TRUE_;
+ if (j <= linlen) {
+ s_copy(buffer + ((i__ - 1) * buffer_len + (j - 1)), " ",
+ buffer_len - (j - 1), (ftnlen)1);
+ }
+ } else {
+ if (j <= linlen) {
+ *(unsigned char *)&buffer[(i__ - 1) * buffer_len + (j - 1)
+ ] = *(unsigned char *)ch;
+ ++j;
+ } else {
+ setmsg_("The output buffer line length (#) was not long "
+ "enough to contain comment line #.", (ftnlen)80);
+ errint_("#", &linlen, (ftnlen)1);
+ errint_("#", &i__, (ftnlen)1);
+ sigerr_("SPICE(COMMENTTOOLONG)", (ftnlen)21);
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* If we have reached the end of the current comment record, */
+/* read in the next one and reset the current position. */
+/* Otherwise, just increment the current position. */
+
+ if (curpos == 1000) {
+ ++recno;
+ io___38.ciunit = daflun;
+ io___38.cirec = recno;
+ iostat = s_rdue(&io___38);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_uio(&c__1, crecrd, (ftnlen)1000);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = e_rdue();
+L100003:
+ if (iostat != 0) {
+ setmsg_("Error reading comment area of binary file named"
+ " #. IOSTAT = #.", (ftnlen)63);
+ errfnm_("#", &daflun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+ }
+ curpos = 1;
+ } else {
+ ++curpos;
+ }
+
+/* Check to make sure that it is safe to continue, i.e., */
+/* that the number of comment characters we have processed */
+/* has not exceeded the number of comment characters in the */
+/* comment area of the DAF file. This should never happen. */
+
+ if (nchars > ncomc) {
+ setmsg_("Count of comment characters (#) exceeds the number "
+ "of comment characters (#) in the DAF file #.", (
+ ftnlen)95);
+ errint_("#", &nchars, (ftnlen)1);
+ errint_("#", &ncomc, (ftnlen)1);
+ errfnm_("#", &daflun, (ftnlen)1);
+ sigerr_("SPICE(BADCOMMENTAREA)", (ftnlen)21);
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* We have just completed a comment line, so we save the comment */
+/* number, increment the buffer line counter, I, and reset the */
+/* buffer line position counter, J. */
+
+ numcom = i__;
+ ++i__;
+ j = 1;
+
+/* Check for the end of the comments. */
+
+ if (nchars == ncomc) {
+
+/* If we have reached the end of the comments, signaled */
+/* by having processed all of the comment characters, NCOMC, */
+/* then we are done. So, set DONE to .TRUE. and remove the */
+/* entry for this file from the file table. */
+
+ *done = TRUE_;
+ lsthan = 0;
+
+/* 0 <= INDEX <= NFILES, and we only want to remove things */
+/* from the file table if: */
+
+/* The file we are currently reading from is in the */
+/* file table, INDEX > 0, which implies NFILES > 0. */
+
+/* So, if INDEX > 0, we know that there are files in the file */
+/* table, and that we are currently reading from one of them. */
+
+ if (index > 0) {
+ i__1 = nfiles - 1;
+ for (k = index; k <= i__1; ++k) {
+ filchr[(i__2 = k - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "filchr", i__2, "dafec_", (ftnlen)810)] = filchr[(
+ i__3 = k) < 1000 && 0 <= i__3 ? i__3 : s_rnge(
+ "filchr", i__3, "dafec_", (ftnlen)810)];
+ filcnt[(i__2 = k - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "filcnt", i__2, "dafec_", (ftnlen)811)] = filcnt[(
+ i__3 = k) < 1000 && 0 <= i__3 ? i__3 : s_rnge(
+ "filcnt", i__3, "dafec_", (ftnlen)811)];
+ filhan[(i__2 = k - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "filhan", i__2, "dafec_", (ftnlen)812)] = filhan[(
+ i__3 = k) < 1000 && 0 <= i__3 ? i__3 : s_rnge(
+ "filhan", i__3, "dafec_", (ftnlen)812)];
+ lstrec[(i__2 = k - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "lstrec", i__2, "dafec_", (ftnlen)813)] = lstrec[(
+ i__3 = k) < 1000 && 0 <= i__3 ? i__3 : s_rnge(
+ "lstrec", i__3, "dafec_", (ftnlen)813)];
+ lstpos[(i__2 = k - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "lstpos", i__2, "dafec_", (ftnlen)814)] = lstpos[(
+ i__3 = k) < 1000 && 0 <= i__3 ? i__3 : s_rnge(
+ "lstpos", i__3, "dafec_", (ftnlen)814)];
+ }
+ --nfiles;
+ }
+ }
+ }
+
+/* Set the number of comment lines in the buffer */
+
+ *n = numcom;
+
+/* At this point, we have either filled the buffer or we have */
+/* finished reading in the comment area. Find out what has */
+/* happened and act accordingly. */
+
+ if (! (*done)) {
+
+/* If we are not done, then we have filled the buffer, so save */
+/* everything that needs to be saved in the file table before */
+/* exiting. */
+
+ if (index == 0) {
+
+/* This was the first time that the comment area of this file */
+/* has been read, so add it to the file table and save all of */
+/* its information if there is room in the file table. */
+
+ if (nfiles >= 1000) {
+ setmsg_("The file table is full with # files, and another fi"
+ "le could not be added.", (ftnlen)73);
+ errint_("#", &c__1000, (ftnlen)1);
+ sigerr_("SPICE(FILETABLEFULL)", (ftnlen)20);
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+ }
+ ++nfiles;
+ filchr[(i__1 = nfiles - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "filchr", i__1, "dafec_", (ftnlen)858)] = nchars;
+ filcnt[(i__1 = nfiles - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "filcnt", i__1, "dafec_", (ftnlen)859)] = ncomc;
+ filhan[(i__1 = nfiles - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "filhan", i__1, "dafec_", (ftnlen)860)] = *handle;
+ lstrec[(i__1 = nfiles - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "lstrec", i__1, "dafec_", (ftnlen)861)] = recno;
+ lstpos[(i__1 = nfiles - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "lstpos", i__1, "dafec_", (ftnlen)862)] = curpos;
+ lsthan = *handle;
+ } else {
+
+/* The comment area of this file is already in the file table, */
+/* so just update its information. */
+
+ filchr[(i__1 = index - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "filchr", i__1, "dafec_", (ftnlen)870)] = nchars;
+ lstrec[(i__1 = index - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "lstrec", i__1, "dafec_", (ftnlen)871)] = recno;
+ lstpos[(i__1 = index - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "lstpos", i__1, "dafec_", (ftnlen)872)] = curpos;
+ lsthan = *handle;
+ }
+ }
+ chkout_("DAFEC", (ftnlen)5);
+ return 0;
+} /* dafec_ */
+
diff --git a/ext/spice/src/cspice/dafec_c.c b/ext/spice/src/cspice/dafec_c.c
new file mode 100644
index 0000000000..7886245910
--- /dev/null
+++ b/ext/spice/src/cspice/dafec_c.c
@@ -0,0 +1,302 @@
+/*
+
+-Procedure dafec_c ( DAF extract comments )
+
+-Abstract
+
+ Extract comments from the comment area of a binary DAF.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+ UTILITY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+ #include "SpiceZst.h"
+
+ void dafec_c ( SpiceInt handle,
+ SpiceInt bufsiz,
+ SpiceInt lenout,
+ SpiceInt * n,
+ void * buffer,
+ SpiceBoolean * done )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of binary DAF opened with read access.
+ bufsiz I Maximum size, in lines, of buffer.
+ lenout I Length of strings in output buffer.
+ n O Number of extracted comment lines.
+ buffer O Buffer where extracted comment lines are placed.
+ done O Indicates whether all comments have been extracted.
+
+-Detailed_Input
+
+ handle is the file handle of a binary DAF which has been opened with
+ read access.
+
+ bufsiz is the maximum number of comments that may be placed into
+ buffer. This would typically be the declared array size for
+ the Fortran character string array passed into this
+ routine.
+
+ lenout is the allowed length of each string element of the output
+ buffer. This length must large enough to hold the longest
+ output string plus the null terminator. The SPICE system
+ imposes no limit on the length of comment lines, so `lenout'
+ normally should be set to a "generous" value that is unlikely
+ to be exceeded.
+
+-Detailed_Output
+
+ n is the number of comment lines extracted from the comment area
+ of the binary DAF associated with `handle'. `n' will be
+ less than or equal to `bufsiz' on output.
+
+ buffer is an array containing comment lines read from the DAF
+ associated with `handle'. `buffer' should be declared
+
+ SpiceChar buffer[bufsiz][lenout];
+
+ On output, the first `n' strings of `buffer' will contain
+ comment text, with one comment line per string.
+
+ done is a logical flag indicating whether or not all of the
+ comment lines from the comment area of the DAF have
+ been read. This variable has the value SPICETRUE after the
+ last comment line has been read. It will have the value
+ SPICEFALSE otherwise.
+
+ If there are no comments in the comment area, this
+ variable will have the value SPICETRUE.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the size of the output line buffer is is not positive,
+ the error SPICE(INVALIDARGUMENT) will be signaled.
+
+ 3) If a comment line in a DAF is longer than the length
+ of a character string array element of BUFFER, the error
+ SPICE(COMMENTTOOLONG) will be signaled.
+
+ 3) If the end of the comments cannot be found, i.e., the end of
+ comments marker is missing on the last comment record, the
+ error SPICE(BADCOMMENTAREA) will be signaled.
+
+ 4) If the number of comment characters scanned exceeds the
+ number of comment characters computed, the error
+ SPICE(BADCOMMENTAREA) will be signaled.
+
+ 5) If the binary DAF attached to HANDLE is not open for
+ reading,an error will be signaled by a routine called by
+ this routine.
+
+ 6) If the output buffer pointer is null the error SPICE(NULLPOINTER)
+ will be signaled.
+
+ 7) If the output buffer string length is less than 2, the error
+ SPICE(STRINGTOOSHORT) will be signaled.
+
+-Files
+
+ See argument `handle' in $ Detailed_Input.
+
+-Particulars
+
+ A binary DAF contains an area which is reserved for storing
+ annotations or descriptive textual information describing the data
+ contained in a file. This area is referred to as the ``comment
+ area'' of the file. The comment area of a DAF is a line
+ oriented medium for storing textual information. The comment
+ area preserves any leading or embedded white space in the line(s)
+ of text which are stored, so that the appearance of the of
+ information will be unchanged when it is retrieved (extracted) at
+ some other time. Trailing blanks, however, are NOT preserved,
+ due to the way that character strings are represented in
+ standard Fortran 77.
+
+ This routine will read the comments from the comment area of
+ a binary DAF, placing them into a line buffer. If the line
+ buffer is not large enough to hold the entire comment area,
+ the portion read will be returned to the caller, and the DONE
+ flag will be set to SPICEFALSE. This allows the comment area to be
+ read in ``chunks,'' a buffer at a time. After all of the comment
+ lines have been read, the `done' flag will be set to SPICETRUE.
+
+ This routine can be used to ``simultaneously'' extract comments
+ from the comment areas of multiple binary DAFs. See Example
+ 2 in the $ Examples section.
+
+-Examples
+
+ 1) The following example will extract the entire comment area of a
+ binary DAF, displaying the comments on the terminal screen.
+
+ #include
+ #include "SpiceUsr.h"
+
+ int main()
+ {
+ #define FILSIZ 256
+ #define LINLEN 1001
+ #define BUFFSZ 25
+
+ SpiceBoolean done = SPICEFALSE;
+
+ SpiceChar daf [FILSIZ];
+ SpiceChar buffer [BUFFSZ][LINLEN];
+
+ SpiceInt handle;
+ SpiceInt i;
+ SpiceInt n;
+
+
+ prompt_c ( "Enter name of DAF > ", FILSIZ, daf );
+
+ dafopr_c ( daf, &handle );
+
+ while ( !done )
+ {
+ dafec_c ( handle, BUFFSZ, LINLEN, &n, buffer, &done );
+
+ for ( i = 0; i < n; i++ )
+ {
+ printf ( "%s\n", buffer[i] );
+ }
+ }
+
+ return ( 0 );
+ }
+
+
+
+-Restrictions
+
+ 1) The comment area may consist only of printing ASCII characters,
+ decimal values 32 - 126.
+
+ 2) There is NO maximum length imposed on the significant portion
+ of a text line that may be placed into the comment area of a
+ DAF. The maximum length of a line stored in the comment area
+ should be kept reasonable, so that they may be easily
+ extracted. A good value for this might be 1000 characters, as
+ this can easily accommodate ``screen width'' lines as well as
+ long lines which may contain some other form of information.
+
+ 3) This routine is only used to read records on environments
+ whose characters are a single byte in size. Updates
+ to this routine and routines in its call tree may be
+ required to properly handle other cases.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 16-NOV-2006 (NJB) (KRG)
+
+-Index_Entries
+
+ extract comments from a DAF
+
+-&
+*/
+
+{ /* Begin dafec_c */
+
+
+ /*
+ Local variables
+ */
+ logical fin;
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafec_c" );
+
+ /*
+ Make sure the string pointer for the buffer array is non-null
+ and that the length lenvals is sufficient.
+ */
+ CHKOSTR ( CHK_STANDARD, "dafec_c", buffer, lenout );
+
+
+ /*
+ Call the f2c'd routine.
+ */
+ dafec_ ( ( integer * ) &handle,
+ ( integer * ) &bufsiz,
+ ( integer * ) n,
+ ( char * ) buffer,
+ ( logical * ) &fin,
+ ( ftnlen ) lenout-1 );
+
+ /*
+ Set the output SpiceBoolean found flag.
+ */
+ *done = fin;
+
+ if ( *n > 0 )
+ {
+ /*
+ `cvals' now contains the requested data in a single Fortran-style
+ string containing (lenout-1)*n significant characters.
+
+ We need to convert `cvals' into an array
+ of n null-terminated strings each `lenout' long.
+ */
+ F2C_ConvertTrStrArr ( *n, lenout, (char *)buffer );
+ }
+
+ chkout_c ( "dafec_c" );
+
+} /* End dafec_c */
diff --git a/ext/spice/src/cspice/daffa.c b/ext/spice/src/cspice/daffa.c
new file mode 100644
index 0000000000..2f10d72801
--- /dev/null
+++ b/ext/spice/src/cspice/daffa.c
@@ -0,0 +1,4239 @@
+/* daffa.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1000 = 1000;
+static integer c__1 = 1;
+static integer c__128 = 128;
+
+/* $Procedure DAFFA ( DAF, find array ) */
+/* Subroutine */ int daffa_0_(int n__, integer *handle, doublereal *sum, char
+ *name__, logical *found, ftnlen name_len)
+{
+ /* Initialized data */
+
+ static logical first = TRUE_;
+ static logical sthvnr[1000] = { FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_ };
+ static integer stfptr = -1;
+ static integer sthead = -1;
+
+ /* System generated locals */
+ integer i__1, i__2, i__3, i__4;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ static integer free;
+ static doublereal exdc[124];
+ static integer exic[250], stfh[1000], prev;
+ static char stnr[1000*1000];
+ static doublereal stsr[128000] /* was [128][1000] */;
+ static integer i__, p;
+ extern logical elemi_(integer *, integer *);
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafps_(integer *,
+ integer *, doublereal *, integer *, doublereal *);
+ static integer bward;
+ static doublereal newdc[124];
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *);
+ static integer fward, newic[250];
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen),
+ moved_(doublereal *, integer *, doublereal *), movei_(integer *,
+ integer *, integer *);
+ static integer nextp;
+ static doublereal exsum[124];
+ static integer nd;
+ extern logical failed_(void);
+ static char dafnam[255];
+ static integer ni;
+ extern /* Subroutine */ int dafhof_(integer *), dafhfn_(integer *, char *,
+ ftnlen), dafhsf_(integer *, integer *, integer *), dafsih_(
+ integer *, char *, ftnlen);
+ static char ifname[60];
+ extern /* Subroutine */ int dafrcr_(integer *, integer *, char *, ftnlen),
+ dafrfr_(integer *, integer *, integer *, char *, integer *,
+ integer *, integer *, ftnlen), dafgsr_(integer *, integer *,
+ integer *, integer *, doublereal *, logical *), dafwdr_(integer *,
+ integer *, doublereal *), dafwcr_(integer *, integer *, char *,
+ ftnlen);
+ static integer offset;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen);
+ static integer namsiz;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen);
+ static integer stnseg[1000];
+ extern /* Subroutine */ int ssizei_(integer *, integer *);
+ static integer opnset[1006];
+ extern logical return_(void);
+ static integer stthis[1000], stpool[1000], stcurr[1000], stprev[1000],
+ stnext[1000], sumsiz;
+ static logical fnd;
+
+/* $ Abstract */
+
+/* Find arrays in a DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* $ Abstract */
+
+/* Parameter declarations for the DAF/DAS handle manager. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF, DAS */
+
+/* $ Keywords */
+
+/* PRIVATE */
+
+/* $ Particulars */
+
+/* This include file contains parameters defining limits and */
+/* integer codes that are utilized in the DAF/DAS handle manager */
+/* routines. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* F.S. Turner (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.20.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL. */
+
+/* - SPICELIB Version 1.19.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL-CC_C. */
+
+/* - SPICELIB Version 1.18.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL-64BIT-CC_C. */
+
+/* - SPICELIB Version 1.17.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-64BIT-NATIVE_C. */
+
+/* - SPICELIB Version 1.16.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-WINDOWS-64BIT-IFORT. */
+
+/* - SPICELIB Version 1.15.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-LINUX-64BIT-GFORTRAN. */
+
+/* - SPICELIB Version 1.14.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-64BIT-MS_C. */
+
+/* - SPICELIB Version 1.13.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-INTEL_C. */
+
+/* - SPICELIB Version 1.12.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-IFORT. */
+
+/* - SPICELIB Version 1.11.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-GFORTRAN. */
+
+/* - SPICELIB Version 1.10.0, 18-MAR-2009 (BVS) */
+
+/* Updated for PC-LINUX-GFORTRAN. */
+
+/* - SPICELIB Version 1.9.0, 18-MAR-2009 (BVS) */
+
+/* Updated for MAC-OSX-GFORTRAN. */
+
+/* - SPICELIB Version 1.8.0, 19-FEB-2008 (BVS) */
+
+/* Updated for PC-LINUX-IFORT. */
+
+/* - SPICELIB Version 1.7.0, 14-NOV-2006 (BVS) */
+
+/* Updated for PC-LINUX-64BIT-GCC_C. */
+
+/* - SPICELIB Version 1.6.0, 14-NOV-2006 (BVS) */
+
+/* Updated for MAC-OSX-INTEL_C. */
+
+/* - SPICELIB Version 1.5.0, 14-NOV-2006 (BVS) */
+
+/* Updated for MAC-OSX-IFORT. */
+
+/* - SPICELIB Version 1.4.0, 14-NOV-2006 (BVS) */
+
+/* Updated for PC-WINDOWS-IFORT. */
+
+/* - SPICELIB Version 1.3.0, 26-OCT-2005 (BVS) */
+
+/* Updated for SUN-SOLARIS-64BIT-GCC_C. */
+
+/* - SPICELIB Version 1.2.0, 03-JAN-2005 (BVS) */
+
+/* Updated for PC-CYGWIN_C. */
+
+/* - SPICELIB Version 1.1.0, 03-JAN-2005 (BVS) */
+
+/* Updated for PC-CYGWIN. */
+
+/* - SPICELIB Version 1.0.1, 17-JUL-2002 */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 1.0.0, 07-NOV-2001 */
+
+/* -& */
+
+/* Unit and file table size parameters. */
+
+/* FTSIZE is the maximum number of files (DAS and DAF) that a */
+/* user may have open simultaneously. */
+
+
+/* RSVUNT is the number of units protected from being locked */
+/* to a particular handle by ZZDDHHLU. */
+
+
+/* SCRUNT is the number of units protected for use by scratch */
+/* files. */
+
+
+/* UTSIZE is the maximum number of logical units this manager */
+/* will utilize at one time. */
+
+
+/* Access method enumeration. These parameters are used to */
+/* identify which access method is associated with a particular */
+/* handle. They need to be synchronized with the STRAMH array */
+/* defined in ZZDDHGSD in the following fashion: */
+
+/* STRAMH ( READ ) = 'READ' */
+/* STRAMH ( WRITE ) = 'WRITE' */
+/* STRAMH ( SCRTCH ) = 'SCRATCH' */
+/* STRAMH ( NEW ) = 'NEW' */
+
+/* These values are used in the file table variable FTAMH. */
+
+
+/* Binary file format enumeration. These parameters are used to */
+/* identify which binary file format is associated with a */
+/* particular handle. They need to be synchronized with the STRBFF */
+/* array defined in ZZDDHGSD in the following fashion: */
+
+/* STRBFF ( BIGI3E ) = 'BIG-IEEE' */
+/* STRBFF ( LTLI3E ) = 'LTL-IEEE' */
+/* STRBFF ( VAXGFL ) = 'VAX-GFLT' */
+/* STRBFF ( VAXDFL ) = 'VAX-DFLT' */
+
+/* These values are used in the file table variable FTBFF. */
+
+
+/* Some random string lengths... more documentation required. */
+/* For now this will have to suffice. */
+
+
+/* Architecture enumeration. These parameters are used to identify */
+/* which file architecture is associated with a particular handle. */
+/* They need to be synchronized with the STRARC array defined in */
+/* ZZDDHGSD in the following fashion: */
+
+/* STRARC ( DAF ) = 'DAF' */
+/* STRARC ( DAS ) = 'DAS' */
+
+/* These values will be used in the file table variable FTARC. */
+
+
+/* For the following environments, record length is measured in */
+/* characters (bytes) with eight characters per double precision */
+/* number. */
+
+/* Environment: Sun, Sun FORTRAN */
+/* Source: Sun Fortran Programmer's Guide */
+
+/* Environment: PC, MS FORTRAN */
+/* Source: Microsoft Fortran Optimizing Compiler User's Guide */
+
+/* Environment: Macintosh, Language Systems FORTRAN */
+/* Source: Language Systems FORTRAN Reference Manual, */
+/* Version 1.2, page 12-7 */
+
+/* Environment: PC/Linux, g77 */
+/* Source: Determined by experiment. */
+
+/* Environment: PC, Lahey F77 EM/32 Version 4.0 */
+/* Source: Lahey F77 EM/32 Language Reference Manual, */
+/* page 144 */
+
+/* Environment: HP-UX 9000/750, FORTRAN/9000 Series 700 computers */
+/* Source: FORTRAN/9000 Reference-Series 700 Computers, */
+/* page 5-110 */
+
+/* Environment: NeXT Mach OS (Black Hardware), */
+/* Absoft Fortran Version 3.2 */
+/* Source: NAIF Program */
+
+
+/* The following parameter defines the size of a string used */
+/* to store a filenames on this target platform. */
+
+
+/* The following parameter controls the size of the character record */
+/* buffer used to read data from non-native files. */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Entry */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I,O DAFBFS, DAFBBS, DAFGH, DAFCS */
+/* SUM I,O DAFGS, DAFRS, DAFWS */
+/* NAME I,O DAFGN, DAFRN */
+/* FOUND O DAFFNA, DAFFPA */
+
+/* $ Detailed_Input */
+
+/* HANDLE on input is the handle of the DAF to be searched. */
+
+/* SUM on input is an array summary that replaces the */
+/* summary of the current array in the DAF currently */
+/* being searched. */
+
+/* NAME on input is an array name that replaces the name */
+/* of the current array in the DAF currently being */
+/* searched. */
+
+/* $ Detailed_Output */
+
+/* HANDLE on output is the handle of the DAF currently being */
+/* searched. */
+
+/* SUM on output is the summary for the array found most */
+/* recently. */
+
+/* NAME on output is the name for the array found */
+/* most recently. */
+
+/* FOUND is true whenever the search for the next or the */
+/* previous array is successful, and is false otherwise. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* DAFs read by DAFFA and its entry points are opened */
+/* elsewhere, and referred to only by their handles. */
+
+/* $ Exceptions */
+
+/* 1) If DAFFA is called directly, the error SPICE(BOGUSENTRY) */
+/* is signalled. */
+
+/* 2) See entry points DAFBFS, DAFFNA, DAFBBS, DAFFPA, DAFGS, DAFGN, */
+/* DAFGH, DAFRS, DAFWS, DAFRN, and DAFCS for exceptions specific */
+/* to those entry points. */
+
+/* $ Particulars */
+
+/* DAFFA serves as an umbrella, allowing data to be shared by its */
+/* entry points: */
+
+/* DAFBFS Begin forward search. */
+/* DAFFNA Find next array. */
+
+/* DAFBBS Begin backward search. */
+/* DAFFPA Find previous array. */
+
+/* DAFGS Get summary. */
+/* DAFGN Get name. */
+/* DAFGH Get handle. */
+
+/* DAFRS Replace summary. */
+/* DAFWS Write summary. */
+/* DAFRN Replace name. */
+
+/* DAFCS Continue search. */
+
+/* The main function of these entry points is to allow the */
+/* contents of any DAF to be examined on an array-by-array */
+/* basis. */
+
+/* Conceptually, the arrays in a DAF form a doubly linked list, */
+/* which can be searched in either of two directions: forward or */
+/* backward. It is possible to search multiple DAFs simultaneously. */
+
+/* DAFBFS (begin forward search) and DAFFNA are used to search the */
+/* arrays in a DAF in forward order. In applications that search a */
+/* single DAF at a time, the normal usage is */
+
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+/* CALL DAFGS ( SUM ) */
+/* CALL DAFGN ( NAME ) */
+/* . */
+/* . */
+
+/* CALL DAFFNA ( FOUND ) */
+/* END DO */
+
+
+
+/* DAFBBS (begin backward search) and DAFFPA are used to search the */
+/* arrays in a DAF in backward order. In applications that search */
+/* a single DAF at a time, the normal usage is */
+
+/* CALL DAFBBS ( HANDLE ) */
+/* CALL DAFFPA ( FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+/* CALL DAFGS ( SUM ) */
+/* CALL DAFGN ( NAME ) */
+/* . */
+/* . */
+
+/* CALL DAFFPA ( FOUND ) */
+/* END DO */
+
+
+/* In applications that conduct multiple searches simultaneously, */
+/* the above usage must be modified to specify the handle of the */
+/* file to operate on, in any case where the file may not be the */
+/* last one specified by DAFBFS or DAFBBS. The routine DAFCS */
+/* (DAF, continue search) is used for this purpose. Below, we */
+/* give an example of an interleaved search of two files specified */
+/* by the handles HANDL1 and HANDL2. The directions of searches */
+/* in different DAFs are independent; here we conduct a forward */
+/* search on one file and a backward search on the other. */
+/* Throughout, we use DAFCS to specify which file to operate on, */
+/* before calling DAFFNA, DAFFPA, DAFGS, DAFRS, DAFWS, DAFGN, or */
+/* DAFRN. */
+
+
+/* CALL DAFBFS ( HANDL1 ) */
+/* CALL DAFBBS ( HANDL2 ) */
+
+/* CALL DAFCS ( HANDL1 ) */
+/* CALL DAFFNA ( FOUND1 ) */
+
+/* CALL DAFCS ( HANDL2 ) */
+/* CALL DAFFPA ( FOUND2 ) */
+
+/* DO WHILE ( FOUND1 .OR. FOUND2 ) */
+
+/* IF ( FOUND1 ) THEN */
+
+/* CALL DAFCS ( HANDL1 ) */
+/* CALL DAFGS ( SUM ) */
+/* CALL DAFGN ( NAME ) */
+/* . */
+/* . */
+/* CALL DAFCS ( HANDL1 ) */
+/* CALL DAFFNA ( FOUND1 ) */
+
+/* END IF */
+
+/* IF ( FOUND2 ) THEN */
+
+/* CALL DAFCS ( HANDL2 ) */
+/* CALL DAFGS ( SUM ) */
+/* CALL DAFGN ( NAME ) */
+/* . */
+/* . */
+/* CALL DAFCS ( HANDL2 ) */
+/* CALL DAFFPA ( FOUND2 ) */
+
+/* END IF */
+
+/* END DO */
+
+
+/* At any time, the latest array found (whether by DAFFNA or DAFFPA) */
+/* is regarded as the `current' array for the file in which the */
+/* array was found. The last DAF in which a search was started, */
+/* executed, or continued by any of DAFBFS, DAFBBS, DAFFNA, DAFFPA */
+/* or DAFCS is regarded as the `current' DAF. The summary and name */
+/* for the current array in the current DAF can be returned */
+/* separately, as shown above, by calls to DAFGS (get summary) and */
+/* DAFGN (get name). The handle of the current DAF can also be */
+/* returned by calling DAFGH (get handle). */
+
+/* The summary and name of the current array in the current DAF can */
+/* be updated (again, separately) by providing new ones through DAFRS */
+/* (replace summary) and DAFRN (replace name). This feature */
+/* should not be used except to correct errors that occurred during */
+/* the creation of a file. Note that changes can only be made to */
+/* files opened for write access. Also, the addresses of an array */
+/* cannot be changed using these routines. (Another routine, */
+/* DAFWS, is provided for this purpose, but should be used only */
+/* to reorder the arrays in a file.) */
+
+/* Once a search has been begun, it may be continued in either */
+/* direction. That is, DAFFPA may be used to back up during a */
+/* forward search, and DAFFNA may be used to advance during a */
+/* backward search. */
+
+/* $ Examples */
+
+/* 1) The following code fragment illustrates the way the entry */
+/* points of DAFFA might be used to edit the summaries and names */
+/* for the arrays contained in a DAF. (All subroutines and */
+/* functions are from SPICELIB.) */
+
+/* In this example, the user begins by supplying the name of */
+/* the file to be edited, followed by any number of the following */
+/* commands. */
+
+/* NEXT finds the next array. */
+
+/* PREV finds the previous array. */
+
+/* EDIT changes the value of an item in the summary or */
+/* of the entire name. The keyword EDIT is */
+/* always followed by the name of the item to be */
+/* edited, */
+
+/* DC n */
+/* IC n */
+/* NAME */
+
+/* and the value, e.g., */
+
+/* EDIT IC 2 315 */
+/* EDIT NAME NAIF test K2905-1 */
+
+/* The user may terminate the session at any time by typing END. */
+/* Commands other than those listed above are ignored. */
+
+/* READ (*,FMT='(A)') FNAME */
+/* CALL DAFOPW ( FNAME, HANDLE ) */
+/* CALL DAFBFS ( HANDLE ) */
+
+/* READ (*,FMT='(A)') COMMAND */
+
+/* DO WHILE ( COMMAND .NE. 'END' ) */
+/* CALL NEXTWD ( COMMAND, VERB, COMMAND ) */
+
+/* IF ( VERB .EQ. 'NEXT' ) THEN */
+/* CALL DAFFNA ( FOUND ) */
+/* IF ( .NOT. FOUND ) THEN */
+/* WRITE (*,*) 'At end of array list.' */
+/* END IF */
+
+/* IF ( VERB .EQ. 'PREV' ) THEN */
+/* CALL DAFFPA ( FOUND ) */
+/* IF ( .NOT. FOUND ) THEN */
+/* WRITE (*,*) 'At beginning of array list.' */
+/* END IF */
+
+/* IF ( VERB .EQ. 'EDIT' ) THEN */
+/* CALL DAFGS ( SUM ) */
+/* CALL DAFGN ( NAME ) */
+/* CALL DAFUS ( SUM, ND, NI, DC, IC ) */
+
+/* CALL NEXTWD ( COMMAND, ITEM, VALUE ) */
+
+/* IF ( ITEM .EQ. 'DC' ) THEN */
+/* CALL NEXTWD ( VALUE, INDEX, VALUE ) */
+/* CALL NPARSI ( INDEX, LOC, ERR, PTR ) */
+/* CALL NPARSD ( VALUE, DC(LOC), ERR, PTR ) */
+
+/* ELSE IF ( ITEM .EQ. 'IC' ) THEN */
+/* CALL NEXTWD ( VALUE, INDEX, VALUE ) */
+/* CALL NPARSI ( INDEX, LOC, ERR, PTR ) */
+/* CALL NPARSI ( VALUE, IC(LOC), ERR, PTR ) */
+
+/* ELSE IF ( ITEM .EQ. 'NAME' ) THEN */
+/* NAME = VALUE */
+/* END IF */
+
+/* CALL DAFPS ( ND, NI, DC, IC, SUM ) */
+/* CALL DAFRS ( SUM ) */
+/* CALL DAFRN ( NAME ) */
+/* END IF */
+
+/* READ (*,FMT='(A)') COMMAND */
+/* END DO */
+
+
+/* 2) The following program compares data in two DAFs. The DAFs are */
+/* expected to have the same number of arrays, the same number */
+/* of elements in each corresponding array, and the same summary */
+/* format. */
+
+/* Each difference whose magnitude exceeds a specified tolerance */
+/* is flagged. The difference information is written to a file. */
+
+
+/* PROGRAM CMPDAF */
+
+/* C */
+/* C Compare data in two DAFs having identical structures. */
+/* C No array in either DAF is longer than ARRYSZ d.p. */
+/* C numbers. */
+/* C */
+
+/* C */
+/* C Local parameters */
+/* C */
+/* INTEGER ARRYSZ */
+/* PARAMETER ( ARRYSZ = 1000 ) */
+
+/* INTEGER ERRLEN */
+/* PARAMETER ( ERRLEN = 240 ) */
+
+/* INTEGER FILEN */
+/* PARAMETER ( FILEN = 128 ) */
+
+/* INTEGER LINLEN */
+/* PARAMETER ( LINLEN = 80 ) */
+
+/* INTEGER MAXND */
+/* PARAMETER ( MAXND = 125 ) */
+
+/* INTEGER MAXNI */
+/* PARAMETER ( MAXNI = 250 ) */
+
+/* INTEGER MAXSUM */
+/* PARAMETER ( MAXSUM = 128 ) */
+
+/* INTEGER RLEN */
+/* PARAMETER ( RLEN = 1000 ) */
+
+
+/* C */
+/* C Local variables */
+/* C */
+/* CHARACTER*(RLEN) ANAME1 */
+/* CHARACTER*(RLEN) ANAME2 */
+/* CHARACTER*(FILEN) DAF1 */
+/* CHARACTER*(FILEN) DAF2 */
+/* CHARACTER*(FILEN) LOG */
+/* CHARACTER*(ERRLEN) PRSERR */
+/* CHARACTER*(LINLEN) STR */
+/* CHARACTER*(LINLEN) TOLCH */
+
+/* DOUBLE PRECISION ARRAY1 ( ARRYSZ ) */
+/* DOUBLE PRECISION ARRAY2 ( ARRYSZ ) */
+/* DOUBLE PRECISION DC1 ( MAXND ) */
+/* DOUBLE PRECISION DC2 ( MAXND ) */
+/* DOUBLE PRECISION TOL */
+/* DOUBLE PRECISION DIFF */
+/* DOUBLE PRECISION SUM1 ( MAXSUM ) */
+/* DOUBLE PRECISION SUM2 ( MAXSUM ) */
+
+/* INTEGER FA1 */
+/* INTEGER FA2 */
+/* INTEGER I */
+/* INTEGER IA1 */
+/* INTEGER IA2 */
+/* INTEGER IC1 ( MAXNI ) */
+/* INTEGER IC2 ( MAXNI ) */
+/* INTEGER FA */
+/* INTEGER HANDL1 */
+/* INTEGER HANDL2 */
+/* INTEGER LEN1 */
+/* INTEGER LEN2 */
+/* INTEGER ND1 */
+/* INTEGER ND2 */
+/* INTEGER NI1 */
+/* INTEGER NI2 */
+/* INTEGER PTR */
+
+/* LOGICAL FOUND */
+
+/* C */
+/* C Start out by obtaining the names of the DAFs to be */
+/* C compared. */
+/* C */
+/* WRITE (*,*) 'Enter name of first DAF.' */
+/* READ (*,FMT='(A)') DAF1 */
+
+/* WRITE (*,*) 'Enter name of second DAF.' */
+/* READ (*,FMT='(A)') DAF2 */
+
+/* WRITE (*,*) 'Enter name of log file.' */
+/* READ (*,FMT='(A)') LOG */
+
+/* WRITE (*,*) 'Enter tolerance for data comparison.' */
+/* READ (*,FMT='(A)') TOLCH */
+
+/* CALL NPARSD ( TOLCH, TOL, PRSERR, PTR ) */
+
+/* DO WHILE ( PRSERR .NE. ' ' ) */
+
+/* WRITE (*,*) PRSERR */
+/* WRITE (*,*) 'Enter tolerance for data comparison.' */
+/* READ (*,FMT='(A)') TOLCH */
+
+/* CALL NPARSD ( TOLCH, TOL, PRSERR, PTR ) */
+
+/* END DO */
+
+/* C */
+/* C Open both DAFs for reading. */
+/* C */
+/* CALL DAFOPR ( DAF1, HANDL1 ) */
+/* CALL DAFOPR ( DAF2, HANDL2 ) */
+
+/* C */
+/* C Start forward searches in both DAFS. */
+/* C */
+/* CALL DAFBFS ( HANDL1 ) */
+/* CALL DAFBFS ( HANDL2 ) */
+
+/* C */
+/* C Obtain the summary formats for each DAF. Stop now */
+/* C if the summary formats don't match. */
+/* C */
+/* CALL DAFHSF ( HANDL1, ND1, NI1 ) */
+/* CALL DAFHSF ( HANDL2, ND2, NI2 ) */
+
+/* IF ( ( ND1 .NE. ND2 ) .OR. ( NI1 .NE. NI2 ) ) THEN */
+
+/* STR = 'Summary formats do not match. NI1 = #, '// */
+/* . 'NI2 = #, ND1 = #, ND2 = #.' */
+
+/* CALL REPMI ( STR, '#', NI1, STR ) */
+/* CALL REPMI ( STR, '#', NI2, STR ) */
+/* CALL REPMI ( STR, '#', ND1, STR ) */
+/* CALL REPMI ( STR, '#', ND2, STR ) */
+
+/* CALL WRLINE ( LOG, STR ) */
+
+/* CALL SIGERR ( 'Incompatible DAFs' ) */
+
+/* END IF */
+
+/* C */
+/* C Find the first array in each DAF. Use DAFCS */
+/* C (DAF, continue search) to set the handle of the DAF */
+/* C to search in before calling DAFFNA. */
+/* C */
+/* CALL DAFCS ( HANDL1 ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* IF ( FOUND ) THEN */
+/* CALL DAFCS ( HANDL2 ) */
+/* CALL DAFFNA ( FOUND ) */
+/* END IF */
+
+/* DO WHILE ( FOUND ) */
+
+/* C */
+/* C Get the summary and name of each array, using */
+/* C DAFCS to select the DAF to get the information */
+/* C from. Unpack the summaries and find the beginning */
+/* C and ending addresses of the arrays. Read the */
+/* C arrays into the variables ARRAY1 and ARRAY2. */
+/* C */
+/* CALL DAFCS ( HANDL1 ) */
+/* CALL DAFGN ( ANAME1 ) */
+/* CALL DAFGS ( SUM1 ) */
+/* CALL DAFUS ( SUM1, ND1, NI1, DC1, IC1 ) */
+
+/* IA1 = IC1 ( NI1 - 1 ) */
+/* FA1 = IC1 ( NI1 ) */
+/* LEN1 = FA1 - IA1 + 1 */
+
+/* IF ( LEN1 .GT. ARRYSZ ) THEN */
+/* CALL SETMSG ( 'Buffer too small; need # elts.') */
+/* CALL ERRINT ( '#', LEN1 ) */
+/* CALL SIGERR ( 'ARRAYTOOSMALL' ) */
+/* ELSE */
+/* CALL DAFRDA ( HANDL1, IA1, FA1, ARRAY1 ) */
+/* END IF */
+
+/* CALL DAFCS ( HANDL2 ) */
+/* CALL DAFGN ( ANAME2 ) */
+/* CALL DAFGS ( SUM2 ) */
+/* CALL DAFUS ( SUM2, ND2, NI2, DC2, IC2 ) */
+
+/* IA2 = IC2 ( NI2 - 1 ) */
+/* FA2 = IC2 ( NI2 ) */
+
+/* LEN2 = FA2 - IA2 + 1 */
+
+/* IF ( LEN1 .GT. ARRYSZ ) THEN */
+
+/* CALL SETMSG ( 'Buffer too small; need # elts.') */
+/* CALL ERRINT ( '#', LEN2 ) */
+/* CALL SIGERR ( 'ARRAYTOOSMALL' ) */
+
+/* ELSE IF ( LEN1 .NE. LEN2 ) THEN */
+
+/* CALL SETMSG ( 'DAF structures do not match. '// */
+/* . 'LEN1 = #, LEN2 = #. ' ) */
+/* CALL ERRINT ( '#', LEN1 ) */
+/* CALL ERRINT ( '#', LEN2 ) */
+/* CALL SIGERR ( 'Incompatible DAFs' ) */
+
+/* ELSE */
+/* CALL DAFRDA ( HANDL2, IA2, FA2, ARRAY2 ) */
+/* END IF */
+/* C */
+/* C */
+/* C Compare the data in the two arrays. Log a message */
+/* C for every instance of data that differs by more */
+/* C than the allowed tolerance. Use the array names */
+/* C to label the data sources. */
+/* C */
+/* DO I = 1, LEN1 */
+
+/* DIFF = ABS( ARRAY1(I) - ARRAY2(I) ) */
+
+/* IF ( DIFF .GT. TOL ) THEN */
+/* C */
+/* C Get the array names. */
+/* C */
+/* CALL DAFCS ( HANDL1 ) */
+/* CALL DAFGN ( ANAME1 ) */
+/* CALL DAFCS ( HANDL2 ) */
+/* CALL DAFGN ( ANAME2 ) */
+
+/* C */
+/* C Construct the report strings. The number 14 */
+/* C below is the number of significant digits to */
+/* C show in the strings representing d.p. */
+/* C numbers. */
+/* C */
+
+/* CALL WRLINE ( LOG, ' ' ) */
+/* CALL WRLINE ( LOG, 'Difference of array ' // */
+/* . 'elements exceeded ' // */
+/* . 'tolerance.' ) */
+/* CALL WRLINE ( LOG, 'First array: '//ANAME1) */
+/* CALL WRLINE ( LOG, 'Second array: '//ANAME2) */
+
+/* STR = 'First value: #' */
+/* CALL REPMD ( STR, '#', ARRAY1(I), 14, STR ) */
+/* CALL WRLINE ( LOG, STR ) */
+
+/* STR = 'Second value: #' */
+/* CALL REPMD ( STR, '#', ARRAY2(I), 14, STR ) */
+/* CALL WRLINE ( LOG, STR ) */
+
+/* STR = 'Difference: #' */
+/* CALL REPMD ( STR, '#', DIFF, 14, STR ) */
+/* CALL WRLINE ( LOG, STR ) */
+/* CALL WRLINE ( LOG, ' ' ) */
+
+/* END IF */
+
+/* END DO */
+
+/* C */
+/* C Find the next pair of arrays. */
+/* C */
+/* CALL DAFCS ( HANDL1 ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* IF ( FOUND ) THEN */
+/* CALL DAFCS ( HANDL2 ) */
+/* CALL DAFFNA ( FOUND ) */
+/* END IF */
+
+/* END DO */
+
+/* C */
+/* C Close the DAFs. */
+/* C */
+/* CALL DAFCLS ( HANDL1 ) */
+/* CALL DAFCLS ( HANDL2 ) */
+
+/* END */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 16-NOV-2001 (FST) */
+
+/* Updated the entry points of DAFFA to enable its */
+/* internal state table size, TBSIZE, to be smaller */
+/* than the file table maintained by DAFAH: FTSIZE. */
+
+/* Calls to DAFRDR were replaced with the translation-aware */
+/* interface DAFGSR for retrieving summary records from */
+/* DAFs. */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* find daf array */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 3.0.0, 16-NOV-2001 (FST) */
+
+/* This umbrella and its entry points were updated to */
+/* work properly with the changes in the DAF system as */
+/* a result of its utilization of the new handle manager. */
+
+/* Since DAFAH now tracks FTSIZE files as defined in */
+/* the include file 'zzddhman.inc', it was decided that */
+/* in the interest of releasing the toolkit this module */
+/* would undergo simple changes. As such most previous */
+/* references to FTSIZE in this umbrella have been replaced */
+/* with TBSIZE where appropriate. DAFBFS and DAFBBS now signal */
+/* errors if there is not enough room to add a new DAF's */
+/* dossier to the state table. Also, after attempting to */
+/* clean up all files listed in the state table that are */
+/* not currently open, DAFBFS and DAFBBS attempt to locate */
+/* the first dossier with STADDG set to FALSE. This is then */
+/* freed to make room for the new DAF. If DAFBNA fails */
+/* to locate such a dossier in the state table, it */
+/* signals the error SPICE(STFULL). */
+
+/* The parameter FILEN was removed, as it is defined */
+/* on an environmental basis in the include file */
+/* 'zzddhman.inc'. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* In previous versions of DAFFA, only one search could be */
+/* conducted at a time. Therefore, there was no question about */
+/* which DAF was being operated on by any of the DAFFA entry */
+/* points that don't accept file handles as input arguments. */
+/* In the current version of DAFFA, the entry points that don't */
+/* accept file handles as inputs operate on the `current DAF'. */
+/* The current DAF is the last one in which a search was */
+/* started by DAFBFS or DAFBBS, or continued by the new entry */
+/* point DAFCS. DAFCS was added to allow users to set the */
+/* current DAF, so that searches of multiple DAFs can be */
+/* interleaved. */
+
+/* Note that the notion of `current DAF' as discussed here applies */
+/* only to DAFs acted upon by entry points of DAFFA. In DAFANA, */
+/* there is a DAF that is treated as the `current DAF' for */
+/* adding data; there is no connection between the DAFs regarded */
+/* as current by DAFFA and DAFANA. */
+
+/* The two principal changes to DAFFA are the addition of the */
+/* new entry point DAFCS, and the addition of a data structure */
+/* called the `state table'. The state table is a collection of */
+/* parallel arrays that maintain information about the state */
+/* of each search that is currently in progress. The arrays are */
+/* indexed by a singly linked list pool; this mechanism allows */
+/* addition and deletion of information about searches without */
+/* requiring movement of data already in the state table. The */
+/* linked list pool contains an `active' list and a `free' list. */
+/* Nodes in the active list are used to index elements of the */
+/* state table where data about searches in progress is stored. */
+/* The head node of the active list is of particular significance: */
+/* the state information pointed to by this node is that of the */
+/* current DAF. Nodes in the free list index elements of the */
+/* state table that are available for use. */
+
+/* When a search is started on a DAF that is not already `known' */
+/* to DAFFA, information about the DAF is added to the state */
+/* table. If there are no free elements in the state table, */
+/* the routine starting the search (DAFBFS or DAFBBS) will */
+/* perform garbage collection: the routine will test the handles */
+/* of each file about which information in stored in the state */
+/* table to see whether that file is still open. Nodes containing */
+/* information about DAFs that are no longer open will be moved */
+/* to the free list. */
+
+/* Whenever a DAF becomes the current DAF, the linked list */
+/* that indexes the state table is adjusted so that the */
+/* information about the current DAF is at the head of the list. */
+/* This way, a slight efficiency is gained when repeated search */
+/* accesses are made to the same DAF, since the linear search */
+/* through the state table for information on that DAF will */
+/* be shortened. */
+
+/* Since the algorithms for maintenance of linked lists are well */
+/* known, they are not documented here. However, see the */
+/* internals of the SPICELIB routine SPKBSR for a nice diagram */
+/* describing a similar data structure. */
+
+/* The state table contains two arrays that are quite large: */
+/* there are buffers that contain the last character record */
+/* and summary record read from each DAF. A parallel situation */
+/* exists in DAFANA, where the name and array summary for each */
+/* array under construction are buffered. The total storage */
+/* required for these arrays (in DAFANA and DAFFA together) is */
+/* 4000 * TBSIZE bytes. For this reason, it may be a good idea */
+/* to reduce the value of TBSIZE in SPICELIB versions for */
+/* machines where memory is scarce. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* State variables. */
+
+/* These variables define the state of each DAF to which data */
+/* is currently being added. For each DAF that we're writing to, we */
+/* maintain a copy of: */
+
+/* STFH File handle. */
+
+/* STPREV Record number of previous array summary. */
+
+/* STTHIS Record number of current array summary. */
+
+/* STNEXT Record number of next array summary. */
+
+/* STNSEG Number of summaries in current summary record. */
+
+/* STCURR Index of current summary within summary record. */
+
+/* STNR Last name record read. */
+
+/* STHVNR Flag indicating whether name record containing */
+/* name of current array is buffered. */
+
+/* STSR Last summary record read. */
+
+/* These variables are maintained in a table of parallel arrays; */
+/* the size of the table is TBSIZE. */
+
+
+/* The table of state variables is indexed by a singly linked list */
+/* of pointers. This mechanism avoids the work of moving */
+/* the state variable data about as information about DAFs is */
+/* added to or deleted from the table. */
+
+/* The structure containing the linked list pointers is called a */
+/* `pool'. The pool contains a list of `active' nodes and a list */
+/* of free nodes. The head nodes of the active and free lists are */
+/* maintained as the variables STHEAD (`state table head') and */
+/* STFPTR (`state table free pointer'), respectively. Every node in */
+/* the pool is on exactly one of these lists. */
+
+
+/* The pool starts out with all of the nodes on the free list. The */
+/* first one of DAFBFS or DAFBBS to be called initializes the pool. */
+/* As new DAFs are searched, DAFBFS and DAFBBS add information about */
+/* them to the state table. Every time a search is started by DAFBFS */
+/* or DAFBBS, the routine in question `moves' the DAF's state */
+/* information to the head of the active list, if the state */
+/* information is not already there. This re-organization is */
+/* accomplished by deleting the node for the DAF from its current */
+/* position in the active list and inserting the node at the head of */
+/* the list. Thus, the change is made merely by setting pointers, */
+/* not by moving chunks of data in the state table. */
+
+/* It may happen that there is no room left in the state table */
+/* to accommodate information about a new DAF. In this case, */
+/* garbage collection must be performed: whichever of DAFBFS or */
+/* DAFBBS needs more room frees all nodes in the table that index */
+/* DAFs that are not currently open. */
+
+/* Note that the routines DAFGS, DAFGN, DAFRS, DAFRN, and DAFWS do */
+/* not modify the state table; they merely act on the current array */
+/* in the DAF that is at the head of the active list. */
+
+
+/* Other local variables */
+
+
+/* Save everything between calls */
+
+
+/* Initial values */
+
+ /* Parameter adjustments */
+ if (sum) {
+ }
+
+ /* Function Body */
+ switch(n__) {
+ case 1: goto L_dafbfs;
+ case 2: goto L_daffna;
+ case 3: goto L_dafbbs;
+ case 4: goto L_daffpa;
+ case 5: goto L_dafgs;
+ case 6: goto L_dafgn;
+ case 7: goto L_dafgh;
+ case 8: goto L_dafrs;
+ case 9: goto L_dafrn;
+ case 10: goto L_dafws;
+ case 11: goto L_dafcs;
+ }
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFFA", (ftnlen)5);
+ sigerr_("SPICE(BOGUSENTRY)", (ftnlen)17);
+ chkout_("DAFFA", (ftnlen)5);
+ }
+ return 0;
+/* $Procedure DAFBFS ( DAF, begin forward search ) */
+
+L_dafbfs:
+/* $ Abstract */
+
+/* Begin a forward search for arrays in a DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of file to be searched. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAF on which a forward */
+/* search is to be conducted. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See argument HANDLE. */
+
+/* $ Exceptions */
+
+/* 1) If the input handle is invalid, the error will be diagnosed */
+/* by routines called by this routine. */
+
+/* $ Particulars */
+
+/* See DAFFA. */
+
+/* $ Examples */
+
+/* See DAFFA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* begin daf forward search */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* This routine now operates on the current DAF---the one at */
+/* the head of the active list. All saved state variables */
+/* used by this routine are now part of the state table, or */
+/* its associated set of pointers. */
+
+/* Also, the $Exceptions section was filled out. */
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFBFS", (ftnlen)6);
+ }
+
+/* Check out the file handle before going any further. */
+
+ dafsih_(handle, "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DAFBFS", (ftnlen)6);
+ return 0;
+ }
+
+/* Initialize the state table pool, if this hasn't been done yet. */
+/* Also initialize the cell used to obtain the set of handles of */
+/* open DAFs. */
+
+ if (first) {
+ ssizei_(&c__1000, opnset);
+ for (i__ = 1; i__ <= 999; ++i__) {
+ stpool[(i__1 = i__ - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stp"
+ "ool", i__1, "daffa_", (ftnlen)1123)] = i__ + 1;
+ }
+ stpool[999] = -1;
+ stfptr = 1;
+ first = FALSE_;
+ }
+
+/* See whether we already have an entry for this DAF in the */
+/* state table. Find the previous node if possible. */
+
+ p = sthead;
+ prev = -1;
+ fnd = FALSE_;
+ while(p != -1 && ! fnd) {
+ if (stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "daffa_", (ftnlen)1142)] == *handle) {
+ fnd = TRUE_;
+ } else {
+ prev = p;
+ p = stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stpool", i__1, "daffa_", (ftnlen)1146)];
+ }
+ }
+
+/* At this point, either FND is false, or P points to a */
+/* state table entry describing the DAF indicated by HANDLE. */
+/* In the latter case, PREV is the predecessor of P. */
+
+ if (fnd) {
+
+/* We already have a dossier on this DAF. We already have */
+/* the information on the summary format, but we must re-set */
+/* our summary record pointers and our name record availability */
+/* flag. */
+
+/* Rather than doing the update here, we do it outside of this */
+/* IF block. That way, the update gets done in just one place. */
+/* This just makes life easier: if the collection of state */
+/* variables is changed, there are fewer places to forget to */
+/* make the required code changes. */
+
+/* Move the node for this DAF to the head of the active list, */
+/* if it is not already there: */
+
+/* - Make the predecessor of P point to the successor of P. */
+
+/* - Make P point to the head of the active list. */
+
+/* - Make P the active list head node. */
+
+
+ if (p != sthead) {
+
+/* P is in the active list, but is not at the head. So, */
+/* the predecessor of P is not NIL. */
+
+ stpool[(i__1 = prev - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stpool", i__1, "daffa_", (ftnlen)1184)] = stpool[(i__2 =
+ p - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("stpool", i__2,
+ "daffa_", (ftnlen)1184)];
+ stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stpool"
+ , i__1, "daffa_", (ftnlen)1185)] = sthead;
+ sthead = p;
+ }
+ } else {
+
+/* We don't yet have any information on this DAF. Make a new */
+/* state table entry for the DAF. We may need to make room for */
+/* the new information by freeing space allocated to DAFs that */
+/* are no longer open. */
+
+ if (stfptr == -1) {
+
+/* Oops, we're out of space. Time for garbage collection. */
+/* Test each file handle to see whether it designates a DAF */
+/* that is still open. DAFHOF will tell us which handles */
+/* point to open DAFs. */
+
+ dafhof_(opnset);
+ p = sthead;
+ prev = -1;
+
+/* For every DAF file represented in the state table, we'll */
+/* delete the corresponding state information if the DAF is */
+/* now closed. We traverse the active list, examining each */
+/* file handle as we go. */
+
+ while(p != -1) {
+ if (elemi_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("stfh", i__1, "daffa_", (ftnlen)1217)], opnset)
+ ) {
+
+/* The file is open. Have a look at the next node. */
+
+ prev = p;
+ p = stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("stpool", i__1, "daffa_", (ftnlen)1222)];
+ } else {
+
+/* This file handle is not on the list, so free the */
+/* node pointing to the information about the DAF it */
+/* designated: */
+
+/* - Save the successor of P. */
+
+/* - Link the predecessor of node P to the successor */
+/* of P, if the predecessor is not NIL. */
+
+/* - If it happens that P is the head node of the */
+/* active list, set the head equal to the */
+/* successor of P. */
+
+/* - Link P into the free list. */
+
+/* - Set P equal to its saved successor. */
+
+/* - (PREV remains unchanged.) */
+
+
+ nextp = stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("stpool", i__1, "daffa_", (ftnlen)1246)];
+ if (p == sthead) {
+
+/* Re-assign STHEAD so that we don't lose the head */
+/* of the active list. P has no predecessor in this */
+/* case, so there's no need to set the forward pointer */
+/* of node PREV. */
+
+ sthead = nextp;
+ } else {
+
+/* Since P is not the head node of the active list, */
+/* PREV is not NIL, so we'll need to set the forward */
+/* pointer of node PREV. */
+
+ stpool[(i__1 = prev - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("stpool", i__1, "daffa_", (ftnlen)1264)
+ ] = nextp;
+ }
+ stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stpool", i__1, "daffa_", (ftnlen)1269)] = stfptr;
+ stfptr = p;
+ p = nextp;
+ }
+ }
+
+/* At this point, we've freed all nodes from the active */
+/* list that were used to index information about DAFs that */
+/* are no longer open. If there's any more room in the state */
+/* table, we have it now. */
+
+ }
+
+/* If there still is no room, there is a bug in DAFAH, since DAFAH */
+/* should not allow more than TBSIZE DAFs to be open. So, we */
+/* assume that we've found some room. The first free node is */
+/* indicated by STFPTR. We'll allocate this node and use it to */
+/* index the state information for the new DAF. */
+
+ p = stfptr;
+
+/* Update the free list pointer, link P to the previous head */
+/* of the active list, and make P the head of the active list. */
+
+ stfptr = stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stpool", i__1, "daffa_", (ftnlen)1297)];
+ stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stpool",
+ i__1, "daffa_", (ftnlen)1298)] = sthead;
+ sthead = p;
+ }
+
+/* At this point, P is the head node of the active list, and P is */
+/* the index in the state table of the information for the current */
+/* DAF. */
+
+
+/* Read the file record and first summary record. Do not read the */
+/* corresponding name record until necessary. In most searches, */
+/* names are of no interest. */
+
+ dafrfr_(handle, &nd, &ni, ifname, &fward, &bward, &free, (ftnlen)60);
+ dafgsr_(handle, &fward, &c__1, &c__128, &stsr[(i__1 = (p << 7) - 128) <
+ 128000 && 0 <= i__1 ? i__1 : s_rnge("stsr", i__1, "daffa_", (
+ ftnlen)1316)], &fnd);
+
+/* Set up the state information for this file. Note that we */
+/* don't have a name record yet, and we have no current array */
+/* yet. */
+
+ stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh", i__1,
+ "daffa_", (ftnlen)1323)] = *handle;
+ stthis[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stthis", i__1,
+ "daffa_", (ftnlen)1324)] = fward;
+ stnext[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stnext", i__1,
+ "daffa_", (ftnlen)1325)] = (integer) stsr[(i__2 = (p << 7) - 128)
+ < 128000 && 0 <= i__2 ? i__2 : s_rnge("stsr", i__2, "daffa_", (
+ ftnlen)1325)];
+ stprev[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stprev", i__1,
+ "daffa_", (ftnlen)1326)] = (integer) stsr[(i__2 = (p << 7) - 127)
+ < 128000 && 0 <= i__2 ? i__2 : s_rnge("stsr", i__2, "daffa_", (
+ ftnlen)1326)];
+ stnseg[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stnseg", i__1,
+ "daffa_", (ftnlen)1327)] = (integer) stsr[(i__2 = (p << 7) - 126)
+ < 128000 && 0 <= i__2 ? i__2 : s_rnge("stsr", i__2, "daffa_", (
+ ftnlen)1327)];
+ sthvnr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("sthvnr", i__1,
+ "daffa_", (ftnlen)1328)] = FALSE_;
+
+/* The arrays are returned in forward order within each summary */
+/* record. */
+
+ stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr", i__1,
+ "daffa_", (ftnlen)1333)] = 0;
+ chkout_("DAFBFS", (ftnlen)6);
+ return 0;
+/* $Procedure DAFFNA ( DAF, find next array ) */
+
+L_daffna:
+/* $ Abstract */
+
+/* Find the next (forward) array in the current DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* LOGICAL FOUND */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FOUND O True if an array was found. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* FOUND is true if an array was found, and is false if, */
+/* when this routine is called, the current array is */
+/* the tail of the array list. (Recall that the */
+/* arrays in a DAF may be viewed as a doubly linked */
+/* list, with the tail being the last array in the file.) */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If this routine is called before a search is begun, the */
+/* error SPICE(DAFNOSEARCH) is signalled. */
+
+/* 2) If the DAF to be searched has actually been closed, the error */
+/* will be diagnosed by routines called by this routine. */
+
+/* 3) If the end of the array list has already been reached when */
+/* this routine is called, this routine has no effect. */
+
+/* $ Particulars */
+
+/* See DAFFA. */
+
+/* $ Examples */
+
+/* See DAFFA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* find next daf array */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* This routine now operates on the current DAF---the one at */
+/* the head of the active list. All saved state variables */
+/* used by this routine are now part of the state table, or */
+/* its associated set of pointers. */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFFNA", (ftnlen)6);
+ }
+
+/* FOUND will be false until we make it past the error checks. */
+
+ *found = FALSE_;
+
+/* Operate on the last DAF in which a search has been started. */
+
+ p = sthead;
+
+/* Make sure that a search has been started in this DAF. */
+
+ if (p == -1) {
+ setmsg_("No DAF is currently being searched.", (ftnlen)35);
+ sigerr_("SPICE(DAFNOSEARCH)", (ftnlen)18);
+ chkout_("DAFFNA", (ftnlen)6);
+ return 0;
+
+/* Make sure that the `current' DAF is still open. */
+
+ } else {
+ dafsih_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)1522)], "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DAFFNA", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* Now that we know a search is going on, assume that we will find */
+/* an array until proven otherwise. */
+
+ *found = TRUE_;
+
+/* Either there are more summaries left in this record, or */
+/* there aren't. If there are, just incrementing the pointer */
+/* is sufficient. If there aren't, we have to find the next */
+/* record and point to the first array there. (If that */
+/* record is empty, or doesn't exist, then there are simply */
+/* no more arrays to be found.) */
+
+ stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr", i__1,
+ "daffa_", (ftnlen)1548)] = stcurr[(i__2 = p - 1) < 1000 && 0 <=
+ i__2 ? i__2 : s_rnge("stcurr", i__2, "daffa_", (ftnlen)1548)] + 1;
+ if (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr",
+ i__1, "daffa_", (ftnlen)1550)] > stnseg[(i__2 = p - 1) < 1000 &&
+ 0 <= i__2 ? i__2 : s_rnge("stnseg", i__2, "daffa_", (ftnlen)1550)]
+ ) {
+ if (stnext[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stnext"
+ , i__1, "daffa_", (ftnlen)1552)] == 0) {
+
+/* There are no more arrays in the list. */
+
+ *found = FALSE_;
+
+/* Make sure that the array pointer stays pointing to */
+/* the position following the end of the list. Otherwise, */
+/* a call to DAFFPA might fail to find the last array in */
+/* the list. */
+
+ stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr"
+ , i__1, "daffa_", (ftnlen)1563)] = stnseg[(i__2 = p - 1) <
+ 1000 && 0 <= i__2 ? i__2 : s_rnge("stnseg", i__2, "daff"
+ "a_", (ftnlen)1563)] + 1;
+
+/* The careful reader may note that we're not updating any */
+/* of the pointers */
+
+/* STTHIS */
+/* STNEXT */
+/* STPREV */
+
+/* These will not be accessed if there is no current array. */
+/* If the array pointer is backed up again by a call to */
+/* DAFFPA, the values we have right now will be correct. */
+
+ } else {
+ dafgsr_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)1578)], &stnext[(i__2 = p
+ - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("stnext", i__2,
+ "daffa_", (ftnlen)1578)], &c__1, &c__128, &stsr[(i__3 = (
+ p << 7) - 128) < 128000 && 0 <= i__3 ? i__3 : s_rnge(
+ "stsr", i__3, "daffa_", (ftnlen)1578)], &fnd);
+
+/* The name (character) record we've saved no longer applies */
+/* to the current summary record. However, we've just updated */
+/* the summary record, so the summary record remains valid. */
+
+ sthvnr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("sthvnr"
+ , i__1, "daffa_", (ftnlen)1584)] = FALSE_;
+ stthis[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stthis"
+ , i__1, "daffa_", (ftnlen)1586)] = stnext[(i__2 = p - 1) <
+ 1000 && 0 <= i__2 ? i__2 : s_rnge("stnext", i__2, "daff"
+ "a_", (ftnlen)1586)];
+ stnext[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stnext"
+ , i__1, "daffa_", (ftnlen)1587)] = (integer) stsr[(i__2 =
+ (p << 7) - 128) < 128000 && 0 <= i__2 ? i__2 : s_rnge(
+ "stsr", i__2, "daffa_", (ftnlen)1587)];
+ stprev[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stprev"
+ , i__1, "daffa_", (ftnlen)1588)] = (integer) stsr[(i__2 =
+ (p << 7) - 127) < 128000 && 0 <= i__2 ? i__2 : s_rnge(
+ "stsr", i__2, "daffa_", (ftnlen)1588)];
+ stnseg[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stnseg"
+ , i__1, "daffa_", (ftnlen)1589)] = (integer) stsr[(i__2 =
+ (p << 7) - 126) < 128000 && 0 <= i__2 ? i__2 : s_rnge(
+ "stsr", i__2, "daffa_", (ftnlen)1589)];
+ stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr"
+ , i__1, "daffa_", (ftnlen)1590)] = 1;
+ *found = stnseg[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("stnseg", i__1, "daffa_", (ftnlen)1592)] > 0;
+ }
+ }
+ chkout_("DAFFNA", (ftnlen)6);
+ return 0;
+/* $Procedure DAFBBS ( DAF, begin backward search ) */
+
+L_dafbbs:
+/* $ Abstract */
+
+/* Begin a backward search for arrays in a DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAF to be searched. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAF on which a backward */
+/* search is to be conducted. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See argument HANDLE. */
+
+/* $ Exceptions */
+
+/* 1) If the input handle is invalid, the error will be diagnosed */
+/* by routines called by this routine. */
+
+/* $ Particulars */
+
+/* See DAFFA. */
+
+/* $ Examples */
+
+/* See DAFFA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* begin daf backward search */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* This routine now makes the DAF designated by HANDLE the */
+/* current DAF---the one at the head of the active list. All */
+/* saved state variables used by this routine are now part of the */
+/* state table, or its associated set of pointers. */
+
+/* Also, the $Exceptions section was filled out. */
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFBBS", (ftnlen)6);
+ }
+
+/* Check out the file handle before going any further. */
+
+ dafsih_(handle, "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DAFBBS", (ftnlen)6);
+ return 0;
+ }
+
+/* Initialize the state table pool, if this hasn't been done yet. */
+/* Also initialize the cell used to obtain the set of handles of */
+/* open DAFs. */
+
+ if (first) {
+ ssizei_(&c__1000, opnset);
+ for (i__ = 1; i__ <= 999; ++i__) {
+ stpool[(i__1 = i__ - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stp"
+ "ool", i__1, "daffa_", (ftnlen)1774)] = i__ + 1;
+ }
+ stpool[999] = -1;
+ stfptr = 1;
+ first = FALSE_;
+ }
+
+/* See whether we already have an entry for this DAF in the */
+/* state table. Find the previous node if possible. */
+
+ p = sthead;
+ prev = -1;
+ fnd = FALSE_;
+ while(p != -1 && ! fnd) {
+ if (stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "daffa_", (ftnlen)1793)] == *handle) {
+ fnd = TRUE_;
+ } else {
+ prev = p;
+ p = stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stpool", i__1, "daffa_", (ftnlen)1797)];
+ }
+ }
+
+/* At this point, either FND is false, or P points to a */
+/* state table entry describing the DAF indicated by HANDLE. */
+/* In the latter case, PREV is the predecessor of P. */
+
+ if (fnd) {
+
+/* We already have a dossier on this DAF. We already have */
+/* the information on the summary format, but we must re-set */
+/* our summary record pointers and our name record availability */
+/* flag. */
+
+/* Rather than doing the update here, we do it outside of this */
+/* IF block. That way, the update gets done in just one place. */
+/* This just makes life easier: if the collection of state */
+/* variables is changed, there are fewer places to forget to */
+/* make the required code changes. */
+
+/* Move the node for this DAF to the head of the active list, */
+/* if it is not already there: */
+
+/* - Make the predecessor of P point to the successor of P. */
+
+/* - Make P point to the head of the active list. */
+
+/* - Make P the active list head node. */
+
+
+ if (p != sthead) {
+
+/* P is in the active list, but is not at the head. So, */
+/* the predecessor of P is not NIL. */
+
+ stpool[(i__1 = prev - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stpool", i__1, "daffa_", (ftnlen)1835)] = stpool[(i__2 =
+ p - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("stpool", i__2,
+ "daffa_", (ftnlen)1835)];
+ stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stpool"
+ , i__1, "daffa_", (ftnlen)1836)] = sthead;
+ sthead = p;
+ }
+ } else {
+
+/* We don't yet have any information on this DAF. Make a new */
+/* state table entry for the DAF. We may need to make room for */
+/* the new information by freeing space allocated to DAFs that */
+/* are no longer open. */
+
+ if (stfptr == -1) {
+
+/* Oops, we're out of space. Time for garbage collection. */
+/* Test each file handle to see whether it designates a DAF */
+/* that is still open. DAFHOF will tell us which handles */
+/* point to open DAFs. */
+
+ dafhof_(opnset);
+ p = sthead;
+ prev = -1;
+
+/* For every DAF file represented in the state table, we'll */
+/* delete the corresponding state information if the DAF is */
+/* now closed. We traverse the active list, examining each */
+/* file handle as we go. */
+
+ while(p != -1) {
+ if (elemi_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("stfh", i__1, "daffa_", (ftnlen)1868)], opnset)
+ ) {
+
+/* The file is open. Have a look at the next node. */
+
+ prev = p;
+ p = stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("stpool", i__1, "daffa_", (ftnlen)1873)];
+ } else {
+
+/* This file handle is not on the list, so free the */
+/* node pointing to the information about the DAF it */
+/* designated: */
+
+/* - Save the successor of P. */
+
+/* - Link the predecessor of node P to the successor */
+/* of P, if the predecessor is not NIL. */
+
+/* - If it happens that P is the head node of the */
+/* active list, set the head equal to the */
+/* successor of P. */
+
+/* - Link P into the free list. */
+
+/* - Set P equal to its saved successor. */
+
+/* - (PREV remains unchanged.) */
+
+
+ nextp = stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("stpool", i__1, "daffa_", (ftnlen)1897)];
+ if (p == sthead) {
+
+/* Re-assign STHEAD so that we don't lose the head */
+/* of the active list. P has no predecessor in this */
+/* case, so there's no need to set the forward pointer */
+/* of node PREV. */
+
+ sthead = nextp;
+ } else {
+
+/* Since P is not the head node of the active list, */
+/* PREV is not NIL, so we'll need to set the forward */
+/* pointer of node PREV. */
+
+ stpool[(i__1 = prev - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("stpool", i__1, "daffa_", (ftnlen)1915)
+ ] = nextp;
+ }
+ stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stpool", i__1, "daffa_", (ftnlen)1920)] = stfptr;
+ stfptr = p;
+ p = nextp;
+ }
+ }
+
+/* At this point, we've freed all nodes from the active */
+/* list that were used to index information about DAFs that */
+/* are no longer open. If there's any more room in the state */
+/* table, we have it now. */
+
+ }
+
+/* If there still is no room, there is a bug in DAFAH, since DAFAH */
+/* should not allow more than TBSIZE DAFs to be open. So, we */
+/* assume that we've found some room. The first free node is */
+/* indicated by STFPTR. We'll allocate this node and use it to */
+/* index the state information for the new DAF. */
+
+ p = stfptr;
+
+/* Update the free list pointer, link P to the previous head */
+/* of the active list, and make P the head of the active list. */
+
+ stfptr = stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stpool", i__1, "daffa_", (ftnlen)1947)];
+ stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stpool",
+ i__1, "daffa_", (ftnlen)1948)] = sthead;
+ sthead = p;
+ }
+
+/* At this point, P is the head node of the active list, and P is */
+/* the index in the state table of the information for the current */
+/* DAF. */
+
+
+/* Read the file record and last summary record. Do not read the */
+/* corresponding name record until necessary. In most searches, */
+/* names are of no interest. */
+
+ dafrfr_(handle, &nd, &ni, ifname, &fward, &bward, &free, (ftnlen)60);
+ dafgsr_(handle, &bward, &c__1, &c__128, &stsr[(i__1 = (p << 7) - 128) <
+ 128000 && 0 <= i__1 ? i__1 : s_rnge("stsr", i__1, "daffa_", (
+ ftnlen)1965)], &fnd);
+ stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh", i__1,
+ "daffa_", (ftnlen)1967)] = *handle;
+ stthis[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stthis", i__1,
+ "daffa_", (ftnlen)1968)] = bward;
+ stnext[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stnext", i__1,
+ "daffa_", (ftnlen)1969)] = (integer) stsr[(i__2 = (p << 7) - 128)
+ < 128000 && 0 <= i__2 ? i__2 : s_rnge("stsr", i__2, "daffa_", (
+ ftnlen)1969)];
+ stprev[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stprev", i__1,
+ "daffa_", (ftnlen)1970)] = (integer) stsr[(i__2 = (p << 7) - 127)
+ < 128000 && 0 <= i__2 ? i__2 : s_rnge("stsr", i__2, "daffa_", (
+ ftnlen)1970)];
+ stnseg[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stnseg", i__1,
+ "daffa_", (ftnlen)1971)] = (integer) stsr[(i__2 = (p << 7) - 126)
+ < 128000 && 0 <= i__2 ? i__2 : s_rnge("stsr", i__2, "daffa_", (
+ ftnlen)1971)];
+ sthvnr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("sthvnr", i__1,
+ "daffa_", (ftnlen)1972)] = FALSE_;
+
+/* The arrays are returned in backward order from each summary */
+/* record. */
+
+ stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr", i__1,
+ "daffa_", (ftnlen)1978)] = stnseg[(i__2 = p - 1) < 1000 && 0 <=
+ i__2 ? i__2 : s_rnge("stnseg", i__2, "daffa_", (ftnlen)1978)] + 1;
+ chkout_("DAFBBS", (ftnlen)6);
+ return 0;
+/* $Procedure DAFFPA ( DAF, find previous array ) */
+
+L_daffpa:
+/* $ Abstract */
+
+/* Find the previous (backward) array in the current DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* LOGICAL FOUND */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FOUND O True if an array was found. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* FOUND is true if an array was found, and is false if, */
+/* when this routine is called, the current array is */
+/* the head of the array list. (Recall that the */
+/* arrays in a DAF may be viewed as a doubly linked */
+/* list, with the head being the first array in the */
+/* file.) */
+
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If this routine is called before a search is begun, the */
+/* error SPICE(DAFNOSEARCH) is signalled. */
+
+/* 2) If the DAF to be searched has actually been closed, the error */
+/* will be diagnosed by routines called by this routine. */
+
+/* 3) If the beginning of the array list has already been reached */
+/* when this routine is called, this routine will not change the */
+/* current array. FOUND will be false on output. */
+
+/* $ Particulars */
+
+/* See DAFFA. */
+
+/* $ Examples */
+
+/* See DAFFA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+/* Also, a bug fix was made to the array pointer adjustment */
+/* algorithm. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* find previous daf array */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* This routine now operates on the current DAF---the one at */
+/* the head of the active list. All saved state variables */
+/* used by this routine are now part of the state table, or */
+/* its associated set of pointers. */
+
+/* Also, a bug fix was made to the array pointer adjustment */
+/* algorithm: the pointer is no longer decremented if it */
+/* is already less than 1 and the array summary pointer */
+/* is already pointing to the first array summary. In */
+/* addition, a test made to detect this condition was fixed: */
+/* the test */
+
+/* CURR .EQ. 0 */
+
+/* was replaced by */
+
+/* STCURR(P) .LE. 0 */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFFPA", (ftnlen)6);
+ }
+
+/* Operate on the last DAF in which a search has been started. */
+
+ p = sthead;
+
+/* FOUND will be false until we make it past the error checks. */
+
+ *found = FALSE_;
+
+/* Make sure that a search has been started in this DAF. */
+
+ if (p == -1) {
+ setmsg_("No DAF is currently being searched.", (ftnlen)35);
+ sigerr_("SPICE(DAFNOSEARCH)", (ftnlen)18);
+ chkout_("DAFFPA", (ftnlen)6);
+ return 0;
+
+/* Make sure that the `current' DAF is still open. */
+
+ } else {
+ dafsih_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)2189)], "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DAFFPA", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* Now that we know a search is going on, assume that we will find */
+/* an array until proven otherwise. */
+
+ *found = TRUE_;
+
+/* Either there are more summaries left in this record, or */
+/* there aren't. If there are, just decrementing the pointer */
+/* is sufficient. If there aren't, we have to find the previous */
+/* record and point to the last array there. (If that */
+/* record is empty, or doesn't exist, then there are simply */
+/* no more arrays to be found.) */
+
+ stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr", i__1,
+ "daffa_", (ftnlen)2212)] = stcurr[(i__2 = p - 1) < 1000 && 0 <=
+ i__2 ? i__2 : s_rnge("stcurr", i__2, "daffa_", (ftnlen)2212)] - 1;
+ if (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr",
+ i__1, "daffa_", (ftnlen)2214)] <= 0) {
+ if (stprev[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stprev"
+ , i__1, "daffa_", (ftnlen)2216)] == 0) {
+
+/* There is no predecessor of the current array in the list. */
+
+ *found = FALSE_;
+
+/* Make sure that the array pointer stays pointing to */
+/* the position preceding the front of the list. Otherwise, */
+/* a call to DAFFNA might fail to find the first array in */
+/* the list. */
+
+ stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr"
+ , i__1, "daffa_", (ftnlen)2227)] = 0;
+
+/* The careful reader may note that we're not updating any */
+/* of the pointers */
+
+/* STTHIS */
+/* STNEXT */
+/* STPREV */
+
+/* These will not be accessed if there is no current array. */
+/* If the array pointer is moved forward again by a call to */
+/* DAFFNA, the values we have right now will be correct. */
+
+ } else {
+ dafgsr_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)2242)], &stprev[(i__2 = p
+ - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("stprev", i__2,
+ "daffa_", (ftnlen)2242)], &c__1, &c__128, &stsr[(i__3 = (
+ p << 7) - 128) < 128000 && 0 <= i__3 ? i__3 : s_rnge(
+ "stsr", i__3, "daffa_", (ftnlen)2242)], &fnd);
+
+/* The name (character) record we've saved no longer applies */
+/* to the current summary record. However, we've just updated */
+/* the summary record, so the summary record remains valid. */
+
+ sthvnr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("sthvnr"
+ , i__1, "daffa_", (ftnlen)2248)] = FALSE_;
+ stthis[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stthis"
+ , i__1, "daffa_", (ftnlen)2250)] = stprev[(i__2 = p - 1) <
+ 1000 && 0 <= i__2 ? i__2 : s_rnge("stprev", i__2, "daff"
+ "a_", (ftnlen)2250)];
+ stnext[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stnext"
+ , i__1, "daffa_", (ftnlen)2251)] = (integer) stsr[(i__2 =
+ (p << 7) - 128) < 128000 && 0 <= i__2 ? i__2 : s_rnge(
+ "stsr", i__2, "daffa_", (ftnlen)2251)];
+ stprev[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stprev"
+ , i__1, "daffa_", (ftnlen)2252)] = (integer) stsr[(i__2 =
+ (p << 7) - 127) < 128000 && 0 <= i__2 ? i__2 : s_rnge(
+ "stsr", i__2, "daffa_", (ftnlen)2252)];
+ stnseg[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stnseg"
+ , i__1, "daffa_", (ftnlen)2253)] = (integer) stsr[(i__2 =
+ (p << 7) - 126) < 128000 && 0 <= i__2 ? i__2 : s_rnge(
+ "stsr", i__2, "daffa_", (ftnlen)2253)];
+ stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr"
+ , i__1, "daffa_", (ftnlen)2254)] = stnseg[(i__2 = p - 1) <
+ 1000 && 0 <= i__2 ? i__2 : s_rnge("stnseg", i__2, "daff"
+ "a_", (ftnlen)2254)];
+ *found = stnseg[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("stnseg", i__1, "daffa_", (ftnlen)2256)] > 0;
+ }
+ }
+ chkout_("DAFFPA", (ftnlen)6);
+ return 0;
+/* $Procedure DAFGS ( DAF, get summary ) */
+
+L_dafgs:
+/* $ Abstract */
+
+/* Return (get) the summary for the current array in the current */
+/* DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* DOUBLE PRECISION SUM ( * ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* SUM O Summary for current array. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* SUM is the summary for the current array (the array */
+/* found by the latest call to DAFFNA or DAFFPA). */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If this routine is called when no search is in progress in the */
+/* the current DAF, the error SPICE(DAFNOSEARCH) is signalled. */
+
+/* 2) If the DAF for which the `current' array's summary is to be */
+/* returned has actually been closed, the error will be diagnosed */
+/* by routines called by this routine. */
+
+/* 3) If no array is current in the current DAF, the error */
+/* SPICE(NOCURRENTARRAY) is signalled. There is no current */
+/* array when a search is started by DAFBFS or DAFBBS, but no */
+/* calls to DAFFNA or DAFBNA have been made yet, or whenever */
+/* DAFFNA or DAFFPA return the value .FALSE. in the FOUND */
+/* argument. */
+
+/* $ Particulars */
+
+/* See DAFFA. */
+
+/* $ Examples */
+
+/* See DAFFA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+/* Bug fix made to handle case of having no current array. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get daf summary */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* This routine now operates on the current DAF---the one at */
+/* the head of the active list. All saved state variables */
+/* used by this routine are now part of the state table, or */
+/* its associated set of pointers. */
+
+/* In addition, this routine now checks whether an array */
+/* is current before trying to read its summary. The routine */
+/* previously crashed under these conditions. */
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFGS", (ftnlen)5);
+ }
+
+/* Operate on the last DAF in which a search has been started. */
+
+ p = sthead;
+
+/* Make sure that a search has been started in this DAF. */
+
+ if (p == -1) {
+ setmsg_("No DAF is currently being searched.", (ftnlen)35);
+ sigerr_("SPICE(DAFNOSEARCH)", (ftnlen)18);
+ chkout_("DAFGS", (ftnlen)5);
+ return 0;
+
+/* Make sure that the `current' DAF is still open. */
+
+ } else {
+ dafsih_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)2454)], "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DAFGS", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Check the current pointer position to make sure that it's in */
+/* bounds. If there is no current array, then we cannot return */
+/* a summary. This situation occurs if DAFFNA was called when the */
+/* current array was the last, or if DAFFPA was called when the */
+/* current array was the first. */
+
+ if (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr",
+ i__1, "daffa_", (ftnlen)2470)] == 0) {
+ dafhfn_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)2472)], dafnam, (ftnlen)255);
+ setmsg_("No array is current; the `next' array is the first array of"
+ " DAF #", (ftnlen)65);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(NOCURRENTARRAY)", (ftnlen)21);
+ chkout_("DAFGS", (ftnlen)5);
+ return 0;
+ } else if (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stcurr", i__1, "daffa_", (ftnlen)2480)] > stnseg[(i__2 = p - 1) <
+ 1000 && 0 <= i__2 ? i__2 : s_rnge("stnseg", i__2, "daffa_", (
+ ftnlen)2480)]) {
+ dafhfn_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)2482)], dafnam, (ftnlen)255);
+ setmsg_("No array is current; the `previous' array is the last array"
+ " of DAF #", (ftnlen)68);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(NOCURRENTARRAY)", (ftnlen)21);
+ chkout_("DAFGS", (ftnlen)5);
+ return 0;
+ }
+
+/* The location of the summary depends on the current pointer */
+/* position. */
+
+ dafhsf_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "daffa_", (ftnlen)2496)], &nd, &ni);
+ sumsiz = nd + (ni + 1) / 2;
+ offset = (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stc"
+ "urr", i__1, "daffa_", (ftnlen)2500)] - 1) * sumsiz + 3;
+ moved_(&stsr[(i__1 = offset + 1 + (p << 7) - 129) < 128000 && 0 <= i__1 ?
+ i__1 : s_rnge("stsr", i__1, "daffa_", (ftnlen)2502)], &sumsiz,
+ sum);
+ chkout_("DAFGS", (ftnlen)5);
+ return 0;
+/* $Procedure DAFGN ( DAF, get array name ) */
+
+L_dafgn:
+/* $ Abstract */
+
+/* Return (get) the name for the current array in the current DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) NAME */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* NAME O Name of current array. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* NAME is the name for the current array (the array */
+/* found by the latest call to DAFFNA or DAFFPA). */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If this routine is called when no search is in progress in the */
+/* the current DAF, the error SPICE(DAFNOSEARCH) is signalled. */
+
+/* 2) If the DAF for which the `current' array's name is to be */
+/* returned has actually been closed, the error will be diagnosed */
+/* by routines called by this routine. */
+
+/* 3) If no array is current in the current DAF, the error */
+/* SPICE(NOCURRENTARRAY) is signalled. There is no current */
+/* array when a search is started by DAFBFS or DAFBBS, but no */
+/* calls to DAFFNA or DAFBNA have been made yet, or whenever */
+/* DAFFNA or DAFFPA return the value .FALSE. in the FOUND */
+/* argument. */
+
+/* $ Particulars */
+
+/* See DAFFA. */
+
+/* $ Examples */
+
+/* See DAFFA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+/* Bug fix made to handle case of having no current array. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get daf array name */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* This routine now operates on the current DAF---the one at */
+/* the head of the active list. All saved state variables */
+/* used by this routine are now part of the state table, or */
+/* its associated set of pointers. */
+
+/* In addition, this routine now checks whether an array */
+/* is current before trying to read its summary. The routine */
+/* previously crashed under these conditions. */
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFGN", (ftnlen)5);
+ }
+
+/* Operate on the last DAF in which a search has been started. */
+
+ p = sthead;
+
+/* Make sure that a search has been started in this DAF. */
+
+ if (p == -1) {
+ setmsg_("No DAF is currently being searched.", (ftnlen)35);
+ sigerr_("SPICE(DAFNOSEARCH)", (ftnlen)18);
+ chkout_("DAFGN", (ftnlen)5);
+ return 0;
+
+/* Make sure that the `current' DAF is still open. */
+
+ } else {
+ dafsih_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)2692)], "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DAFGN", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Check the current pointer position to make sure that it's in */
+/* bounds. If there is no current array, then we cannot get the */
+/* array's summary's name. This situation occurs if DAFFNA was */
+/* called when the current array was the last, or if DAFFPA was */
+/* called when the current array was the first. */
+
+ if (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr",
+ i__1, "daffa_", (ftnlen)2708)] == 0) {
+ dafhfn_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)2710)], dafnam, (ftnlen)255);
+ setmsg_("No array is current; the `next' array is the first array of"
+ " DAF #", (ftnlen)65);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(NOCURRENTARRAY)", (ftnlen)21);
+ chkout_("DAFGN", (ftnlen)5);
+ return 0;
+ } else if (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stcurr", i__1, "daffa_", (ftnlen)2718)] > stnseg[(i__2 = p - 1) <
+ 1000 && 0 <= i__2 ? i__2 : s_rnge("stnseg", i__2, "daffa_", (
+ ftnlen)2718)]) {
+ dafhfn_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)2720)], dafnam, (ftnlen)255);
+ setmsg_("No array is current; the `previous' array is the last array"
+ " of DAF #", (ftnlen)68);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(NOCURRENTARRAY)", (ftnlen)21);
+ chkout_("DAFGN", (ftnlen)5);
+ return 0;
+ }
+
+/* Read the name record for this summary record, if we don't have it */
+/* already. */
+
+ if (! sthvnr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("sthvnr",
+ i__1, "daffa_", (ftnlen)2735)]) {
+ i__4 = stthis[(i__2 = p - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "stthis", i__2, "daffa_", (ftnlen)2737)] + 1;
+ dafrcr_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)2737)], &i__4, stnr + ((i__3 =
+ p - 1) < 1000 && 0 <= i__3 ? i__3 : s_rnge("stnr", i__3,
+ "daffa_", (ftnlen)2737)) * 1000, (ftnlen)1000);
+ sthvnr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("sthvnr",
+ i__1, "daffa_", (ftnlen)2739)] = TRUE_;
+ }
+
+/* The location of the name depends on the current pointer */
+/* position. */
+
+ dafhsf_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "daffa_", (ftnlen)2748)], &nd, &ni);
+ sumsiz = nd + (ni + 1) / 2;
+ namsiz = sumsiz << 3;
+ offset = (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stc"
+ "urr", i__1, "daffa_", (ftnlen)2754)] - 1) * namsiz;
+ i__2 = offset;
+ s_copy(name__, stnr + (((i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 :
+ s_rnge("stnr", i__1, "daffa_", (ftnlen)2756)) * 1000 + i__2),
+ name_len, offset + namsiz - i__2);
+ chkout_("DAFGN", (ftnlen)5);
+ return 0;
+/* $Procedure DAFGH ( DAF, get handle ) */
+
+L_dafgh:
+/* $ Abstract */
+
+/* Return (get) the handle of the DAF currently being searched. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE O Handle for current DAF. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the handle for the current DAF (the handle */
+/* connected to the DAF that is currently being */
+/* searched). */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If this routine is called when no search is in progress in the */
+/* the current DAF, the error SPICE(DAFNOSEARCH) is signalled. */
+
+/* 2) If the DAF whose handle is to be returned has actually been */
+/* closed, the error will be diagnosed by routines called by */
+/* this routine. */
+
+/* $ Particulars */
+
+/* Under rare circumstances, it may be necessary to identify */
+/* the particular DAF that is being searched (such as when */
+/* the search is begun by one module and continued by another). */
+
+/* $ Examples */
+
+/* Consider a program like the following, which examines the */
+/* individual arrays in a DAF and examines the contents of those */
+/* meeting certain criteria. */
+
+/* CALL DAFOPW ( FNAME, HANDLE ) */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+/* CALL CHECK_DAF ( STATUS ) */
+
+/* IF ( STATUS .EQ. 'EXAMINE' ) THEN */
+/* CALL EXAMINE_DAF */
+/* END IF */
+
+/* CALL DAFFNA ( FOUND ) */
+/* END DO */
+
+/* The subroutine CHECK_DAF, which assumes that a search is in */
+/* progress, gets the summary and name for the current array, and */
+/* uses them to decide whether the data in the array merit further */
+/* consideration. */
+
+/* SUBROUTINE CHECK_DAF ( STATUS ) */
+
+/* CALL DAFGS ( SUM ) */
+/* CALL DAFGN ( NAME ) */
+/* CALL DAFUS ( SUM, ND, NI, DC, IC ) */
+/* . */
+/* . */
+
+/* The subroutine EXAMINE_DAF needs to examine the data in */
+/* the array itself. In order to do do, it needs to have access */
+/* not only to the summary, but to the handle of the file */
+/* containing the array. This is provided by DAFGH. */
+
+/* SUBROUTINE EXAMINE_DAF */
+
+/* CALL DAFGS ( SUM ) */
+/* CALL DAFGH ( HANDLE ) */
+/* CALL DAFUS ( SUM, ND, NI, DC, IC ) */
+
+/* CALL DAFRDA ( HANDLE, BEGIN, END, DATA ) */
+/* . */
+/* . */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* get daf handle */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* This routine now operates on the current DAF---the one at */
+/* the head of the active list. All saved state variables */
+/* used by this routine are now part of the state table, or */
+/* its associated set of pointers. */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFGH", (ftnlen)5);
+ }
+
+/* Operate on the last DAF in which a search has been started. */
+
+ p = sthead;
+
+/* Make sure that a search has been started in this DAF. */
+
+ if (p == -1) {
+ setmsg_("No DAF is currently being searched.", (ftnlen)35);
+ sigerr_("SPICE(DAFNOSEARCH)", (ftnlen)18);
+ chkout_("DAFGH", (ftnlen)5);
+ return 0;
+
+/* Make sure that the `current' DAF is still open. */
+
+ } else {
+ dafsih_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)2983)], "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DAFGH", (ftnlen)5);
+ return 0;
+ }
+ }
+ *handle = stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "daffa_", (ftnlen)2993)];
+ chkout_("DAFGH", (ftnlen)5);
+ return 0;
+/* $Procedure DAFRS ( DAF, replace summary ) */
+
+L_dafrs:
+/* $ Abstract */
+
+/* Change the summary for the current array in the current DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* DOUBLE PRECISION SUM */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* SUM I New summary for current array. */
+
+/* $ Detailed_Input */
+
+/* SUM is the new summary for the current array. This */
+/* replaces the existing summary. However, the addresses */
+/* (the final two integer components) of the original */
+/* summary are not changed. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If this routine is called when no search is in progress in the */
+/* the current DAF, the error SPICE(DAFNOSEARCH) is signalled. */
+
+/* 2) If the DAF containing the `current' array has actually been */
+/* closed, the error will be diagnosed by routines called by */
+/* this routine. */
+
+/* 3) If the DAF containing the `current' array is not open for */
+/* writing, the error will be diagnosed by routines called by */
+/* this routine. */
+
+/* 4) If no array is current in the current DAF, the error */
+/* SPICE(NOCURRENTARRAY) is signalled. There is no current */
+/* array when a search is started by DAFBFS or DAFBBS, but no */
+/* calls to DAFFNA or DAFBNA have been made yet, or whenever */
+/* DAFFNA or DAFFPA return the value .FALSE. in the FOUND */
+/* argument. */
+
+/* $ Particulars */
+
+/* See DAFFA. */
+
+/* $ Examples */
+
+/* See DAFFA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+/* Bug fix made to handle case of having no current array. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* replace daf summary */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* This routine now operates on the current DAF---the one at */
+/* the head of the active list. All saved state variables */
+/* used by this routine are now part of the state table, or */
+/* its associated set of pointers. */
+
+/* In addition, this routine now checks whether an array */
+/* is current before trying to read its summary. The routine */
+/* previously crashed under these conditions. */
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFRS", (ftnlen)5);
+ }
+
+/* Operate on the last DAF in which a search has been started. */
+
+ p = sthead;
+
+/* Make sure that a search has been started in this DAF. */
+
+ if (p == -1) {
+ setmsg_("No DAF is currently being searched.", (ftnlen)35);
+ sigerr_("SPICE(DAFNOSEARCH)", (ftnlen)18);
+ chkout_("DAFRS", (ftnlen)5);
+ return 0;
+
+/* Make sure that the `current' DAF is still open, and that it */
+/* is open for writing. */
+
+ } else {
+ dafsih_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)3192)], "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DAFRS", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Check the current pointer position to make sure that it's in */
+/* bounds. If there is no current array, then we cannot replace the */
+/* array's summary. This situation occurs if DAFFNA was called */
+/* when the current array was the last, or if DAFFPA was called when */
+/* the current array was the first. */
+
+ if (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr",
+ i__1, "daffa_", (ftnlen)3208)] == 0) {
+ dafhfn_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)3210)], dafnam, (ftnlen)255);
+ setmsg_("No array is current; the `next' array is the first array of"
+ " DAF #", (ftnlen)65);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(NOCURRENTARRAY)", (ftnlen)21);
+ chkout_("DAFRS", (ftnlen)5);
+ return 0;
+ } else if (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stcurr", i__1, "daffa_", (ftnlen)3218)] > stnseg[(i__2 = p - 1) <
+ 1000 && 0 <= i__2 ? i__2 : s_rnge("stnseg", i__2, "daffa_", (
+ ftnlen)3218)]) {
+ dafhfn_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)3220)], dafnam, (ftnlen)255);
+ setmsg_("No array is current; the `previous' array is the last array"
+ " of DAF #", (ftnlen)68);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(NOCURRENTARRAY)", (ftnlen)21);
+ chkout_("DAFRS", (ftnlen)5);
+ return 0;
+ }
+
+/* The location of the summary depends on the current pointer */
+/* position. */
+
+ dafhsf_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "daffa_", (ftnlen)3234)], &nd, &ni);
+ sumsiz = nd + (ni + 1) / 2;
+ offset = (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stc"
+ "urr", i__1, "daffa_", (ftnlen)3238)] - 1) * sumsiz + 3;
+
+/* Get the existing summary, and unpack it. Replace everything */
+/* but the addresses (the final two integer components), and */
+/* repack. Then replace the existing summary within the record. */
+
+ moved_(&stsr[(i__1 = offset + 1 + (p << 7) - 129) < 128000 && 0 <= i__1 ?
+ i__1 : s_rnge("stsr", i__1, "daffa_", (ftnlen)3245)], &sumsiz,
+ exsum);
+ dafus_(exsum, &nd, &ni, exdc, exic);
+ dafus_(sum, &nd, &ni, newdc, newic);
+ moved_(newdc, &nd, exdc);
+ i__1 = ni - 2;
+ movei_(newic, &i__1, exic);
+ dafps_(&nd, &ni, exdc, exic, exsum);
+ moved_(exsum, &sumsiz, &stsr[(i__1 = offset + 1 + (p << 7) - 129) <
+ 128000 && 0 <= i__1 ? i__1 : s_rnge("stsr", i__1, "daffa_", (
+ ftnlen)3254)]);
+
+/* Rewrite the modified summary record. */
+
+ dafwdr_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "daffa_", (ftnlen)3259)], &stthis[(i__2 = p - 1) < 1000 &&
+ 0 <= i__2 ? i__2 : s_rnge("stthis", i__2, "daffa_", (ftnlen)3259)]
+ , &stsr[(i__3 = (p << 7) - 128) < 128000 && 0 <= i__3 ? i__3 :
+ s_rnge("stsr", i__3, "daffa_", (ftnlen)3259)]);
+ chkout_("DAFRS", (ftnlen)5);
+ return 0;
+/* $Procedure DAFRN ( DAF, change array name ) */
+
+L_dafrn:
+/* $ Abstract */
+
+/* Replace the name for the current array in the current DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) NAME */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* NAME I New name for current array. */
+
+/* $ Detailed_Input */
+
+/* NAME is the new name for the current array. */
+/* This replaces the existing name. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If this routine is called when no search is in progress in the */
+/* the current DAF, the error SPICE(DAFNOSEARCH) is signalled. */
+
+/* 2) If the DAF containing the `current' array has actually been */
+/* closed, the error will be diagnosed by routines called by */
+/* this routine. */
+
+/* 3) If the DAF containing the `current' array is not open for */
+/* writing, the error will be diagnosed by routines called by */
+/* this routine. */
+
+/* 4) If no array is current in the current DAF, the error */
+/* SPICE(NOCURRENTARRAY) is signalled. There is no current */
+/* array when a search is started by DAFBFS or DAFBBS, but no */
+/* calls to DAFFNA or DAFBNA have been made yet, or whenever */
+/* DAFFNA or DAFFPA return the value .FALSE. in the FOUND */
+/* argument. */
+
+/* $ Particulars */
+
+/* See DAFFA. */
+
+/* $ Examples */
+
+/* See DAFFA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* change daf array name */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* This routine now operates on the current DAF---the one at */
+/* the head of the active list. All saved state variables */
+/* used by this routine are now part of the state table, or */
+/* its associated set of pointers. */
+
+/* In addition, this routine now checks whether an array */
+/* is current before trying to read its summary. The routine */
+/* previously crashed under these conditions. */
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFRN", (ftnlen)5);
+ }
+
+/* Operate on the last DAF in which a search has been started. */
+
+ p = sthead;
+
+/* Make sure that a search has been started in this DAF. */
+
+ if (p == -1) {
+ setmsg_("No DAF is currently being searched.", (ftnlen)35);
+ sigerr_("SPICE(DAFNOSEARCH)", (ftnlen)18);
+ chkout_("DAFRN", (ftnlen)5);
+ return 0;
+
+/* Make sure that the `current' DAF is still open, and that it */
+/* is open for writing. */
+
+ } else {
+ dafsih_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)3453)], "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DAFRN", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Check the current pointer position to make sure that it's in */
+/* bounds. If there is no current array, then we cannot replace */
+/* the array's summary's name. This situation occurs if DAFFNA was */
+/* called when the current array was the last, or if DAFFPA was */
+/* called when the current array was the first. */
+
+ if (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr",
+ i__1, "daffa_", (ftnlen)3469)] == 0) {
+ dafhfn_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)3471)], dafnam, (ftnlen)255);
+ setmsg_("No array is current; the `next' array is the first array of"
+ " DAF #", (ftnlen)65);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(NOCURRENTARRAY)", (ftnlen)21);
+ chkout_("DAFRN", (ftnlen)5);
+ return 0;
+ } else if (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stcurr", i__1, "daffa_", (ftnlen)3479)] > stnseg[(i__2 = p - 1) <
+ 1000 && 0 <= i__2 ? i__2 : s_rnge("stnseg", i__2, "daffa_", (
+ ftnlen)3479)]) {
+ dafhfn_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)3481)], dafnam, (ftnlen)255);
+ setmsg_("No array is current; the `previous' array is the last array"
+ " of DAF #", (ftnlen)68);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(NOCURRENTARRAY)", (ftnlen)21);
+ chkout_("DAFRN", (ftnlen)5);
+ return 0;
+ }
+
+/* Read the name record for this summary record, if we don't have it */
+/* already. */
+
+ if (! sthvnr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("sthvnr",
+ i__1, "daffa_", (ftnlen)3497)]) {
+ i__4 = stthis[(i__2 = p - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge(
+ "stthis", i__2, "daffa_", (ftnlen)3499)] + 1;
+ dafrcr_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)3499)], &i__4, stnr + ((i__3 =
+ p - 1) < 1000 && 0 <= i__3 ? i__3 : s_rnge("stnr", i__3,
+ "daffa_", (ftnlen)3499)) * 1000, (ftnlen)1000);
+ sthvnr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("sthvnr",
+ i__1, "daffa_", (ftnlen)3501)] = TRUE_;
+ }
+
+/* The location of the name depends on the current pointer */
+/* position. */
+
+ dafhsf_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "daffa_", (ftnlen)3510)], &nd, &ni);
+ sumsiz = nd + (ni + 1) / 2;
+ namsiz = sumsiz << 3;
+ offset = (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stc"
+ "urr", i__1, "daffa_", (ftnlen)3516)] - 1) * namsiz;
+ i__2 = offset;
+ s_copy(stnr + (((i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stnr",
+ i__1, "daffa_", (ftnlen)3518)) * 1000 + i__2), name__, offset +
+ namsiz - i__2, name_len);
+
+/* Rewrite the character record. */
+
+ i__4 = stthis[(i__2 = p - 1) < 1000 && 0 <= i__2 ? i__2 : s_rnge("stthis",
+ i__2, "daffa_", (ftnlen)3523)] + 1;
+ dafwcr_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "daffa_", (ftnlen)3523)], &i__4, stnr + ((i__3 = p - 1) <
+ 1000 && 0 <= i__3 ? i__3 : s_rnge("stnr", i__3, "daffa_", (ftnlen)
+ 3523)) * 1000, (ftnlen)1000);
+ chkout_("DAFRN", (ftnlen)5);
+ return 0;
+/* $Procedure DAFWS ( DAF, write summary ) */
+
+L_dafws:
+/* $ Abstract */
+
+/* Write a new summary for the current array in the current DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* DOUBLE PRECISION SUM ( * ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* SUM I New summary for current array in the current DAF. */
+
+/* $ Detailed_Input */
+
+/* SUM is the new summary for the current array. This */
+/* replaces the existing summary, including the */
+/* addresses (the final two integer components) of */
+/* the original summary. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* DAFWS updates the DAF currently being searched. The handle */
+/* of this DAF can be retrieved using the routine DAFGH. */
+
+/* $ Exceptions */
+
+/* 1) If this routine is called when no search is in progress in the */
+/* the current DAF, the error SPICE(DAFNOSEARCH) is signalled. */
+
+/* 2) If the DAF containing the `current' array has actually been */
+/* closed, the error will be diagnosed by routines called by */
+/* this routine. */
+
+/* 3) If the DAF containing the `current' array is not open for */
+/* writing, the error will be diagnosed by routines called by */
+/* this routine. */
+
+/* 4) If no array is current in the current DAF, the error */
+/* SPICE(NOCURRENTARRAY) is signalled. There is no current */
+/* array when a search is started by DAFBFS or DAFBBS, but no */
+/* calls to DAFFNA or DAFBNA have been made yet, or whenever */
+/* DAFFNA or DAFFPA return the value .FALSE. in the FOUND */
+/* argument. */
+
+/* $ Particulars */
+
+/* Unless you are reordering the arrays in the file being searched, */
+/* you should be using DAFRS instead of this routine. */
+
+/* See also DAFFA, DAFRS. */
+
+/* $ Examples */
+
+/* See DAFFA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+/* Bug fix made to handle case of having no current array. */
+
+/* - SPICELIB Version 1.0.0, 28-MAR-1991 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write daf summary */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* Updated to support simultaneous searches of multiple DAFs. */
+
+/* This routine now operates on the current DAF---the one at */
+/* the head of the active list. All saved state variables */
+/* used by this routine are now part of the state table, or */
+/* its associated set of pointers. */
+
+/* In addition, this routine now checks whether an array */
+/* is current before trying to read its summary. The routine */
+/* previously crashed under these conditions. */
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFWS", (ftnlen)5);
+ }
+
+/* Operate on the last DAF in which a search has been started. */
+
+ p = sthead;
+
+/* Make sure that a search has been started in this DAF. */
+
+ if (p == -1) {
+ setmsg_("No DAF is currently being searched.", (ftnlen)35);
+ sigerr_("SPICE(DAFNOSEARCH)", (ftnlen)18);
+ chkout_("DAFWS", (ftnlen)5);
+ return 0;
+
+/* Make sure that the `current' DAF is still open, and that it is */
+/* open for writing. */
+
+ } else {
+ dafsih_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)3719)], "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DAFWS", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Check the current pointer position to make sure that it's in */
+/* bounds. If there is no current array, then we cannot write a */
+/* new array summary. This situation occurs if DAFFNA was called */
+/* when the current array was the last, or if DAFFPA was called */
+/* when the current array was the first. */
+
+ if (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stcurr",
+ i__1, "daffa_", (ftnlen)3735)] == 0) {
+ dafhfn_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)3737)], dafnam, (ftnlen)255);
+ setmsg_("No array is current; the `next' array is the first array of"
+ " DAF #", (ftnlen)65);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(NOCURRENTARRAY)", (ftnlen)21);
+ chkout_("DAFWS", (ftnlen)5);
+ return 0;
+ } else if (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stcurr", i__1, "daffa_", (ftnlen)3745)] > stnseg[(i__2 = p - 1) <
+ 1000 && 0 <= i__2 ? i__2 : s_rnge("stnseg", i__2, "daffa_", (
+ ftnlen)3745)]) {
+ dafhfn_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stfh", i__1, "daffa_", (ftnlen)3747)], dafnam, (ftnlen)255);
+ setmsg_("No array is current; the `previous' array is the last array"
+ " of DAF #", (ftnlen)68);
+ errch_("#", dafnam, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(NOCURRENTARRAY)", (ftnlen)21);
+ chkout_("DAFWS", (ftnlen)5);
+ return 0;
+ }
+
+/* The location of the summary depends on the current pointer */
+/* position. */
+
+ dafhsf_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "daffa_", (ftnlen)3763)], &nd, &ni);
+ sumsiz = nd + (ni + 1) / 2;
+ offset = (stcurr[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stc"
+ "urr", i__1, "daffa_", (ftnlen)3767)] - 1) * sumsiz + 3;
+ moved_(sum, &sumsiz, &stsr[(i__1 = offset + 1 + (p << 7) - 129) < 128000
+ && 0 <= i__1 ? i__1 : s_rnge("stsr", i__1, "daffa_", (ftnlen)3769)
+ ]);
+
+/* Rewrite the modified summary record. */
+
+ dafwdr_(&stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "daffa_", (ftnlen)3774)], &stthis[(i__2 = p - 1) < 1000 &&
+ 0 <= i__2 ? i__2 : s_rnge("stthis", i__2, "daffa_", (ftnlen)3774)]
+ , &stsr[(i__3 = (p << 7) - 128) < 128000 && 0 <= i__3 ? i__3 :
+ s_rnge("stsr", i__3, "daffa_", (ftnlen)3774)]);
+ chkout_("DAFWS", (ftnlen)5);
+ return 0;
+/* $Procedure DAFCS ( DAF, continue search ) */
+
+L_dafcs:
+/* $ Abstract */
+
+/* Select a DAF that already has a search in progress as the */
+/* one to continue searching. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAF to continue searching. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAF in which either a forward */
+/* or backward search has already been started by */
+/* DAFBFS or DAFBBS. The DAF may be open for read */
+/* or write access. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input handle is invalid, the error will be diagnosed */
+/* by routines called by this routine. */
+
+/* 2) If this routine is called when no search is in progress in the */
+/* the current DAF, the error SPICE(DAFNOSEARCH) is signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* DAFCS supports simultaneous searching of multiple DAFs. In */
+/* applications that use this capability, DAFCS should be called */
+/* prior to each call to DAFFNA, DAFFPA, DAFGN, DAFGS, DAFRS, or */
+/* DAFWS, to specify which DAF is to be acted upon. */
+
+/* $ Examples */
+
+/* See DAFFA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 04-SEP-1991 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* select a daf to continue searching */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFCS", (ftnlen)5);
+ }
+
+/* Validate the DAF's handle before going any further. DAFSIH will */
+/* signal an error if HANDLE doesn't designate an open DAF. */
+
+ dafsih_(handle, "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DAFCS", (ftnlen)5);
+ return 0;
+ }
+
+/* See whether we already have an entry for this DAF in the */
+/* state table. Find the previous node if possible. */
+
+ p = sthead;
+ prev = -1;
+ fnd = FALSE_;
+ while(p != -1 && ! fnd) {
+ if (stfh[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stfh",
+ i__1, "daffa_", (ftnlen)3938)] == *handle) {
+ fnd = TRUE_;
+ } else {
+ prev = p;
+ p = stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge(
+ "stpool", i__1, "daffa_", (ftnlen)3942)];
+ }
+ }
+
+/* Either FND is false, or P is the index in the state table of */
+/* the DAF specified by HANDLE, and PREV is the predecessor of P. */
+
+
+/* You can't continue searching a DAF that you're not already */
+/* searching. */
+
+ if (! fnd) {
+ setmsg_("No DAF is currently being searched.", (ftnlen)35);
+ sigerr_("SPICE(DAFNOSEARCH)", (ftnlen)18);
+ chkout_("DAFCS", (ftnlen)5);
+ return 0;
+ }
+
+/* Move the node for this DAF to the head of the active list, */
+/* if it is not already there: */
+
+/* - Make the predecessor of P point to the successor of P. */
+
+/* - Make P point to the head of the active list. */
+
+/* - Make P the active list head node. */
+
+
+ if (p != sthead) {
+
+/* P is in the active list, but is not at the head. So, */
+/* the predecessor of P is not NIL. */
+
+ stpool[(i__1 = prev - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stpool",
+ i__1, "daffa_", (ftnlen)3983)] = stpool[(i__2 = p - 1) <
+ 1000 && 0 <= i__2 ? i__2 : s_rnge("stpool", i__2, "daffa_", (
+ ftnlen)3983)];
+ stpool[(i__1 = p - 1) < 1000 && 0 <= i__1 ? i__1 : s_rnge("stpool",
+ i__1, "daffa_", (ftnlen)3984)] = sthead;
+ sthead = p;
+ }
+ chkout_("DAFCS", (ftnlen)5);
+ return 0;
+} /* daffa_ */
+
+/* Subroutine */ int daffa_(integer *handle, doublereal *sum, char *name__,
+ logical *found, ftnlen name_len)
+{
+ return daffa_0_(0, handle, sum, name__, found, name_len);
+ }
+
+/* Subroutine */ int dafbfs_(integer *handle)
+{
+ return daffa_0_(1, handle, (doublereal *)0, (char *)0, (logical *)0, (
+ ftnint)0);
+ }
+
+/* Subroutine */ int daffna_(logical *found)
+{
+ return daffa_0_(2, (integer *)0, (doublereal *)0, (char *)0, found, (
+ ftnint)0);
+ }
+
+/* Subroutine */ int dafbbs_(integer *handle)
+{
+ return daffa_0_(3, handle, (doublereal *)0, (char *)0, (logical *)0, (
+ ftnint)0);
+ }
+
+/* Subroutine */ int daffpa_(logical *found)
+{
+ return daffa_0_(4, (integer *)0, (doublereal *)0, (char *)0, found, (
+ ftnint)0);
+ }
+
+/* Subroutine */ int dafgs_(doublereal *sum)
+{
+ return daffa_0_(5, (integer *)0, sum, (char *)0, (logical *)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dafgn_(char *name__, ftnlen name_len)
+{
+ return daffa_0_(6, (integer *)0, (doublereal *)0, name__, (logical *)0,
+ name_len);
+ }
+
+/* Subroutine */ int dafgh_(integer *handle)
+{
+ return daffa_0_(7, handle, (doublereal *)0, (char *)0, (logical *)0, (
+ ftnint)0);
+ }
+
+/* Subroutine */ int dafrs_(doublereal *sum)
+{
+ return daffa_0_(8, (integer *)0, sum, (char *)0, (logical *)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dafrn_(char *name__, ftnlen name_len)
+{
+ return daffa_0_(9, (integer *)0, (doublereal *)0, name__, (logical *)0,
+ name_len);
+ }
+
+/* Subroutine */ int dafws_(doublereal *sum)
+{
+ return daffa_0_(10, (integer *)0, sum, (char *)0, (logical *)0, (ftnint)0)
+ ;
+ }
+
+/* Subroutine */ int dafcs_(integer *handle)
+{
+ return daffa_0_(11, handle, (doublereal *)0, (char *)0, (logical *)0, (
+ ftnint)0);
+ }
+
diff --git a/ext/spice/src/cspice/daffna_c.c b/ext/spice/src/cspice/daffna_c.c
new file mode 100644
index 0000000000..a413b86f1f
--- /dev/null
+++ b/ext/spice/src/cspice/daffna_c.c
@@ -0,0 +1,263 @@
+/*
+
+-Procedure daffna_c ( DAF, find next array )
+
+-Abstract
+
+ Find the next (forward) array in the current DAF.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+
+ void daffna_c ( SpiceBoolean * found )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ found O SPICETRUE if an array was found.
+
+-Detailed_Input
+
+ None.
+
+-Detailed_Output
+
+ found is SPICETRUE if an array was found, and is SPICEFALSE
+ if, when this routine is called, the current array is
+ the tail of the array list. (Recall that the arrays in
+ a DAF may be viewed as a doubly linked list, with the
+ tail being the last array in the file.)
+
+-Parameters
+
+ None.
+
+-Files
+
+ None.
+
+-Exceptions
+
+ 1) If this routine is called before a search is begun, the
+ error SPICE(DAFNOSEARCH) is signalled.
+
+ 2) If the DAF to be searched has actually been closed, the error
+ will be diagnosed by routines called by this routine.
+
+ 3) If the end of the array list has already been reached when
+ this routine is called, this routine has no effect.
+
+-Particulars
+
+
+ The DAF search routines are:
+
+ dafbfs_c Begin forward search.
+ daffna Find next array.
+
+ dafbbs_c Begin backward search.
+ daffpa_c Find previous array.
+
+ dafgs_c Get summary.
+ dafgn_c Get name.
+ dafgh_c Get handle.
+
+ dafcs_c Continue search.
+
+ The main function of these entry points is to allow the
+ contents of any DAF to be examined on an array-by-array
+ basis.
+
+ Conceptually, the arrays in a DAF form a doubly linked list,
+ which can be searched in either of two directions: forward or
+ backward. It is possible to search multiple DAFs simultaneously.
+
+ dafbfs_c (begin forward search) and daffna are used to search the
+ arrays in a DAF in forward order. In applications that search a
+ single DAF at a time, the normal usage is
+
+ dafbfs_c ( handle );
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffna_c ( &found );
+ }
+
+
+ dafbbs_c (begin backward search) and daffpa_c are used to search the
+ arrays in a DAF in backward order. In applications that search
+ a single DAF at a time, the normal usage is
+
+ dafbbs_c ( handle );
+ daffpa_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffpa_c ( &found );
+ }
+
+
+ In applications that conduct multiple searches simultaneously,
+ the above usage must be modified to specify the handle of the
+ file to operate on, in any case where the file may not be the
+ last one specified by dafbfs_c or dafbbs_c. The routine dafcs_c
+ (DAF, continue search) is used for this purpose. Below, we
+ give an example of an interleaved search of two files specified
+ by the handles handl1 and handl2. The directions of searches
+ in different DAFs are independent; here we conduct a forward
+ search on one file and a backward search on the other.
+ Throughout, we use dafcs to specify which file to operate on,
+ before calling daffna_c, daffpa_c, dafgs_c, or dafgn_c.
+
+
+ dafbfs_c ( handl1 );
+ dafbbs_c ( handl2 );
+
+ dafcs_c ( handl1 );
+ daffna_c ( &found1 );
+
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+
+ while ( found1 || found2 )
+ {
+ if ( found1 )
+ {
+ dafcs_c ( handl1 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( &handl1 );
+ daffna_c ( &found1 );
+ }
+
+ if ( found2 )
+ {
+ dafcs_c ( handl2 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+ }
+ }
+
+
+ At any time, the latest array found (whether by daffna_c or daffpa_c)
+ is regarded as the "current" array for the file in which the
+ array was found. The last DAF in which a search was started,
+ executed, or continued by any of dafbfs_c, dafbbs_c, daffna_c,
+ daffpa_c or dafcs_c is regarded as the "current" DAF. The summary
+ and name for the current array in the current DAF can be obtained
+ separately, as shown above, by calls to DAFGS (get summary) and
+ dafgn_c (get name). The handle of the current DAF can also be
+ obtained by calling dafgh_c (get handle).
+
+ Once a search has been begun, it may be continued in either
+ direction. That is, daffpa_c may be used to back up during a
+ forward search, and daffna_c may be used to advance during a
+ backward search.
+
+-Examples
+
+ 1) See Particulars.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ NAIF Document 167.0, "Double Precision Array Files (DAF)
+ Specification and User's Guide"
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 31-JUL-1999 (NJB) (WLT) (IMU)
+
+-Index_Entries
+
+ find next daf array
+
+-&
+*/
+
+{ /* Begin daffna_c */
+
+ /*
+ Local variables
+ */
+ logical fnd;
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "daffna_c" );
+
+
+ daffna_ ( ( logical * ) &fnd );
+
+ *found = fnd;
+
+
+ chkout_c ( "daffna_c" );
+
+} /* End daffna_c */
diff --git a/ext/spice/src/cspice/daffpa_c.c b/ext/spice/src/cspice/daffpa_c.c
new file mode 100644
index 0000000000..053bed0e2f
--- /dev/null
+++ b/ext/spice/src/cspice/daffpa_c.c
@@ -0,0 +1,265 @@
+/*
+
+-Procedure daffpa_c ( DAF, find previous array )
+
+-Abstract
+
+ Find the previous (backward) array in the current DAF.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+
+ void daffpa_c ( SpiceBoolean * found )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ found O SPICETRUE if an array was found.
+
+-Detailed_Input
+
+ None.
+
+-Detailed_Output
+
+ found is SPICETRUE if an array was found, and is SPICEFALSE
+ if, when this routine is called, the current array is
+ the head of the array list. (Recall that the arrays in
+ a DAF may be viewed as a doubly linked list, with the
+ head being the first array in the file.)
+
+-Parameters
+
+ None.
+
+-Files
+
+ None.
+
+-Exceptions
+
+ 1) If this routine is called before a search is begun, the
+ error SPICE(DAFNOSEARCH) is signaled.
+
+ 2) If the DAF to be searched has actually been closed, the error
+ will be diagnosed by routines called by this routine.
+
+ 3) If the beginning of the array list has already been reached
+ when this routine is called, this routine will not change the
+ current array. found will be SPICEFALSE on output.
+
+-Particulars
+
+ The DAF search routines are:
+
+
+ dafbfs_c Begin forward search.
+ daffna Find next array.
+
+ dafbbs_c Begin backward search.
+ daffpa_c Find previous array.
+
+ dafgs_c Get summary.
+ dafgn_c Get name.
+ dafgh_c Get handle.
+
+ dafcs_c Continue search.
+
+ The main function of these entry points is to allow the
+ contents of any DAF to be examined on an array-by-array
+ basis.
+
+ Conceptually, the arrays in a DAF form a doubly linked list,
+ which can be searched in either of two directions: forward or
+ backward. It is possible to search multiple DAFs simultaneously.
+
+ dafbfs_c (begin forward search) and daffna are used to search the
+ arrays in a DAF in forward order. In applications that search a
+ single DAF at a time, the normal usage is
+
+ dafbfs_c ( handle );
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffna_c ( &found );
+ }
+
+
+ dafbbs_c (begin backward search) and daffpa_c are used to search the
+ arrays in a DAF in backward order. In applications that search
+ a single DAF at a time, the normal usage is
+
+ dafbbs_c ( handle );
+ daffpa_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffpa_c ( &found );
+ }
+
+
+ In applications that conduct multiple searches simultaneously,
+ the above usage must be modified to specify the handle of the
+ file to operate on, in any case where the file may not be the
+ last one specified by dafbfs_c or dafbbs_c. The routine dafcs_c
+ (DAF, continue search) is used for this purpose. Below, we
+ give an example of an interleaved search of two files specified
+ by the handles handl1 and handl2. The directions of searches
+ in different DAFs are independent; here we conduct a forward
+ search on one file and a backward search on the other.
+ Throughout, we use dafcs to specify which file to operate on,
+ before calling daffna_c, daffpa_c, dafgs_c, or dafgn_c.
+
+
+ dafbfs_c ( handl1 );
+ dafbbs_c ( handl2 );
+
+ dafcs_c ( handl1 );
+ daffna_c ( &found1 );
+
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+
+ while ( found1 || found2 )
+ {
+ if ( found1 )
+ {
+ dafcs_c ( handl1 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( &handl1 );
+ daffna_c ( &found1 );
+ }
+
+ if ( found2 )
+ {
+ dafcs_c ( handl2 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+ }
+ }
+
+
+ At any time, the latest array found (whether by daffna_c or daffpa_c)
+ is regarded as the "current" array for the file in which the
+ array was found. The last DAF in which a search was started,
+ executed, or continued by any of dafbfs_c, dafbbs_c, daffna_c,
+ daffpa_c or dafcs_c is regarded as the "current" DAF. The summary
+ and name for the current array in the current DAF can be obtained
+ separately, as shown above, by calls to DAFGS (get summary) and
+ dafgn_c (get name). The handle of the current DAF can also be
+ obtained by calling dafgh_c (get handle).
+
+ Once a search has been begun, it may be continued in either
+ direction. That is, daffpa_c may be used to back up during a
+ forward search, and daffna_c may be used to advance during a
+ backward search.
+
+-Examples
+
+ 1) See Particulars.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ NAIF Document 167.0, "Double Precision Array Files (DAF)
+ Specification and User's Guide"
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 31-JUL-1999 (NJB) (WLT) (IMU)
+
+-Index_Entries
+
+ find previous daf array
+
+-&
+*/
+
+{ /* Begin daffpa_c */
+
+ /*
+ Local variables
+ */
+ logical fnd;
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "daffpa_c" );
+
+
+ daffpa_ ( ( logical * ) &fnd );
+
+ *found = fnd;
+
+
+ chkout_c ( "daffpa_c" );
+
+} /* End daffpa_c */
diff --git a/ext/spice/src/cspice/dafgda.c b/ext/spice/src/cspice/dafgda.c
new file mode 100644
index 0000000000..3169ecfdbf
--- /dev/null
+++ b/ext/spice/src/cspice/dafgda.c
@@ -0,0 +1,244 @@
+/* dafgda.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DAFGDA ( DAF, read data from address ) */
+/* Subroutine */ int dafgda_(integer *handle, integer *begin, integer *end,
+ doublereal *data)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer begr, begw, endr, endw, last, next;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer recno;
+ logical found;
+ integer first;
+ extern /* Subroutine */ int dafgdr_(integer *, integer *, integer *,
+ integer *, doublereal *, logical *), cleard_(integer *,
+ doublereal *), dafarw_(integer *, integer *, integer *), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen),
+ errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Read the double precision data bounded by two addresses within */
+/* a DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of a DAF. */
+/* BEGIN, */
+/* END I Initial, final address within file. */
+/* DATA O Data contained between BEGIN and END. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAF. */
+
+/* BEGIN, */
+/* END are the initial and final addresses of a contiguous */
+/* set of double precision numbers within a DAF. */
+/* Presumably, these make up all or part of a particular */
+/* array. */
+
+/* $ Detailed_Output */
+
+/* DATA are the double precision data contained between */
+/* the specified addresses within the specified file. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If BEGIN is zero or negative, the error SPICE(DAFNEGADDR) */
+/* is signalled. */
+
+/* 2) If the BEGIN > END, the error SPICE(DAFBEGGTEND) */
+/* is signalled. */
+
+/* 3) If HANDLE is invalid, routines in the call tree of DAFGDA */
+/* signal an appropriate error. */
+
+/* 4) If the range of addresses covered between BEGIN and END */
+/* includes records that do not contain strictly double */
+/* precision data, then the values returned in DATA are */
+/* undefined. See the Restrictions section below for details. */
+
+/* $ Particulars */
+
+/* The principal reason that DAFs are so easy to use is that */
+/* the data in each DAF are considered to be one long contiguous */
+/* set of double precision numbers. You can grab data from anywhere */
+/* within a DAF without knowing (or caring) about the physical */
+/* records in which they are stored. */
+
+/* This routine replaces DAFRDA as the principle mechanism for */
+/* reading the contents of DAF arrays. */
+
+/* $ Examples */
+
+/* The following code fragment illustrates the use of DAFGDA */
+/* to read data from an imaginary array. The array begins with a */
+/* directory containing 11 epochs. Each pair of epochs bounds */
+/* an interval, and each interval is covered by a set of eight */
+/* osculating elements. */
+
+/* CALL DAFUS ( SUM, ND, NI, DC, IC ) */
+/* BEGIN = IC(5) */
+/* END = IC(6) */
+
+/* CALL DAFGDA ( HANDLE, BEGIN, BEGIN+10, EPOCHS ) */
+
+/* DO I = 1, 10 */
+/* IF ( ET .GE. EPOCHS(I) .AND. ET .LE. EPOCHS(I+1) ) THEN */
+/* OFFSET = 11 + (I - 1) * 8 */
+
+/* CALL DAFGDA ( HANDLE, OFFSET+1, OFFSET+8, ELEMENTS ) */
+/* RETURN */
+/* END IF */
+/* END DO */
+
+
+/* $ Restrictions */
+
+/* 1) There are several types of records in a DAF. This routine */
+/* is only to be used to read double precision data bounded */
+/* between two DAF addresses. The range of addresses input */
+/* may not cross data and summary record boundaries. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* F.S. Turner (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 16-NOV-2001 (FST) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read data from daf address */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+
+/* Bad addresses? */
+
+ if (*begin <= 0) {
+ chkin_("DAFGDA", (ftnlen)6);
+ setmsg_("Negative value for BEGIN address: #", (ftnlen)35);
+ errint_("#", begin, (ftnlen)1);
+ sigerr_("SPICE(DAFNEGADDR)", (ftnlen)17);
+ chkout_("DAFGDA", (ftnlen)6);
+ return 0;
+ } else if (*begin > *end) {
+ chkin_("DAFGDA", (ftnlen)6);
+ setmsg_("Beginning address (#) greater than ending address (#).", (
+ ftnlen)54);
+ errint_("#", begin, (ftnlen)1);
+ errint_("#", end, (ftnlen)1);
+ sigerr_("SPICE(DAFBEGGTEND)", (ftnlen)18);
+ chkout_("DAFGDA", (ftnlen)6);
+ return 0;
+ }
+
+/* Convert raw addresses to record/word representations. */
+
+ dafarw_(begin, &begr, &begw);
+ dafarw_(end, &endr, &endw);
+
+/* Get as many records as needed. Return the last part of the */
+/* first record, the first part of the last record, and all of */
+/* every record in between. Any record not found is assumed to */
+/* be filled with zeros. */
+
+ next = 1;
+ i__1 = endr;
+ for (recno = begr; recno <= i__1; ++recno) {
+ if (begr == endr) {
+ first = begw;
+ last = endw;
+ } else if (recno == begr) {
+ first = begw;
+ last = 128;
+ } else if (recno == endr) {
+ first = 1;
+ last = endw;
+ } else {
+ first = 1;
+ last = 128;
+ }
+ dafgdr_(handle, &recno, &first, &last, &data[next - 1], &found);
+ if (! found) {
+ i__2 = last - first + 1;
+ cleard_(&i__2, &data[next - 1]);
+ }
+ next += last - first + 1;
+ }
+ return 0;
+} /* dafgda_ */
+
diff --git a/ext/spice/src/cspice/dafgda_c.c b/ext/spice/src/cspice/dafgda_c.c
new file mode 100644
index 0000000000..ea13f93fa7
--- /dev/null
+++ b/ext/spice/src/cspice/dafgda_c.c
@@ -0,0 +1,193 @@
+/*
+
+-Procedure dafgda_c ( DAF, read data from address )
+
+-Abstract
+
+ Read the double precision data bounded by two addresses within
+ a DAF.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+
+*/
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+
+ void dafgda_c ( SpiceInt handle,
+ SpiceInt begin,
+ SpiceInt end,
+ SpiceDouble * data )
+/*
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of a DAF.
+ begin,
+ end I Initial, final address within file.
+ data O Data contained between `begin' and `end'.
+
+-Detailed_Input
+
+ handle is the handle of a DAF.
+
+ begin,
+ end are the initial and final addresses of a contiguous
+ set of double precision numbers within a DAF.
+ Presumably, these make up all or part of a particular
+ array.
+
+ Note that CSPICE DAF addresses begin at 1 as in the
+ FORTRAN version of the SPICE Toolkit.
+
+-Detailed_Output
+
+ data are the double precision data contained between
+ the specified addresses within the specified file.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If `begin' is zero or negative, the error SPICE(DAFNEGADDR)
+ is signaled.
+
+ 2) If `begin' > `end', the error SPICE(DAFBEGGTEND)
+ is signaled.
+
+ 3) If `handle' is invalid, routines in the call tree of dafgda_c
+ signal an appropriate error.
+
+ 4) If the range of addresses covered between `begin' and `end'
+ includes records that do not contain strictly double
+ precision data, then the values returned in `data' are
+ undefined. See the Restrictions section below for details.
+
+-Files
+
+ None.
+
+-Particulars
+
+ The principal reason that DAFs are so easy to use is that
+ the data in each DAF are considered to be one long contiguous
+ set of double precision numbers. You can grab data from anywhere
+ within a DAF without knowing (or caring) about the physical
+ records in which they are stored.
+
+ This routine replaces dafrda_c as the principal mechanism for
+ reading the contents of DAF arrays.
+
+-Examples
+
+ The following code fragment illustrates the use of dafgda_c to read
+ data from an array. The array begins with a directory containing 11
+ epochs. Each pair of epochs bounds an interval, and each interval is
+ covered by a set of eight osculating elements.
+
+ #include "SpiceUsr.h"
+
+ .
+ .
+ .
+
+ dafus_c ( sum, nd, ni, dc, ic );
+ begin = ic[4];
+ end = ic[5];
+
+ dafgda_c ( handle, begin, begin+10, epochs );
+
+ for ( i = 0; i < 10; i++ )
+ {
+ if ( ( et > epochs[i] )
+ && ( et < epochs[i+1] ) )
+ {
+ offset = begin + 11 + (i - 1) * 8;
+ dafgda_c ( handle, offset+1, offset+8, elements );
+ return;
+ }
+ }
+
+
+-Restrictions
+
+ 1) There are several types of records in a DAF. This routine
+ is only to be used to read double precision data bounded
+ between two DAF addresses. The range of addresses input
+ may not cross data and summary record boundaries.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.1, 23-JAN-2008 (EDW)
+
+ Removed a spurious and unneeded "-Declarations"
+ tag. The tag's presence prevented the HTML API doc
+ script from parsing the function description.
+
+ -CSPICE Version 1.0.0, 14-SEP-2006 (NJB)
+
+-Index_Entries
+
+ read data from daf address
+
+-&
+*/
+
+{ /* Begin dafgda_c */
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafgda_c" );
+
+ dafgda_ ( ( integer * ) &handle,
+ ( integer * ) &begin,
+ ( integer * ) &end,
+ ( doublereal * ) data );
+
+ chkout_c ( "dafgda_c" );
+
+} /* End of dafgda_c */
+
diff --git a/ext/spice/src/cspice/dafgn_c.c b/ext/spice/src/cspice/dafgn_c.c
new file mode 100644
index 0000000000..e5f51fca14
--- /dev/null
+++ b/ext/spice/src/cspice/dafgn_c.c
@@ -0,0 +1,290 @@
+/*
+
+-Procedure dafgn_c ( DAF, get array name )
+
+-Abstract
+
+ Return (get) the name for the current array in the current DAF.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+ #include "SpiceZst.h"
+
+
+ void dafgn_c ( SpiceInt lenout,
+ SpiceChar * name )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ lenout I Length of array name string.
+ name O Name of current array.
+
+-Detailed_Input
+
+ lenout is the length of the name string, including room for
+ the null terminator. For a DAF with summary
+ parameters ND and NI, the maximum length of an array
+ name is
+
+ (NI + 1)
+ NC = 8 * ( ND + -------- ) (Note that this is
+ 2 integer division.)
+
+ Given NC, lenout should be set equal to NC+1.
+
+-Detailed_Output
+
+ name is the name for the current array (the array found by
+ the latest call to daffna_c or daffpa_c).
+
+-Parameters
+
+ None.
+
+-Files
+
+ None.
+
+-Exceptions
+
+ 1) If this routine is called when no search is in progress in the
+ the current DAF, the error SPICE(DAFNOSEARCH) is signalled.
+
+ 2) If the DAF for which the "current" array's name is to be
+ returned has actually been closed, the error will be diagnosed
+ by routines called by this routine.
+
+ 3) If no array is current in the current DAF, the error
+ SPICE(NOCURRENTARRAY) is signalled. There is no current
+ array when a search is started by dafbfs_c or dafbbs_c, but no
+ calls to daffna_c or dafbna_c have been made yet, or whenever
+ daffna_c or daffpa_c return the value SPICEFALSE in the found
+ argument.
+
+ 4) The error SPICE(NULLPOINTER) is signaled if the input string
+ pointer is null.
+
+ 5) The caller must pass a value indicating the length of the output
+ string. If this value is not at least 2, the error
+ SPICE(STRINGTOOSHORT) is signaled.
+
+-Particulars
+
+ The DAF search routines are:
+
+ dafbfs_c Begin forward search.
+ daffna Find next array.
+
+ dafbbs_c Begin backward search.
+ daffpa_c Find previous array.
+
+ dafgs_c Get summary.
+ dafgn_c Get name.
+ dafgh_c Get handle.
+
+ dafcs_c Continue search.
+
+ The main function of these entry points is to allow the
+ contents of any DAF to be examined on an array-by-array
+ basis.
+
+ Conceptually, the arrays in a DAF form a doubly linked list,
+ which can be searched in either of two directions: forward or
+ backward. It is possible to search multiple DAFs simultaneously.
+
+ dafbfs_c (begin forward search) and daffna are used to search the
+ arrays in a DAF in forward order. In applications that search a
+ single DAF at a time, the normal usage is
+
+ dafbfs_c ( handle );
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffna_c ( &found );
+ }
+
+
+ dafbbs_c (begin backward search) and daffpa_c are used to search the
+ arrays in a DAF in backward order. In applications that search
+ a single DAF at a time, the normal usage is
+
+ dafbbs_c ( handle );
+ daffpa_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffpa_c ( &found );
+ }
+
+
+ In applications that conduct multiple searches simultaneously,
+ the above usage must be modified to specify the handle of the
+ file to operate on, in any case where the file may not be the
+ last one specified by dafbfs_c or dafbbs_c. The routine dafcs_c
+ (DAF, continue search) is used for this purpose. Below, we
+ give an example of an interleaved search of two files specified
+ by the handles handl1 and handl2. The directions of searches
+ in different DAFs are independent; here we conduct a forward
+ search on one file and a backward search on the other.
+ Throughout, we use dafcs to specify which file to operate on,
+ before calling daffna_c, daffpa_c, dafgs_c, or dafgn_c.
+
+
+ dafbfs_c ( handl1 );
+ dafbbs_c ( handl2 );
+
+ dafcs_c ( handl1 );
+ daffna_c ( &found1 );
+
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+
+ while ( found1 || found2 )
+ {
+ if ( found1 )
+ {
+ dafcs_c ( handl1 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( &handl1 );
+ daffna_c ( &found1 );
+ }
+
+ if ( found2 )
+ {
+ dafcs_c ( handl2 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+ }
+ }
+
+
+ At any time, the latest array found (whether by daffna_c or daffpa_c)
+ is regarded as the "current" array for the file in which the
+ array was found. The last DAF in which a search was started,
+ executed, or continued by any of dafbfs_c, dafbbs_c, daffna_c,
+ daffpa_c or dafcs_c is regarded as the "current" DAF. The summary
+ and name for the current array in the current DAF can be obtained
+ separately, as shown above, by calls to DAFGS (get summary) and
+ dafgn_c (get name). The handle of the current DAF can also be
+ obtained by calling dafgh_c (get handle).
+
+ Once a search has been begun, it may be continued in either
+ direction. That is, daffpa_c may be used to back up during a
+ forward search, and daffna_c may be used to advance during a
+ backward search.
+
+-Examples
+
+ 1) See Particulars.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ NAIF Document 167.0, "Double Precision Array Files (DAF)
+ Specification and User's Guide"
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 01-AUG-1999 (NJB) (WLT) (IMU)
+
+-Index_Entries
+
+ get daf array name
+
+-&
+*/
+
+{ /* Begin dafgn_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafgn_c" );
+
+ /*
+ Make sure the output string has at least enough room for one output
+ character and a null terminator. Also check for a null pointer.
+ */
+ CHKOSTR ( CHK_STANDARD, "dafgn_c", name, lenout );
+
+
+ dafgn_ ( ( char * ) name,
+ ( ftnlen ) lenout-1 );
+
+ /*
+ Convert the output string to C style.
+ */
+ F2C_ConvertStr ( lenout, name );
+
+
+ chkout_c ( "dafgn_c" );
+
+} /* End dafgn_c */
diff --git a/ext/spice/src/cspice/dafgs_c.c b/ext/spice/src/cspice/dafgs_c.c
new file mode 100644
index 0000000000..c8f7575028
--- /dev/null
+++ b/ext/spice/src/cspice/dafgs_c.c
@@ -0,0 +1,261 @@
+/*
+
+-Procedure dafgs_c ( DAF, get summary )
+
+-Abstract
+
+ Return (get) the summary for the current array in the current
+ DAF.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+
+ void dafgs_c ( SpiceDouble sum[] )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ sum O Summary for current array.
+
+-Detailed_Input
+
+ None.
+
+-Detailed_Output
+
+ sum is the summary for the current array (the array
+ found by the latest call to daffna_c or daffpa_c).
+ Summaries are also called "segment descriptors."
+
+-Parameters
+
+ None.
+
+-Files
+
+ None.
+
+-Exceptions
+
+ 1) If this routine is called when no search is in progress in the
+ the current DAF, the error SPICE(DAFNOSEARCH) is signalled.
+
+ 2) If the DAF for which the "current" array's summary is to be
+ returned has actually been closed, the error will be diagnosed
+ by routines called by this routine.
+
+ 3) If no array is current in the current DAF, the error
+ SPICE(NOCURRENTARRAY) is signalled. There is no current
+ array when a search is started by dafbfs_c or dafbbs_c, but no
+ calls to daffna_c or dafbna_c have been made yet, or whenever
+ daffna_c or daffpa_c return the value SPICEFALSE in the found
+ argument.
+
+-Particulars
+
+ The DAF search routines are:
+
+
+ dafbfs_c Begin forward search.
+ daffna Find next array.
+
+ dafbbs_c Begin backward search.
+ daffpa_c Find previous array.
+
+ dafgs_c Get summary.
+ dafgn_c Get name.
+ dafgh_c Get handle.
+
+ dafcs_c Continue search.
+
+ The main function of these entry points is to allow the
+ contents of any DAF to be examined on an array-by-array
+ basis.
+
+ Conceptually, the arrays in a DAF form a doubly linked list,
+ which can be searched in either of two directions: forward or
+ backward. It is possible to search multiple DAFs simultaneously.
+
+ dafbfs_c (begin forward search) and daffna are used to search the
+ arrays in a DAF in forward order. In applications that search a
+ single DAF at a time, the normal usage is
+
+ dafbfs_c ( handle );
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffna_c ( &found );
+ }
+
+
+ dafbbs_c (begin backward search) and daffpa_c are used to search the
+ arrays in a DAF in backward order. In applications that search
+ a single DAF at a time, the normal usage is
+
+ dafbbs_c ( handle );
+ daffpa_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+
+ daffpa_c ( &found );
+ }
+
+
+ In applications that conduct multiple searches simultaneously,
+ the above usage must be modified to specify the handle of the
+ file to operate on, in any case where the file may not be the
+ last one specified by dafbfs_c or dafbbs_c. The routine dafcs_c
+ (DAF, continue search) is used for this purpose. Below, we
+ give an example of an interleaved search of two files specified
+ by the handles handl1 and handl2. The directions of searches
+ in different DAFs are independent; here we conduct a forward
+ search on one file and a backward search on the other.
+ Throughout, we use dafcs to specify which file to operate on,
+ before calling daffna_c, daffpa_c, dafgs_c, or dafgn_c.
+
+
+ dafbfs_c ( handl1 );
+ dafbbs_c ( handl2 );
+
+ dafcs_c ( handl1 );
+ daffna_c ( &found1 );
+
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+
+ while ( found1 || found2 )
+ {
+ if ( found1 )
+ {
+ dafcs_c ( handl1 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( &handl1 );
+ daffna_c ( &found1 );
+ }
+
+ if ( found2 )
+ {
+ dafcs_c ( handl2 );
+ dafgs_c ( sum );
+ dafgn_c ( name );
+ .
+ .
+ dafcs_c ( handl2 );
+ daffpa_c ( &found2 );
+ }
+ }
+
+
+ At any time, the latest array found (whether by daffna_c or daffpa_c)
+ is regarded as the "current" array for the file in which the
+ array was found. The last DAF in which a search was started,
+ executed, or continued by any of dafbfs_c, dafbbs_c, daffna_c,
+ daffpa_c or dafcs_c is regarded as the "current" DAF. The summary
+ and name for the current array in the current DAF can be obtained
+ separately, as shown above, by calls to DAFGS (get summary) and
+ dafgn_c (get name). The handle of the current DAF can also be
+ obtained by calling dafgh_c (get handle).
+
+ Once a search has been begun, it may be continued in either
+ direction. That is, daffpa_c may be used to back up during a
+ forward search, and daffna_c may be used to advance during a
+ backward search.
+
+-Examples
+
+ 1) See Particulars.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ NAIF Document 167.0, "Double Precision Array Files (DAF)
+ Specification and User's Guide"
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 31-JUL-1999 (NJB) (WLT) (IMU)
+
+-Index_Entries
+
+ get daf summary
+
+-&
+*/
+
+{ /* Begin dafgs_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafgs_c" );
+
+
+ dafgs_ ( ( doublereal * ) sum );
+
+
+ chkout_c ( "dafgs_c" );
+
+} /* End dafgs_c */
diff --git a/ext/spice/src/cspice/dafgsr_c.c b/ext/spice/src/cspice/dafgsr_c.c
new file mode 100644
index 0000000000..e077616d87
--- /dev/null
+++ b/ext/spice/src/cspice/dafgsr_c.c
@@ -0,0 +1,208 @@
+/*
+
+-Procedure dafgsr_c ( DAF, get summary/descriptor record )
+
+-Abstract
+
+ Read a portion of the contents of a summary record in a DAF file.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+
+ void dafgsr_c ( SpiceInt handle,
+ SpiceInt recno,
+ SpiceInt begin,
+ SpiceInt end,
+ SpiceDouble * data,
+ SpiceBoolean * found )
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of DAF.
+ recno I Record number.
+ begin I First word to read from record.
+ end I Last word to read from record.
+ data O Contents of record.
+ found O True if record is found.
+
+-Detailed_Input
+
+ handle is the handle associated with a DAF.
+
+ recno is the record number of a particular double precision
+ record within the DAF, whose contents are to be read.
+ DAF record numbers start at 1.
+
+ begin is the first word in the specified record to be
+ returned. For compatibility with SPICELIB, word
+ numbers range from 1 to 128.
+
+ end is the final word in the specified record to be
+ returned. For compatibility with SPICELIB, word
+ numbers range from 1 to 128.
+
+-Detailed_Output
+
+ data contains the specified portion (from `begin' to `end',
+ inclusive) of the specified record.
+
+ found is SPICETRUE when the specified record is found, and is
+ SPICEFALSE otherwise.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) Bad values for `begin' and `end' (begin < 1, end < begin,
+ etc.) are not signaled as errors, but result in the actions
+ implied by the pseudo-code:
+
+ for ( j = 0, i = max(1,begin); i <= max(128,end); i++, j++ )
+ {
+ data[j] = buffered_DAF_record[i];
+ }
+
+ 2) If `handle' is invalid, the error will be diagnosed by
+ routines called by this routine.
+
+-Files
+
+ The input handle must refer to a DAF that is open for read or write
+ access.
+
+-Particulars
+
+ dafgsr_c checks the DAF record buffer to see if the requested
+ record can be returned without actually reading it from
+ external storage. If not, it reads the record and stores
+ it in the buffer, typically removing another record from
+ the buffer as a result.
+
+ Once in the buffer, the specified portion of the record is
+ returned.
+
+-Examples
+
+ The following code fragment illustrates one way that dafgsr_c
+ and dafwdr_ can be used to update part of a summary record.
+ If the record does not yet exist, we can assume that it is
+ filled with zeros.
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+ SpiceInt size = 128;
+ SpiceInt recno;
+ SpiceInt handle;
+ .
+ .
+ .
+ dafgsr_c ( handle, recno, 1, 128, drec, &found );
+
+ if ( !found )
+ {
+ cleard_ ( &size, drec );
+ }
+
+ for ( i = first; i <= last; i++ )
+ {
+ drec[i] = new_value[i];
+ }
+
+ dafwdr_ ( &handle, &recno, drec );
+
+ Note that since only entire records may be written using dafwdr_,
+ the entire record needs to be read also.
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ F.S. Turner (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 17-JUN-2009 (NJB) (FST)
+
+-Index_Entries
+
+ read daf summary record
+
+-&
+*/
+
+{ /* Begin dafgsr_c */
+
+ /*
+ Local variables
+ */
+ logical fnd;
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafgsr_c" );
+
+
+ dafgsr_ ( ( integer * ) &handle,
+ ( integer * ) &recno,
+ ( integer * ) &begin,
+ ( integer * ) &end,
+ ( doublereal * ) data,
+ ( logical * ) &fnd );
+
+ *found = (SpiceBoolean) fnd;
+
+
+ chkout_c ( "dafgsr_c" );
+
+} /* End dafgsr_c */
diff --git a/ext/spice/src/cspice/dafopr_c.c b/ext/spice/src/cspice/dafopr_c.c
new file mode 100644
index 0000000000..ab4c238162
--- /dev/null
+++ b/ext/spice/src/cspice/dafopr_c.c
@@ -0,0 +1,205 @@
+/*
+
+-Procedure dafopr_c ( DAF, open for read )
+
+-Abstract
+
+ Open a DAF for subsequent read requests.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ DAF
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ void dafopr_c ( ConstSpiceChar * fname,
+ SpiceInt * handle )
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ fname I Name of DAF to be opened.
+ handle O Handle assigned to DAF.
+
+-Detailed_Input
+
+ fname is the file name of a DAF to be opened for read
+ access.
+
+-Detailed_Output
+
+ handle is the file handle associated with the file. This
+ handle is used to identify the file in subsequent
+ calls to other DAF routines.
+
+-Parameters
+
+ None.
+
+-Files
+
+ See argument fname.
+
+-Exceptions
+
+ 1) If the specified file has already been opened for read
+ access, the handle already associated with the file is
+ returned.
+
+ 2) If the specified file has already been opened for write
+ access, the error SPICE(DAFRWCONFLICT) is signaled.
+
+ 3) If the specified file has already been opened by a non-DAF
+ routine, the error SPICE(DAFIMPROPOPEN) is signaled.
+
+ 4) If the specified file cannot be opened without exceeding
+ the maximum number of files, the error SPICE(DAFFTFULL)
+ is signaled.
+
+ 5) If (for some reason) the file cannot be opened properly,
+ the error SPICE(DAFOPENFAIL) is signaled.
+
+ 6) If the attempt to read the file's ID word fails, the error
+ SPICE(FILEREADFAILED) will be signaled.
+
+ 7) If the specified file is not a DAF file, as indicated by the
+ file's ID word, the error SPICE(NOTADAFFILE) is signaled.
+
+ 8) If no logical units are available, the error will be
+ signaled by routines called by this routine.
+
+ 9) If the file does not exist, the error SPICE(FILEDOESNOTEXIST)
+ is signaled.
+
+ 10) If the INQUIRE fails, the error SPICE(INQUIREFAILED)
+ is signaled.
+
+ 11) If the file record cannot (for some reason) be read,
+ the error SPICE(DAFFRNOTFOUND) is signaled.
+
+ 12) If the file name is blank, the error SPICE(BLANKFILENAME)
+ is signaled.
+
+-Particulars
+
+ Most DAFs require only read access. If you do not need to
+ change the contents of a file, you should open it with dafopr_c.
+
+-Examples
+
+ In the following code fragment, dafopr_c is used to open a file,
+ which is then searched for DAFs containing data for a particular
+ object.
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ dafopr_c ( fname, &handle );
+ dafbfs_c ( handle );
+
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafus_c ( sum, ND, NI, dc, ic );
+
+ if ( ic[0] == target_object )
+ {
+ .
+ .
+ .
+ }
+
+ daffna_c ( &found );
+ }
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ NAIF Document 167.0, "Double Precision Array Files (DAF)
+ Specification and User's Guide"
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ J.M. Lynch (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 01-AUG-1999 (NJB) (KRG) (JML) (WLT) (IMU)
+
+-Index_Entries
+
+ open daf for read
+
+-&
+*/
+
+{ /* Begin dafopr_c */
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafopr_c" );
+
+ /*
+ Check the file name to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "dafopr_c", fname );
+
+
+ dafopr_ ( ( char * ) fname,
+ ( integer * ) handle,
+ ( ftnlen ) strlen(fname) );
+
+
+ chkout_c ( "dafopr_c" );
+
+} /* End dafopr_c */
diff --git a/ext/spice/src/cspice/dafopw_c.c b/ext/spice/src/cspice/dafopw_c.c
new file mode 100644
index 0000000000..0e7d7aaa7a
--- /dev/null
+++ b/ext/spice/src/cspice/dafopw_c.c
@@ -0,0 +1,308 @@
+/*
+
+-Procedure dafopw_c ( DAF, open for write )
+
+-Abstract
+
+ Open a DAF for subsequent write requests.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ DAF
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+ #include "SpiceZst.h"
+
+
+ void dafopw_c ( ConstSpiceChar * fname,
+ SpiceInt * handle )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ fname I Name of DAF to be opened.
+ handle O Handle assigned to DAF.
+
+-Detailed_Input
+
+ fname is the name of a DAF to be opened with write
+ access.
+
+-Detailed_Output
+
+ handle is the file handle associated with the file. This
+ handle is used to identify the file in subsequent
+ calls to other DAF routines.
+
+-Parameters
+
+ None.
+
+-Files
+
+ See argument `fname'.
+
+-Exceptions
+
+ 1) If the specified file has already been opened, either by
+ the DAF routines or by other code, an error is signaled by
+ routines in the call tree of this routine. Note that this
+ response is not paralleled by dafopr_c, which allows you
+ to open a DAF for reading even if it is already open for
+ reading.
+
+ 2) If the specified file cannot be opened without exceeding
+ the maximum number of files, the error SPICE(DAFFTFULL)
+ is signaled.
+
+ 3) If the attempt to read the file's file record fails, the
+ error SPICE(FILEREADFAILED) will be signaled.
+
+ 4) If the specified file is not a DAF file, an error is
+ signaled by routines in the call tree of this routine.
+
+ 5) If no logical units are available, an error is
+ signaled by routines called by this routine.
+
+ 6) If the file does not exist, the error SPICE(FILENOTFOUND)
+ is signaled by routines in the call tree of this routine.
+
+ 7) If an I/O error occurs in the process of opening the file,
+ routines in the call tree of this routine signal an error.
+
+ 8) If the file name is blank or otherwise inappropriate
+ routines in the call tree of this routine signal an error.
+
+ 9) If the file was transferred improperly via FTP, routines
+ in the call tree of this routine signal an error.
+
+ 10) If the file utilizes a non-native binary file format, an
+ error is signaled by routines in the call tree of this
+ routine.
+
+ 11) The error SPICE(EMPTYSTRING) is signaled if the file namne
+ string does not contain at least one character, since the
+ string cannot be converted to a Fortran-style string
+ in this case.
+
+ 12) The error SPICE(NULLPOINTER) is signaled if the input file
+ name string pointer is null.
+
+-Particulars
+
+ Most DAFs require only read access. If you do not need to
+ change the contents of a file, you should open it with dafopr_c.
+ Use dafopw_c when you need to
+
+ -- change (update) one or more summaries, names, or
+ arrays within a file; or
+
+ -- add new arrays to a file.
+
+-Examples
+
+ In the following code fragment, dafopw_c is used to open a
+ file, which is then searched for arrays containing data for
+ a particular object. The code for the object is then changed
+ (perhaps to reflect some new convention).
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+ int main()
+ {
+ void dafopw_c ( ConstSpiceChar * fname,
+ SpiceInt * handle );
+
+ #define DSCSIZ 5
+ #define FILSIZ 256
+ #define LINSIZ 81
+ #define ND 2
+ #define NI 6
+
+ SpiceBoolean found;
+
+ SpiceChar fname [ FILSIZ ];
+ SpiceChar line [ LINSIZ ];
+
+ SpiceDouble dc [ ND ];
+ SpiceDouble sum [ DSCSIZ ];
+
+ SpiceInt handle;
+ SpiceInt ic [ NI ];
+ SpiceInt nd = ND;
+ SpiceInt new_code;
+ SpiceInt ni = NI;
+ SpiceInt old_code;
+
+
+ /.
+ Get the file name.
+ ./
+ prompt_c ( "Enter name of existing DAF > ", FILSIZ, fname );
+
+ prompt_c ( "Enter ID code to change > ", LINSIZ, line );
+ prsint_c ( line, &old_code );
+
+ prompt_c ( "Enter replacement code > ", LINSIZ, line );
+ prsint_c ( line, &new_code );
+
+ /.
+ Open the existing DAF file for write access.
+ ./
+ dafopw_c ( fname, &handle );
+
+ /.
+ Start a forward search through the file.
+ ./
+ dafbfs_c ( handle );
+
+ /.
+ Find the first array (segment).
+ ./
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ /.
+ Read and unpack the current DAF array summary
+ (aka segment descriptor) sum:
+ ./
+ dafgs_c ( sum );
+ dafus_c ( sum, nd, ni, dc, ic );
+
+
+ if ( ic[0] == old_code )
+ {
+ ic[0] = new_code;
+
+ /.
+ Pack the summary array using the updated
+ integer array ic. Note this is an f2c'd
+ routine, so the array sizes are passed by
+ reference.
+ ./
+ dafps_ ( &nd, &ni, dc, ic, sum );
+
+ /.
+ Replace the segment descriptor in the DAF.
+ ./
+ dafrs_ ( sum );
+ }
+
+ /.
+ Find the next segment.
+ ./
+ daffna_c ( &found );
+ }
+
+ /.
+ Close the DAF.
+ ./
+ dafcls_c ( handle );
+
+ return ( 0 );
+ }
+
+
+-Restrictions
+
+ 1) Only files of the native binary file format may be opened
+ with this routine.
+
+ 2) Files opened using this routine must be closed with dafcls_c.
+
+-Literature_References
+
+ NAIF Document 167.0, "Double Precision Array Files (DAF)
+ Specification and User's Guide"
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ J.M. Lynch (JPL)
+ J.E. McLean (JPL)
+ W.L. Taber (JPL)
+ F.S. Turner (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 13-OCT-2004 (NJB) (KRG) (JML) (JEM) (WLT) (FST) (IMU)
+
+-Index_Entries
+
+ open existing daf for write
+
+-&
+*/
+
+{ /* Begin dafopw_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+ chkin_c ( "dafopw_c" );
+
+ /*
+ Check the file name to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "dafopw_c", fname );
+
+ /*
+ Let the f2c'd routine do the work.
+ */
+ dafopw_ ( ( char * ) fname,
+ ( integer * ) handle,
+ ( ftnlen ) strlen(fname) );
+
+
+ chkout_c ( "dafopw_c" );
+
+} /* End dafopw_c */
+
+
diff --git a/ext/spice/src/cspice/dafps.c b/ext/spice/src/cspice/dafps.c
new file mode 100644
index 0000000000..bf0a22adde
--- /dev/null
+++ b/ext/spice/src/cspice/dafps.c
@@ -0,0 +1,367 @@
+/* dafps.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DAFPS ( DAF, pack summary ) */
+/* Subroutine */ int dafps_0_(int n__, integer *nd, integer *ni, doublereal *
+ dc, integer *ic, doublereal *sum)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+ static doublereal equiv_0[125];
+
+ /* Local variables */
+ integer m, n;
+ extern /* Subroutine */ int moved_(doublereal *, integer *, doublereal *),
+ movei_(integer *, integer *, integer *);
+#define dequiv (equiv_0)
+#define iequiv ((integer *)equiv_0)
+
+/* $ Abstract */
+
+/* Pack (assemble) an array summary from its double precision and */
+/* integer components. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* ND I Number of double precision components. */
+/* NI I Number of integer components. */
+/* DC I Double precision components. */
+/* IC I Integer components. */
+/* SUM O Array summary. */
+
+/* $ Detailed_Input */
+
+/* ND is the number of double precision components in */
+/* the summary to be packed. */
+
+/* NI is the number of integer components in the summary. */
+
+/* DC are the double precision components of the summary. */
+
+/* IC are the integer components of the summary. */
+
+/* $ Detailed_Output */
+
+/* SUM is an array summary containing the components in DC */
+/* and IC. This identifies the contents and location of */
+/* a single array within a DAF. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* 1) If ND is zero or negative, no DP components are stored. */
+
+/* 2) If NI is zero or negative, no integer components are stored. */
+
+/* 3) If the total size of the summary is greater than 125 double */
+/* precision words, some components may not be stored. */
+
+/* $ Particulars */
+
+/* The components of array summaries are packed into double */
+/* precision arrays for reasons outlined in [1]. Two routines, */
+/* DAFPS (pack summary) and DAFUS (unpack summary) are provided */
+/* for packing and unpacking summaries. */
+
+/* The total size of the summary is */
+
+/* (NI - 1) */
+/* ND + -------- + 1 */
+/* 2 */
+
+/* double precision words (where ND, NI are nonnegative). */
+
+/* $ Examples */
+
+/* Maybe later. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* pack daf summary */
+
+/* -& */
+
+/* Local variables */
+
+
+/* Equivalences */
+
+
+/* Here's the deal: the DP components always precede the integer */
+/* components, avoiding alignment problems. The DP components can */
+/* be stored directly. */
+
+ switch(n__) {
+ case 1: goto L_dafus;
+ }
+
+/* Computing MIN */
+ i__1 = 125, i__2 = max(0,*nd);
+ n = min(i__1,i__2);
+ moved_(dc, &n, sum);
+
+/* The integer components must detour through an equivalence. */
+
+/* Computing MIN */
+ i__1 = 250 - (n << 1), i__2 = max(0,*ni);
+ m = min(i__1,i__2);
+ movei_(ic, &m, iequiv);
+ i__1 = (m - 1) / 2 + 1;
+ moved_(dequiv, &i__1, &sum[n]);
+ return 0;
+/* $Procedure DAFUS ( DAF, unpack summary ) */
+
+L_dafus:
+/* $ Abstract */
+
+/* Unpack an array summary into its double precision and integer */
+/* components. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* FILES */
+
+/* $ Declarations */
+
+/* DOUBLE PRECISION SUM ( * ) */
+/* INTEGER ND */
+/* INTEGER NI */
+/* DOUBLE PRECISION DC ( * ) */
+/* INTEGER IC ( * ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* SUM I Array summary. */
+/* ND I Number of double precision components. */
+/* NI I Number of integer components. */
+/* DC O Double precision components. */
+/* IC O Integer components. */
+
+/* $ Detailed_Input */
+
+/* SUM is an array summary. This identifies the contents and */
+/* location of a single array within a DAF. */
+
+/* ND is the number of double precision components in */
+/* the summary. */
+
+/* NI is the number of integer components in the summary. */
+
+/* $ Detailed_Output */
+
+/* DC are the double precision components of the summary. */
+
+/* IC are the integer components of the summary. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* 1) If ND is zero or negative, no double precision components */
+/* are returned. */
+
+/* 2) If NI is zero or negative, no integer components are returned. */
+
+/* 3) If the total size of the summary is greater than 125 double */
+/* precision words, some components may not be returned. */
+
+/* $ Particulars */
+
+/* The components of array summaries are packed into double */
+/* precision arrays for reasons outlined in [1]. Two routines, */
+/* DAFPS (pack summary) and DAFUS (unpack summary) are provided */
+/* for packing and unpacking summaries. */
+
+/* The total size of the summary is */
+
+/* (NI - 1) */
+/* ND + -------- + 1 */
+/* 2 */
+
+/* double precision words (where ND, NI are nonnegative). */
+
+/* $ Examples */
+
+/* Maybe later. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* unpack daf summary */
+
+/* -& */
+
+/* Just undo whatever DAFPS did. */
+
+/* Computing MIN */
+ i__1 = 125, i__2 = max(0,*nd);
+ n = min(i__1,i__2);
+ moved_(sum, &n, dc);
+/* Computing MIN */
+ i__1 = 250 - (n << 1), i__2 = max(0,*ni);
+ m = min(i__1,i__2);
+ i__1 = (m - 1) / 2 + 1;
+ moved_(&sum[n], &i__1, dequiv);
+ movei_(iequiv, &m, ic);
+ return 0;
+} /* dafps_ */
+
+#undef iequiv
+#undef dequiv
+
+
+/* Subroutine */ int dafps_(integer *nd, integer *ni, doublereal *dc, integer
+ *ic, doublereal *sum)
+{
+ return dafps_0_(0, nd, ni, dc, ic, sum);
+ }
+
+/* Subroutine */ int dafus_(doublereal *sum, integer *nd, integer *ni,
+ doublereal *dc, integer *ic)
+{
+ return dafps_0_(1, nd, ni, dc, ic, sum);
+ }
+
diff --git a/ext/spice/src/cspice/dafps_c.c b/ext/spice/src/cspice/dafps_c.c
new file mode 100644
index 0000000000..aa232ed0f9
--- /dev/null
+++ b/ext/spice/src/cspice/dafps_c.c
@@ -0,0 +1,243 @@
+/*
+
+-Procedure dafps_c ( DAF, pack summary )
+
+-Abstract
+
+ Pack (assemble) an array summary from its double precision and
+ integer components.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ CONVERSION
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZim.h"
+ #undef dafps_c
+
+
+ void dafps_c ( SpiceInt nd,
+ SpiceInt ni,
+ ConstSpiceDouble * dc,
+ ConstSpiceInt * ic,
+ SpiceDouble * sum )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ nd I Number of double precision components.
+ ni I Number of integer components.
+ dc I Double precision components.
+ ic I Integer components.
+ sum O Array summary.
+
+-Detailed_Input
+
+ nd is the number of double precision components in
+ the summary to be packed.
+
+ ni is the number of integer components in the summary.
+
+ dc are the double precision components of the summary.
+
+ ic are the integer components of the summary.
+
+-Detailed_Output
+
+ sum is an array summary containing the components in `dc'
+ and `ic'. This identifies the contents and location of
+ a single array within a DAF.
+
+-Parameters
+
+ None.
+
+-Files
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+ 1) If ND is zero or negative, no DP components are stored.
+
+ 2) If NI is zero or negative, no integer components are stored.
+
+ 3) If the total size of the summary is greater than 125 double
+ precision words, some components may not be stored.
+
+-Particulars
+
+ The components of array summaries are packed into double
+ precision arrays for reasons outlined in [1]. Two routines,
+ dafps_c (pack summary) and dafus_c (unpack summary) are provided
+ for packing and unpacking summaries.
+
+ The total size of the summary is
+
+ (NI - 1)
+ ND + -------- + 1
+ 2
+
+ double precision words (where ND, NI are nonnegative).
+
+-Examples
+
+
+ 1) Replace the body ID code -999 with -1999 in every descriptor
+ of an SPK file.
+
+
+ #include
+
+ int main ( int argc, char **argv )
+ {
+ #define ND 2
+ #define NI 6
+ #define DSCSIZ 5
+ #define NEWCODE ( -1999 )
+ #define OLDCODE ( -999 )
+
+ SpiceBoolean found;
+
+ SpiceInt handle;
+ SpiceInt ic [ NI ];
+
+ SpiceDouble dc [ ND ];
+ SpiceDouble sum [ DSCSIZ ];
+
+ /.
+ Open for writing the SPK file specified on the command line.
+ ./
+ dafopw_c ( argv[1], &handle );
+
+ /.
+ Search the file in forward order.
+ ./
+ dafbfs_c ( handle );
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ /.
+ Fetch and unpack the descriptor (aka summary)
+ of the current segment.
+ ./
+ dafgs_c ( sum );
+ dafus_c ( sum, ND, NI, dc, ic );
+
+ /.
+ Replace ID codes if necessary.
+ ./
+ if ( ic[0] == OLDCODE )
+ {
+ ic[0] = NEWCODE;
+ }
+ if ( ic[1] == OLDCODE )
+ {
+ ic[1] = NEWCODE;
+ }
+
+ /.
+ Re-pack the descriptor; replace the descriptor
+ in the file.
+ ./
+ dafps_c ( ND, NI, dc, ic, sum );
+
+ dafrs_c ( sum );
+
+ /.
+ Find the next segment.
+ ./
+ daffna_c ( &found );
+ }
+
+ /.
+ Close the file.
+ ./
+ dafcls_c ( handle );
+
+ return ( 0 );
+ }
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 23-NOV-2004 (NJB)
+
+-Index_Entries
+
+ pack daf summary
+
+-&
+*/
+
+{ /* Begin dafps_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafps_c" );
+
+
+ dafps_ ( ( integer * ) &nd,
+ ( integer * ) &ni,
+ ( doublereal * ) dc,
+ ( integer * ) ic,
+ ( doublereal * ) sum );
+
+
+ chkout_c ( "dafps_c" );
+
+} /* End dafps_c */
diff --git a/ext/spice/src/cspice/dafra.c b/ext/spice/src/cspice/dafra.c
new file mode 100644
index 0000000000..c03069254b
--- /dev/null
+++ b/ext/spice/src/cspice/dafra.c
@@ -0,0 +1,365 @@
+/* dafra.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DAFRA ( DAF, Re-order arrays ) */
+/* Subroutine */ int dafra_(integer *handle, integer *iorder, integer *n)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer hold, i__;
+ extern /* Subroutine */ int dafgn_(char *, ftnlen), dafgs_(doublereal *),
+ dafrn_(char *, ftnlen), chkin_(char *, ftnlen);
+ char holdn[1000];
+ extern /* Subroutine */ int dafws_(doublereal *);
+ integer index;
+ doublereal holds[128];
+ logical found;
+ char tempn[1000];
+ integer total;
+ doublereal temps[128];
+ integer start;
+ extern /* Subroutine */ int daffna_(logical *);
+ extern logical failed_(void);
+ extern /* Subroutine */ int dafbfs_(integer *), sigerr_(char *, ftnlen),
+ chkout_(char *, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ extern logical isordv_(integer *, integer *), return_(void);
+
+/* $ Abstract */
+
+/* Re-order the arrays in a DAF according to a given order */
+/* vector. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+/* SORT */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAF. */
+/* IORDER I Order vector. */
+/* N I Dimension of IORDER. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAF that has been opened for */
+/* write access. Use DAFOPW, for example, to open */
+/* an existing file and get its handle. */
+
+/* IORDER is the order vector to be used to re-order the */
+/* arrays stored in the DAF specified by HANDLE. */
+
+/* An integer order vector is an array of length */
+/* N whose elements are the integers 1 through N. */
+
+/* The first element of IORDER is the index of the */
+/* first array in the re-ordered file, and so on. */
+
+/* N is the number of elements in the order vector. */
+/* This may be less than the number of arrays in */
+/* the file. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* DAFRA does not actually move the elements of the double */
+/* precision arrays; it works by rearranging the contents */
+/* of the summary and name records in the file. The result */
+/* is that the search routines (BFS, FNA, BBS, FPA) will */
+/* return the arrays in the indicated order. */
+
+/* After re-ordering, array IORDER(1) of the input file is the */
+/* first array of the output file, array IORDER(2) of the input */
+/* file is the second array of the output file, and so on. */
+
+/* The order vector used by DAFRA is typically created for */
+/* a related array by one of the ORDER routines, as shown in */
+/* the example below. */
+
+/* $ Examples */
+
+/* The following code fragment sorts the arrays in a DAF by name. */
+
+/* C */
+/* C Collect the names of the arrays in the file. */
+/* C */
+/* CALL DAFOPW ( FILE, HANDLE ) */
+
+/* N = 0 */
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+/* N = N + 1 */
+/* CALL DAFGN ( NAMES(I) ) */
+/* CALL DAFFNA ( FOUND ) */
+/* END DO */
+
+/* C */
+/* C Sort the names. */
+/* C */
+/* CALL ORDERC ( NAMES, N, IORDER ) */
+
+/* C */
+/* C Re-order the arrays. */
+/* C */
+/* CALL DARFA ( HANDLE, IORDER, N ) */
+/* CALL DAFCLS ( HANDLE ) */
+
+/* Afterward, a forward search like the one shown below */
+
+/* CALL DAFBFS ( HANDLE ) */
+/* CALL DAFFNA ( FOUND ) */
+
+/* DO WHILE ( FOUND ) */
+/* CALL DAFGN ( NAME ) */
+/* WRITE (*,*) NAME */
+
+/* CALL DAFFNA ( FOUND ) */
+/* END DO */
+
+/* produces an ordered list of the names in the sorted file. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If IORDER is not an order vector (that is, if it does */
+/* not contain every integer between 1 and N), the error */
+/* SPICE(DISORDER) is signalled. */
+
+/* 2) If N is greater than the number of arrays in the file, */
+/* the error SPICE(DISARRAY) is signalled. */
+
+/* $ Files */
+
+/* See argument HANDLE. */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 28-MAR-1991 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* reorder daf arrays */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFRA", (ftnlen)5);
+ }
+
+/* If the order vector has fewer than two elements, don't bother. */
+
+ if (*n < 2) {
+ chkout_("DAFRA", (ftnlen)5);
+ return 0;
+ }
+
+/* If IORDER is not an order vector, complain. */
+
+ if (! isordv_(iorder, n)) {
+ setmsg_("Sorry, IORDER is not an order vector.", (ftnlen)37);
+ sigerr_("SPICE(DISORDER)", (ftnlen)15);
+ chkout_("DAFRA", (ftnlen)5);
+ return 0;
+ }
+
+/* If the number of arrays to be moved exceeds the number of */
+/* arrays in the file, complain. */
+
+ total = 0;
+ dafbfs_(handle);
+ daffna_(&found);
+ while(found && ! failed_()) {
+ ++total;
+ daffna_(&found);
+ }
+ if (failed_()) {
+ chkout_("DAFRA", (ftnlen)5);
+ return 0;
+ } else if (total < *n) {
+ setmsg_("N (#) exceeds number of arrays (#).", (ftnlen)35);
+ errint_("#", n, (ftnlen)1);
+ errint_("#", &total, (ftnlen)1);
+ sigerr_("SPICE(DISARRAY)", (ftnlen)15);
+ chkout_("DAFRA", (ftnlen)5);
+ return 0;
+ }
+
+/* Not surprisingly, this routine is patterned closely after the */
+/* (original) REORDx routines in SPICELIB. The only differences */
+/* are that */
+
+/* 1) This routine is not error free---it checks to make */
+/* sure that IORDER is in fact an order vector, and that */
+/* every element in IORDER refers to an existing array. */
+
+/* 2) Instead of moving elements of an array in and out of */
+/* a temporary location, it moves summaries and names. */
+/* This means that two sets of temporary storage locations */
+/* are needed: one to hold the summary and name of the */
+/* guy who began the current cycle; and one to hold the guy */
+/* being moved from location HOLD to location INDEX. */
+
+ start = 1;
+ while(start < *n && ! failed_()) {
+
+/* Start the cycle. One guy (pair of summary and name record) */
+/* has to sit out (in HOLDS and HOLDN) until the end of the cycle */
+/* is reached. */
+
+ index = start;
+ hold = iorder[index - 1];
+ dafbfs_(handle);
+ i__1 = index;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ daffna_(&found);
+ }
+ dafgs_(holds);
+ dafgn_(holdn, (ftnlen)1000);
+
+/* Move guys from HOLD to INDEX; then update HOLD (to point */
+/* to the next guy to be moved) and INDEX (to point at the */
+/* space just vacated). */
+
+/* Keep going until HOLD points to the first guy moved during */
+/* the current cycle. This ends the cycle. */
+
+ while(hold != start) {
+
+/* Get the guy in position HOLD. */
+
+ dafbfs_(handle);
+ i__1 = hold;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ daffna_(&found);
+ }
+ dafgs_(temps);
+ dafgn_(tempn, (ftnlen)1000);
+
+/* Move him to position INDEX. (Note that DAFWS is used to */
+/* update the summary instead of DAFRS, because the addresses */
+/* are actually being changed.) */
+
+ dafbfs_(handle);
+ i__1 = index;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ daffna_(&found);
+ }
+ dafws_(temps);
+ dafrn_(tempn, (ftnlen)1000);
+
+/* Update HOLD and INDEX. */
+
+ index = hold;
+ hold = iorder[hold - 1];
+ iorder[index - 1] = -iorder[index - 1];
+ }
+
+/* The last element in the cycle is restored from TEMP. */
+
+ dafbfs_(handle);
+ i__1 = index;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ daffna_(&found);
+ }
+ dafws_(holds);
+ dafrn_(holdn, (ftnlen)1000);
+ iorder[hold - 1] = -iorder[hold - 1];
+
+/* Begin the next cycle at the next element in the order */
+/* vector with a positive sign. (That is, the next one */
+/* that hasn't been moved.) */
+
+ while(iorder[start - 1] < 0 && start < *n) {
+ ++start;
+ }
+ }
+
+/* Restore the original signs of the elements of the order */
+/* vector, for the next go around. */
+
+ i__1 = *n;
+ for (index = 1; index <= i__1; ++index) {
+ iorder[index - 1] = (i__2 = iorder[index - 1], abs(i__2));
+ }
+ chkout_("DAFRA", (ftnlen)5);
+ return 0;
+} /* dafra_ */
+
diff --git a/ext/spice/src/cspice/dafrcr.c b/ext/spice/src/cspice/dafrcr.c
new file mode 100644
index 0000000000..7a478974cf
--- /dev/null
+++ b/ext/spice/src/cspice/dafrcr.c
@@ -0,0 +1,256 @@
+/* dafrcr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static logical c_false = FALSE_;
+static integer c__1 = 1;
+
+/* $Procedure DAFRCR ( DAF, read character record ) */
+/* Subroutine */ int dafrcr_(integer *handle, integer *recno, char *crec,
+ ftnlen crec_len)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen), s_rdue(cilist *), do_uio(integer *, char *,
+ ftnlen), e_rdue(void);
+
+ /* Local variables */
+ integer unit;
+ extern /* Subroutine */ int zzddhhlu_(integer *, char *, logical *,
+ integer *, ftnlen), chkin_(char *, ftnlen);
+ extern logical failed_(void);
+ extern /* Subroutine */ int dafsih_(integer *, char *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+ /* Fortran I/O blocks */
+ static cilist io___3 = { 1, 0, 1, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Read the contents of a character record from a DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAF. */
+/* RECNO I Record number of character record. */
+/* CREC O Character record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a DAF. */
+
+/* RECNO is the record number of a character record within */
+/* the file. */
+
+/* $ Detailed_Output */
+
+/* CREC contains the first 1000 characters of the specified */
+/* record from the specified file. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the declared length of CREC is not 1000 characters, */
+/* the error SPICE(DAFBADRECLEN) is signalled. */
+
+/* 2) If the specified record cannot (for some reason) be read, */
+/* the error SPICE(DAFCRNOTFOUND) is signalled. */
+
+/* $ Particulars */
+
+/* Unlike double precision records, character records are */
+/* not buffered. Also, while failing to find a specific double */
+/* precision record is indicated through the calling sequence, */
+/* failing to find a character record results in an error. */
+
+/* $ Examples */
+
+/* In the following example, matching summary and name records are */
+/* read from a DAF: */
+
+/* CALL DAFGDR ( HANDLE, NEXT, DREC, FOUND ) */
+/* CALL DAFRCR ( HANDLE, NEXT+1, CREC ) */
+
+/* Note that a character record always immediately follows a summary */
+/* record. */
+
+/* $ Restrictions */
+
+/* 1) This routine is only used to read records on environments */
+/* whose characters are a single byte in size. Updates */
+/* to this routine and routines in its call tree may be */
+/* required to properly handle other cases. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* Updated this routine to make proper use of the new */
+/* handle manager functionality installed underneath */
+/* DAF. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read daf character record */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* This routine now makes use of the handle manager */
+/* code. A call to DAFSIH was inserted just after */
+/* the standard SPICE error handling code at the */
+/* head of the module. This was done to insure that */
+/* the caller is referring to a legitmately loaded */
+/* DAF. The penalty for performing this check is */
+/* a binary search on the number of loaded files, */
+/* which should be small compared to the actual READ */
+/* performed below. */
+
+/* The call to DAFHLU has been replaced with ZZDDHHLU, */
+/* since calls to DAFHLU locks handles to their logical */
+/* units. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFRCR", (ftnlen)6);
+ }
+
+/* Check to be sure that HANDLE is attached to a file that is open */
+/* with read access. If the call fails, check out and return. */
+
+ dafsih_(handle, "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DAFRCR", (ftnlen)6);
+ return 0;
+ }
+
+/* Now make certain that the string to receive the contents of */
+/* the character record is the appropriate length. */
+
+ if (i_len(crec, crec_len) != 1000) {
+ setmsg_("Expected length of character record is 1000. Passed string "
+ "has length #", (ftnlen)71);
+ i__1 = i_len(crec, crec_len);
+ errint_("#", &i__1, (ftnlen)1);
+ sigerr_("SPICE(DAFBADCRECLEN)", (ftnlen)20);
+ } else {
+
+/* Retrieve a logical unit for this handle. This has the */
+/* side-effect of locking this UNIT to HANDLE. */
+
+ zzddhhlu_(handle, "DAF", &c_false, &unit, (ftnlen)3);
+ if (failed_()) {
+ chkout_("DAFRCR", (ftnlen)6);
+ return 0;
+ }
+ io___3.ciunit = unit;
+ io___3.cirec = *recno;
+ iostat = s_rdue(&io___3);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, crec, crec_len);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rdue();
+L100001:
+ if (iostat != 0) {
+ setmsg_("Could not read record #. IOSTAT was #.", (ftnlen)38);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFCRNOTFOUND)", (ftnlen)20);
+ }
+ }
+ chkout_("DAFRCR", (ftnlen)6);
+ return 0;
+} /* dafrcr_ */
+
diff --git a/ext/spice/src/cspice/dafrda.c b/ext/spice/src/cspice/dafrda.c
new file mode 100644
index 0000000000..c0bcc6bae4
--- /dev/null
+++ b/ext/spice/src/cspice/dafrda.c
@@ -0,0 +1,318 @@
+/* dafrda.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DAFRDA ( DAF, read data from address ) */
+/* Subroutine */ int dafrda_(integer *handle, integer *begin, integer *end,
+ doublereal *data)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer begr, begw, endr, endw, last, next;
+ extern /* Subroutine */ int zzddhisn_(integer *, logical *, logical *),
+ chkin_(char *, ftnlen);
+ integer recno;
+ logical found;
+ integer first;
+ extern /* Subroutine */ int cleard_(integer *, doublereal *), dafrdr_(
+ integer *, integer *, integer *, integer *, doublereal *, logical
+ *), dafarw_(integer *, integer *, integer *), errhan_(char *,
+ integer *, ftnlen);
+ logical native;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Read the double precision data bounded by two addresses within */
+/* a DAF. */
+
+/* Deprecated: This routine has been superseded by DAFGDA and */
+/* DAFGSR. This routine is supported for purposes of backward */
+/* compatibility only. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of a DAF. */
+/* BEGIN, */
+/* END I Initial, final address within file. */
+/* DATA O Data contained between BEGIN and END. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAF. */
+
+/* BEGIN, */
+/* END are the initial and final addresses of a contiguous */
+/* set of double precision numbers within a DAF. */
+/* Presumably, these make up all or part of a particular */
+/* array. */
+
+/* $ Detailed_Output */
+
+/* DATA are the double precision data contained between */
+/* the specified addresses within the specified file. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If BEGIN is zero or negative, the error SPICE(DAFNEGADDR) */
+/* is signalled. */
+
+/* 2) If the BEGIN > END, the error SPICE(DAFBEGGTEND) */
+/* is signalled. */
+
+/* 3) If the file associated with HANDLE is not of the native */
+/* binary file format this routine signals the error */
+/* SPICE(UNSUPPORTEDBFF). */
+
+/* 4) If HANDLE is invalid, routines in the call tree of DAFRDA */
+/* signal an appropriate error. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The principal reason that DAFs are so easy to use is that */
+/* the data in each DAF are considered to be one long contiguous */
+/* set of double precision numbers. You can grab data from anywhere */
+/* within a DAF without knowing (or caring) about the physical */
+/* records in which they are stored. */
+
+/* This routine has been made obsolete by the routines DAFGDA and */
+/* DAFGSR. This routine is supported for reasons of backward */
+/* compatibility only. New software development should utilize */
+/* DAFGDA or DAFGSR. */
+
+/* $ Examples */
+
+/* The following code fragment illustrates the use of DAFRDA */
+/* to read data from an imaginary array. The array begins with a */
+/* directory containing 11 epochs. Each pair of epochs bounds */
+/* an interval, and each interval is covered by a set of eight */
+/* osculating elements. */
+
+/* CALL DAFUS ( SUM, ND, NI, DC, IC ) */
+/* BEGIN = IC(5) */
+/* END = IC(6) */
+
+/* CALL DAFRDA ( HANDLE, BEGIN, BEGIN+10, EPOCHS ) */
+
+/* DO I = 1, 10 */
+/* IF ( ET .GE. EPOCHS(I) .AND. ET .LE. EPOCHS(I+1) ) THEN */
+/* OFFSET = IC(5) + 11 + (I - 1) * 8 */
+
+/* CALL DAFRDA ( HANDLE, OFFSET+1, OFFSET+8, ELEMENTS ) */
+/* RETURN */
+/* END IF */
+/* END DO */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.2, 18-MAY-2010 (BVS) */
+
+/* Index line now states that this routine is deprecated. */
+
+/* - SPICELIB Version 2.0.1, 27-OCT-2003 (NJB) */
+
+/* The header now states that this routine is deprecated. */
+/* The Exceptions header section has been extended. */
+/* Minor additional header updates were made. */
+
+/* - SPICELIB Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* Added SPICE(UNSUPPORTEDBFF) exception to the routine. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* DEPRECATED read data from daf address */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* The exception SPICE(UNSUPPORTEDBFF) was added to guarantee */
+/* this routine's functionality remains unchanged as a result */
+/* of the updates to the underlying DAF software's utilization of */
+/* the handle manager. In versions of the Toolkit prior to this, */
+/* all DAFs loaded were of the native binary file format. */
+/* While rather unlikely, this routine could be used to read */
+/* the contents of summary records in addition to the usual */
+/* data records. The non-native to native translation process */
+/* for these two different types of records in general are not */
+/* the same. Rather than attempt to interpret the caller's */
+/* intent, this routine is deprecated and restricted to */
+/* functioning only on DAFs of the native binary file format. */
+
+/* - Beta Version 1.1.0, 1-NOV-1989 (RET) */
+
+/* DAFRDA now only checks in and checks out if one of the two */
+/* possible exceptions occurs. The purpose of this change was to */
+/* help speed up a routine that gets called constantly by higher */
+/* level DAF routines. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+
+/* Check to see if HANDLE is associated with a DAF of the native */
+/* binary file format. */
+
+ zzddhisn_(handle, &native, &found);
+
+/* If the HANDLE was located, then check whether the binary file */
+/* format is native. Otherwise, defer diagnosing the missing */
+/* handle to DAFRDR. */
+
+ if (found && ! native) {
+ chkin_("DAFRDA", (ftnlen)6);
+ setmsg_("The binary file format for file '#' is not native. This rou"
+ "tine operates only on files of the native format.", (ftnlen)
+ 108);
+ errhan_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(UNSUPPORTEDBFF)", (ftnlen)21);
+ chkout_("DAFRDA", (ftnlen)6);
+ return 0;
+ }
+
+/* Bad addresses? */
+
+ if (*begin <= 0) {
+ chkin_("DAFRDA", (ftnlen)6);
+ setmsg_("Negative value for BEGIN address: #", (ftnlen)35);
+ errint_("#", begin, (ftnlen)1);
+ sigerr_("SPICE(DAFNEGADDR)", (ftnlen)17);
+ chkout_("DAFRDA", (ftnlen)6);
+ return 0;
+ } else if (*begin > *end) {
+ chkin_("DAFRDA", (ftnlen)6);
+ setmsg_("Beginning address (#) greater than ending address (#).", (
+ ftnlen)54);
+ errint_("#", begin, (ftnlen)1);
+ errint_("#", end, (ftnlen)1);
+ sigerr_("SPICE(DAFBEGGTEND)", (ftnlen)18);
+ chkout_("DAFRDA", (ftnlen)6);
+ return 0;
+ }
+
+/* Convert raw addresses to record/word representations. */
+
+ dafarw_(begin, &begr, &begw);
+ dafarw_(end, &endr, &endw);
+
+/* Get as many records as needed. Return the last part of the */
+/* first record, the first part of the last record, and all of */
+/* every record in between. Any record not found is assumed to */
+/* be filled with zeros. */
+
+ next = 1;
+ i__1 = endr;
+ for (recno = begr; recno <= i__1; ++recno) {
+ if (begr == endr) {
+ first = begw;
+ last = endw;
+ } else if (recno == begr) {
+ first = begw;
+ last = 128;
+ } else if (recno == endr) {
+ first = 1;
+ last = endw;
+ } else {
+ first = 1;
+ last = 128;
+ }
+ dafrdr_(handle, &recno, &first, &last, &data[next - 1], &found);
+ if (! found) {
+ i__2 = last - first + 1;
+ cleard_(&i__2, &data[next - 1]);
+ }
+ next += last - first + 1;
+ }
+ return 0;
+} /* dafrda_ */
+
diff --git a/ext/spice/src/cspice/dafrda_c.c b/ext/spice/src/cspice/dafrda_c.c
new file mode 100644
index 0000000000..4d1b2cce77
--- /dev/null
+++ b/ext/spice/src/cspice/dafrda_c.c
@@ -0,0 +1,211 @@
+/*
+
+-Procedure dafrda_c ( DAF, read data from address )
+
+-Abstract
+
+ Read the double precision data bounded by two addresses within
+ a DAF.
+
+ Deprecated: This routine has been superseded by dafgda_c and
+ dafgsr_c. This routine is supported for purposes of backward
+ compatibility only.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+
+*/
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+
+ void dafrda_c ( SpiceInt handle,
+ SpiceInt begin,
+ SpiceInt end,
+ SpiceDouble * data )
+/*
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of a DAF.
+ begin,
+ end I Initial, final address within file.
+ data O Data contained between begin and end.
+
+-Detailed_Input
+
+ handle is the handle of a DAF.
+
+ begin,
+ end are the initial and final addresses of a contiguous
+ set of double precision numbers within a DAF.
+ Presumably, these make up all or part of a particular
+ array.
+
+ Note that CSPICE DAF addresses begin at 1 as in the
+ FORTRAN version of the SPICE Toolkit.
+
+-Detailed_Output
+
+ data are the double precision data contained between
+ the specified addresses within the specified file.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If `begin' is zero or negative, the error SPICE(DAFNEGADDR)
+ is signaled.
+
+ 2) If the begin > end, the error SPICE(DAFBEGGTEND)
+ is signaled.
+
+ 3) If the file associated with `handle' is not of the native
+ binary file format this routine signals the error
+ SPICE(UNSUPPORTEDBFF).
+
+ 4) If `handle' is invalid, routines in the call tree of dafrda_c
+ signal an appropriate error.
+
+-Files
+
+ None.
+
+-Particulars
+
+ The principal reason that DAFs are so easy to use is that
+ the data in each DAF are considered to be one long contiguous
+ set of double precision numbers. You can grab data from anywhere
+ within a DAF without knowing (or caring) about the physical
+ records in which they are stored.
+
+ This routine has been made obsolete by the routines dafgda_c and
+ dafgsr_c. This routine is supported for reasons of backward
+ compatibility only. New software development should utilize
+ dafgda_c or dafgsr_c.
+
+-Examples
+
+ The following code fragment illustrates the use of dafrda_c
+ to read data from an imaginary array. The array begins with a
+ directory containing 11 epochs. Each pair of epochs bounds
+ an interval, and each interval is covered by a set of eight
+ osculating elements.
+
+ #include "SpiceUsr.h"
+
+ .
+ .
+ .
+
+ dafus_c ( sum, nd, ni, dc, ic );
+ begin = ic[4];
+ end = ic[5];
+
+ dafrda_c ( handle, begin, begin+10, epochs );
+
+ for ( i = 0; i < 10; i++ )
+ {
+ if ( ( et > epochs[i] )
+ && ( et < epochs[i+1] ) )
+ {
+ offset = ic[4] + 11 + (i - 1) * 8;
+ dafrda_c ( handle, offset+1, offset+8, elements );
+ return;
+ }
+ }
+
+
+-Restrictions
+
+ 1) This routine is deprecated. See the routines dafgda_c and
+ dafgsr_c.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ F.S. Turner (JPL)
+ R.E. Thurman (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.3, 19-MAY-2010 (BVS)
+
+ Index line now states that this routine is deprecated.
+
+ -CSPICE Version 1.0.2, 23-JAN-2008 (EDW)
+
+ Removed a spurious and unneeded "-Declarations"
+ tag. The tag's presence prevented the HTML API doc
+ script from parsing the function description.
+
+ -CSPICE Version 1.0.1, 27-OCT-2003 (NJB) (FST)
+
+ The header now states that this routine is deprecated.
+ The Exceptions header section has been extended.
+ Minor additional header updates were made.
+
+ -CSPICE Version 1.0.0, 14-DEC-1999 (NJB) (RET) (IMU) (WLT)
+
+-Index_Entries
+
+ DEPRECATED read data from daf address
+
+-&
+*/
+
+{ /* Begin dafrda_c */
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafrda_c" );
+
+ dafrda_ ( ( integer * ) &handle,
+ ( integer * ) &begin,
+ ( integer * ) &end,
+ ( doublereal * ) data );
+
+ chkout_c ( "dafrda_c" );
+
+} /* End of dafrda_c */
+
diff --git a/ext/spice/src/cspice/dafrfr.c b/ext/spice/src/cspice/dafrfr.c
new file mode 100644
index 0000000000..e968eee8eb
--- /dev/null
+++ b/ext/spice/src/cspice/dafrfr.c
@@ -0,0 +1,280 @@
+/* dafrfr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DAFRFR ( DAF, read file record ) */
+/* Subroutine */ int dafrfr_(integer *handle, integer *nd, integer *ni, char *
+ ifname, integer *fward, integer *bward, integer *free, ftnlen
+ ifname_len)
+{
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ extern /* Subroutine */ int zzdafgfr_(integer *, char *, integer *,
+ integer *, char *, integer *, integer *, integer *, logical *,
+ ftnlen, ftnlen), chkin_(char *, ftnlen);
+ logical found;
+ extern logical failed_(void);
+ extern /* Subroutine */ int dafsih_(integer *, char *, ftnlen);
+ char idword[8];
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Read the contents of the file record of a DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of an open DAF file. */
+/* ND O Number of double precision components in summaries. */
+/* NI O Number of integer components in summaries. */
+/* IFNAME O Internal file name. */
+/* FWARD O Forward list pointer. */
+/* BWARD O Backward list pointer. */
+/* FREE O Free address pointer. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle assigned to a DAF file opened for */
+/* reading. */
+
+/* $ Detailed_Output */
+
+/* ND, */
+/* NI are the numbers of double precision and integer */
+/* components, respectively, in each array summary in */
+/* the specified file. */
+
+/* IFNAME is the internal file name stored in the first */
+/* (or file) record of the specified file. */
+
+/* FWARD is the forward list pointer. This points to the */
+/* first summary record in the file. (Records between */
+/* the first record and the first summary record are */
+/* reserved when the file is created, and are invisible */
+/* to DAF routines.) */
+
+/* BWARD is the backward list pointer. This points */
+/* to the final summary record in the file. */
+
+/* FREE is the free address pointer. This contains the */
+/* first free address in the file. (That is, the */
+/* initial address of the next array to be added */
+/* to the file.) */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the handle passed to this routine is not the handle of an */
+/* open DAF file, the error will be signaled by a routine called */
+/* by this routine. */
+
+/* 2) If the specified DAF file is not open for read access, the */
+/* error will be diagnosed by a routine called by this routine. */
+
+/* 3) If the specified record cannot (for some reason) be read, */
+/* the error SPICE(DAFFRNOTFOUND) is signaled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The file record of a DAF is the only record that contains */
+/* any global information about the file. This record is created */
+/* when the file is created, and is updated only when new arrays */
+/* are added. */
+
+/* Like character records, file records are not buffered. */
+
+/* $ Examples */
+
+/* In the following example, the value of the forward list */
+/* pointer is examined in order to determine the number of */
+/* reserved records in the DAF. These records are then read */
+/* and the contents printed to the screen. */
+
+/* CALL DAFRFR ( HANDLE, ND, NI, IFNAME, FWARD, BWARD, FREE ) */
+/* CALL DAFHLU ( HANDLE, UNIT ) */
+
+/* DO I = 2, FWARD - 1 */
+/* READ (UNIT,REC=I) PRIVATE(1:1000) */
+/* WRITE (*,*) PRIVATE(1:1000) */
+/* END DO */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.1.0, 30-DEC-2009 (EDW) */
+
+/* Expanded DAFFRNOTFOUND error message to identify the file */
+/* handle corresponding to the error condition. */
+
+/* Reordered header sections to conform to SPICE format. */
+/* Merged the Revisions sections, now deleted, with Version. */
+
+/* - SPICELIB Version 3.0.0, 16-NOV-2001 (FST) */
+
+/* Updated this routine to utilize interfaces built on */
+/* the new handle manager to perform I/O operations. */
+
+/* This routine now utilizes ZZDAFGFR to retrieve information */
+/* from the file record. As this private interface takes a */
+/* handle and performs the necessary logical unit to handle */
+/* mapping, the call to DAFHLU was removed. The DAFSIH call */
+/* remains, since this insures that HANDLE is known to DAFAH. */
+/* C */
+/* - SPICELIB Version 2.0.0, 04-OCT-1993 (KRG) */
+
+/* The error SPICE(DAFNOIDWORD) is no longer signaled by this */
+/* routine. The reason for this is that if DAFSIH returns OK then */
+/* the handle passed to this routine is indeed a valid DAF file */
+/* handle, otherwise the error is diagnosed by DAFSIH. */
+
+/* Added a call to DAFSIH to signal an invalid handle and a test */
+/* of FAILED () after it. This is to make sure that the DAF file */
+/* is open for reading. If this call succeeds, we know that we */
+/* have a valid DAF handle, so there is no need to check FAILED */
+/* after the call to DAFHLU. */
+
+/* The variable name DAFWRD was changed to IDWORD. */
+
+/* Added two new exceptions to the $ Exceptions section: 1 and 2. */
+/* The remaining exception (3) was already present. The exceptions */
+/* that were added are not new, but are being documented for the */
+/* first time. */
+
+
+/* - SPICELIB Version 1.0.3, 6-OCT-1992 (HAN) */
+
+/* Corrected a typo in the Brief_I/O section. ND was listed */
+/* twice as an input, and NI was not listed. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read daf file record */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local Parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFRFR", (ftnlen)6);
+ }
+
+/* Do some initializations */
+
+ s_copy(idword, " ", (ftnlen)8, (ftnlen)1);
+
+/* Check to be sure that HANDLE is attached to a file that is open */
+/* with read access. If the call fails, check out and return. */
+
+ dafsih_(handle, "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DAFRFR", (ftnlen)6);
+ return 0;
+ }
+
+/* Retrieve all but the internal file name directly from the */
+/* file record. Read the internal file name into a temporary */
+/* string, to be sure of the length. Check FOUND. */
+
+ zzdafgfr_(handle, idword, nd, ni, ifname, fward, bward, free, &found, (
+ ftnlen)8, ifname_len);
+ if (! found) {
+ setmsg_("File record not found for file handle #1. Check if program "
+ "code uses handle #2 for a read or write operation.", (ftnlen)
+ 109);
+ errint_("#1", handle, (ftnlen)2);
+ errint_("#2", handle, (ftnlen)2);
+ sigerr_("SPICE(DAFFRNOTFOUND)", (ftnlen)20);
+ chkout_("DAFRFR", (ftnlen)6);
+ return 0;
+ }
+ chkout_("DAFRFR", (ftnlen)6);
+ return 0;
+} /* dafrfr_ */
+
diff --git a/ext/spice/src/cspice/dafrfr_c.c b/ext/spice/src/cspice/dafrfr_c.c
new file mode 100644
index 0000000000..455ab4e0f3
--- /dev/null
+++ b/ext/spice/src/cspice/dafrfr_c.c
@@ -0,0 +1,228 @@
+/*
+
+-Procedure dafrfr_c ( DAF, read file record )
+
+-Abstract
+
+ Read the contents of the file record of a DAF.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+
+ void dafrfr_c ( SpiceInt handle,
+ SpiceInt lenout,
+ SpiceInt * nd,
+ SpiceInt * ni,
+ SpiceChar * ifname,
+ SpiceInt * fward,
+ SpiceInt * bward,
+ SpiceInt * free )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of an open DAF file.
+ lenout I Available room in the output string `ifname'.
+ nd O Number of double precision components in summaries.
+ ni O Number of integer components in summaries.
+ ifname O Internal file name.
+ fward O Forward list pointer.
+ bward O Backward list pointer.
+ free O Free address pointer.
+
+-Detailed_Input
+
+ handle is the handle assigned to a DAF file opened for
+ reading.
+
+ lenout is the maximum number of characters that can be
+ accommodated in the output string `ifname'. This count
+ includes room for the terminating null character.
+ DAF internal file names may contain up to 60
+ characters, so lenout normally should be set to 61.
+
+-Detailed_Output
+
+ nd,
+ ni are the numbers of double precision and integer
+ components, respectively, in each array summary in
+ the specified file.
+
+ ifname is the internal file name stored in the first
+ (or file) record of the specified file. `ifname'
+ should be declared with the length specified by
+ `lenout'.
+
+ fward is the forward list pointer. This points to the
+ first summary record in the file. (Records between
+ the first record and the first summary record are
+ reserved when the file is created, and are invisible
+ to DAF routines.)
+
+ DAF list pointers are actually Fortran record numbers,
+ and as such, start at one.
+
+ bward is the backward list pointer. This points
+ to the final summary record in the file.
+
+
+ free is the free address pointer. This contains the
+ first free address in the file. (That is, the
+ initial address of the next array to be added
+ to the file.)
+
+ `free' is a DAF address; for compatiblity with
+ SPICELIB, the range of DAF addresses starts at 1.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the handle passed to this routine is not the handle of an
+ open DAF file, the error will be signaled by a routine called
+ by this routine.
+
+ 2) If the specified DAF file is not open for read access, the
+ error will be diagnosed by a routine called by this routine.
+
+ 3) If the specified record cannot (for some reason) be read,
+ the error SPICE(DAFFRNOTFOUND) is signaled.
+
+-Files
+
+ The input `handle' should refer to a DAF file open for read
+ or write access.
+
+-Particulars
+
+ The file record of a DAF is the only record that contains
+ any global information about the file. This record is created
+ when the file is created, and is updated only when new arrays
+ are added.
+
+ Like character records, file records are not buffered.
+
+-Examples
+
+ In the following example, the file record of a DAF is read
+ to determine the first free address in the file.
+
+ #include
+ #include "SpiceUsr.h"
+
+ int main ( int argc, char ** argv )
+ {
+ #define IFNLEN 61
+
+ SpiceChar ifname[IFNLEN];
+
+ SpiceInt bward;
+ SpiceInt free;
+ SpiceInt fward;
+ SpiceInt handle;
+ SpiceInt nd;
+ SpiceInt ni;
+
+ dafopr_c ( argv[1], &handle );
+
+ dafrfr_c ( handle, IFNLEN, &nd, &ni, ifname, &fward, &bward, &free );
+
+ printf ( "First free DAF address is %ld.\n", free );
+
+ return ( 0 );
+ }
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 17-JUN-2009 (NJB) (KRG) (IMU)
+
+-Index_Entries
+
+ read daf file record
+
+-&
+*/
+
+{ /* Begin dafrfr_c */
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafrfr_c" );
+
+ dafrfr_ ( (integer *) &handle,
+ (integer *) nd,
+ (integer *) ni,
+ (char *) ifname,
+ (integer *) fward,
+ (integer *) bward,
+ (integer *) free,
+ (ftnlen ) lenout-1 );
+
+ /*
+ Convert the internal file name to a C-style string.
+ */
+ F2C_ConvertStr ( lenout, ifname );
+
+
+ chkout_c ( "dafrfr_c" );
+
+} /* End dafrfr_c */
+
diff --git a/ext/spice/src/cspice/dafrrr.c b/ext/spice/src/cspice/dafrrr.c
new file mode 100644
index 0000000000..42c752c219
--- /dev/null
+++ b/ext/spice/src/cspice/dafrrr.c
@@ -0,0 +1,392 @@
+/* dafrrr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static integer c__128 = 128;
+
+/* $Procedure DAFRRR ( DAF, remove reserved records ) */
+/* Subroutine */ int dafrrr_(integer *handle, integer *resv)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ char crec[1000];
+ doublereal drec[128];
+ integer decr, free, word, next;
+ extern /* Subroutine */ int dafgs_(doublereal *), chkin_(char *, ftnlen),
+ dafps_(integer *, integer *, doublereal *, integer *, doublereal *
+ );
+ integer bward;
+ extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
+ doublereal *, integer *);
+ integer fward;
+ extern /* Subroutine */ int dafws_(doublereal *);
+ integer recno;
+ logical found;
+ doublereal dc[125];
+ integer ic[250];
+ extern /* Subroutine */ int daffna_(logical *);
+ integer nd;
+ extern logical failed_(void);
+ extern /* Subroutine */ int dafbfs_(integer *);
+ integer begblk, ni;
+ extern /* Subroutine */ int dafsih_(integer *, char *, ftnlen);
+ char ifname[60];
+ integer endblk;
+ extern /* Subroutine */ int dafrcr_(integer *, integer *, char *, ftnlen),
+ dafrdr_(integer *, integer *, integer *, integer *, doublereal *,
+ logical *), dafrfr_(integer *, integer *, integer *, char *,
+ integer *, integer *, integer *, ftnlen), dafarw_(integer *,
+ integer *, integer *), dafwcr_(integer *, integer *, char *,
+ ftnlen), dafwdr_(integer *, integer *, doublereal *), dafwfr_(
+ integer *, integer *, integer *, char *, integer *, integer *,
+ integer *, ftnlen);
+ integer remove;
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ extern logical return_(void);
+ doublereal sum[125];
+
+/* $ Abstract */
+
+/* Remove a specified number of reserved records from a Double */
+/* Precision Array File (DAF). */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAF, opened for writing. */
+/* RESV I Number of records to remove. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a DAF that has been */
+/* opened with write access. */
+
+/* RESV is the number of reserved records to be removed */
+/* from the specified file. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If RESV is less than one, the file is not changed. */
+
+/* 2) If RESV is greater than the number of reserved records in the */
+/* file, all of the reserved records are removed. */
+
+/* $ Files */
+
+/* See argument HANDLE. */
+
+/* $ Particulars */
+
+/* Normally, the reserved records in an array file are reserved */
+/* when the file is created. However, it may occasionally become */
+/* desirable to remove reserved records---when their contents are */
+/* significantly reduced, for example. */
+
+/* The records nearest the end of the file are removed. Note */
+/* that the physical size of the file is not reduced when reserved */
+/* records are removed. */
+
+/* $ Examples */
+
+/* For the following call to DAFRRR, assume that HANDLE is the file */
+/* handle for a DAF file that has been opened for write access, and */
+/* that the DAF file already contains 12 reserved records (located in */
+/* records 2-13 of the physical file). */
+
+/* CALL DAFRRR ( HANDLE, 7 ) */
+
+/* After this call to DAFRRR, the number of reserved records has been */
+/* decreased by 7, leaving only the first five of the original */
+/* reserved records, physical records 2-6. */
+
+/* $ Restrictions */
+
+/* 1) This routine will only remove reserve records from DAFs open */
+/* for write. These files are implicitly of the native binary */
+/* file format. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.2.0, 16-NOV-2001 (FST) */
+
+/* Added a call to DAFSIH to prevent this routine from */
+/* attempting to write to non-native binary file formats. */
+/* This will provide a more useful error diagnostic with */
+/* little impact on performance. */
+
+/* - SPICELIB Version 1.1.0, 30-SEP-1993 (KRG) */
+
+/* Detailed_Input and Examples section of the header were */
+/* modified. */
+
+/* Added calls to the FORTRAN intrinsic functions INT and */
+/* DBLE in the code that updates the summary record. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 18-JUL-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* remove daf reserved records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 30-SEP-1993 (KRG) */
+
+/* $ Detailed_Input section was modified. References to any */
+/* specific routines by name as a method for opening a DAF file */
+/* for write access were removed. The assumption is that a person */
+/* using DAF files would already know something about opening and */
+/* closing the files. */
+
+/* $ Examples section was modified. References to any specific */
+/* routines by name as a method for opening a DAF file for writing */
+/* were removed, and the example was reworded in such a way that */
+/* the use of the subroutine remained clear. */
+
+/* Added calls to the INT intrinsic function to convert a DP */
+/* number to an integer before assigning it to NEXT or ENDBLK, */
+/* both of which are integer variables. Also added calls to INT */
+/* in IF statements where comparisons were made between DP numbers */
+/* and INTEGERs, when integral values were actually being */
+/* compared. */
+
+/* Added calls to the intrinsic function DBLE to convert an */
+/* integer, REMOVE, into a DP number when doing some arithmetic. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* IFNLEN is the length of a DAF internal file name. */
+
+
+/* WPR is the maximum number of double precision */
+/* numbers per record. WPR stands for words */
+/* per record. */
+
+
+/* MAXD, are the maximum number of double precision */
+/* MAXI, numbers, integers, and characters, respectively, */
+/* MAXC not including space reserved for control information. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFRRR", (ftnlen)6);
+ }
+
+/* Before proceeding any further, check that the DAF associated */
+/* with HANDLE is available for write access. */
+
+ dafsih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DAFRRR", (ftnlen)6);
+ return 0;
+ }
+
+/* Get the contents of the file record. If it fails, then just check */
+/* out and return, as an appropriate error message should have */
+/* already been set. */
+
+ dafrfr_(handle, &nd, &ni, ifname, &fward, &bward, &free, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DAFRRR", (ftnlen)6);
+ return 0;
+ }
+
+/* Don't remove more than the current number of reserved records! */
+/* If there are none, check out. */
+
+/* Computing MIN */
+ i__1 = *resv, i__2 = fward - 2;
+ remove = min(i__1,i__2);
+ if (remove < 1) {
+ chkout_("DAFRRR", (ftnlen)6);
+ return 0;
+ }
+
+/* Okay, here's the plan. We are just going to move records */
+/* forward, starting with the first summary record in the file */
+/* and ending with the last data record. */
+
+/* After everything has been moved, the initial and final */
+/* addresses of all the arrays have to be decremented by the */
+/* same amount: the number of words per record (128) times */
+/* the number of records removed. */
+
+ decr = remove << 7;
+
+/* Records will be moved in `blocks', where each block contains */
+
+/* -- a summary record */
+
+/* -- a name record */
+
+/* -- one or more data records */
+
+/* Most blocks lie between one summary record and the next. */
+/* The final block lies between the final summary record and */
+/* whatever data record contains the first free address. */
+
+/* BEGBLK is initially the first summary record location. */
+
+ begblk = fward;
+ while(begblk > 0 && ! failed_()) {
+
+/* Move the summary record first. The location of the next */
+/* summary record determines the end of this block, and the */
+/* beginning of the next. */
+
+/* Be sure to adjust the forward and backward pointers; */
+/* otherwise, we won't be able to find the summaries again. */
+
+ recno = begblk;
+ dafrdr_(handle, &recno, &c__1, &c__128, drec, &found);
+ if ((integer) drec[0] > 0) {
+ endblk = (integer) drec[0] - 1;
+ next = (integer) drec[0];
+ } else {
+ dafarw_(&free, &endblk, &word);
+ next = 0;
+ }
+ if ((integer) drec[0] > 0) {
+ drec[0] -= (doublereal) remove;
+ }
+ if ((integer) drec[1] > 0) {
+ drec[1] -= (doublereal) remove;
+ }
+ i__1 = recno - remove;
+ dafwdr_(handle, &i__1, drec);
+
+/* Then the name record. */
+
+ recno = begblk + 1;
+ dafrcr_(handle, &recno, crec, (ftnlen)1000);
+ i__1 = recno - remove;
+ dafwcr_(handle, &i__1, crec, (ftnlen)1000);
+
+/* Finally, the data records. */
+
+ i__1 = endblk;
+ for (recno = begblk + 2; recno <= i__1; ++recno) {
+ dafrdr_(handle, &recno, &c__1, &c__128, drec, &found);
+ i__2 = recno - remove;
+ dafwdr_(handle, &i__2, drec);
+ }
+
+/* Start the next block, if one exists. */
+
+ begblk = next;
+ }
+
+/* Rewrite the file record, to reflect the new organization of */
+/* the file. */
+
+ fward -= remove;
+ bward -= remove;
+ free -= decr;
+ dafwfr_(handle, &nd, &ni, ifname, &fward, &bward, &free, (ftnlen)60);
+
+/* Get the summary for each array, decrement the addresses (stored */
+/* in the final two integer components), and replace the summary. */
+
+ dafbfs_(handle);
+ daffna_(&found);
+ while(found && ! failed_()) {
+ dafgs_(sum);
+ dafus_(sum, &nd, &ni, dc, ic);
+ ic[(i__1 = ni - 2) < 250 && 0 <= i__1 ? i__1 : s_rnge("ic", i__1,
+ "dafrrr_", (ftnlen)393)] = ic[(i__2 = ni - 2) < 250 && 0 <=
+ i__2 ? i__2 : s_rnge("ic", i__2, "dafrrr_", (ftnlen)393)] -
+ decr;
+ ic[(i__1 = ni - 1) < 250 && 0 <= i__1 ? i__1 : s_rnge("ic", i__1,
+ "dafrrr_", (ftnlen)394)] = ic[(i__2 = ni - 1) < 250 && 0 <=
+ i__2 ? i__2 : s_rnge("ic", i__2, "dafrrr_", (ftnlen)394)] -
+ decr;
+ dafps_(&nd, &ni, dc, ic, sum);
+ dafws_(sum);
+ daffna_(&found);
+ }
+ chkout_("DAFRRR", (ftnlen)6);
+ return 0;
+} /* dafrrr_ */
+
diff --git a/ext/spice/src/cspice/dafrs_c.c b/ext/spice/src/cspice/dafrs_c.c
new file mode 100644
index 0000000000..f498680963
--- /dev/null
+++ b/ext/spice/src/cspice/dafrs_c.c
@@ -0,0 +1,228 @@
+/*
+
+-Procedure dafrs_c ( DAF, replace summary )
+
+-Abstract
+
+ Change the summary for the current array in the current DAF.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZim.h"
+ #undef dafrs_c
+
+
+ void dafrs_c ( ConstSpiceDouble * sum )
+
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ sum I New summary for current array.
+
+-Detailed_Input
+
+ sum is the new summary for the current array. This
+ replaces the existing summary. However, the addresses
+ (the final two integer components) of the original
+ summary are not changed.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Files
+
+ This routine operates on a DAF opened for write access. A search
+ must be in progress at the time this routine is called; this
+ routine replaces the descriptor of the current segment.
+
+-Exceptions
+
+ 1) If this routine is called when no search is in progress in the
+ the current DAF, the error SPICE(DAFNOSEARCH) is signaled.
+
+ 2) If the DAF containing the `current' array has actually been
+ closed, the error will be diagnosed by routines called by
+ this routine.
+
+ 3) If the DAF containing the `current' array is not open for
+ writing, the error will be diagnosed by routines called by
+ this routine.
+
+ 4) If no array is current in the current DAF, the error
+ SPICE(NOCURRENTARRAY) is signaled. There is no current
+ array when a search is started by dafbfs_c or dafbbs_c, but no
+ calls to daffna_c or dafbna_ have been made yet, or whenever
+ daffna_c or daffpa_c return the value SPICEFALSE in the `found'
+ argument.
+
+-Particulars
+
+ See SPICELIB umbrella routine DAFFA.
+
+-Examples
+
+ 1) Replace the body ID code -999 with -1999 in every descriptor
+ of an SPK file.
+
+
+ #include
+
+ int main ( int argc, char **argv )
+ {
+ #define ND 2
+ #define NI 6
+ #define DSCSIZ 5
+ #define NEWCODE ( -1999 )
+ #define OLDCODE ( -999 )
+
+ SpiceBoolean found;
+
+ SpiceInt handle;
+ SpiceInt ic [ NI ];
+
+ SpiceDouble dc [ ND ];
+ SpiceDouble sum [ DSCSIZ ];
+
+ /.
+ Open for writing the SPK file specified on the command line.
+ ./
+ dafopw_c ( argv[1], &handle );
+
+ /.
+ Search the file in forward order.
+ ./
+ dafbfs_c ( handle );
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ /.
+ Fetch and unpack the descriptor (aka summary)
+ of the current segment.
+ ./
+ dafgs_c ( sum );
+ dafus_c ( sum, ND, NI, dc, ic );
+
+ /.
+ Replace ID codes if necessary.
+ ./
+ if ( ic[0] == OLDCODE )
+ {
+ ic[0] = NEWCODE;
+ }
+ if ( ic[1] == OLDCODE )
+ {
+ ic[1] = NEWCODE;
+ }
+
+ /.
+ Re-pack the descriptor; replace the descriptor
+ in the file.
+ ./
+ dafps_c ( ND, NI, dc, ic, sum );
+
+ dafrs_c ( sum );
+
+ /.
+ Find the next segment.
+ ./
+ daffna_c ( &found );
+ }
+
+ /.
+ Close the file.
+ ./
+ dafcls_c ( handle );
+
+ return ( 0 );
+ }
+
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 23-NOV-2004 (NJB)
+
+-Index_Entries
+
+ replace daf summary
+
+-&
+*/
+
+{ /* Begin dafrs_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafrs_c" );
+
+ /*
+ Not much to it.
+ */
+ dafrs_ ( (doublereal *) sum );
+
+
+ chkout_c ( "dafrs_c" );
+
+} /* End dafrs_c */
diff --git a/ext/spice/src/cspice/dafrwa.c b/ext/spice/src/cspice/dafrwa.c
new file mode 100644
index 0000000000..5f0b86d874
--- /dev/null
+++ b/ext/spice/src/cspice/dafrwa.c
@@ -0,0 +1,316 @@
+/* dafrwa.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DAFRWA ( DAF, record/word to address ) */
+/* Subroutine */ int dafrwa_0_(int n__, integer *recno, integer *wordno,
+ integer *addr__)
+{
+ extern /* Subroutine */ int chkin_(char *, ftnlen), sigerr_(char *,
+ ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen),
+ errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Convert a record/word pair to its equivalent address within */
+/* a DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* RECNO, */
+/* WORDNO I Record, word numbers of a location within DAF. */
+/* ADDR O Corresponding address. */
+
+/* $ Detailed_Input */
+
+/* RECNO, */
+/* WORDNO are the record and word numbers of an arbitrary */
+/* location within a DAF. */
+
+/* $ Detailed_Output */
+
+/* ADDR is the corresponding address within the DAF. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If either RECNO or WORDNO is zero or negative, the error */
+/* SPICE(DAFNOSUCHADDR) is signalled. */
+
+/* $ Particulars */
+
+/* To the user, the data in a DAF appear to be a contiguous */
+/* collection of double precision numbers, each of which has an */
+/* address. To the DAF software, however, the data appear to be */
+/* a collection of records, each containing 128 double precision */
+/* words. The routines DAFARW and DAFRWA translate between these */
+/* two representations. */
+
+/* $ Examples */
+
+/* Routines DAFRDA and DAFWDA illustrate the use of DAFARW and */
+/* DAFRWA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* record/word to daf address */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Standard SPICE error handling. */
+
+ switch(n__) {
+ case 1: goto L_dafarw;
+ }
+
+ if (return_()) {
+ return 0;
+ } else if (*recno <= 0 || *wordno <= 0) {
+ chkin_("DAFRWA", (ftnlen)6);
+ setmsg_("No address for record #, word #.", (ftnlen)32);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", wordno, (ftnlen)1);
+ sigerr_("SPICE(DAFNOSUCHADDR)", (ftnlen)20);
+ chkout_("DAFRWA", (ftnlen)6);
+ return 0;
+ }
+
+/* If the record and word numbers are legal, the computation is */
+/* straightforward. */
+
+ *addr__ = *wordno + (*recno - 1 << 7);
+ return 0;
+/* $Procedure DAFARW ( DAF, address to record/word ) */
+
+L_dafarw:
+/* $ Abstract */
+
+/* Convert an address within a DAF to its equivalent */
+/* record/word representation. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER ADDR */
+/* INTEGER RECNO */
+/* INTEGER WORDNO */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* ADDR I Address within DAF. */
+/* RECNO, */
+/* WORDNO O Corresponding record, word numbers. */
+
+/* $ Detailed_Input */
+
+/* ADDR is an arbitrary address within a DAF. */
+
+/* $ Detailed_Output */
+
+/* RECNO, */
+/* WORDNO are the corresponding record and word numbers */
+/* within the DAF. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If ADDR is zero or negative, the error SPICE(DAFNOSUCHADDR) */
+/* is signalled. */
+
+/* $ Particulars */
+
+/* To the user, the data in a DAF appear to be a contiguous */
+/* collection of double precision numbers, each of which has an */
+/* address. To the DAF software, however, the data appear to be */
+/* a collection of records, each containing 128 double precision */
+/* words. The routines DAFARW and DAFRWA translate between these */
+/* two representations. */
+
+/* $ Examples */
+
+/* Routines DAFRDA and DAFWDA illustrate the use of DAFARW and */
+/* DAFRWA. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* daf address to record/word */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else if (*addr__ <= 0) {
+ chkin_("DAFARW", (ftnlen)6);
+ setmsg_("No record, word for address #.", (ftnlen)30);
+ errint_("#", addr__, (ftnlen)1);
+ sigerr_("SPICE(DAFNOSUCHADDR)", (ftnlen)20);
+ chkout_("DAFARW", (ftnlen)6);
+ return 0;
+ }
+
+/* If the address is legal, the computation is straightforward. */
+
+ *recno = (*addr__ - 1) / 128 + 1;
+ *wordno = *addr__ - (*recno - 1 << 7);
+ return 0;
+} /* dafrwa_ */
+
+/* Subroutine */ int dafrwa_(integer *recno, integer *wordno, integer *addr__)
+{
+ return dafrwa_0_(0, recno, wordno, addr__);
+ }
+
+/* Subroutine */ int dafarw_(integer *addr__, integer *recno, integer *wordno)
+{
+ return dafrwa_0_(1, recno, wordno, addr__);
+ }
+
diff --git a/ext/spice/src/cspice/dafrwd.c b/ext/spice/src/cspice/dafrwd.c
new file mode 100644
index 0000000000..c27b64a24e
--- /dev/null
+++ b/ext/spice/src/cspice/dafrwd.c
@@ -0,0 +1,2304 @@
+/* dafrwd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static logical c_false = FALSE_;
+static integer c__128 = 128;
+
+/* $Procedure DAFRWD ( DAF, read, write double precision ) */
+/* Subroutine */ int dafrwd_0_(int n__, integer *handle, integer *recno,
+ integer *begin, integer *end, doublereal *drec, doublereal *data,
+ logical *found, integer *reads, integer *reqs)
+{
+ /* Initialized data */
+
+ static integer rbhan[100] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0 };
+ static integer rbrec[100] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0 };
+ static integer rbreq[100] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0 };
+ static doublereal rbdat[12800] /* was [128][100] */ = { 0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
+ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0. };
+ static integer rbnbr = 1;
+ static integer nread = 0;
+ static integer nreq = 0;
+
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer), s_wdue(cilist *),
+ do_uio(integer *, char *, ftnlen), e_wdue(void);
+
+ /* Local variables */
+ logical done;
+ integer unit;
+ extern /* Subroutine */ int zzdafgdr_(integer *, integer *, doublereal *,
+ logical *), zzddhrcm_(integer *, integer *, integer *), zzdafgsr_(
+ integer *, integer *, integer *, integer *, doublereal *, logical
+ *), zzddhhlu_(integer *, char *, logical *, integer *, ftnlen),
+ zzddhisn_(integer *, logical *, logical *);
+ integer b, e;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), minai_(integer *,
+ integer *, integer *, integer *), moved_(doublereal *, integer *,
+ doublereal *);
+ integer count, nd;
+ extern logical failed_(void);
+ integer ni;
+ extern /* Subroutine */ int dafhsf_(integer *, integer *, integer *);
+ logical locfnd;
+ integer bufloc;
+ extern /* Subroutine */ int errhan_(char *, integer *, ftnlen);
+ integer minval;
+ logical native;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen);
+ logical stored;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+ /* Fortran I/O blocks */
+ static cilist io___21 = { 1, 0, 0, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Read, write, and rewrite double precision records to and */
+/* from DAFs. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Entry */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAFGDR. DAFGSR, DAFRDR (Obsolete), DAFWDR */
+/* RECNO I DAFGDR. DAFGSR, DAFRDR (Obsolete), DAFWDR */
+/* BEGIN I DAFGDR. DAFGSR, DAFRDR (Obsolete) */
+/* END I DAFGDR. DAFGSR, DAFRDR (Obsolete) */
+/* DREC I DAFWDR */
+/* DATA O DAFGDR. DAFGSR, DAFRDR (Obsolete) */
+/* FOUND O DAFGDR. DAFGSR, DAFRDR (Obsolete) */
+/* READS O DAFNRR */
+/* REQS O DAFNRR */
+/* RBSIZE P DAFGDR. DAFGSR, DAFRDR (Obsolete), DAFWDR, DAFNRR */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a DAF. */
+
+/* RECNO is the record number of a double precision record */
+/* within a DAF to be read or written. */
+
+/* BEGIN is the first in word in a double precision record */
+/* to be read. */
+
+/* END is the last in word in a double precision record */
+/* to be read. */
+
+/* DREC contains a single double precision record, to be */
+/* written to the specified DAF. */
+
+/* $ Detailed_Output */
+
+/* DATA contains a portion of a single double precision */
+/* record, read from the specified DAF. */
+
+/* FOUND is true when the specified record is found, and is */
+/* false otherwise. */
+
+/* READS, */
+/* REQS are the number of physical reads and the number */
+/* of requests processed by DAFRDR during the current */
+/* execution of the calling program. */
+
+
+/* $ Parameters */
+
+/* RBSIZE is the size of the record buffer maintained by */
+/* DAFRWD. In effect, RBSIZE is the maximum number */
+/* of records that can be stored (buffered) at any */
+/* one time. Higher values of RBSIZE reduce the */
+/* amount of time spent reading from disk at the */
+/* cost of increasing the amount of space required */
+/* by the calling program. The optimal value of */
+/* RBSIZE may differ from environment to environment, */
+/* and may even vary from application to application. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If DAFRWD is called directly, the error SPICE(BOGUSENTRY) */
+/* is signalled. */
+
+/* 2) See entry points DAFGDR, DAFGSR, DAFRDR, DAFWDR, and DAFNRR */
+/* for exceptions specific to those entry points. */
+
+/* $ Particulars */
+
+/* DAFRWD serves as an umbrella, allowing data to be shared by its */
+/* entry points: */
+
+/* DAFGDR Read double precision record. */
+
+/* DAFGSR Read summary/descriptor record. */
+
+/* DAFRDR Read double precision record. (Obsolete, use */
+/* DAFGDR) */
+
+/* DAFWDR Write double precision record. */
+
+/* DAFNRR Number of reads, requests. */
+
+/* DAFGDR, DAFGSR, and DAFWDR are the only approved means for */
+/* reading and writing double precision records to and from DAFs. */
+/* DAFRDR continues to function, but only on files of the native */
+/* binary format. They keep track of which records have been read */
+/* most recently, and of which records have been requested most */
+/* often, in order to minimize the amount of time spent actually */
+/* reading from external storage. */
+
+/* DAFNRR may be used at any time during the execution of a */
+/* program to determine the number of requests that have been */
+/* processed, and the number of actual read operations needed */
+/* to fulfill those requests. Ideally, the ratio of reads to */
+/* requests should approach zero. In the worst case, the ratio */
+/* approaches one. The ratio is related to the size of the */
+/* record buffer, which controlled by parameter RBSIZE. The */
+/* results returned by DAFNRR may be used to determine the */
+/* optimal value of RBSIZE empirically. */
+
+/* All data records in a DAF can be treated as an undifferentiated */
+/* collection of double precision numbers. Summary records must */
+/* be read using the DAFGSR interface, but their contents are */
+/* properly buffered in a single buffer with the data records. */
+/* No special buffers are required for each new data type, or to */
+/* keep summary records separate from data records. */
+
+/* $ Examples */
+
+/* See entry points DAFGDR, DAFGSR, DAFRDR, DAFWDR, and DAFNRR */
+/* for examples specific to those entry points. */
+
+/* $ Restrictions */
+
+/* 1) An integer overflow may occur if the number of requests */
+/* by a single program exceeds the maximum number that can */
+/* be stored in an integer variable. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* Added DAFGDR and DAFGSR entry points to allow read access */
+/* to DAFs utilizing non-native, but supported, binary file */
+/* formats. */
+
+/* DAFRDR was phased into obsolescence. */
+
+/* The umbrella no longer suffers from integer overflow if */
+/* a sufficient number of successful read requests are made. */
+
+/* DAFWDR no longer uses DAFHLU to retrieve a logical unit */
+/* for HANDLE. This call has been replaced with the handle */
+/* manager interface, which does not lock handles to their */
+/* logical units. */
+
+/* - SPICELIB Version 1.3.0, 24-MAR-2000 (WLT) */
+
+/* The loop in DAFRDR that moved buffered d.p.s into the output */
+/* array DATA was modified to use the routine MOVED. */
+
+/* - SPICELIB Version 1.2.0, 01-AUG-1997 (NJB) */
+
+/* Unnecessary CHKIN and CHKOUT calls were removed from entry */
+/* point DAFRDR. */
+
+/* - SPICELIB Version 1.1.0, 25-NOV-1992 (JML) */
+
+/* 1) In DAFRDR, the found flag is now set to false if the */
+/* call to DAFHLU fails. */
+
+/* 2) In the example code fragment in DAFRDR and DAFWDR, the */
+/* calling sequence to MOVED was corrected. */
+
+/* 3) In DAFRDR a variable name was changed. */
+
+/* 4) In DAFNRR a cut and paste error in the header was fixed. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read write d.p. daf */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* Updated this umbrella and its entry points in preparation */
+/* for DAF's utilization of the handle manager. DAFRDR is */
+/* obsolete, and will now signal errors when used to read */
+/* records from DAFs using non-native, binary file formats. */
+
+/* Two new entry points were added: DAFGDR and DAFGDR. These */
+/* are the translation-aware 'get data record' and 'get */
+/* summary record' routines that all new software developed */
+/* should utilize. */
+
+/* - SPICELIB Version 1.3.0, 24-MAR-2000 (WLT) */
+
+/* The loop in DAFRDR that moved buffered d.p.s into the output */
+/* array DATA was modified to use the routine MOVED. */
+
+/* - SPICELIB Version 1.2.0, 01-AUG-1997 (NJB) */
+
+/* Unnecessary CHKIN and CHKOUT calls were removed from entry */
+/* point DAFRDR. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+ /* Parameter adjustments */
+ if (drec) {
+ }
+ if (data) {
+ }
+
+ /* Function Body */
+ switch(n__) {
+ case 1: goto L_dafgdr;
+ case 2: goto L_dafgsr;
+ case 3: goto L_dafrdr;
+ case 4: goto L_dafwdr;
+ case 5: goto L_dafnrr;
+ }
+
+
+/* As double precision records are processed, they are stored in a */
+/* record buffer. (File and character records are not buffered.) */
+/* The user controls the number of records that may be stored at */
+/* any one time by setting the value of the paramater RBSIZE before */
+/* compiling the routine. */
+
+/* The record buffer contains one entry for each record that has */
+/* been read. */
+
+/* +----------+----------+----------+----------+ */
+/* | File Record Request Contents | */
+/* | Handle Number Number | */
+/* +----------+----------+----------+----------+ */
+/* | INT INT INT DP(128) | */
+/* +----------+----------+----------+----------+ */
+
+/* The request number is a counter that is incremented every time */
+/* a record is requested. When all the slots in the record buffer are */
+/* full, the least recently requested record (the one with the lowest */
+/* request number) is replaced by the new record. */
+
+/* In addition, a separate counter is used to keep track of the */
+/* number of actual file reads performed. It is possible to tune */
+/* the entire package by checking the read/request ratio for */
+/* any specific buffer configuration. */
+
+/* Note also that whenever a write operation fails, the affected */
+/* buffers (if any) should NOT be updated. */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFRWD", (ftnlen)6);
+ sigerr_("SPICE(BOGUSENTRY)", (ftnlen)17);
+ chkout_("DAFRWD", (ftnlen)6);
+ }
+ return 0;
+/* $Procedure DAFGDR ( DAF, get double precision record ) */
+
+L_dafgdr:
+/* $ Abstract */
+
+/* Read a portion of the contents of a double precision record in a */
+/* DAF file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* INTEGER BEGIN */
+/* INTEGER END */
+/* DOUBLE PRECISION DATA ( * ) */
+/* LOGICAL FOUND */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAF. */
+/* RECNO I Record number. */
+/* BEGIN I First word to read from record. */
+/* END I Last word to read from record. */
+/* DATA O Contents of record. */
+/* FOUND O True if record is found. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a DAF. */
+
+/* RECNO is the record number of a particular double precision */
+/* record within the DAF, whose contents are to be read. */
+
+/* BEGIN is the first word in the specified record to be */
+/* returned. */
+
+/* END is the final word in the specified record to be */
+/* returned. */
+
+/* $ Detailed_Output */
+
+/* DATA contains the specified portion (from BEGIN to END, */
+/* inclusize) of the specified record from the specified */
+/* file, specifically. */
+
+/* FOUND is true when the specified record is found, and is */
+/* false otherwise. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* None. */
+
+/* $ Particulars */
+
+/* DAFGDR checks the record buffer to see if the requested */
+/* record can be returned without actually reading it from */
+/* external storage. If not, it reads the record and stores */
+/* it in the buffer, typically removing another record from */
+/* the buffer as a result. */
+
+/* Once in the buffer, the specified portion of the record is */
+/* returned, using the following control loop. */
+
+/* J = 1 */
+/* DO I = MAX( 1, BEGIN ), MIN( 128, END ) */
+/* DATA( J ) = Buffered record ( I ) */
+/* J = J + 1 */
+/* END DO */
+
+/* Therefore bad values for BEGIN and END (BEGIN < 1, END < BEGIN, */
+/* etc.) are not signaled as errors, but result in the actions */
+/* implied by the above. */
+
+/* $ Examples */
+
+/* The following code fragment illustrates one way that DAFGDR */
+/* and DAFWDR can be used to update part of a double precision */
+/* record. If the record does not yet exist, we can assume that */
+/* it is filled with zeros. */
+
+/* CALL DAFGDR ( HANDLE, RECNO, 1, 128, DREC, FOUND ) */
+
+/* IF ( .NOT. FOUND ) THEN */
+/* CALL MOVED ( 0.D0, 128, DREC ) */
+/* END IF */
+
+/* DO I = FIRST, LAST */
+/* DREC(I) = NEW_VALUE(I) */
+/* END DO */
+
+/* CALL DAFWDR ( HANDLE, RECNO, DREC ) */
+
+/* Note that since only entire records may be written using DAFWDR, */
+/* the entire record needs to be read also. */
+
+/* $ Restrictions */
+
+/* 1) Bad values for BEGIN and END ( BEGIN < 1, END > 128, */
+/* END < BEGIN ) are not signalled as errors. The effects of */
+/* such assignments on the returned data are defined by the */
+/* following control structure: */
+
+/* J = 1 */
+/* DO I = MAX( 1, BEGIN ), MIN( 128, END ) */
+/* DATA( J ) = Buffered record ( I ) */
+/* J = J + 1 */
+/* END DO */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* F.S. Turner (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read daf d.p. record */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+
+/* Assume that the record will be found until proven otherwise. */
+
+ *found = TRUE_;
+
+/* First, find the record. */
+
+/* If the specified handle and record number match those of */
+/* a buffered record, determine the location of that record */
+/* within the buffer. */
+
+ bufloc = 0;
+ done = FALSE_;
+ stored = FALSE_;
+ while(! done) {
+ ++bufloc;
+ stored = *handle == rbhan[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("rbhan", i__1, "dafrwd_", (ftnlen)592)] && *
+ recno == rbrec[(i__2 = bufloc - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("rbrec", i__2, "dafrwd_", (ftnlen)592)];
+ done = stored || bufloc == rbnbr;
+ }
+
+/* If not, determine the location of the least recently requested */
+/* record (the one with the smallest request number). Get the unit */
+/* number for the file, and read the record into this location. */
+
+/* If an error occurs while reading the record, clear the entire */
+/* buffer entry in case the entry was corrupted by a partial read. */
+/* Otherwise, increment the number of reads performed so far. */
+
+ if (! stored) {
+ minai_(rbreq, &rbnbr, &minval, &bufloc);
+ zzdafgdr_(handle, recno, &rbdat[(i__1 = (bufloc << 7) - 128) < 12800
+ && 0 <= i__1 ? i__1 : s_rnge("rbdat", i__1, "dafrwd_", (
+ ftnlen)612)], &locfnd);
+
+/* If the call to ZZDAFGDR failed, or the record was not found, */
+/* then clean up. */
+
+ if (failed_() || ! locfnd) {
+ *found = FALSE_;
+ rbhan[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbhan", i__1, "dafrwd_", (ftnlen)620)] = 0;
+ rbrec[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbrec", i__1, "dafrwd_", (ftnlen)621)] = 0;
+ rbreq[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbreq", i__1, "dafrwd_", (ftnlen)622)] = 0;
+ } else {
+ ++nread;
+ rbhan[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbhan", i__1, "dafrwd_", (ftnlen)625)] = *handle;
+ rbrec[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbrec", i__1, "dafrwd_", (ftnlen)626)] = *recno;
+ if (rbnbr < 100) {
+ ++rbnbr;
+ }
+ }
+ }
+
+/* Whether previously stored or just read, the record is now in */
+/* the buffer. Return the specified portion directly, and increment */
+/* the corresponding request number. */
+
+ if (*found) {
+ b = max(1,*begin);
+ e = min(128,*end);
+ count = e - b + 1;
+ moved_(&rbdat[(i__1 = b + (bufloc << 7) - 129) < 12800 && 0 <= i__1 ?
+ i__1 : s_rnge("rbdat", i__1, "dafrwd_", (ftnlen)646)], &count,
+ data);
+
+/* Increment the request counter in such a way that integer */
+/* overflow will not occur. This private module from the */
+/* handle manager halves RBREQ if adding 1 to NREQ would */
+/* cause its value to exceed INTMAX. */
+
+ zzddhrcm_(&rbnbr, rbreq, &nreq);
+ rbreq[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("rbreq",
+ i__1, "dafrwd_", (ftnlen)655)] = nreq;
+ }
+ return 0;
+/* $Procedure DAFGSR ( DAF, get summary/descriptor record ) */
+
+L_dafgsr:
+/* $ Abstract */
+
+/* Read a portion of the contents of a summary record in a */
+/* DAF file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* INTEGER BEGIN */
+/* INTEGER END */
+/* DOUBLE PRECISION DATA ( * ) */
+/* LOGICAL FOUND */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAF. */
+/* RECNO I Record number. */
+/* BEGIN I First word to read from record. */
+/* END I Last word to read from record. */
+/* DATA O Contents of record. */
+/* FOUND O True if record is found. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a DAF. */
+
+/* RECNO is the record number of a particular double precision */
+/* record within the DAF, whose contents are to be read. */
+
+/* BEGIN is the first word in the specified record to be */
+/* returned. */
+
+/* END is the final word in the specified record to be */
+/* returned. */
+
+/* $ Detailed_Output */
+
+/* DATA contains the specified portion (from BEGIN to END, */
+/* inclusize) of the specified record from the specified */
+/* file, specifically. */
+
+/* FOUND is true when the specified record is found, and is */
+/* false otherwise. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* None. */
+
+/* $ Particulars */
+
+/* DAFGSR checks the record buffer to see if the requested */
+/* record can be returned without actually reading it from */
+/* external storage. If not, it reads the record and stores */
+/* it in the buffer, typically removing another record from */
+/* the buffer as a result. */
+
+/* Once in the buffer, the specified portion of the record is */
+/* returned, using the following control loop. */
+
+/* J = 1 */
+/* DO I = MAX( 1, BEGIN ), MIN( 128, END ) */
+/* DATA( J ) = Buffered record ( I ) */
+/* J = J + 1 */
+/* END DO */
+
+/* Therefore bad values for BEGIN and END (BEGIN < 1, END < BEGIN, */
+/* etc.) are not signalled as errors, but result in the actions */
+/* implied by the above. */
+
+/* $ Examples */
+
+/* The following code fragment illustrates one way that DAFGSR */
+/* and DAFWDR can be used to update part of a summary record. */
+/* If the record does not yet exist, we can assume that it is */
+/* filled with zeros. */
+
+/* CALL DAFGSR ( HANDLE, RECNO, 1, 128, DREC, FOUND ) */
+
+/* IF ( .NOT. FOUND ) THEN */
+/* CALL MOVED ( 0.D0, 128, DREC ) */
+/* END IF */
+
+/* DO I = FIRST, LAST */
+/* DREC(I) = NEW_VALUE(I) */
+/* END DO */
+
+/* CALL DAFWDR ( HANDLE, RECNO, DREC ) */
+
+/* Note that since only entire records may be written using DAFWDR, */
+/* the entire record needs to be read also. */
+
+/* $ Restrictions */
+
+/* 1) Bad values for BEGIN and END ( BEGIN < 1, END > 128, */
+/* END < BEGIN ) are not signalled as errors. The effects of */
+/* such assignments on the returned data are defined by the */
+/* following control structure: */
+
+/* J = 1 */
+/* DO I = MAX( 1, BEGIN ), MIN( 128, END ) */
+/* DATA( J ) = Buffered record ( I ) */
+/* J = J + 1 */
+/* END DO */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* F.S. Turner (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read daf summary record */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+
+/* Assume that the record will be found until proven otherwise. */
+
+ *found = TRUE_;
+
+/* First, find the record. */
+
+/* If the specified handle and record number match those of */
+/* a buffered record, determine the location of that record */
+/* within the buffer. */
+
+ bufloc = 0;
+ done = FALSE_;
+ stored = FALSE_;
+ while(! done) {
+ ++bufloc;
+ stored = *handle == rbhan[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("rbhan", i__1, "dafrwd_", (ftnlen)862)] && *
+ recno == rbrec[(i__2 = bufloc - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("rbrec", i__2, "dafrwd_", (ftnlen)862)];
+ done = stored || bufloc == rbnbr;
+ }
+
+/* If not, determine the location of the least recently requested */
+/* record (the one with the smallest request number). Get the unit */
+/* number for the file, and read the record into this location. */
+
+/* If an error occurs while reading the record, clear the entire */
+/* buffer entry in case the entry was corrupted by a partial read. */
+/* Otherwise, increment the number of reads performed so far. */
+
+ if (! stored) {
+ minai_(rbreq, &rbnbr, &minval, &bufloc);
+ dafhsf_(handle, &nd, &ni);
+ zzdafgsr_(handle, recno, &nd, &ni, &rbdat[(i__1 = (bufloc << 7) - 128)
+ < 12800 && 0 <= i__1 ? i__1 : s_rnge("rbdat", i__1, "dafrwd_"
+ , (ftnlen)884)], &locfnd);
+
+/* If the call to ZZDAFGSR or DAFHSF failed, or the record */
+/* was not found, then clean up. */
+
+ if (failed_() || ! locfnd) {
+ *found = FALSE_;
+ rbhan[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbhan", i__1, "dafrwd_", (ftnlen)893)] = 0;
+ rbrec[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbrec", i__1, "dafrwd_", (ftnlen)894)] = 0;
+ rbreq[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbreq", i__1, "dafrwd_", (ftnlen)895)] = 0;
+ } else {
+ ++nread;
+ rbhan[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbhan", i__1, "dafrwd_", (ftnlen)898)] = *handle;
+ rbrec[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbrec", i__1, "dafrwd_", (ftnlen)899)] = *recno;
+ if (rbnbr < 100) {
+ ++rbnbr;
+ }
+ }
+ }
+
+/* Whether previously stored or just read, the record is now in */
+/* the buffer. Return the specified portion directly, and increment */
+/* the corresponding request number. */
+
+ if (*found) {
+ b = max(1,*begin);
+ e = min(128,*end);
+ count = e - b + 1;
+ moved_(&rbdat[(i__1 = b + (bufloc << 7) - 129) < 12800 && 0 <= i__1 ?
+ i__1 : s_rnge("rbdat", i__1, "dafrwd_", (ftnlen)919)], &count,
+ data);
+
+/* Increment the request counter in such a way that integer */
+/* overflow will not occur. This private module from the */
+/* handle manager halves RBREQ if adding 1 to NREQ would */
+/* cause its value to exceed INTMAX. */
+
+ zzddhrcm_(&rbnbr, rbreq, &nreq);
+ rbreq[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("rbreq",
+ i__1, "dafrwd_", (ftnlen)928)] = nreq;
+ }
+ return 0;
+/* $Procedure DAFRDR ( DAF, read double precision record ) */
+
+L_dafrdr:
+/* $ Abstract */
+
+/* Read a portion of the contents of a double precision record in a */
+/* DAF file. */
+/* Obsolete: This routine has been superceded by DAFGDR, and it is */
+/* supported for purposes of backwards compatibility only. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* INTEGER BEGIN */
+/* INTEGER END */
+/* DOUBLE PRECISION DATA ( * ) */
+/* LOGICAL FOUND */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAF. */
+/* RECNO I Record number. */
+/* BEGIN I First word to read from record. */
+/* END I Last word to read from record. */
+/* DATA O Contents of record. */
+/* FOUND O True if record is found. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a DAF. */
+
+/* RECNO is the record number of a particular double precision */
+/* record within the DAF, whose contents are to be read. */
+
+/* BEGIN is the first word in the specified record to be */
+/* returned. */
+
+/* END is the final word in the specified record to be */
+/* returned. */
+
+/* $ Detailed_Output */
+
+/* DATA contains the specified portion (from BEGIN to END, */
+/* inclusize) of the specified record from the specified */
+/* file, specifically. */
+
+/* FOUND is true when the specified record is found, and is */
+/* false otherwise. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the file associated with HANDLE is not of the native */
+/* binary file format, this routine signals the error */
+/* SPICE(UNSUPPORTEDBFF). */
+
+/* $ Particulars */
+
+/* DAFRDR checks the record buffer to see if the requested */
+/* record can be returned without actually reading it from */
+/* external storage. If not, it reads the record and stores */
+/* it in the buffer, typically removing another record from */
+/* the buffer as a result. */
+
+/* Once in the buffer, the specified portion of the record is */
+/* returned, using the following control loop. */
+
+/* J = 1 */
+/* DO I = MAX( 1, BEGIN ), MIN( 128, END ) */
+/* DATA( J ) = Buffered record ( I ) */
+/* J = J + 1 */
+/* END DO */
+
+/* Therefore bad values for BEGIN and END (BEGIN < 1, END < BEGIN, */
+/* etc.) are not signalled as errors, but result in the actions */
+/* implied by the above. */
+
+/* This routine has been made obsolete by the routine DAFGDR, */
+/* and it is supported for reasons of backwards compatibility */
+/* only. New software development should utilize DAFGDA. */
+
+/* $ Examples */
+
+/* The following code fragment illustrates one way that DAFRDR */
+/* and DAFWDR can be used to update part of a double precision */
+/* record. If the record does not yet exist, we can assume that */
+/* it is filled with zeros. */
+
+/* CALL DAFRDR ( HANDLE, RECNO, 1, 128, DREC, FOUND ) */
+
+/* IF ( .NOT. FOUND ) THEN */
+/* CALL MOVED ( 0.D0, 128, DREC ) */
+/* END IF */
+
+/* DO I = FIRST, LAST */
+/* DREC(I) = NEW_VALUE(I) */
+/* END DO */
+
+/* CALL DAFWDR ( HANDLE, RECNO, DREC ) */
+
+/* Note that since only entire records may be written using DAFWDR, */
+/* the entire record needs to be read also. */
+
+/* $ Restrictions */
+
+/* 1) An integer overflow may occur if the number of requests */
+/* by a single program exceeds the maximum number that can */
+/* be stored in an integer variable. */
+
+/* 2) Bad values for BEGIN and END ( BEGIN < 1, END > 128, */
+/* END < BEGIN ) are not signalled as errors. The effects of */
+/* such assignments on the returned data are defined by the */
+/* following control structure: */
+
+/* J = 1 */
+/* DO I = MAX( 1, BEGIN ), MIN( 128, END ) */
+/* DATA( J ) = Buffered record ( I ) */
+/* J = J + 1 */
+/* END DO */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* R.E. Thurman (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* Added SPICE(UNSUPPORTEDBFF) exception to the routine. */
+
+/* - SPICELIB Version 1.3.0, 24-MAR-2000 (WLT) */
+
+/* The loop in DAFRDR that moved buffered d.p.s into the output */
+/* array DATA was modified to use the routine MOVED. */
+
+/* - SPICELIB Version 1.2.0, 01-AUG-1997 (NJB) */
+
+/* Unnecessary CHKIN and CHKOUT calls were removed from entry */
+/* point DAFRDR. */
+
+/* - SPICELIB Version 1.1.0, 25-NOV-1992 (JML) */
+
+/* 1) In DAFRDR, the found flag is now set to false if the */
+/* call to DAFHLU fails. */
+
+/* 2) In the example code fragment in DAFRDR and DAFWDR, the */
+/* calling sequence to MOVED was corrected. */
+
+/* 3) In the call to MINAI the argument for the minimum value */
+/* was changed from I to MINVAL. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read daf d.p. record */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* The exception SPICE(UNSUPPORTEDBFF) was added to guarantee */
+/* this routine's functionality remains unchanged as a result */
+/* of the updates to the underlying DAF software's utilization of */
+/* the handle manager. In versions of the toolkit prior to this, */
+/* all DAFs loaded were of the native binary file format. */
+/* Previously, this routine was used to read the contents of */
+/* summary records in addition to the usual data records. */
+/* The non-native to native translation process for these two */
+/* different types of records in general are not the same. */
+/* Rather than attempt to interpret the caller's intent, this */
+/* routine is obsolete and restricted to functioning only on */
+/* DAFs of the native binary file format. */
+
+/* - SPICELIB Version 1.3.0, 24-MAR-2000 (WLT) */
+
+/* The loop in DAFRDR that moved buffered d.p.s into the output */
+/* array DATA was modified to use the routine MOVED. */
+
+/* - SPICELIB Version 1.2.0, 01-AUG-1997 (NJB) */
+
+/* Unnecessary CHKIN and CHKOUT calls were removed from entry */
+/* point DAFRDR. These calls were placed together prior to */
+/* a RETURN statement. It's unclear why they were there in the */
+/* first place. */
+
+/* - SPICELIB Version 1.1.0, 25-NOV-1992 (JML) */
+
+/* 1) In DAFRDR, the found flag is now set to false if the */
+/* call to DAFHLU fails. */
+
+/* 2) In the example code fragment in DAFRDR and DAFWDR, the */
+/* calling sequence to MOVED was corrected. */
+
+/* 3) In the call to MINAI the argument for the minimum value */
+/* was changed from I to MINVAL. */
+
+/* - Beta Version 2.0.0, 1-NOV-1989 (RET) */
+
+/* The function of DAFRDR was changed so that it returns only */
+/* a specified portion of the record. The calling sequence there- */
+/* fore changed from */
+
+/* DAFRDR ( HANDLE, RECNO, DREC, FOUND ) to */
+/* DAFRDR ( HANDLE, RECNO, BEGIN, END, DATA, FOUND ) */
+
+/* The change was made to cut down on the shuffling of unneeded */
+/* data. */
+
+/* Also, DAFRDR now only checks in and checks out if DAFHLU has */
+/* failed (the only routine called by DAFRDR that could possibly */
+/* signal an error). The purpose of this change was to help */
+/* speed up a routine that gets called constantly by higher level */
+/* DAF routines. */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+
+/* Assume that the record will be found until proven otherwise. */
+
+ *found = TRUE_;
+
+/* First check to see if HANDLE is associated with a DAF of the */
+/* native binary file format. */
+
+ zzddhisn_(handle, &native, &locfnd);
+ if (locfnd && ! native) {
+ *found = FALSE_;
+ chkin_("DAFRDR", (ftnlen)6);
+ setmsg_("The binary file format for file '#' is not native. This rou"
+ "tine operates only on files of the native format.", (ftnlen)
+ 108);
+ errhan_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(UNSUPPORTEDBFF)", (ftnlen)21);
+ chkout_("DAFRDR", (ftnlen)6);
+ return 0;
+ }
+
+/* Now, find the record. */
+
+/* If the specified handle and record number match those of */
+/* a buffered record, determine the location of that record */
+/* within the buffer. */
+
+ bufloc = 0;
+ done = FALSE_;
+ stored = FALSE_;
+ while(! done) {
+ ++bufloc;
+ stored = *handle == rbhan[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("rbhan", i__1, "dafrwd_", (ftnlen)1264)] && *
+ recno == rbrec[(i__2 = bufloc - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("rbrec", i__2, "dafrwd_", (ftnlen)1264)];
+ done = stored || bufloc == rbnbr;
+ }
+
+/* If not, determine the location of the least recently requested */
+/* record (the one with the smallest request number). Get the unit */
+/* number for the file, and read the record into this location. */
+
+/* If an error occurs while reading the record, clear the entire */
+/* buffer entry in case the entry was corrupted by a partial read. */
+/* Otherwise, increment the number of reads performed so far. */
+
+ if (! stored) {
+ minai_(rbreq, &rbnbr, &minval, &bufloc);
+ zzdafgdr_(handle, recno, &rbdat[(i__1 = (bufloc << 7) - 128) < 12800
+ && 0 <= i__1 ? i__1 : s_rnge("rbdat", i__1, "dafrwd_", (
+ ftnlen)1284)], &locfnd);
+
+/* If the call to ZZDAFGDR failed, or the record was not found, */
+/* then clean up. */
+
+ if (failed_() || ! locfnd) {
+ *found = FALSE_;
+ rbhan[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbhan", i__1, "dafrwd_", (ftnlen)1292)] = 0;
+ rbrec[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbrec", i__1, "dafrwd_", (ftnlen)1293)] = 0;
+ rbreq[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbreq", i__1, "dafrwd_", (ftnlen)1294)] = 0;
+ } else {
+ ++nread;
+ rbhan[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbhan", i__1, "dafrwd_", (ftnlen)1297)] = *handle;
+ rbrec[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbrec", i__1, "dafrwd_", (ftnlen)1298)] = *recno;
+ if (rbnbr < 100) {
+ ++rbnbr;
+ }
+ }
+ }
+
+/* Whether previously stored or just read, the record is now in */
+/* the buffer. Return the specified portion directly, and increment */
+/* the corresponding request number. */
+
+ if (*found) {
+ b = max(1,*begin);
+ e = min(128,*end);
+ count = e - b + 1;
+ moved_(&rbdat[(i__1 = b + (bufloc << 7) - 129) < 12800 && 0 <= i__1 ?
+ i__1 : s_rnge("rbdat", i__1, "dafrwd_", (ftnlen)1318)], &
+ count, data);
+
+/* Increment the request counter in such a way that integer */
+/* overflow will not occur. This private module from the */
+/* handle manager halves RBREQ if adding 1 to NREQ would */
+/* cause its value to exceed INTMAX. */
+
+ zzddhrcm_(&rbnbr, rbreq, &nreq);
+ rbreq[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge("rbreq",
+ i__1, "dafrwd_", (ftnlen)1327)] = nreq;
+ }
+ return 0;
+/* $Procedure DAFWDR ( DAF, write double precision record ) */
+
+L_dafwdr:
+/* $ Abstract */
+
+/* Write or rewrite the contents of a double precision record in */
+/* a DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* DOUBLE PRECISION DREC ( 128 ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAF. */
+/* RECNO I Record number. */
+/* DREC I Contents of record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a DAF. */
+
+/* RECNO is the record number of a particular double */
+/* precision record within the file, whose */
+/* contents are to be written (if the record does */
+/* not yet exist) or overwritten (if it does). */
+
+/* DREC contains the new contents of the record. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the file is not open for write access, the error */
+/* SPICE(DAFILLEGWRITE) is signalled. */
+
+/* 2) If (for some reason) the record cannot be written the */
+/* error SPICE(DAFDPWRITEFAIL) is signalled. */
+
+/* $ Particulars */
+
+/* Like DAFRDR, DAFWDR checks the record buffer to see if the */
+/* requested record is in the buffer. If so, the buffer is */
+/* updated along with the file. This prevents the buffer from */
+/* becoming outdated. */
+
+/* $ Examples */
+
+/* The following code fragment illustrates one way that DAFRDR */
+/* and DAFWDR can be used to update part of a double precision */
+/* record. If the record does not yet exist, we can assume that */
+/* it is filled with zeros. */
+
+/* CALL DAFRDR ( HANDLE, RECNO, DREC, FOUND ) */
+
+/* IF ( .NOT. FOUND ) THEN */
+/* CALL MOVED ( 0.D0, 128, DREC ) */
+/* END IF */
+
+/* DO I = FIRST, LAST */
+/* DREC(I) = NEW_VALUE(I) */
+/* END DO */
+
+/* CALL DAFWDR ( HANDLE, RECNO, DREC ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 16-NOV-2001 (FST) */
+
+/* Replaced the call to DAFHLU to ZZDDHHLU. This prevents */
+/* DAFWDR from tying up resources in the handle manager. */
+
+/* - SPICELIB Version 1.3.0, 24-MAR-2000 (WLT) */
+
+/* The loop in DAFRDR that moved buffered d.p.s into the output */
+/* array DATA was modified to use the routine MOVED. */
+
+/* - SPICELIB Version 1.1.0, 25-NOV-1992 (JML) */
+
+/* In the example code fragment in DAFRDR and DAFWDR, the */
+/* calling sequence to MOVED was corrected. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write daf d.p. record */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFWDR", (ftnlen)6);
+ }
+
+/* No fair writing to a read-only file! */
+
+ if (*handle >= 0) {
+ setmsg_("Attempt was made to write to a read-only file.", (ftnlen)46);
+ sigerr_("SPICE(DAFILLEGWRITE)", (ftnlen)20);
+ chkout_("DAFWDR", (ftnlen)6);
+ return 0;
+ }
+
+/* If the specified handle and record number match those of */
+/* a buffered record, determine the location of that record */
+/* within the buffer. */
+
+ bufloc = 0;
+ done = FALSE_;
+ stored = FALSE_;
+ while(! done) {
+ ++bufloc;
+ stored = *handle == rbhan[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ?
+ i__1 : s_rnge("rbhan", i__1, "dafrwd_", (ftnlen)1532)] && *
+ recno == rbrec[(i__2 = bufloc - 1) < 100 && 0 <= i__2 ? i__2 :
+ s_rnge("rbrec", i__2, "dafrwd_", (ftnlen)1532)];
+ done = stored || bufloc == 100;
+ }
+
+/* Get the unit number for the file, and write the record. */
+
+ zzddhhlu_(handle, "DAF", &c_false, &unit, (ftnlen)3);
+ io___21.ciunit = unit;
+ io___21.cirec = *recno;
+ iostat = s_wdue(&io___21);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__128, (char *)&drec[0], (ftnlen)sizeof(doublereal));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_wdue();
+L100001:
+
+/* If the record was buffered, replace it---with the input */
+/* record if the write was successful, or with zeros if it */
+/* was not. */
+
+ if (stored) {
+ if (iostat == 0) {
+ moved_(drec, &c__128, &rbdat[(i__1 = (bufloc << 7) - 128) < 12800
+ && 0 <= i__1 ? i__1 : s_rnge("rbdat", i__1, "dafrwd_", (
+ ftnlen)1555)]);
+ } else {
+ rbhan[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbhan", i__1, "dafrwd_", (ftnlen)1557)] = 0;
+ rbrec[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbrec", i__1, "dafrwd_", (ftnlen)1558)] = 0;
+ rbreq[(i__1 = bufloc - 1) < 100 && 0 <= i__1 ? i__1 : s_rnge(
+ "rbreq", i__1, "dafrwd_", (ftnlen)1559)] = 0;
+ }
+ }
+
+/* Declare an error if the write failed. */
+
+ if (iostat != 0) {
+ setmsg_("Double precision write failed. Value of IOSTAT was #", (
+ ftnlen)52);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFDPWRITEFAIL)", (ftnlen)21);
+ }
+ chkout_("DAFWDR", (ftnlen)6);
+ return 0;
+/* $Procedure DAFNRR ( DAF number of reads, requests ) */
+
+L_dafnrr:
+/* $ Abstract */
+
+/* Return the number of reads and requests fielded by DAFRDR. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER READS */
+/* INTEGER REQS */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Entry */
+/* -------- --- -------------------------------------------------- */
+/* READS, */
+/* REQS O Reads, requests in this execution. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* READS, */
+/* REQS are the number of physical reads and the number */
+/* of requests processed by DAFRDR during the current */
+/* execution of the calling program. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Particulars */
+
+/* The ratio of reads to requests tells you something about */
+/* the effectiveness with which the record buffer is preventing */
+/* unwanted disk access. In the ideal case, most of the records */
+/* needed by the calling program can be returned directly from */
+/* the buffer, and the ratio of reads to requests approaches zero. */
+/* More realistically, it should be be somewhere between 1/10 */
+/* and 1/2. */
+
+/* If the ratio is greater than 1/2, you should consider increasing */
+/* the size of the record buffer (which is controlled by parameter */
+/* RBSIZE) in order to improve the performance of the DAF package, */
+/* unless your application is strapped for space. */
+
+/* $ Examples */
+
+/* In the following code fragment, the ratio of reads to requests */
+/* is determined following a series of calls to the reader DAFEZ. */
+
+/* DO I = 1, N */
+/* CALL DAFEZ ( ..., STATES(1,I), ... ) */
+/* END DO */
+
+/* CALL DAFNRR ( READS, REQS ) */
+
+/* WRITE (*,*) 'Reads/requests = ', FLOAT( READS ) / FLOAT( REQS ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.3.0, 24-MAR-2000 (WLT) */
+
+/* The loop in DAFRDR that moved buffered d.p.s into the output */
+/* array DATA was modified to use the routine MOVED. */
+
+/* - SPICELIB Version 1.1.0, 25-NOV-1992 (JML) */
+
+/* A cut and paste error in the literature references */
+/* section of the header was fixed. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* number of daf read requests */
+
+/* -& */
+ *reads = nread;
+ *reqs = nreq;
+ return 0;
+} /* dafrwd_ */
+
+/* Subroutine */ int dafrwd_(integer *handle, integer *recno, integer *begin,
+ integer *end, doublereal *drec, doublereal *data, logical *found,
+ integer *reads, integer *reqs)
+{
+ return dafrwd_0_(0, handle, recno, begin, end, drec, data, found, reads,
+ reqs);
+ }
+
+/* Subroutine */ int dafgdr_(integer *handle, integer *recno, integer *begin,
+ integer *end, doublereal *data, logical *found)
+{
+ return dafrwd_0_(1, handle, recno, begin, end, (doublereal *)0, data,
+ found, (integer *)0, (integer *)0);
+ }
+
+/* Subroutine */ int dafgsr_(integer *handle, integer *recno, integer *begin,
+ integer *end, doublereal *data, logical *found)
+{
+ return dafrwd_0_(2, handle, recno, begin, end, (doublereal *)0, data,
+ found, (integer *)0, (integer *)0);
+ }
+
+/* Subroutine */ int dafrdr_(integer *handle, integer *recno, integer *begin,
+ integer *end, doublereal *data, logical *found)
+{
+ return dafrwd_0_(3, handle, recno, begin, end, (doublereal *)0, data,
+ found, (integer *)0, (integer *)0);
+ }
+
+/* Subroutine */ int dafwdr_(integer *handle, integer *recno, doublereal *
+ drec)
+{
+ return dafrwd_0_(4, handle, recno, (integer *)0, (integer *)0, drec, (
+ doublereal *)0, (logical *)0, (integer *)0, (integer *)0);
+ }
+
+/* Subroutine */ int dafnrr_(integer *reads, integer *reqs)
+{
+ return dafrwd_0_(5, (integer *)0, (integer *)0, (integer *)0, (integer *)
+ 0, (doublereal *)0, (doublereal *)0, (logical *)0, reads, reqs);
+ }
+
diff --git a/ext/spice/src/cspice/daft2b.c b/ext/spice/src/cspice/daft2b.c
new file mode 100644
index 0000000000..d1da3371b8
--- /dev/null
+++ b/ext/spice/src/cspice/daft2b.c
@@ -0,0 +1,815 @@
+/* daft2b.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__9 = 9;
+static integer c__1 = 1;
+static integer c__3 = 3;
+static integer c__5 = 5;
+
+/* $Procedure DAFT2B ( DAF, text to binary ) */
+/* Subroutine */ int daft2b_(integer *text, char *binary, integer *resv,
+ ftnlen binary_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen),
+ e_rsle(void), s_cmp(char *, char *, ftnlen, ftnlen), s_rnge(char *
+ , integer, char *, integer);
+
+ /* Local variables */
+ char name__[1000*2];
+ integer more, i__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafps_(integer *,
+ integer *, doublereal *, integer *, doublereal *);
+ char tarch[8];
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
+ integer chunk, isize, lsize;
+ char ttype[8];
+ extern /* Subroutine */ int idw2at_(char *, char *, char *, ftnlen,
+ ftnlen, ftnlen), dafada_(doublereal *, integer *);
+ doublereal dc[125];
+ extern /* Subroutine */ int dafbna_(integer *, doublereal *, char *,
+ ftnlen);
+ integer ic[250];
+ extern /* Subroutine */ int dafena_(void);
+ integer nd;
+ extern logical failed_(void);
+ integer ni, handle;
+ extern /* Subroutine */ int dafcls_(integer *);
+ char ifname[60*2];
+ extern /* Subroutine */ int dafopn_(char *, integer *, integer *, char *,
+ integer *, integer *, ftnlen, ftnlen);
+ doublereal buffer[1024];
+ char idword[8];
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+ doublereal sum[125];
+
+ /* Fortran I/O blocks */
+ static cilist io___5 = { 1, 0, 1, 0, 0 };
+ static cilist io___6 = { 1, 0, 1, 0, 0 };
+ static cilist io___13 = { 1, 0, 1, 0, 0 };
+ static cilist io___15 = { 1, 0, 1, 0, 0 };
+ static cilist io___17 = { 1, 0, 1, 0, 0 };
+ static cilist io___20 = { 1, 0, 1, 0, 0 };
+ static cilist io___23 = { 1, 0, 1, 0, 0 };
+ static cilist io___25 = { 1, 0, 1, 0, 0 };
+ static cilist io___27 = { 1, 0, 1, 0, 0 };
+ static cilist io___28 = { 1, 0, 1, 0, 0 };
+ static cilist io___29 = { 1, 0, 1, 0, 0 };
+ static cilist io___30 = { 1, 0, 1, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Reconstruct a binary DAF from a text file opened by */
+/* the calling program. (Obsolete, maintained for backward */
+/* compatibility only.) */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* TEXT I Logical unit connected to text file. */
+/* BINARY I Name of a binary DAF to be created. */
+/* RESV I Number of records to reserve. */
+/* BSIZE P Buffer size. */
+
+/* $ Detailed_Input */
+
+/* TEXT is a logical unit number, to which a text file has */
+/* been connected by the calling program, and into */
+/* which the contents of binary DAF have been */
+/* written. The file pointer should be placed just */
+/* before the file ID word. */
+
+/* BINARY is the name of a binary DAF to be created. */
+/* The binary DAF contains the same data as the */
+/* text file, but in a form more suitable for use */
+/* by application programs. */
+
+/* RESV is the number of records to be reserved in the */
+/* binary DAF. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* BSIZE is the size of the buffer used to read array elements */
+/* from the text file. No single group of elements should */
+/* contains more than BSIZE elements. */
+
+/* $ Files */
+
+/* See arguments TEXT, BINARY. */
+
+/* $ Exceptions */
+
+/* 1) If for some reason the text file cannot be read, */
+/* the error SPICE(DAFREADFAIL) is signalled. */
+
+/* 2) If the architecture of the file is not DAF, as specified by */
+/* the ID word, the error SPICE(NOTADAFFILE) will be signalled. */
+
+/* 3) If the text file does not contain matching internal file */
+/* names, the error SPICE(DAFNOIFNMATCH) is signalled. */
+
+/* 4) If the text file does not contain matching array names, */
+/* the error SPICE(DAFNONAMEMATCH) is signalled. */
+
+/* 5) If the buffer size is not sufficient, the error */
+/* SPICE(DAFOVERFLOW) is signalled. */
+
+/* $ Particulars */
+
+/* This routine has been made obsolete by the new DAF text to binary */
+/* conversion routine DAFTB. This routine remains available for */
+/* reasons of backward compatibility. We strongly recommend that you */
+/* use the new conversion routines for any new software development. */
+/* Please see the header of the routine DAFTB for details. */
+
+/* This routine is necessary for converting older DAF text files into */
+/* their equivalent binary formats, as DAFTB uses a different text */
+/* file format that is incompatible with the text file format */
+/* expected by this routine. */
+
+/* Any binary DAF may be transferred between heterogeneous */
+/* Fortran environments by converting it to an equivalent file */
+/* containing only ASCII characters. Such a file can be transferred */
+/* almost universally, using any number of established protocols */
+/* (Kermit, FTP, and so on). Once transferred, the ASCII file can */
+/* be reconverted to a binary DAF, using the representations */
+/* native to the new host environment. */
+
+/* There are two pairs of routines that can be used to convert */
+/* DAFs between binary and ASCII. The first pair, DAFB2A */
+/* and DAFA2B, works with complete files. That is, DAFB2A creates */
+/* a complete ASCII file containing all of the information in */
+/* a particular binary DAF, and nothing else; this file can */
+/* be fed directly into DAFA2B to produce a complete binary DAF. */
+/* In each case, the names of the files are specified. */
+
+/* A related pair of routines, DAFB2T and DAFT2B, assume that */
+/* the ASCII data are to be stored in the midst of a text file. */
+/* This allows the calling program to surround the data with */
+/* standardized labels, to append several binary DAFs into a */
+/* single text file, and so on. */
+
+/* Note that you must select the number of records to be reserved */
+/* in the binary DAF. The contents of reserved records are ignored */
+/* by the normal transfer process. */
+
+/* $ Examples */
+
+/* DAFB2A and DAFA2B are typically used for simple transfers. */
+/* If A.DAF is a binary DAF in environment 1, it can be transferred */
+/* to environment 2 in three steps. */
+
+/* 1) Convert it to ASCII: */
+
+/* CALL DAFB2A ( 'A.DAF', 'A.ASCII' ) */
+
+/* 2) Transfer the ASCII file, using FTP, Kermit, or some other */
+/* file transfer utility: */
+
+/* ftp> put a.ascii */
+
+/* 3) Convert it to binary on the new machine, */
+
+/* CALL DAFA2B ( 'A.ASCII', 'A.DAF', RESV ) */
+
+/* Note that DAFB2A and DAFA2B work in any standard Fortran-77 */
+/* environment. */
+
+/* If the file needs to contain other information---a standard */
+/* label, for instance---the first and third steps must be modified */
+/* to use DAFB2T and DAFT2B. The first step becomes */
+
+/* (Open a text file) */
+/* (Write the label) */
+/* CALL DAFB2T ( BINARY, UNIT ) */
+/* (Close the text file) */
+
+/* The third step becomes */
+
+/* (Open the text file) */
+/* (Read the label) */
+/* CALL DAFT2B ( UNIT, BINARY, RESV ) */
+/* (Close the text file) */
+
+/* $ Restrictions */
+
+/* DAFT2B cannot be executed while any other DAF is open */
+/* for writing. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* K. R. Gehringer (JPL) */
+/* J.E. McLean (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 04-OCT-1993 (KRG) */
+
+/* Removed the error SPICE(DAFNOIDWORD) as it was no longer */
+/* relevant. */
+
+/* Added the error SPICE(NOTADAFFILE) if this routine is called */
+/* with a file that does not contain an ID word identifying the */
+/* file as a DAF file. */
+
+/* There were no checks of the IOSTAT variable after attempting to */
+/* read from the text file, a single test of the IOSTAT variable */
+/* was made at the end of the routine. This was not adequate to */
+/* detect errors when writing to the text file. So after all of */
+/* these read statements, an IF ... END IF block was added to */
+/* signal an error if IOSTAT .NE. 0. */
+
+/* Added a statement to the $ Particulars section to the effect */
+/* that this routine has been made obsolete by the introduction of */
+/* the routine DAFTB, and that we strongly recommend the use of */
+/* the new routine. This routine must, however, be used when */
+/* converting older text files to binary, as the old and new */
+/* formats are not compatible. */
+
+/* Modified the $ Abstract section to reflect the fact that this */
+/* routine is obsolete and maintained for purposes of backward */
+/* compatibility only. */
+
+/* - SPICELIB Version 2.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.1, 6-AUG-1990 (HAN) */
+
+/* Header documentation was corrected. This routine will */
+/* convert a file containing either ID word, 'NAIF/DAF' or */
+/* 'NAIF/NIP'. (Previous versions of SPICELIB software used */
+/* the ID word 'NAIF/NIP'.) */
+
+/* - SPICELIB Version 2.0.0, 2-AUG-1990 (JEM) */
+
+/* The previous version of this routine always failed and */
+/* signalled the error SPICE(DAFNOIDWORD) because of a faulty */
+/* logical expression in an error-checking IF statement. */
+/* The error SPICE(DAFNOIDWORD) should be signalled if the */
+/* next non-blank line in the text file does not begin with the */
+/* word 'NAIF/DAF' AND does not begin with the word 'NAIF/NIP'. */
+/* Previously the logic was incorrect causing the error to be */
+/* signalled every time no matter what the word was. The */
+/* correction consisted of replacing '.OR.' with '.AND.' */
+/* in the logical expression. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* text daf to binary */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 3.0.0, 04-OCT-1993 (KRG) */
+
+/* Removed the error SPICE(DAFNOIDWORD) as it was no longer */
+/* relevant. */
+
+/* Added the error SPICE(NOTADAFFILE) if this routine is called */
+/* with a file that does not contain an ID word identifying the */
+/* file as a DAF file. */
+
+/* There were no checks of the IOSTAT variable after attempting to */
+/* read from the text file, a single test of the IOSTAT variable */
+/* was made at the end of the routine. This was not adequate to */
+/* detect errors when writing to the text file. So after all of */
+/* these read statements, an IF ... END IF block was added to */
+/* signal an error if IOSTAT .NE. 0. */
+
+/* IF ( IOSTAT .NE. 0 ) THEN */
+
+/* CALL SETMSG ( 'The attempt to read from file ''#''' // */
+/* . ' failed. IOSTAT = #.' ) */
+/* CALL ERRFNM ( '#', UNIT ) */
+/* CALL SIGERR ( 'SPICE(DAFREADFAIL)' ) */
+/* CALL CHKOUT ( 'DAFT2B' ) */
+/* RETURN */
+
+/* END IF */
+
+/* Removed the code from the end of the routine that purported to */
+/* check for read errors: */
+
+/* C */
+/* C If any read screws up, they should all screw up. Why */
+/* C make a billion separate checks? */
+/* C */
+/* IF ( IOSTAT .NE. 0 ) THEN */
+/* CALL SETMSG ( 'Value of IOSTAT was: #. ' ) */
+/* CALL ERRINT ( '#', IOSTAT ) */
+/* CALL SIGERR ( 'SPICE(DAFREADFAIL)' ) */
+/* END IF */
+
+/* The answer to the question is: */
+
+/* You have to do a billion separate checks because the IOSTAT */
+/* value is only valid for the most recently executed read. */
+
+/* Added a statment to the $ Particulars section to the effect */
+/* that this routine has been made obsolete by the introduction of */
+/* the routine DAFTB, and that we strongly recommend the use of */
+/* the new routine. This routine must, however, be used when */
+/* converting older text files to binary, as the old and new */
+/* formats are not compatible. */
+
+/* Modified the $ Abstract section to reflect the fact that this */
+/* routine is obsolete and maintained for purposes of backward */
+/* compatibility only. */
+
+/* - SPICELIB Version 2.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 2.0.1, 6-AUG-1990 (HAN) */
+
+/* Header documentation was corrected. This routine will */
+/* convert a file containing either ID word, 'NAIF/DAF' or */
+/* 'NAIF/NIP'. (Previous versions of SPICELIB software used */
+/* the ID word 'NAIF/NIP'.) */
+
+/* - SPICELIB Version 2.0.0, 2-AUG-1990 (JEM) */
+
+/* The previous version of this routine always failed and */
+/* signalled the error SPICE(DAFNOIDWORD) because of a faulty */
+/* logical expression in an error-checking IF statement. */
+/* The error SPICE(DAFNOIDWORD) should be signalled if the */
+/* next non-blank line in the text file does not begin with the */
+/* word 'NAIF/DAF' AND does not begin with the word 'NAIF/NIP'. */
+/* Previously the logic was incorrect causing the error to be */
+/* signalled every time no matter what the word was. The */
+/* correction consisted of replacing '.OR.' with '.AND.' */
+/* in the logical expression. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local Parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFT2B", (ftnlen)6);
+ }
+ s_copy(idword, " ", (ftnlen)8, (ftnlen)1);
+ s_copy(tarch, " ", (ftnlen)8, (ftnlen)1);
+ s_copy(ttype, " ", (ftnlen)8, (ftnlen)1);
+
+/* We should be positioned and ready to read the file ID word from */
+/* the text file, so let's try it. */
+
+ io___5.ciunit = *text;
+ iostat = s_rsle(&io___5);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_lio(&c__9, &c__1, idword, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rsle();
+L100001:
+ if (iostat != 0) {
+ setmsg_("The attempt to read from file '#' failed. IOSTAT = #.", (
+ ftnlen)53);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+
+/* Split the ID word into an architecture and type, and verify that */
+/* the architecture is 'DAF'. If it is not, this is the wrong */
+/* routine, and an error will be signalled. */
+
+ idw2at_(idword, tarch, ttype, (ftnlen)8, (ftnlen)8, (ftnlen)8);
+ if (s_cmp(tarch, "DAF", (ftnlen)8, (ftnlen)3) != 0) {
+ setmsg_("File architecture is not 'DAF' for file '#'", (ftnlen)43);
+ errfnm_("#", text, (ftnlen)1);
+ sigerr_("SPICE(NOTADAFFILE)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ io___6.ciunit = *text;
+ iostat = s_rsle(&io___6);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_lio(&c__3, &c__1, (char *)&nd, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_lio(&c__3, &c__1, (char *)&ni, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_lio(&c__9, &c__1, ifname, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_rsle();
+L100002:
+ if (iostat != 0) {
+ setmsg_("The attempt to read from file '#' failed. IOSTAT = #.", (
+ ftnlen)53);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+
+/* Open the new binary file. */
+
+ dafopn_(binary, &nd, &ni, ifname, resv, &handle, binary_len, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+
+/* Each array is preceded by a '1', which indicates that more */
+/* arrays are to come. The array itself begins with the name */
+/* and the summary components, and ends with the name again. */
+/* The contents are written in arbitrary chunks. The final */
+/* chunk is followed by a '0', which indicates that no chunks */
+/* remain. The names must match, or the array should not */
+/* be terminated normally. */
+
+/* If the chunks in the file are bigger than the local buffer */
+/* size, we are in trouble. */
+
+ lsize = nd + (ni - 1) / 2 + 1;
+ isize = lsize << 3;
+ io___13.ciunit = *text;
+ iostat = s_rsle(&io___13);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_lio(&c__3, &c__1, (char *)&more, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = e_rsle();
+L100003:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to read from file '#' failed. IOSTAT = #.", (
+ ftnlen)53);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ while(more > 0) {
+ io___15.ciunit = *text;
+ iostat = s_rsle(&io___15);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_lio(&c__9, &c__1, name__, isize);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = e_rsle();
+L100004:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to read from file '#' failed. IOSTAT = #.", (
+ ftnlen)53);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ io___17.ciunit = *text;
+ iostat = s_rsle(&io___17);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ i__1 = nd;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ iostat = do_lio(&c__5, &c__1, (char *)&dc[(i__2 = i__ - 1) < 125
+ && 0 <= i__2 ? i__2 : s_rnge("dc", i__2, "daft2b_", (
+ ftnlen)517)], (ftnlen)sizeof(doublereal));
+ if (iostat != 0) {
+ goto L100005;
+ }
+ }
+ iostat = e_rsle();
+L100005:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to read from file '#' failed. IOSTAT = #.", (
+ ftnlen)53);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ io___20.ciunit = *text;
+ iostat = s_rsle(&io___20);
+ if (iostat != 0) {
+ goto L100006;
+ }
+ i__2 = ni - 2;
+ for (i__ = 1; i__ <= i__2; ++i__) {
+ iostat = do_lio(&c__3, &c__1, (char *)&ic[(i__1 = i__ - 1) < 250
+ && 0 <= i__1 ? i__1 : s_rnge("ic", i__1, "daft2b_", (
+ ftnlen)532)], (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100006;
+ }
+ }
+ iostat = e_rsle();
+L100006:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to read from file '#' failed. IOSTAT = #.", (
+ ftnlen)53);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ dafps_(&nd, &ni, dc, ic, sum);
+ dafbna_(&handle, sum, name__, isize);
+ if (failed_()) {
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ io___23.ciunit = *text;
+ iostat = s_rsle(&io___23);
+ if (iostat != 0) {
+ goto L100007;
+ }
+ iostat = do_lio(&c__3, &c__1, (char *)&chunk, (ftnlen)sizeof(integer))
+ ;
+ if (iostat != 0) {
+ goto L100007;
+ }
+ iostat = e_rsle();
+L100007:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to read from file '#' failed. IOSTAT = #.", (
+ ftnlen)53);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ while(chunk > 0) {
+ if (chunk > 1024) {
+ dafcls_(&handle);
+ setmsg_("Buffer size exceeded. Increase to #.", (ftnlen)36);
+ errint_("#", &chunk, (ftnlen)1);
+ sigerr_("SPICE(DAFOVERFLOW)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ } else {
+ io___25.ciunit = *text;
+ iostat = s_rsle(&io___25);
+ if (iostat != 0) {
+ goto L100008;
+ }
+ i__1 = chunk;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ iostat = do_lio(&c__5, &c__1, (char *)&buffer[(i__2 = i__
+ - 1) < 1024 && 0 <= i__2 ? i__2 : s_rnge("buffer",
+ i__2, "daft2b_", (ftnlen)585)], (ftnlen)sizeof(
+ doublereal));
+ if (iostat != 0) {
+ goto L100008;
+ }
+ }
+ iostat = e_rsle();
+L100008:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to read from file '#' failed. IOSTA"
+ "T = #.", (ftnlen)53);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ dafada_(buffer, &chunk);
+ if (failed_()) {
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ }
+ io___27.ciunit = *text;
+ iostat = s_rsle(&io___27);
+ if (iostat != 0) {
+ goto L100009;
+ }
+ iostat = do_lio(&c__3, &c__1, (char *)&chunk, (ftnlen)sizeof(
+ integer));
+ if (iostat != 0) {
+ goto L100009;
+ }
+ iostat = e_rsle();
+L100009:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to read from file '#' failed. IOSTAT = "
+ "#.", (ftnlen)53);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ }
+ io___28.ciunit = *text;
+ iostat = s_rsle(&io___28);
+ if (iostat != 0) {
+ goto L100010;
+ }
+ iostat = do_lio(&c__9, &c__1, name__ + 1000, isize);
+ if (iostat != 0) {
+ goto L100010;
+ }
+ iostat = e_rsle();
+L100010:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to read from file '#' failed. IOSTAT = #.", (
+ ftnlen)53);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ if (s_cmp(name__, name__ + 1000, isize, isize) != 0) {
+ dafcls_(&handle);
+ setmsg_("Array name mismatch: # and #.", (ftnlen)29);
+ errch_("#", name__, (ftnlen)1, isize);
+ errch_("#", name__ + 1000, (ftnlen)1, isize);
+ sigerr_("SPICE(DAFNONAMEMATCH)", (ftnlen)21);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ } else {
+ dafena_();
+ if (failed_()) {
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ }
+ io___29.ciunit = *text;
+ iostat = s_rsle(&io___29);
+ if (iostat != 0) {
+ goto L100011;
+ }
+ iostat = do_lio(&c__3, &c__1, (char *)&more, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100011;
+ }
+ iostat = e_rsle();
+L100011:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to read from file '#' failed. IOSTAT = #.", (
+ ftnlen)53);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* The final '0' indicates that no arrays remain. The first shall */
+/* be last: the internal file name brings up the rear. If it doesn't */
+/* match the one at the front, complain. */
+
+ io___30.ciunit = *text;
+ iostat = s_rsle(&io___30);
+ if (iostat != 0) {
+ goto L100012;
+ }
+ iostat = do_lio(&c__9, &c__1, ifname + 60, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100012;
+ }
+ iostat = e_rsle();
+L100012:
+ if (iostat != 0) {
+ dafcls_(&handle);
+ setmsg_("The attempt to read from file '#' failed. IOSTAT = #.", (
+ ftnlen)53);
+ errfnm_("#", text, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+ if (s_cmp(ifname, ifname + 60, (ftnlen)60, (ftnlen)60) != 0) {
+ dafcls_(&handle);
+ setmsg_("Internal file name mismatch: # and #", (ftnlen)36);
+ errch_("#", ifname, (ftnlen)1, (ftnlen)60);
+ errch_("#", ifname + 60, (ftnlen)1, (ftnlen)60);
+ sigerr_("SPICE(DAFNOIFNMATCH)", (ftnlen)20);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+ }
+
+/* Close the DAF file we just created. */
+
+ dafcls_(&handle);
+ chkout_("DAFT2B", (ftnlen)6);
+ return 0;
+} /* daft2b_ */
+
diff --git a/ext/spice/src/cspice/daftb.c b/ext/spice/src/cspice/daftb.c
new file mode 100644
index 0000000000..6661f020d0
--- /dev/null
+++ b/ext/spice/src/cspice/daftb.c
@@ -0,0 +1,900 @@
+/* daftb.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__9 = 9;
+static integer c__1 = 1;
+static integer c__2 = 2;
+static integer c__0 = 0;
+static integer c__3 = 3;
+
+/* $Procedure DAFTB ( DAF, convert transfer file to binary file ) */
+/* Subroutine */ int daftb_(integer *xfrlun, char *binfil, ftnlen binfil_len)
+{
+ /* System generated locals */
+ integer i__1;
+ cilist ci__1;
+
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen),
+ e_rsle(void), s_cmp(char *, char *, ftnlen, ftnlen), s_rsfe(
+ cilist *), do_fio(integer *, char *, ftnlen), e_rsfe(void);
+
+ /* Local variables */
+ char name__[1000];
+ integer barr;
+ char line[255];
+ integer bcnt, earr, ecnt;
+ logical more;
+ char word[255], rest[255];
+ extern /* Subroutine */ int chkin_(char *, ftnlen), dafps_(integer *,
+ integer *, doublereal *, integer *, doublereal *);
+ char tarch[8];
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
+ logical inarr;
+ char ttype[8];
+ extern /* Subroutine */ int idw2at_(char *, char *, char *, ftnlen,
+ ftnlen, ftnlen), dafada_(doublereal *, integer *), dafbna_(
+ integer *, doublereal *, char *, ftnlen), dafena_(void);
+ integer nd;
+ extern logical failed_(void);
+ integer ni;
+ extern /* Subroutine */ int dafcls_(integer *);
+ char ifname[60];
+ integer binhdl;
+ extern /* Subroutine */ int rdencd_(integer *, integer *, doublereal *),
+ rdenci_(integer *, integer *, integer *), dafopn_(char *, integer
+ *, integer *, char *, integer *, integer *, ftnlen, ftnlen);
+ doublereal buffer[1024];
+ integer dtacnt;
+ extern /* Subroutine */ int dafonw_(char *, char *, integer *, integer *,
+ char *, integer *, integer *, ftnlen, ftnlen, ftnlen);
+ char idword[8];
+ integer arrcnt, numdta;
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen);
+ integer snmlen;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen);
+ char errmsg[320];
+ extern /* Subroutine */ int nparsi_(char *, integer *, char *, integer *,
+ ftnlen, ftnlen);
+ integer iostat, numarr, numlft;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen), nextwd_(char *, char *, char *, ftnlen,
+ ftnlen, ftnlen);
+ integer lftovr;
+ extern logical return_(void);
+ integer errptr;
+ doublereal dsumry[125];
+ integer isumry[250];
+ doublereal summry[125];
+
+ /* Fortran I/O blocks */
+ static cilist io___5 = { 1, 0, 1, 0, 0 };
+ static cilist io___9 = { 1, 0, 1, 0, 0 };
+ static cilist io___27 = { 1, 0, 1, 0, 0 };
+ static cilist io___32 = { 1, 0, 1, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Convert the contents of an DAF transfer file into an equivalent */
+/* binary DAF file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* XFRLUN I Logical unit of an open DAF transfer file. */
+/* BINFIL I Name of a binary DAF file to be created. */
+
+/* $ Detailed_Input */
+
+/* XFRLUN The Fortran logical unit number of a previously opened */
+/* DAF transfer file has been. */
+
+/* The file pointer should be positioned ready to read */
+/* the file ID word. */
+
+/* BINFIL The name of the binary DAF file to be created. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See arguments XFRLUN, BINFIL. */
+
+/* $ Exceptions */
+
+/* 1) If the DAF transfer file cannot be read, the error */
+/* SPICE(FILEREADFAILED) will be signalled. */
+
+/* 2) If the architecture of the file is not DAF, as specified by */
+/* the ID word, the error SPICE(NOTADAFFILE) will be signalled. */
+
+/* 3) If an error occurs while attempting to decode data in the */
+/* DAF transfer file, the error SPICE(BADDAFTRANSFERFILE) will */
+/* be signalled. */
+
+/* 4) If the DAF file cannot be written, a DAF file access routine */
+/* will signal an error with an appropriate error message. */
+
+/* 5) The binary DAF file opened by this routine, BINFIL, is only */
+/* GUARANTEED to be closed upon successful completion of the */
+/* transfer file to binary file conversion process. In the event */
+/* of an error, the caller of this routine is required to close */
+/* the binary DAF file BINFIL. */
+
+/* $ Particulars */
+
+/* Any binary DAF file may be transferred between heterogeneous */
+/* Fortran environments by converting it to an equivalent file */
+/* containing only ASCII characters. Such a file can be transferred */
+/* almost universally, using any number of established protocols. */
+/* Once transferred, the ASCII file can be converted to a binary */
+/* file, using the representations native to the new host */
+/* environment. */
+
+/* This routine provides a mechanism for converting an DAF transfer */
+/* file created by DAFBT, or an equivalent procedure, into an */
+/* equivalent binary DAF file which may be used with the SPICE */
+/* system. It is one of a pair of routines for performing conversions */
+/* between the binary format of a DAF file and the DAF transfer file. */
+/* The inverse of this routine is the routine DAFBT. */
+
+/* This routine makes NO use of the DAF reserved record area. It */
+/* can only deal with the data portion of a DAF file in the DAF */
+/* transfer file. */
+
+/* Upon successful completion, the binary DAF file specified by */
+/* BINFIL will have been created. The binary DAF file that was */
+/* created will be closed when this routine exits. The DAF transfer */
+/* file will remain open, as it was on entry, and it will be */
+/* positioned to read the first line after the encoded DAF file data. */
+
+/* $ Examples */
+
+/* Let */
+
+/* XFRLUN be the Fortran logical unit attached to a DAF */
+/* transfer file which is to be converted into its binary */
+/* DAF equivalent. */
+
+/* BINFIL be the name of the binary DAF file which will be */
+/* created from the DAF transfer file. */
+
+/* The following subroutine call would read the DAF transfer file */
+/* attached to the Fortran logical unit XFRLUN, convert its data into */
+/* binary format, and write that data to the binary DAF file which */
+/* has been created: */
+
+/* CALL DAFTB( XFRLUN, BINFIL ) */
+
+/* $ Restrictions */
+
+/* 1) This routine assumes that it is positioned ready to read the */
+/* file ID word from the DAF transfer file. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.1, 22-AUG-2001 (EDW) */
+
+/* Corrected ENDIF to END IF. */
+
+/* - SPICELIB Version 3.0.0, 25-JAN-1995 (KRG) */
+
+/* Updated the header and in line comments to reflect the change */
+/* from calling files text files to calling them transfer files. */
+
+/* Changed the variable name TXTLUN to XFRLUN to make it */
+/* compatible with the change in terminology. */
+
+/* Changed the short error message from "BADDAFTEXTFILE" to */
+/* "BADDAFTRANSFERFILE". */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1993 (KRG) */
+
+/* This routine was modified to incorporate the file ID word */
+/* changes which will allow run time identification of the type of */
+/* data in a SPICE binary file. */
+
+/* Removed the error SPICE(IDWORDNOTKNOWN) as it was no longer */
+/* relevant. */
+
+/* Added the error SPICE(NOTADAFFILE) if this routine is called */
+/* with a file that does not contain an ID word identifying the */
+/* file as a DAF file. */
+
+/* - SPICELIB Version 1.0.1, 24-JUN-1993 (KRG) */
+
+/* Modified the description of the DAF encoded text file format */
+/* appearing before the program code. */
+
+/* - SPICELIB Version 1.0.0, 02-NOV-1992 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* convert daf transfer file to binary */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 3.0.0, 25-JAN-1995 (KRG) */
+
+/* Updated the header and in line comments to reflect the change */
+/* from calling files text files to calling them transfer files. */
+
+/* Changed the variable name TXTLUN to XFRLUN to make it */
+/* compatible with the change in terminology. */
+
+/* Changed the short error message from "BADDAFTEXTFILE" to */
+/* "BADDAFTRANSFERFILE". */
+
+/* - SPICELIB Version 2.0.0, 04-SEP-1993 (KRG) */
+
+/* This routine was modified to incorporate the file ID word */
+/* changes which will allow runtime identification of the type of */
+/* data in a binary file SPICE binary file. */
+
+/* Removed the error SPICE(IDWORDNOTKNOWN) as it was no longer */
+/* relevant. */
+
+/* Added the error SPICE(NOTADAFFILE) if this routine is called */
+/* with a file that does not contain an ID word identifying the */
+/* file as a DAF file. */
+
+/* - SPICELIB Version 1.0.1, 24-JUN-1993 (KRG) */
+
+/* Modified the description of the DAF encoded text file format */
+/* appearing before the program code. Changed the line: */
+
+/* C < DAF ND value > < DAF NI value > */
+
+/* to the lines: */
+
+/* C < DAF ND value > */
+/* C < DAF NI value > */
+
+/* This change was necessary because the output format for the */
+/* low level routines which encode and write the data were */
+/* modified to fix a problem. See the routines WRENCD and WRENCI */
+/* for details of the modification. */
+
+/* - SPICELIB Version 1.0.0, 29-OCT-1992 (KRG) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local Parameters */
+
+
+/* Local variables */
+
+
+/* Standard/ SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFTB", (ftnlen)5);
+ }
+
+/* A brief description of the DAF transfer file format and its */
+/* intended use follows. This description is intended to provide a */
+/* simple ``picture'' of the DAF transfer file format to aid in the */
+/* understanding of this routine. This description is NOT intended to */
+/* be a detailed specification of the file format. */
+
+/* A DAF transfer file contains all of the data from a binary */
+/* DAF file, except for the reserved record area, in an encoded */
+/* ASCII format. The file also contains some bookkeeping information */
+/* for maintaining the integrity of the data. The DAF transfer file */
+/* format allows the full precision of both integer and floating */
+/* point numeric data to be maintained in a portable fashion. The DAF */
+/* transfer file format is intended to provide a reliable and */
+/* accurate means for porting data among multiple computer systems */
+/* and for the archival storage of data. */
+
+/* A DAF transfer file is not intended to be used directly to */
+/* provide data to a program, the equivalent binary DAF file is */
+/* to be used for this purpose. In no way should any program, other */
+/* than a DAF binary <-> transfer conversion program, rely on the DAF */
+/* encoded transfer file format. */
+
+/* To correctly understand the DAF transfer file description */
+/* the reader should be familiar with the DAF file architecture. */
+/* Items enclosed in angle brackets, '<' and '>', are used to */
+/* represent the data which is to be placed at that position in */
+/* the file. The bookkeeping information is represented exactly */
+/* as it would appear in a DAF transfer file. */
+
+/* Let */
+
+/* BOF denote the beginning of the file */
+/* EOF denote the end of the file */
+
+/* and */
+
+/* n denote the total number of arrays in a DAF file */
+/* NA(i) denote the number of double precision numbers in array i */
+/* m(i) denote the number of blocks of encoded data for array i */
+/* N(i,j) denote the number of encoded double precision numbers */
+/* in block j of array i */
+
+/* and */
+
+/* m(i) */
+/* ----- */
+/* \ */
+/* > N(i,k) = NA(i), i = 1, ..., n. */
+/* / */
+/* ----- */
+/* k=1 */
+
+/* A DAF encoded transfer file has the following format: */
+
+/* */
+/* < Information line > */
+/* < DAF file ID word > */
+/* < DAF ND value > */
+/* < DAF NI value > */
+/* < DAF internal file name > */
+/* BEGIN_ARRAY 1 NA(1) */
+/* < Name for array 1 > */
+/* < ND double precision summary values > */
+/* < NI-2 integer summary values > */
+/* N(1,1) */
+/* < N(1,1) Encoded double precision numbers > */
+/* N(1,2) */
+/* < N(1,2) Encoded double precision numbers > */
+/* . */
+/* . */
+/* . */
+/* N(1,m(1)) */
+/* < N(1,m(1)) Encoded double precision numbers > */
+/* END_ARRAY 1 NA(1) */
+/* BEGIN_ARRAY 2 NA(2) */
+/* < Name for array 2 > */
+/* < ND double precision summary values > */
+/* < NI-2 integer summary values > */
+/* N(2,1) */
+/* < N(2,1) Encoded double precision numbers > */
+/* N(2,2) */
+/* < N(2,2) Encoded double precision numbers > */
+/* . */
+/* . */
+/* . */
+/* N(2,m(2)) */
+/* < N(2,m(2)) Encoded double precision numbers > */
+/* END_ARRAY 2 NA(2) */
+/* . */
+/* . */
+/* . */
+/* BEGIN_ARRAY n NA(n) */
+/* < Name for array n > */
+/* < ND double precision summary values > */
+/* < NI-2 integer summary values > */
+/* N(n,1) */
+/* < N(n,1) Encoded double precision numbers > */
+/* N(n,2) */
+/* < N(n,2) Encoded double precision numbers > */
+/* . */
+/* . */
+/* . */
+/* N(n,m(n)) */
+/* < N(n,m(n)) Encoded double precision numbers > */
+/* END_ARRAY n NA(n) */
+/* TOTAL_ARRAYS n */
+/* */
+
+
+/* Initialize a few things. */
+
+ s_copy(tarch, " ", (ftnlen)8, (ftnlen)1);
+ s_copy(ttype, " ", (ftnlen)8, (ftnlen)1);
+ s_copy(idword, " ", (ftnlen)8, (ftnlen)1);
+
+/* We begin by reading the DAF file ID word from the DAF transfer */
+/* file. We should have been positioned ready to read this. If an */
+/* error occurs, set an appropriate error message and signal the */
+/* error. */
+
+ io___5.ciunit = *xfrlun;
+ iostat = s_rsle(&io___5);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_lio(&c__9, &c__1, idword, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rsle();
+L100001:
+ if (iostat != 0) {
+ setmsg_("Error reading the file ID word from the DAF transfer file '"
+ "#'. IOSTAT = #.", (ftnlen)74);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Separate the ID word into its components and verify that we are */
+/* looking at a DAF transfer file. If we're not, then this routine */
+/* should not be used. */
+
+ idw2at_(idword, tarch, ttype, (ftnlen)8, (ftnlen)8, (ftnlen)8);
+ if (s_cmp(tarch, "DAF", (ftnlen)8, (ftnlen)3) != 0) {
+ setmsg_("File architecture is not 'DAF' for file '#'", (ftnlen)43);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(NOTADAFFILE)", (ftnlen)18);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* The file architecture is OK, but before we can open the binary */
+/* DAF, we need to get the summary format and the internal file name */
+/* from the DAF transfer file. We begin doing this here. */
+
+/* Read in the ND and NI values for the DAF file. */
+
+ rdenci_(xfrlun, &c__2, isumry);
+ if (failed_()) {
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+ nd = isumry[0];
+ ni = isumry[1];
+
+/* Read the internal filename for the DAF file. */
+
+ io___9.ciunit = *xfrlun;
+ iostat = s_rsle(&io___9);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_lio(&c__9, &c__1, ifname, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_rsle();
+L100002:
+ if (iostat != 0) {
+ setmsg_("Error reading the internal filename from the DAF transfer f"
+ "ile '#'. IOSTAT = #.", (ftnlen)79);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Open a new binary DAF file. Call the proper open routine, */
+/* depending on whether it's a new file or an old file. */
+
+ if (s_cmp(ttype, "?", (ftnlen)8, (ftnlen)1) != 0) {
+ dafonw_(binfil, ttype, &nd, &ni, ifname, &c__0, &binhdl, binfil_len, (
+ ftnlen)8, (ftnlen)60);
+ } else {
+ dafopn_(binfil, &nd, &ni, ifname, &c__0, &binhdl, binfil_len, (ftnlen)
+ 60);
+ }
+ if (failed_()) {
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Calculate the length of the segment names. */
+
+ snmlen = nd + (ni + 1) / 2 << 3;
+
+/* Initialize a few things: the array counter and the data counter. */
+
+ arrcnt = 0;
+ dtacnt = 0;
+
+/* We currently have more to process. */
+
+ more = TRUE_;
+
+/* We are currently not processing an array. */
+
+ inarr = FALSE_;
+
+/* Begin converting the DAF transfer file into a binary DAF file */
+/* here. */
+
+ while(more) {
+ ci__1.cierr = 1;
+ ci__1.ciend = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_rsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_fio(&c__1, line, (ftnlen)255);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = e_rsfe();
+L100003:
+ if (iostat != 0) {
+ setmsg_("Error reading from the DAF transfer file '#'. IOSTAT = "
+ "#.", (ftnlen)57);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* At this point, we should be beginning an array, ending an */
+/* array, or scanning for the total number of arrays. So look */
+/* for the appropriate keyword. */
+
+ nextwd_(line, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)255);
+ if (s_cmp(word, "BEGIN_ARRAY", (ftnlen)255, (ftnlen)11) == 0) {
+
+/* Get the array number. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)255);
+ nparsi_(word, &barr, errmsg, &errptr, (ftnlen)255, (ftnlen)320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+ setmsg_("Begin array error, could not parse array number. Er"
+ "ror: # File: #", (ftnlen)65);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDAFTRANSFERFILE)", (ftnlen)25);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the count of double precision numbers in the array. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)255);
+ nparsi_(word, &bcnt, errmsg, &errptr, (ftnlen)255, (ftnlen)320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+ setmsg_("Begin array error, could not parse the data count f"
+ "or array: #. Error: # File: #", (ftnlen)80);
+ errint_("#", &barr, (ftnlen)1);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDAFTRANSFERFILE)", (ftnlen)25);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we are inside an array, so set the in */
+/* array flag, INARR, to .TRUE. and increment the array */
+/* counter. */
+
+ inarr = TRUE_;
+ ++arrcnt;
+ } else if (s_cmp(word, "END_ARRAY", (ftnlen)255, (ftnlen)9) == 0) {
+
+/* Get the array number. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)255);
+ nparsi_(word, &earr, errmsg, &errptr, (ftnlen)255, (ftnlen)320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+ setmsg_("End array error, could not parse array number. Erro"
+ "r: # File: #", (ftnlen)63);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDAFTRANSFERFILE)", (ftnlen)25);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the count of double precision numbers in the array. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)255);
+ nparsi_(word, &ecnt, errmsg, &errptr, (ftnlen)255, (ftnlen)320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+ setmsg_("End array error, could not parse the data count for"
+ " array: #. Error: # File: #", (ftnlen)78);
+ errint_("#", &earr, (ftnlen)1);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDAFTRANSFERFILE)", (ftnlen)25);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the beginning and ending array numbers */
+/* match. If not, signal an appropriate error. */
+
+ if (earr != barr) {
+ setmsg_("Data array number mismatch: Beginning number: #; En"
+ "ding number: #. File: #", (ftnlen)74);
+ errint_("#", &barr, (ftnlen)1);
+ errint_("#", &earr, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDAFTRANSFERFILE)", (ftnlen)25);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the beginning and ending array data counts */
+/* match. If not, signal an appropriate error. */
+
+ if (ecnt != bcnt) {
+ setmsg_("Data array count mismatch: Beginning count: #; Endi"
+ "ng count: #. File: #", (ftnlen)71);
+ errint_("#", &bcnt, (ftnlen)1);
+ errint_("#", &ecnt, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDAFTRANSFERFILE)", (ftnlen)25);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we have successfully ended the */
+/* processing of an array, so set the in array flag, INARR, */
+/* to .FALSE.. */
+
+ inarr = FALSE_;
+ } else if (s_cmp(word, "TOTAL_ARRAYS", (ftnlen)255, (ftnlen)12) == 0)
+ {
+
+/* We have the total arrays keyword to parse, so get */
+/* the total number of arrays processed. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)255);
+ nparsi_(word, &numarr, errmsg, &errptr, (ftnlen)255, (ftnlen)320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+ setmsg_("Array count error, could not parse the total number"
+ " of arrays: #. File: #", (ftnlen)73);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDAFTRANSFERFILE)", (ftnlen)25);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+ if (arrcnt != numarr) {
+ setmsg_("The number of data arrays processed (#) was not equ"
+ "al to the number of data arrays placed in the DAF tr"
+ "ansfer file (#). File: #", (ftnlen)127);
+ errint_("#", &arrcnt, (ftnlen)1);
+ errint_("#", &numarr, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDAFTRANSFERFILE)", (ftnlen)25);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we have successfully processed the */
+/* entir data portion of the DAF transfer file, so there is */
+/* no more data. */
+
+ more = FALSE_;
+ } else {
+ setmsg_("Unknown keyword '#' encountered while processing the DA"
+ "F transfer file #.", (ftnlen)73);
+ errch_("#", word, (ftnlen)1, (ftnlen)255);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDAFTRANSFERFILE)", (ftnlen)25);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we have begun an array, then process it. Otherwise, we */
+/* have either ended an array or ended the file. */
+
+ if (inarr) {
+ dtacnt = 0;
+ io___27.ciunit = *xfrlun;
+ iostat = s_rsle(&io___27);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_lio(&c__9, &c__1, name__, snmlen);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = e_rsle();
+L100004:
+ if (iostat != 0) {
+ setmsg_("Error reading the array name from the DAF transfer "
+ "file #. IOSTAT = #.", (ftnlen)70);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Read in the double precision part of the summary. */
+
+ rdencd_(xfrlun, &nd, dsumry);
+ if (failed_()) {
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Read in the integer part of the summary. The beginning and */
+/* ending addresses, ISUMRY(NI-1) and ISUMRY(NI), for the */
+/* array are not known currently. They will be filled in when */
+/* the array is actually written to the DAF file. */
+
+ i__1 = ni - 2;
+ rdenci_(xfrlun, &i__1, isumry);
+ if (failed_()) {
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Pack the summary information into the DAF array summary. */
+
+ dafps_(&nd, &ni, dsumry, isumry, summry);
+
+/* Begin a new array in the binary DAF file. */
+
+ dafbna_(&binhdl, summry, name__, snmlen);
+ if (failed_()) {
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Read and decode the data in the current DAF array. */
+
+/* First set the count of numbers yet to be decoded and placed */
+/* in the binary DAF file. */
+
+ numlft = bcnt;
+ while(numlft > 0) {
+
+/* First, read in the count of encoded numbers in the */
+/* current data block. */
+
+ io___32.ciunit = *xfrlun;
+ iostat = s_rsle(&io___32);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_lio(&c__3, &c__1, (char *)&numdta, (ftnlen)sizeof(
+ integer));
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = e_rsle();
+L100005:
+ if (iostat != 0) {
+ setmsg_("Error reading array data from the DAF transfer "
+ "file #. IOSTAT = #.", (ftnlen)66);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Now read and decode the data in the current data block, */
+/* placing the data in the current array in the binary DAF */
+/* file. */
+
+ lftovr = numdta;
+ while(lftovr > 0) {
+ if (lftovr >= 1024) {
+ numdta = 1024;
+ } else {
+ numdta = lftovr;
+ }
+
+/* Read and decode a buffer of encoded double precision */
+/* data from the DAF transfer file. */
+
+ rdencd_(xfrlun, &numdta, buffer);
+ if (failed_()) {
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Write the double precision data to the current array */
+/* in the binary DAF file. */
+
+ dafada_(buffer, &numdta);
+ if (failed_()) {
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Decrement the counters for the amount of data */
+/* remaining to be moved from the current data block, */
+/* LFTOVR, and the current array, NUMLFT. */
+
+ lftovr -= numdta;
+ numlft -= numdta;
+
+/* Increment the counter for the amount of data that */
+/* has been successfully moved into the current array */
+/* in the binary DAF file. */
+
+ dtacnt += numdta;
+ }
+
+/* At this point, we have either finished reading in the */
+/* entire array, or we have just completed reading the */
+/* current encoded block of data for the current array */
+/* from the DAF transfer file. */
+
+ }
+
+/* If we got to here, we have successfully written an array */
+/* to the binary file, so we need to end it. */
+
+ dafena_();
+ if (failed_()) {
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+ }
+ }
+ }
+
+/* Close only the binary file. */
+
+ dafcls_(&binhdl);
+ chkout_("DAFTB", (ftnlen)5);
+ return 0;
+} /* daftb_ */
+
diff --git a/ext/spice/src/cspice/dafus_c.c b/ext/spice/src/cspice/dafus_c.c
new file mode 100644
index 0000000000..6588494852
--- /dev/null
+++ b/ext/spice/src/cspice/dafus_c.c
@@ -0,0 +1,197 @@
+/*
+
+-Procedure dafus_c ( DAF, unpack summary )
+
+-Abstract
+
+ Unpack an array summary into its double precision and integer
+ components.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAF
+
+-Keywords
+
+ CONVERSION
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #undef dafus_c
+
+
+ void dafus_c ( ConstSpiceDouble sum [],
+ SpiceInt nd,
+ SpiceInt ni,
+ SpiceDouble dc [],
+ SpiceInt ic [] )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ sum I Array summary.
+ nd I Number of double precision components.
+ ni I Number of integer components.
+ dc O Double precision components.
+ ic O Integer components.
+
+-Detailed_Input
+
+ sum is an array summary. This identifies the contents and
+ location of a single array within a DAF.
+
+ nd is the number of double precision components in
+ the summary.
+
+ ni is the number of integer components in the summary.
+
+-Detailed_Output
+
+ dc are the double precision components of the summary.
+
+ ic are the integer components of the summary.
+
+-Parameters
+
+ None.
+
+-Files
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+ 1) If nd is zero or negative, no double precision components
+ are returned.
+
+ 2) If ni is zero or negative, no integer components are returned.
+
+ 3) If the total size of the summary is greater than 125 double
+ precision words, some components may not be returned.
+
+-Particulars
+
+ The components of array summaries are packed into double
+ precision arrays for reasons outlined in [1]. Two routines,
+ DAFPS (pack summary) and dafus_c (unpack summary) are provided
+ for packing and unpacking summaries.
+
+ The total size of the summary is
+
+ (ni - 1)
+ nd + -------- + 1
+ 2
+
+ double precision words (where nd, ni are nonnegative).
+
+-Examples
+
+
+ In the following code fragment, dafopr_c is used to open a file,
+ which is then searched for DAFs containing data for a particular
+ object. dafus_c is used to unpack the summaries so the applicability
+ of the segments can be determined.
+
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ dafopr_c ( fname, &handle );
+ dafbfs_c ( handle );
+
+ daffna_c ( &found );
+
+ while ( found )
+ {
+ dafgs_c ( sum );
+ dafus_c ( sum, ND, NI, dc, ic );
+
+ if ( ic[0] == target_object )
+ {
+ .
+ .
+ .
+ }
+
+ daffna_c ( &found );
+ }
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ NAIF Document 167.0, "Double Precision Array Files (DAF)
+ Specification and User's Guide"
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 01-AUG-1999 (NJB), (IMU)
+
+-Index_Entries
+
+ unpack daf summary
+
+-&
+*/
+
+{ /* Begin dafus_c */
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dafus_c" );
+
+
+ dafus_ ( ( doublereal * ) sum,
+ ( integer * ) &nd,
+ ( integer * ) &ni,
+ ( doublereal * ) dc,
+ ( integer * ) ic );
+
+
+ chkout_c ( "dafus_c" );
+
+} /* End dafus_c */
diff --git a/ext/spice/src/cspice/dafwcr.c b/ext/spice/src/cspice/dafwcr.c
new file mode 100644
index 0000000000..4685c51045
--- /dev/null
+++ b/ext/spice/src/cspice/dafwcr.c
@@ -0,0 +1,240 @@
+/* dafwcr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static logical c_false = FALSE_;
+static integer c__1 = 1;
+
+/* $Procedure DAFWCR ( DAF, write character record ) */
+/* Subroutine */ int dafwcr_(integer *handle, integer *recno, char *crec,
+ ftnlen crec_len)
+{
+ /* System generated locals */
+ integer i__1;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen), s_wdue(cilist *), do_uio(integer *, char *,
+ ftnlen), e_wdue(void);
+
+ /* Local variables */
+ integer unit;
+ extern /* Subroutine */ int zzddhhlu_(integer *, char *, logical *,
+ integer *, ftnlen), chkin_(char *, ftnlen), dafsih_(integer *,
+ char *, ftnlen), sigerr_(char *, ftnlen), chkout_(char *, ftnlen),
+ setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+ /* Fortran I/O blocks */
+ static cilist io___3 = { 1, 0, 0, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Write or rewrite the contents of a character record to */
+/* a DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAF. */
+/* RECNO I Record number of character record. */
+/* CREC I Character record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a DAF. */
+
+/* RECNO is the record number of a character record within */
+/* the file. If the record does not already exist, it */
+/* is created. Otherwise its contents are overwritten. */
+
+/* CREC contains the first 1000 characters of the specified */
+/* record. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified file is not open for write access, an error */
+/* is signaled by routines in the call tree of this routine. */
+
+/* 2) If the declared length of CREC is not 1000 characters, */
+/* the error SPICE(DAFBADRECLEN) is signaled. */
+
+/* 2) If the specified record cannot (for some reason) be written, */
+/* the error SPICE(DAFWRITEFAIL) is signaled. */
+
+/* $ Particulars */
+
+/* Unlike double precision records, character records are */
+/* not buffered. */
+
+/* $ Examples */
+
+/* In the following example, matching summary and name records are */
+/* written to a DAF: */
+
+/* CALL DAFWDR ( HANDLE, NEXT, DREC ) */
+/* CALL DAFWCR ( HANDLE, NEXT+1, CREC ) */
+
+/* Note that a character record always immediately follows a summary */
+/* record. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.0, 27-NOV-2001 (FST) */
+
+/* Updated this routine to utilize new handle manager */
+/* interfaces. Replaced the check of the input handle's */
+/* sign with the appropriate call to DAFSIH. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write daf character record */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 27-NOV-2001 (FST) */
+
+/* The call to DAFHLU has been replaced with a call to */
+/* ZZDDHHLU, the handle manager interface for retrieving */
+/* a logical unit. DAFHLU is no longer used, since it */
+/* locks the unit returned to its HANDLE, tying up resources */
+/* in the handle manager. A call to DAFSIH was inserted to */
+/* make certain that HANDLE is present in DAFAH's file table, */
+/* rather than simply checking the sign of HANDLE. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFWCR", (ftnlen)6);
+ }
+ zzddhhlu_(handle, "DAF", &c_false, &unit, (ftnlen)3);
+
+/* Look out for */
+
+/* -- Writing to a file that is open for read-only. */
+
+/* -- Trying to write a record that doesn't have length 1000. */
+
+/* -- Failed write. */
+
+ dafsih_(handle, "WRITE", (ftnlen)5);
+ if (i_len(crec, crec_len) != 1000) {
+ setmsg_("Expected length of character record is 1000. Length of pass"
+ "ed record is #", (ftnlen)73);
+ i__1 = i_len(crec, crec_len);
+ errint_("#", &i__1, (ftnlen)1);
+ sigerr_("SPICE(DAFBADCRECLEN)", (ftnlen)20);
+ } else {
+ io___3.ciunit = unit;
+ io___3.cirec = *recno;
+ iostat = s_wdue(&io___3);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, crec, crec_len);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_wdue();
+L100001:
+ if (iostat != 0) {
+ setmsg_("Character record write failed. Value of IOSTAT was #", (
+ ftnlen)52);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ }
+ }
+ chkout_("DAFWCR", (ftnlen)6);
+ return 0;
+} /* dafwcr_ */
+
diff --git a/ext/spice/src/cspice/dafwda.c b/ext/spice/src/cspice/dafwda.c
new file mode 100644
index 0000000000..df94958fce
--- /dev/null
+++ b/ext/spice/src/cspice/dafwda.c
@@ -0,0 +1,262 @@
+/* dafwda.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static integer c__128 = 128;
+
+/* $Procedure DAFWDA ( DAF, write data to address ) */
+/* Subroutine */ int dafwda_(integer *handle, integer *begin, integer *end,
+ doublereal *data)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer begr, begw, endr, endw, next, n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer recno;
+ extern /* Subroutine */ int moved_(doublereal *, integer *, doublereal *);
+ logical found;
+ integer first;
+ extern /* Subroutine */ int cleard_(integer *, doublereal *), dafrdr_(
+ integer *, integer *, integer *, integer *, doublereal *, logical
+ *), dafarw_(integer *, integer *, integer *), dafwdr_(integer *,
+ integer *, doublereal *);
+ doublereal buffer[128];
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Write or rewrite the double precision data bounded by two */
+/* addresses within a DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of a DAF. */
+/* BEGIN, */
+/* END I Initial, final address within file. */
+/* DATA I Data to be stored between BEGIN and END. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAF. */
+
+/* BEGIN, */
+/* END are the initial and final addresses of a contiguous */
+/* set of double precision numbers within a DAF. */
+/* Presumably, these make up all or part of a */
+/* particular array. */
+
+/* DATA are the double precision data to be stored between */
+/* the specified addresses within the specified file. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If BEGIN is zero or negative, the error SPICE(DAFNEGADDR) */
+/* is signalled. */
+
+/* 1) If the BEGIN > END, the error SPICE(DAFBEGGTEND) */
+/* is signalled. */
+
+/* $ Particulars */
+
+/* The principal reason that DAFs are so easy to use is that */
+/* the data in each DAF are considered to be one long contiguous */
+/* set of double precision numbers. You can store data anywhere */
+/* within a DAF without knowing (or caring) about the physical */
+/* records in which they are stored. */
+
+/* Of course, if you are merely adding arrays to a DAF, */
+/* you should not use DAFWDA directly, but should use DAFANA */
+/* (add new array) and its entry points, since these update */
+/* the appropriate bookkeeping records automatically. */
+
+/* $ Examples */
+
+/* The following code fragment illustrates the use of DAFWDA */
+/* to update an imaginary array. The array begins with a directory */
+/* containing 11 epochs. Each pair of epochs bounds an */
+/* interval, and each interval is covered by a set of eight */
+/* osculating elements. */
+
+/* By accident, the elements were written with the wrong value for */
+/* the GM of the central body (the last element in each set). Each */
+/* set must be retrieved, updated,and rewritten. */
+
+/* CALL DAFUS ( SUM, ND, NI, DC, IC ) */
+/* BEGIN = IC(5) */
+
+/* DO I = 1, 10 */
+/* OFFSET = BEGIN + 11 + (I - 1) * 8 */
+
+/* CALL DAFRDA ( HANDLE, OFFSET+1, OFFSET+8, ELEMENTS ) */
+/* ELEMENTS(8) = NEW_GM */
+
+/* CALL DAFWDA ( HANDLE, OFFSET+1, OFFSET+8, ELEMENTS ) */
+/* END DO */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write data to daf address */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFWDA", (ftnlen)6);
+ }
+
+/* Bad addresses? */
+
+ if (*begin <= 0) {
+ setmsg_("Negative beginning address: #", (ftnlen)29);
+ errint_("#", begin, (ftnlen)1);
+ sigerr_("SPICE(DAFNEGADDR)", (ftnlen)17);
+ chkout_("DAFWDA", (ftnlen)6);
+ return 0;
+ } else if (*begin > *end) {
+ setmsg_("Beginning address (#) greater than ending address (#)", (
+ ftnlen)53);
+ errint_("#", begin, (ftnlen)1);
+ errint_("#", end, (ftnlen)1);
+ sigerr_("SPICE(DAFBEGGTEND)", (ftnlen)18);
+ chkout_("DAFWDA", (ftnlen)6);
+ return 0;
+ }
+
+/* Convert raw addresses to record/word representations. */
+
+ dafarw_(begin, &begr, &begw);
+ dafarw_(end, &endr, &endw);
+
+/* The first and last records may have to be read, updated, and */
+/* rewritten. Any records in between may be written directly. */
+
+ next = 1;
+ i__1 = endr;
+ for (recno = begr; recno <= i__1; ++recno) {
+ if (recno == begr || recno == endr) {
+ dafrdr_(handle, &recno, &c__1, &c__128, buffer, &found);
+ if (! found) {
+ cleard_(&c__128, buffer);
+ }
+ }
+ if (begr == endr) {
+ first = begw;
+ n = endw - begw + 1;
+ } else if (recno == begr) {
+ first = begw;
+ n = 128 - begw + 1;
+ } else if (recno == endr) {
+ first = 1;
+ n = endw;
+ } else {
+ first = 1;
+ n = 128;
+ }
+ moved_(&data[next - 1], &n, &buffer[(i__2 = first - 1) < 128 && 0 <=
+ i__2 ? i__2 : s_rnge("buffer", i__2, "dafwda_", (ftnlen)258)])
+ ;
+ next += n;
+ dafwdr_(handle, &recno, buffer);
+ }
+ chkout_("DAFWDA", (ftnlen)6);
+ return 0;
+} /* dafwda_ */
+
diff --git a/ext/spice/src/cspice/dafwfr.c b/ext/spice/src/cspice/dafwfr.c
new file mode 100644
index 0000000000..c57be627b9
--- /dev/null
+++ b/ext/spice/src/cspice/dafwfr.c
@@ -0,0 +1,478 @@
+/* dafwfr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static logical c_false = FALSE_;
+static integer c__1 = 1;
+
+/* $Procedure DAFWFR ( DAF write file record ) */
+/* Subroutine */ int dafwfr_(integer *handle, integer *nd, integer *ni, char *
+ ifname, integer *fward, integer *bward, integer *free, ftnlen
+ ifname_len)
+{
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_rdue(cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void),
+ s_wdue(cilist *), e_wdue(void);
+
+ /* Local variables */
+ char tail[928];
+ integer unit;
+ extern /* Subroutine */ int zzddhhlu_(integer *, char *, logical *,
+ integer *, ftnlen), chkin_(char *, ftnlen);
+ integer locnd, locni;
+ extern logical failed_(void);
+ integer locffa;
+ extern /* Subroutine */ int dafsih_(integer *, char *, ftnlen);
+ char locifn[60];
+ integer locfdr, locldr;
+ char format[8], idword[8];
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+ char ifn[60];
+
+ /* Fortran I/O blocks */
+ static cilist io___4 = { 1, 0, 1, 0, 1 };
+ static cilist io___14 = { 1, 0, 0, 0, 1 };
+
+
+/* $ Abstract */
+
+/* Write or rewrite the contents of the file record of a DAF. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAF */
+
+/* $ Keywords */
+
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of an open DAF file. */
+/* ND I Number of double precision components in summaries. */
+/* ND I Number of integer components in summaries. */
+/* IFNAME I Internal filename. */
+/* FWARD I Forward list pointer. */
+/* BWARD I Backward list pointer. */
+/* FREE I Free address pointer. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle associated with a DAF file opened for */
+/* writing. */
+
+/* ND, */
+/* NI are the numbers of double precision and integer */
+/* components, respectively, in each array summary */
+/* in the specified file. */
+
+/* IFNAME is the internal file name to be stored in the first */
+/* (or file) record of the specified file. */
+
+/* FWARD is the forward list pointer. This points to the */
+/* first summary record in the file. */
+
+/* BWARD is the backward list pointer. This points to the */
+/* final summary record in the file. */
+
+/* FREE is the free address pointer. This contains the */
+/* first free address in the file. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the handle passed to this routine is not the handle of an */
+/* open DAF file, the error will be signaled by a routine called */
+/* by this routine. */
+
+/* 2) If the specified DAF file is not open for write access, the */
+/* error will be diagnosed by a routine called by this routine. */
+
+/* 3) If the file record cannot (for some reason) be written, */
+/* the error SPICE(DAFWRITEFAIL) is signaled. */
+
+/* 4) If the attempt to read the file record fails, the error */
+/* SPICE(DAFREADFAIL) will be signaled. */
+
+/* $ Particulars */
+
+/* The file record of a DAF is the only record that contains */
+/* any global information about the file. This record is created */
+/* when the file is created, and is updated only when new arrays */
+/* are added. */
+
+/* DO NOT CHANGE THE CONTENTS OF THE FILE RECORD UNLESS */
+/* YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING. */
+
+/* Like character records, file records are not buffered. */
+
+/* $ Examples */
+
+/* None. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* NAIF Document 167.0, "Double Precision Array Files (DAF) */
+/* Specification and User's Guide" */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 4.0.0, 27-NOV-2001 (FST) */
+
+/* Updated this routine to utilize new handle manager */
+/* interfaces. Comments were expanded and clarified. */
+
+/* - SPICELIB Version 3.0.0, 21-MAR-1999 (FST) */
+
+/* This routine was modified to accomodate the preservation */
+/* of the FTP validation and binary file format strings that */
+/* are now part of the DAF file record. */
+
+/* - SPICELIB Version 2.0.0, 05-OCT-1993 (KRG) */
+
+/* The error SPICE(DAFNOIDWORD) is no longer signalled by this */
+/* routine. The reason for this is that if DAFSIH returns OK then */
+/* the handle passed to this routine is indeed a valid DAF file */
+/* handle, otherwise the error is diagnosed by DAFSIH. */
+
+/* Added two new exceptions to the $ Exceptions section: 1 and 4. */
+/* The remaining exceptions (2 and 3) were already present. The */
+/* exceptions that were added are not new, but are being */
+/* documented for the first time. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write daf file record */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 4.0.0, 27-NOV-2001 (FST) */
+
+/* The call to DAFHLU has been replaced with a call to */
+/* ZZDDHHLU, the handle manager interface for retrieving */
+/* a logical unit. DAFHLU is no longer used, since it */
+/* locks the unit returned to its HANDLE, tying up resources */
+/* in the handle manager. */
+
+/* - SPICELIB Version 3.0.0, 21-MAR-1999 (FST) */
+
+/* In order to preserve the additional information that */
+/* now resides in the file record, this routine reads */
+/* the entire record into local buffers, including the */
+/* TAILEN characters that follow the actual data content. */
+/* The contents of the local buffers that correspond to */
+/* information brought in from the call sequence of the */
+/* routine are ignored when the record is rewritten. */
+/* However, the ID word, the file format string, and the */
+/* trailing TAILEN characters that contain the FTP validation */
+/* string are rewritten along with the input values. */
+
+/* This routine does not simply replace the FTP validation */
+/* string with the components from ZZFTPSTR, since that */
+/* would possibly validate a corrupt file created using a newer */
+/* Toolkit. */
+
+/* - SPICELIB Version 2.0.0, 05-OCT-1993 (KRG) */
+
+/* The error SPICE(DAFNOIDWORD) is no longer signalled by this */
+/* routine. The reason for this is that if DAFSIH returns OK then */
+/* the handle passed to this routine is indeed a valid DAF file */
+/* handle, otherwise the error is diagnosed by DAFSIH. */
+
+/* Added a call to DAFSIH to signal an invalid handle and a test */
+/* of FAILED () after it. This is to make sure that the DAF file */
+/* is open for writing. If this call succeeds, we know that we */
+/* have a valid DAF handle, so there is no need to check FAILED */
+/* after the call to DAFHLU. */
+
+/* Added code to read the file ID word so that it could be */
+/* preserved when the file record is written. This supports the ID */
+/* word format that contains type information. */
+
+/* Added variable IDWORD to the routine, as well as the parameters */
+/* IDWLEN and IFNLEN. */
+
+/* Added two new exceptions to the $ Exceptions section: 1 and 4. */
+/* The remaining exceptions (2 and 3) were already present. The */
+/* exceptions that were added are not new, but are being */
+/* documented for the first time. */
+
+/* Removed code that tested the sign of HANDLE to see if the file */
+/* was open for write access, HANDLE < 0. This test was no longer */
+/* necessary, as the call to DASSIH performs this test as well. No */
+/* sense doing it twice. */
+
+/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
+
+/* Literature references added to the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local Parameters */
+
+
+/* The parameter TAILEN determines the tail length of a DAF file */
+/* record. This is the number of bytes (characters) that */
+/* occupy the portion of the file record that follows the */
+/* integer holding the first free address. For environments */
+/* with a 32 bit word length, 1 byte characters, and DAF */
+/* record sizes of 1024 bytes, we have: */
+
+/* 8 bytes - IDWORD */
+/* 4 bytes - ND (32 bit integer) */
+/* 4 bytes - NI (32 bit integer) */
+/* 60 bytes - IFNAME */
+/* 4 bytes - FWARD (32 bit integer) */
+/* 4 bytes - BWARD (32 bit integer) */
+/* + 4 bytes - FREE (32 bit integer) */
+/* --------- */
+/* 88 bytes - (All file records utilize this space.) */
+
+/* So the size of the remaining portion (or tail) of the DAF */
+/* file record for computing enviroments as described above */
+/* would be: */
+
+/* 1024 bytes - DAF record size */
+/* - 8 bytes - DAF Binary File Format Word */
+/* - 88 bytes - (from above) */
+/* ------------ */
+/* 928 bytes - DAF file record tail length */
+
+/* Note: environments that do not have a 32 bit word length, */
+/* 1 byte characters, and a DAF record size of 1024 bytes, will */
+/* require the adjustment of this parameter. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DAFWFR", (ftnlen)6);
+ }
+
+/* Do some initializations */
+
+ s_copy(idword, " ", (ftnlen)8, (ftnlen)1);
+
+/* Check to be sure that HANDLE is attached to a file that is open */
+/* with write access. If the call fails, check out and return. */
+
+ dafsih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DAFWFR", (ftnlen)6);
+ return 0;
+ }
+
+/* Get the logical unit for the file, as we know we have a valid DAF */
+/* handle with the correct access method. */
+
+ zzddhhlu_(handle, "DAF", &c_false, &unit, (ftnlen)3);
+ if (failed_()) {
+ chkout_("DAFWFR", (ftnlen)6);
+ return 0;
+ }
+
+/* In order to maintain the integrity of the file ID word, the */
+/* file FORMAT, and the FTP string if present, we need to */
+/* read the entire file record into the appropriate sized local */
+/* buffers. The values of the LOCxxx variables are simply */
+/* ignored, since the caller passes new values in for updates. */
+
+ io___4.ciunit = unit;
+ iostat = s_rdue(&io___4);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, idword, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&locnd, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&locni, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, locifn, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&locfdr, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&locldr, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&locffa, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, format, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, tail, (ftnlen)928);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rdue();
+L100001:
+ if (iostat != 0) {
+ setmsg_("Attempt to read the file record failed for file '#'. IOSTAT"
+ " = #", (ftnlen)63);
+ errfnm_("#", &unit, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFREADFAIL)", (ftnlen)18);
+ chkout_("DAFWFR", (ftnlen)6);
+ return 0;
+ }
+
+/* Set the value of the internal filename before writing. This is to */
+/* guarantee that its length is ok. */
+
+ s_copy(ifn, ifname, (ftnlen)60, ifname_len);
+ io___14.ciunit = unit;
+ iostat = s_wdue(&io___14);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, idword, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&(*nd), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&(*ni), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, ifn, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&(*fward), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&(*bward), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&(*free), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, format, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, tail, (ftnlen)928);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_wdue();
+L100002:
+ if (iostat != 0) {
+ setmsg_("File record write failed. Value of IOSTAT was #", (ftnlen)47)
+ ;
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DAFWRITEFAIL)", (ftnlen)19);
+ chkout_("DAFWFR", (ftnlen)6);
+ return 0;
+ }
+ chkout_("DAFWFR", (ftnlen)6);
+ return 0;
+} /* dafwfr_ */
+
diff --git a/ext/spice/src/cspice/dasa2l.c b/ext/spice/src/cspice/dasa2l.c
new file mode 100644
index 0000000000..7de3607f56
--- /dev/null
+++ b/ext/spice/src/cspice/dasa2l.c
@@ -0,0 +1,1042 @@
+/* dasa2l.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static integer c__2 = 2;
+static integer c__256 = 256;
+
+/* $Procedure DASA2L ( DAS, address to physical location ) */
+/* Subroutine */ int dasa2l_(integer *handle, integer *type__, integer *
+ addrss, integer *clbase, integer *clsize, integer *recno, integer *
+ wordno)
+{
+ /* Initialized data */
+
+ static integer next[3] = { 2,3,1 };
+ static integer prev[3] = { 3,1,2 };
+ static integer nw[3] = { 1024,128,256 };
+ static integer rngloc[3] = { 3,5,7 };
+ static logical first = TRUE_;
+ static integer nfiles = 0;
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer), s_cmp(char *, char *,
+ ftnlen, ftnlen);
+
+ /* Local variables */
+ static integer free, nrec, fidx;
+ static logical fast;
+ static integer unit, i__, range[2], tbhan[20];
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ static integer ncomc, ncomr, ndirs;
+ static logical known;
+ static integer hiaddr;
+ extern /* Subroutine */ int dasham_(integer *, char *, ftnlen);
+ static integer tbbase[60] /* was [3][20] */;
+ static char access[10];
+ static integer dscloc, dirrec[256];
+ extern /* Subroutine */ int dashfs_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *, integer *, integer *);
+ static logical samfil;
+ static integer mxaddr;
+ extern integer isrchi_(integer *, integer *, integer *);
+ static integer tbmxad[60] /* was [3][20] */;
+ static logical tbfast[20];
+ static integer mxclrc;
+ extern /* Subroutine */ int dashlu_(integer *, integer *), errfnm_(char *,
+ integer *, ftnlen);
+ static integer lstrec[3];
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ static integer prvhan;
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ static integer nresvc, tbsize[60] /* was [3][20] */, nxtrec;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen), dasrri_(integer *, integer *, integer *,
+ integer *, integer *);
+ static logical rdonly;
+ static integer lstwrd[3], nresvr, ntypes, curtyp, prvtyp;
+
+/* $ Abstract */
+
+/* Map a DAS address to a physical location in the DAS file */
+/* it refers to. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* TRANSFORMATION */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* TYPE I Data type specifier. */
+/* ADDRSS I DAS address of a word of data type TYPE. */
+/* CLBASE, */
+/* CLSIZE O Cluster base record number and size. */
+/* RECNO, */
+/* WORDNO O Record/word pair corresponding to ADDRSS. */
+/* CHAR P Parameter indicating character data type. */
+/* DP P Parameter indicating double precision data type. */
+/* INT P Parameter indicating integer data type. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the file handle of an open DAS file. */
+
+/* TYPE is a data type specifier. TYPE may be any of */
+/* the parameters */
+
+/* CHAR */
+/* DP */
+/* INT */
+
+/* which indicate `character', `double precision', */
+/* and `integer' respectively. */
+
+
+/* ADDRSS is the address in a DAS of a word of data */
+/* type TYPE. For each data type (double precision, */
+/* integer, or character), addresses range */
+/* from 1 to the maximum current value for that type, */
+/* which is available from DAFRFR. */
+
+/* $ Detailed_Output */
+
+/* CLBASE, */
+/* CLSIZE are, respectively, the base record number and */
+/* size, in records, of the cluster containing the */
+/* word corresponding to ADDRSS. The cluster spans */
+/* records numbered CLBASE through CLBASE + */
+/* CLSIZE - 1. */
+
+/* RECNO, */
+/* WORD are, respectively, the number of the physical */
+/* record and the number of the word within the */
+/* record that correspond to ADDRSS. Word numbers */
+/* start at 1 and go up to NC, ND, or NI in */
+/* character, double precision, or integer records */
+/* respectively. */
+
+/* $ Parameters */
+
+/* CHAR, */
+/* DP, */
+/* INT are data type specifiers which indicate */
+/* `character', `double precision', and `integer' */
+/* respectively. These parameters are used in */
+/* all DAS routines that require a data type */
+/* specifier as input. */
+
+/* $ Exceptions */
+
+/* 1) If TYPE is not recognized, the error SPICE(DASINVALIDTYPE) */
+/* will be signalled. */
+
+/* 2) ADDRSS must be between 1 and LAST inclusive, where LAST */
+/* is last address in the DAS for a word of the specified */
+/* type. If ADDRSS is out of range, the error */
+/* SPICE(DASNOSUCHADDRESS) will be signalled. */
+
+/* 3) If this routine fails to find directory information for */
+/* the input address, the error SPICE(NOSUCHRECORD) will be */
+/* signalled. */
+
+/* 4) If the input handle is invalid, the error will be diagnosed */
+/* by routines called by this routine. */
+
+
+/* If any of the above exceptions occur, the output arguments may */
+/* contain bogus information. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* The DAS architecture allows a programmer to think of the data */
+/* within a DAS file as three one-dimensional arrays: one of */
+/* double precision numbers, one of integers, and one of characters. */
+/* This model allows a programmer to ask the DAS system for the */
+/* `nth double precision number (or integer, or character) in the */
+/* file'. */
+
+/* DAS files are Fortran direct access files, so to find the */
+/* `nth double precision number', you must have the number of the */
+/* record containing it and the `word number', or position, within */
+/* the record of the double precision number. This routine finds */
+/* the record/word number pair that specify the physical location */
+/* in a DAS file corresponding to a DAS address. */
+
+/* As opposed to DAFs, the mapping of addresses to physical locations */
+/* for a DAS file depends on the organization of data in the file. */
+/* Given a fixed set of DAS format parameters, the physical location */
+/* of the nth double precision number can depend on how many integer */
+/* and character records have been written prior to the record */
+/* containing that double precision number. */
+
+/* The cluster information output from this routine allows the */
+/* caller to substantially reduce the number of directory reads */
+/* required to read a from range of addresses that spans */
+/* multiple physical records; the reading program only need call */
+/* this routine once per cluster read, rather than once per */
+/* physical record read. */
+
+/* $ Examples */
+
+/* 1) Use this routine to read integers from a range of */
+/* addresses. This is done in the routine DASRDI. */
+
+/* C */
+/* C Decide how many integers to read. */
+/* C */
+/* NUMINT = LAST - FIRST + 1 */
+/* NREAD = 0 */
+
+/* C */
+/* C Find out the physical location of the first */
+/* C integer. If FIRST is invalid, DASA2L will take care */
+/* C of the problem. */
+/* C */
+
+/* CALL DASA2L ( HANDLE, INT, FIRST, */
+/* . CLBASE, CLSIZE, RECNO, WORDNO ) */
+
+/* C */
+/* C Read as much data from record RECNO as necessary. */
+/* C */
+/* N = MIN ( NUMINT, NWI - WORDNO + 1 ) */
+
+/* CALL DASRRI ( HANDLE, RECNO, WORDNO, WORDNO + N-1, */
+/* . DATA ) */
+
+/* NREAD = N */
+/* RECNO = RECNO + 1 */
+
+/* C */
+/* C Read from as many additional records as necessary. */
+/* C */
+/* DO WHILE ( NREAD .LT. NUMINT ) */
+/* C */
+/* C At this point, RECNO is the correct number of the */
+/* C record to read from next. CLBASE is the number */
+/* C of the first record of the cluster we're about */
+/* C to read from. */
+/* C */
+
+/* IF ( RECNO .LT. ( CLBASE + CLSIZE ) ) THEN */
+/* C */
+/* C We can continue reading from the current */
+/* C cluster. */
+/* C */
+/* N = MIN ( NUMINT - NREAD, NWI ) */
+
+/* CALL DASRRI ( HANDLE, */
+/* . RECNO, */
+/* . 1, */
+/* . N, */
+/* . DATA ( NREAD + 1 ) ) */
+
+/* NREAD = NREAD + N */
+/* RECNO = RECNO + 1 */
+
+
+/* ELSE */
+/* C */
+/* C We must find the next integer cluster to */
+/* C read from. The first integer in this */
+/* C cluster has address FIRST + NREAD. */
+/* C */
+/* CALL DASA2L ( HANDLE, */
+/* . INT, */
+/* . FIRST + NREAD, */
+/* . CLBASE, */
+/* . CLSIZE, */
+/* . RECNO, */
+/* . WORDNO ) */
+
+/* END IF */
+
+/* END DO */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.2.1 20-NOV-2001 (NJB) */
+
+/* Comment fix: diagram showing directory record pointers */
+/* incorrectly showed element 2 of the record as a backward */
+/* pointer. The element is actually a forward pointer. */
+
+/* - SPICELIB Version 1.2.0 03-JUL-1996 (NJB) */
+
+/* Bug fix: calculation to determine whether file is segregated */
+/* has been fixed. */
+
+/* - SPICELIB Version 1.1.1 19-DEC-1995 (NJB) */
+
+/* Corrected title of permuted index entry section. */
+
+/* - SPICELIB Version 1.1.0, 03-NOV-1995 (NJB) */
+
+/* Re-written to optimize address calculations for segregated, */
+/* read-only files. */
+
+/* - SPICELIB Version 1.0.1, 26-OCT-1993 (KRG) */
+
+/* Fixed a typo in the $ Brief_I/O section of the header. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* map DAS logical address to physical location */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.2.0 03-JUL-1996 (NJB) */
+
+/* Bug fix: calculation to determine whether file is segregated */
+/* has been fixed. An incorrect variable name used in a bound */
+/* calculation resulted in an incorrect determination of whether */
+/* a file was segregated, and caused arithmetic overflow for */
+/* files with large maximum addresses. */
+
+/* In the previous version, the number of DAS words in a cluster */
+/* was incorrectly calculated as the product of the maximum */
+/* address of the cluster's data type and the number of words of */
+/* that data type in a DAS record. The correct product involves */
+/* the number of records in the cluster and the number of words of */
+/* that data type in a DAS record. */
+
+/* - SPICELIB Version 1.1.0, 03-NOV-1995 (NJB) */
+
+/* Re-written to optimize address calculations for segregated, */
+/* read-only files. */
+
+/* - SPICELIB Version 1.0.1, 26-OCT-1993 (KRG) */
+
+/* Fixed a typo in the $ Brief_I/O section of the header. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Words per data record, for each data type: */
+
+
+/* Directory pointer locations */
+
+
+/* Directory address range locations */
+
+
+/* Indices of lowest and highest addresses in a `range array': */
+
+
+/* Location of first type descriptor */
+
+
+/* Access word length */
+
+
+/* File table size */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+
+/* NEXT and PREV map the DAS data type codes to their */
+/* successors and predecessors, respectively. */
+
+
+/* Discovery check-in is used in this routine. */
+
+
+/* DAS files have the following general structure: */
+
+/* +------------------------+ */
+/* | file record | */
+/* +------------------------+ */
+/* | reserved records | */
+/* | | */
+/* +------------------------+ */
+/* | comment records | */
+/* | | */
+/* | | */
+/* | | */
+/* +------------------------+ */
+/* | first data directory | */
+/* +------------------------+ */
+/* | data records | */
+/* | | */
+/* | | */
+/* | | */
+/* | | */
+/* +------------------------+ */
+/* . */
+/* . */
+/* +------------------------+ */
+/* | last data directory | */
+/* +------------------------+ */
+/* | data records | */
+/* | | */
+/* | | */
+/* +------------------------+ */
+
+
+/* Within each DAS data record, word numbers start at one and */
+/* increase up to NWI, NWD, or NWC: the number of words in an */
+/* integer, double precision, or character data record. */
+
+
+/* +--------------------------------+ */
+/* | | | ... | | */
+/* +--------------------------------+ */
+/* 1 2 NWD */
+
+/* +--------------------------------+ */
+/* | | | ... | | */
+/* +--------------------------------+ */
+/* 1 2 NWI */
+
+/* +------------------------------------+ */
+/* | | | ... | | */
+/* +------------------------------------+ */
+/* 1 2 NWC */
+
+
+/* Directories are single records that describe the data */
+/* types of data records that follow. The directories */
+/* in a DAS file form a doubly linked list: each directory */
+/* contains forward and backward pointers to the next and */
+/* previous directories. */
+
+/* Each directory also contains, for each data type, the lowest */
+/* and highest logical address occurring in any of the records */
+/* described by the directory. */
+
+/* Following the pointers and address range information is */
+/* a sequence of data type descriptors. These descriptors */
+/* indicate the data type of data records following the */
+/* directory record. Each descriptor gives the data type */
+/* of a maximal set of contiguous data records, all having the */
+/* same type. By `maximal set' we mean that no data records of */
+/* the same type bound the set of records in question. */
+
+/* Pictorially, the structure of a directory is as follows: */
+
+/* +----------------------------------------------------+ */
+/* | | | | */
+/* +----------------------------------------------------+ */
+
+/* where the section looks like */
+
+/* +-----------------------------------------+ */
+/* | | | */
+/* +-----------------------------------------+ */
+
+/* the section looks like */
+
+/* +-------------------------------------------+ */
+/* | | | | */
+/* +-------------------------------------------+ */
+
+/* and each range looks like one of: */
+
+/* +------------------------------------------------+ */
+/* | | | */
+/* +------------------------------------------------+ */
+
+/* +------------------------------------------------+ */
+/* | | | */
+/* +------------------------------------------------+ */
+
+/* +------------------------------------------------+ */
+/* | | | */
+/* +------------------------------------------------+ */
+
+/* The type descriptors implement a run-length encoding */
+/* scheme. The first element of the series of descriptors */
+/* occupies two integers: it contains a type code and a count. */
+/* The rest of the descriptors are just signed counts; the data */
+/* types of the records they describe are deduced from the sign */
+/* of the count and the data type of the previous descriptor. */
+/* The method of finding the data type for a given descriptor */
+/* in terms of its predecessor is as follows: if the sign of a */
+/* descriptor is positive, the type of that descriptor is the */
+/* successor of the type of the preceding descriptor in the */
+/* sequence of types below. If the sign of a descriptor is */
+/* negative, the type of the descriptor is the predecessor of the */
+/* type of the preceding descriptor. */
+
+/* C --> D --> I --> C */
+
+/* For example, if the preceding type is `I', and a descriptor */
+/* contains the number 16, the type of the descriptor is `C', */
+/* whereas if the descriptor contained the number -800, the type */
+/* of the descriptor would be `D'. */
+
+
+/* Make sure the data type is valid. */
+
+ if (*type__ < 1 || *type__ > 3) {
+ chkin_("DASA2L", (ftnlen)6);
+ dashlu_(handle, &unit);
+ setmsg_("Invalid data type: #. File was #", (ftnlen)33);
+ errint_("#", type__, (ftnlen)1);
+ errfnm_("#", &unit, (ftnlen)1);
+ sigerr_("SPICE(DASINVALIDTYPE)", (ftnlen)21);
+ chkout_("DASA2L", (ftnlen)6);
+ return 0;
+ }
+
+/* Decide whether we're looking at the same file as we did on */
+/* the last call. */
+
+ if (first) {
+ samfil = FALSE_;
+ fast = FALSE_;
+ prvhan = *handle;
+ first = FALSE_;
+ } else {
+ samfil = *handle == prvhan;
+ prvhan = *handle;
+ }
+
+/* We have a special case if we're looking at a `fast' file */
+/* that we saw on the last call. When we say a file is fast, */
+/* we're implying that it's open for read access only and that it's */
+/* segregated. In this case, we can do an address calculation */
+/* without looking up any information from the file. */
+
+ if (samfil && fast) {
+ *clbase = tbbase[(i__1 = *type__ + fidx * 3 - 4) < 60 && 0 <= i__1 ?
+ i__1 : s_rnge("tbbase", i__1, "dasa2l_", (ftnlen)666)];
+ *clsize = tbsize[(i__1 = *type__ + fidx * 3 - 4) < 60 && 0 <= i__1 ?
+ i__1 : s_rnge("tbsize", i__1, "dasa2l_", (ftnlen)667)];
+ mxaddr = tbmxad[(i__1 = *type__ + fidx * 3 - 4) < 60 && 0 <= i__1 ?
+ i__1 : s_rnge("tbmxad", i__1, "dasa2l_", (ftnlen)668)];
+ hiaddr = *clsize * nw[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("nw", i__1, "dasa2l_", (ftnlen)669)];
+
+/* Make sure that ADDRSS points to an existing location. */
+
+ if (*addrss < 1 || *addrss > mxaddr) {
+ chkin_("DASA2L", (ftnlen)6);
+ dashlu_(handle, &unit);
+ setmsg_("ADDRSS was #; valid range for type # is # to #. File w"
+ "as #", (ftnlen)59);
+ errint_("#", addrss, (ftnlen)1);
+ errint_("#", type__, (ftnlen)1);
+ errint_("#", &c__1, (ftnlen)1);
+ errint_("#", &mxaddr, (ftnlen)1);
+ errfnm_("#", &unit, (ftnlen)1);
+ sigerr_("SPICE(DASNOSUCHADDRESS)", (ftnlen)23);
+ chkout_("DASA2L", (ftnlen)6);
+ return 0;
+ }
+ } else {
+
+/* If the current file is not the same one we looked at on the */
+/* last call, find out whether the file is on record in our file */
+/* table. Add the file to the table if necessary. Bump the */
+/* oldest file in the table if there's no room. */
+
+ if (! samfil) {
+ fidx = isrchi_(handle, &nfiles, tbhan);
+ known = fidx > 0;
+ if (known) {
+
+/* The file is in our list. */
+
+ fast = tbfast[(i__1 = fidx - 1) < 20 && 0 <= i__1 ? i__1 :
+ s_rnge("tbfast", i__1, "dasa2l_", (ftnlen)708)];
+ if (fast) {
+
+/* This is a segregated, read-only file. Look up the */
+/* saved information we'll need to calculate addresses. */
+
+ *clbase = tbbase[(i__1 = *type__ + fidx * 3 - 4) < 60 &&
+ 0 <= i__1 ? i__1 : s_rnge("tbbase", i__1, "dasa2"
+ "l_", (ftnlen)715)];
+ *clsize = tbsize[(i__1 = *type__ + fidx * 3 - 4) < 60 &&
+ 0 <= i__1 ? i__1 : s_rnge("tbsize", i__1, "dasa2"
+ "l_", (ftnlen)716)];
+ mxaddr = tbmxad[(i__1 = *type__ + fidx * 3 - 4) < 60 && 0
+ <= i__1 ? i__1 : s_rnge("tbmxad", i__1, "dasa2l_",
+ (ftnlen)717)];
+ hiaddr = *clsize * nw[(i__1 = *type__ - 1) < 3 && 0 <=
+ i__1 ? i__1 : s_rnge("nw", i__1, "dasa2l_", (
+ ftnlen)718)];
+
+/* Make sure that ADDRSS points to an existing location. */
+
+ if (*addrss < 1 || *addrss > mxaddr) {
+ chkin_("DASA2L", (ftnlen)6);
+ dashlu_(handle, &unit);
+ setmsg_("ADDRSS was #; valid range for type # is # "
+ "to #. File was #", (ftnlen)60);
+ errint_("#", addrss, (ftnlen)1);
+ errint_("#", type__, (ftnlen)1);
+ errint_("#", &c__1, (ftnlen)1);
+ errint_("#", &mxaddr, (ftnlen)1);
+ errfnm_("#", &unit, (ftnlen)1);
+ sigerr_("SPICE(DASNOSUCHADDRESS)", (ftnlen)23);
+ chkout_("DASA2L", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* FAST is set. */
+
+ }
+
+/* KNOWN is set. */
+
+ }
+
+/* SAMFIL, FAST, and KNOWN are set. If the file is the same one */
+/* we saw on the last call, the state variables FAST, and KNOWN */
+/* retain their values from the previous call. */
+
+/* FIDX is set at this point only if we're looking at a known */
+/* file. */
+
+/* Unless the file is recognized and known to be a fast file, we */
+/* look up all metadata for the file. */
+
+ if (! (known && fast)) {
+ if (! known) {
+
+/* This file is not in our list. If the list is not full, */
+/* append the file to the list. If the list is full, */
+/* replace the oldest (first) file with this one. */
+
+ if (nfiles < 20) {
+ ++nfiles;
+ fidx = nfiles;
+ } else {
+ fidx = 1;
+ }
+ tbhan[(i__1 = fidx - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge(
+ "tbhan", i__1, "dasa2l_", (ftnlen)781)] = *handle;
+
+/* Find out whether the file is open for read or write */
+/* access. We consider the file to be `slow' until we find */
+/* out otherwise. The contents of the arrays TBHIGH, */
+/* TBBASE, TBSIZE, and TBMXAD are left undefined for slow */
+/* files. */
+
+ dasham_(handle, access, (ftnlen)10);
+ rdonly = s_cmp(access, "READ", (ftnlen)10, (ftnlen)4) == 0;
+ fast = FALSE_;
+ tbfast[(i__1 = fidx - 1) < 20 && 0 <= i__1 ? i__1 : s_rnge(
+ "tbfast", i__1, "dasa2l_", (ftnlen)794)] = fast;
+
+/* We'll set the flag KNOWN at the end of the outer IF */
+/* block. */
+
+ } else {
+
+/* We set RDONLY to .FALSE. for any known file that is */
+/* not fast. It's actually possible for a read-only file */
+/* to be unsegregated, but this is expected to be a rare */
+/* case, one that's not worth complicating this routine */
+/* further for. */
+
+ rdonly = FALSE_;
+ }
+
+/* RDONLY is set. */
+
+/* FIDX is now set whether or not the current file is known. */
+
+/* Get the number of reserved records, comment records, and */
+/* the current last address of the data type TYPE from the */
+/* file summary. */
+
+ dashfs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, &tbmxad[(
+ i__1 = fidx * 3 - 3) < 60 && 0 <= i__1 ? i__1 : s_rnge(
+ "tbmxad", i__1, "dasa2l_", (ftnlen)821)], lstrec, lstwrd);
+ mxaddr = tbmxad[(i__1 = *type__ + fidx * 3 - 4) < 60 && 0 <= i__1
+ ? i__1 : s_rnge("tbmxad", i__1, "dasa2l_", (ftnlen)831)];
+
+/* Make sure that ADDRSS points to an existing location. */
+
+ if (*addrss < 1 || *addrss > mxaddr) {
+ chkin_("DASA2L", (ftnlen)6);
+ dashlu_(handle, &unit);
+ setmsg_("ADDRSS was #; valid range for type # is # to #. F"
+ "ile was #", (ftnlen)60);
+ errint_("#", addrss, (ftnlen)1);
+ errint_("#", type__, (ftnlen)1);
+ errint_("#", &c__1, (ftnlen)1);
+ errint_("#", &mxaddr, (ftnlen)1);
+ errfnm_("#", &unit, (ftnlen)1);
+ sigerr_("SPICE(DASNOSUCHADDRESS)", (ftnlen)23);
+ chkout_("DASA2L", (ftnlen)6);
+ return 0;
+ }
+
+/* Find out which directory describes the cluster containing */
+/* this word. To do this, we must traverse the directory */
+/* list. The first directory record comes right after the */
+/* last comment record. (Don't forget the file record when */
+/* counting the predecessors of the directory record.) */
+
+/* Note that we don't need to worry about not finding a */
+/* directory record that contains the address we're looking */
+/* for, since we've already checked that the address is in */
+/* range. */
+
+/* Keep track of the number of directory records we see. We'll */
+/* use this later to determine whether we've got a segregated */
+/* file. */
+
+ nrec = nresvr + ncomr + 2;
+ ndirs = 1;
+ i__3 = rngloc[(i__2 = *type__ - 1) < 3 && 0 <= i__2 ? i__2 :
+ s_rnge("rngloc", i__2, "dasa2l_", (ftnlen)872)] + 1;
+ dasrri_(handle, &nrec, &rngloc[(i__1 = *type__ - 1) < 3 && 0 <=
+ i__1 ? i__1 : s_rnge("rngloc", i__1, "dasa2l_", (ftnlen)
+ 872)], &i__3, range);
+ while(range[1] < *addrss) {
+
+/* The record number of the next directory is the forward */
+/* pointer in the current directory record. Update NREC */
+/* with this pointer. Get the address range for the */
+/* specified type covered by this next directory record. */
+
+ dasrri_(handle, &nrec, &c__2, &c__2, &nxtrec);
+ nrec = nxtrec;
+ ++ndirs;
+ i__3 = rngloc[(i__2 = *type__ - 1) < 3 && 0 <= i__2 ? i__2 :
+ s_rnge("rngloc", i__2, "dasa2l_", (ftnlen)891)] + 1;
+ dasrri_(handle, &nrec, &rngloc[(i__1 = *type__ - 1) < 3 && 0
+ <= i__1 ? i__1 : s_rnge("rngloc", i__1, "dasa2l_", (
+ ftnlen)891)], &i__3, range);
+ }
+
+/* NREC is now the record number of the directory that contains */
+/* the type descriptor for the address we're looking for. */
+
+/* Our next task is to find the descriptor for the cluster */
+/* containing the input address. To do this, we must examine */
+/* the directory record in `left-to-right' order. As we do so, */
+/* we'll keep track of the highest address of type TYPE */
+/* occurring in the clusters whose descriptors we've seen. */
+/* The variable HIADDR will contain this address. */
+
+ dasrri_(handle, &nrec, &c__1, &c__256, dirrec);
+
+/* In the process of finding the physical location */
+/* corresponding to ADDRSS, we'll find the record number of the */
+/* base of the cluster containing ADDRSS. We'll start out by */
+/* initializing this value with the number of the first data */
+/* record of the next cluster. */
+
+ *clbase = nrec + 1;
+
+/* We'll initialize HIADDR with the value preceding the lowest */
+/* address of type TYPE described by the current directory. */
+
+ hiaddr = dirrec[(i__2 = rngloc[(i__1 = *type__ - 1) < 3 && 0 <=
+ i__1 ? i__1 : s_rnge("rngloc", i__1, "dasa2l_", (ftnlen)
+ 925)] - 1) < 256 && 0 <= i__2 ? i__2 : s_rnge("dirrec",
+ i__2, "dasa2l_", (ftnlen)925)] - 1;
+
+/* Initialize the number of records described by the last seen */
+/* type descriptor. This number, when added to CLBASE, should */
+/* yield the number of the first record of the current cluster; */
+/* that's why it's initialized to 0. */
+
+ *clsize = 0;
+
+/* Now find the descriptor for the cluster containing ADDRSS. */
+/* Read descriptors until we get to the one that describes the */
+/* record containing ADDRSS. Keep track of descriptor data */
+/* types as we go. Also count the descriptors. */
+
+/* At this point, HIADDR is less than ADDRSS, so the loop will */
+/* always be executed at least once. */
+
+ prvtyp = prev[(i__1 = dirrec[8] - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("prev", i__1, "dasa2l_", (ftnlen)944)];
+ dscloc = 10;
+ while(hiaddr < *addrss) {
+
+/* Update CLBASE so that it is the record number of the */
+/* first record of the current cluster. */
+
+ *clbase += *clsize;
+
+/* Find the type of the current descriptor. */
+
+ if (dirrec[(i__1 = dscloc - 1) < 256 && 0 <= i__1 ? i__1 :
+ s_rnge("dirrec", i__1, "dasa2l_", (ftnlen)957)] > 0) {
+ curtyp = next[(i__1 = prvtyp - 1) < 3 && 0 <= i__1 ? i__1
+ : s_rnge("next", i__1, "dasa2l_", (ftnlen)958)];
+ } else {
+ curtyp = prev[(i__1 = prvtyp - 1) < 3 && 0 <= i__1 ? i__1
+ : s_rnge("prev", i__1, "dasa2l_", (ftnlen)960)];
+ }
+
+/* Forgetting to update PRVTYP is a Very Bad Thing (VBT). */
+
+ prvtyp = curtyp;
+
+/* If the current descriptor is of the type we're interested */
+/* in, update the highest address count. */
+
+ if (curtyp == *type__) {
+ hiaddr += nw[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1
+ : s_rnge("nw", i__1, "dasa2l_", (ftnlen)973)] * (
+ i__3 = dirrec[(i__2 = dscloc - 1) < 256 && 0 <=
+ i__2 ? i__2 : s_rnge("dirrec", i__2, "dasa2l_", (
+ ftnlen)973)], abs(i__3));
+ }
+
+/* Compute the number of records described by the current */
+/* descriptor. Update the descriptor location. */
+
+ *clsize = (i__2 = dirrec[(i__1 = dscloc - 1) < 256 && 0 <=
+ i__1 ? i__1 : s_rnge("dirrec", i__1, "dasa2l_", (
+ ftnlen)980)], abs(i__2));
+ ++dscloc;
+ }
+
+/* If we have an unknown read-only file, see whether the file */
+/* is segregated. If it is, we'll be able to compute */
+/* addresses much faster for subsequent reads to this file. */
+
+ if (rdonly && ! known) {
+ if (ndirs == 1) {
+
+/* If this file is segregated, there are at most three */
+/* cluster descriptors, and each one points to a cluster */
+/* containing all records of the corresponding data type. */
+/* For each data type having a non-zero maximum address, */
+/* the size of the corresponding cluster must be large */
+/* enough to hold all addresses of that type. */
+
+ ntypes = 0;
+ for (i__ = 1; i__ <= 3; ++i__) {
+ if (tbmxad[(i__1 = i__ + fidx * 3 - 4) < 60 && 0 <=
+ i__1 ? i__1 : s_rnge("tbmxad", i__1, "dasa2l_"
+ , (ftnlen)1005)] > 0) {
+ ++ntypes;
+ }
+ }
+
+/* Now look at the first NTYPES cluster descriptors, */
+/* collecting cluster bases and sizes as we go. */
+
+ mxclrc = nrec + 1;
+ prvtyp = prev[(i__1 = dirrec[8] - 1) < 3 && 0 <= i__1 ?
+ i__1 : s_rnge("prev", i__1, "dasa2l_", (ftnlen)
+ 1016)];
+ dscloc = 10;
+ fast = TRUE_;
+ while(dscloc <= ntypes + 9 && fast) {
+
+/* Find the type of the current descriptor. */
+
+ if (dirrec[(i__1 = dscloc - 1) < 256 && 0 <= i__1 ?
+ i__1 : s_rnge("dirrec", i__1, "dasa2l_", (
+ ftnlen)1025)] > 0) {
+ curtyp = next[(i__1 = prvtyp - 1) < 3 && 0 <=
+ i__1 ? i__1 : s_rnge("next", i__1, "dasa"
+ "2l_", (ftnlen)1026)];
+ } else {
+ curtyp = prev[(i__1 = prvtyp - 1) < 3 && 0 <=
+ i__1 ? i__1 : s_rnge("prev", i__1, "dasa"
+ "2l_", (ftnlen)1028)];
+ }
+ prvtyp = curtyp;
+ tbbase[(i__1 = curtyp + fidx * 3 - 4) < 60 && 0 <=
+ i__1 ? i__1 : s_rnge("tbbase", i__1, "dasa2l_"
+ , (ftnlen)1032)] = mxclrc;
+ tbsize[(i__1 = curtyp + fidx * 3 - 4) < 60 && 0 <=
+ i__1 ? i__1 : s_rnge("tbsize", i__1, "dasa2l_"
+ , (ftnlen)1033)] = (i__3 = dirrec[(i__2 =
+ dscloc - 1) < 256 && 0 <= i__2 ? i__2 :
+ s_rnge("dirrec", i__2, "dasa2l_", (ftnlen)
+ 1033)], abs(i__3));
+ mxclrc += tbsize[(i__1 = curtyp + fidx * 3 - 4) < 60
+ && 0 <= i__1 ? i__1 : s_rnge("tbsize", i__1,
+ "dasa2l_", (ftnlen)1034)];
+ fast = tbmxad[(i__1 = curtyp + fidx * 3 - 4) < 60 &&
+ 0 <= i__1 ? i__1 : s_rnge("tbmxad", i__1,
+ "dasa2l_", (ftnlen)1037)] <= tbsize[(i__2 =
+ curtyp + fidx * 3 - 4) < 60 && 0 <= i__2 ?
+ i__2 : s_rnge("tbsize", i__2, "dasa2l_", (
+ ftnlen)1037)] * nw[(i__3 = curtyp - 1) < 3 &&
+ 0 <= i__3 ? i__3 : s_rnge("nw", i__3, "dasa2"
+ "l_", (ftnlen)1037)];
+ ++dscloc;
+ }
+
+/* FAST is set. */
+
+ } else {
+
+/* The file has more than one directory record. */
+
+ fast = FALSE_;
+ }
+
+/* If the file was unknown, readonly, and had one directory */
+/* record, we determined whether it was a fast file. */
+
+
+ } else {
+
+/* The file was already known and wasn't fast, or is not */
+/* readonly. */
+
+ fast = FALSE_;
+ }
+
+/* FAST is set. */
+
+ }
+
+/* This is the end of the `.NOT. ( KNOWN .AND. FAST )' case. */
+
+/* At this point, we've set or looked up CLBASE, CLSIZE, MXADDR, */
+/* and HIADDR. */
+
+/* If the file was unknown, we set TBHAN, TBRDON, and TBFAST. */
+/* If the file was unknown and turned out to be fast, we set */
+/* TBBASE, TBSIZE, TBHIGH, and TBMXAD as well. */
+
+/* At this point, it's safe to indicate that the file is known. */
+
+ known = TRUE_;
+ }
+
+/* At this point, */
+
+/* -- CLBASE is properly set: it is the record number of the */
+/* first record of the cluster containing ADDRSS. */
+
+/* -- CLSIZE is properly set: it is the size of the cluster */
+/* containing ADDRSS. */
+
+/* -- HIADDR is the last logical address in the cluster */
+/* containing ADDRSS. */
+
+/* Now we must find the physical record and word corresponding */
+/* to ADDRSS. The structure of the cluster containing ADDRSS and */
+/* HIADDR is shown below: */
+
+/* +--------------------------------------+ */
+/* | | Record # CLBASE */
+/* +--------------------------------------+ */
+/* . */
+/* . */
+/* . */
+/* +--------------------------------------+ */
+/* | |ADDRSS| | Record # RECNO */
+/* +--------------------------------------+ */
+/* . */
+/* . */
+/* . */
+/* +--------------------------------------+ Record # */
+/* | |HIADDR| */
+/* +--------------------------------------+ CLBASE + CLSIZE - 1 */
+
+
+
+ *recno = *clbase + *clsize - 1 - (hiaddr - *addrss) / nw[(i__1 = *type__
+ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("nw", i__1, "dasa2l_", (
+ ftnlen)1122)];
+ *wordno = *addrss - (*addrss - 1) / nw[(i__1 = *type__ - 1) < 3 && 0 <=
+ i__1 ? i__1 : s_rnge("nw", i__1, "dasa2l_", (ftnlen)1125)] * nw[(
+ i__2 = *type__ - 1) < 3 && 0 <= i__2 ? i__2 : s_rnge("nw", i__2,
+ "dasa2l_", (ftnlen)1125)];
+ return 0;
+} /* dasa2l_ */
+
diff --git a/ext/spice/src/cspice/dasac.c b/ext/spice/src/cspice/dasac.c
new file mode 100644
index 0000000000..eb19ce6505
--- /dev/null
+++ b/ext/spice/src/cspice/dasac.c
@@ -0,0 +1,548 @@
+/* dasac.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DASAC ( DAS add comments ) */
+/* Subroutine */ int dasac_(integer *handle, integer *n, char *buffer, ftnlen
+ buffer_len)
+{
+ /* Initialized data */
+
+ static logical first = TRUE_;
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer i__, j, space;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc, recno, ncomr;
+ extern logical failed_(void);
+ extern /* Subroutine */ int dasacr_(integer *, integer *);
+ char ifname[60], crecrd[1024];
+ extern /* Subroutine */ int dasioc_(char *, integer *, integer *, char *,
+ ftnlen, ftnlen), dassih_(integer *, char *, ftnlen);
+ integer nchars;
+ extern integer lastnb_(char *, ftnlen);
+ integer length, newrec, daslun;
+ extern /* Subroutine */ int dashlu_(integer *, integer *);
+ char idword[8];
+ static char eolmrk[1];
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen), dasrfr_(integer *, char
+ *, char *, integer *, integer *, integer *, integer *, ftnlen,
+ ftnlen), daswfr_(integer *, char *, char *, integer *, integer *,
+ integer *, integer *, ftnlen, ftnlen);
+ integer nresvc;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ integer rinuse, curpos;
+ extern logical return_(void);
+ integer nresvr;
+
+/* $ Abstract */
+
+/* Add comments from a buffer of character strings to the comment */
+/* area of a binary DAS file, appending them to any comments which */
+/* are already present in the file's comment area. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS handle of a file opened with write access. */
+/* N I Number of comments to put into the comment area. */
+/* BUFFER I Buffer of lines to be put into the comment area. */
+
+/* $ Detailed_Input */
+
+/* HANDLE The file handle of a binary DAS file which has been */
+/* opened with write access. */
+
+/* N The number of comments in BUFFER that are to be */
+/* added to the comment area of the binary DAS file */
+/* attached to HANDLE. */
+
+/* BUFFER A buffer containing comments which are to be added */
+/* to the comment area of the binary DAS file attached */
+/* to HANDLE. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the number of comments to be added is not positive, the */
+/* error SPICE(INVALIDARGUMENT) will be signalled. */
+
+/* 2) If a non printing ASCII character is encountered in the */
+/* comments, the error SPICE(ILLEGALCHARACTER) will be */
+/* signalled. */
+
+/* 3) If the binary DAS file attached to HANDLE is not open with */
+/* write access an error will be signalled by a routine called */
+/* by this routine. */
+
+/* $ Files */
+
+/* See argument HANDLE in $ Detailed_Input. */
+
+/* $ Particulars */
+
+/* Binary DAS files contain a data area which is reserved for storing */
+/* annotations or descriptive textual information about the data */
+/* contained in a file. This area is referred to as the ``comment */
+/* area'' of the file. The comment area of a DAS file is a line */
+/* oriented medium for storing textual information. The comment */
+/* area preserves any leading or embedded white space in the line(s) */
+/* of text which are stored so that the appearance of the */
+/* information will be unchanged when it is retrieved (extracted) at */
+/* some other time. Trailing blanks, however, are NOT preserved, */
+/* due to the way that character strings are represented in */
+/* standard Fortran 77. */
+
+/* This routine will take a buffer of text lines and add (append) */
+/* them to the comment area of a binary DAS file. If there are no */
+/* comments in the comment area of the file, then space will be */
+/* allocated and the text lines in BUFFER will then placed into the */
+/* comment area. The text lines may contain only printable ASCII */
+/* characters (decimal values 32 - 126). */
+
+/* There is NO maximum length imposed on the significant portion */
+/* of a text line that may be placed into the comment area of a */
+/* DAS file. The maximum length of a line stored in the comment */
+/* area should be reasonable, however, so that they may be easily */
+/* extracted. A good value for this would be 255 characters, as */
+/* this can easily accommodate ``screen width'' lines as well as */
+/* long lines which may contain some other form of information. */
+
+/* $ Examples */
+
+/* Let */
+
+/* HANDLE be the handle for a DAS file which has been opened */
+/* with write access. */
+
+/* N be the number of lines of text to be added to the */
+/* comment area of the binary DAS file attached to */
+/* HANDLE. */
+
+/* BUFFER is a list of text lines to be added to the comment */
+/* area of the binary DAS file attached to HANDLE. */
+
+/* The call */
+
+/* CALL DASAC ( HANDLE, N, BUFFER ) */
+
+/* will append the first N line(s) in BUFFER to the comment area */
+/* of the binary DAS file attached to HANDLE. */
+
+/* $ Restrictions */
+
+/* 1) This routine uses constants that are specific to the ASCII */
+/* character sequence. The results of using this routine with */
+/* a different character sequence are unpredictable. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - Beta Version 1.0.1, 12-MAY-1994 (KRG) */
+
+/* Fixed a typo in the $ Particulars section. */
+
+/* - Beta Version 1.0.0, 23-NOV-1992 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* add comments to a binary das file */
+/* append comments to a das file comment area */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.0.1, 12-MAY-1994 (KRG) */
+
+/* Fixed a typo in the $ Particulars section. */
+
+/* - Beta Version 1.0.0, 23-NOV-1992 (KRG) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* Length of a DAS character record, in characters. */
+
+
+/* Maximum and minimum decimal values for the printable ASCII */
+/* characters. */
+
+
+/* Decimal value for the DAS comment area end-of-line (EOL) marker. */
+
+
+/* Length of a DAS file ID word. */
+
+
+/* Length of a DAS file internal filename. */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASAC", (ftnlen)5);
+ }
+
+/* The lines of text in BUFFER will be ``packed'' into DAS comment */
+/* records: the significant portion of each comment line from BUFFER */
+/* will be terminated by the special character EOLMRK to indicate the */
+/* end of the line. When a comment record is full or all of the */
+/* comments have been added to the file, the comment record will be */
+/* written to the comment area of the binary DAS file. */
+
+/* If this is the first time that this routine has been called, */
+/* we need to initialize the character value for the end-of-line */
+/* marker. */
+
+ if (first) {
+ first = FALSE_;
+ *(unsigned char *)eolmrk = '\0';
+ }
+
+/* Verify that the DAS file attached to HANDLE is opened with write */
+/* access. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DASAC", (ftnlen)5);
+ return 0;
+ }
+
+/* Convert the DAS file handle to its corresponding Fortran logical */
+/* unit number for reading and writing comment records. */
+
+ dashlu_(handle, &daslun);
+ if (failed_()) {
+ chkout_("DASAC", (ftnlen)5);
+ return 0;
+ }
+
+/* Check for a nonpositive number of lines in the buffer. */
+
+ if (*n <= 0) {
+ setmsg_("The number of comment lines to be added to the binary DAS f"
+ "ile # was not positive: #.", (ftnlen)85);
+ errfnm_("#", &daslun, (ftnlen)1);
+ errint_("#", n, (ftnlen)1);
+ sigerr_("SPICE(INVALIDARGUMENT)", (ftnlen)22);
+ chkout_("DASAC", (ftnlen)5);
+ return 0;
+ }
+
+/* Count the number of characters in the buffer ignoring trailing */
+/* blanks on nonblank lines and blank lines. The count will be */
+/* modified to include the contribution of blank lines later. This */
+/* count is used to determine the number of character records to be */
+/* added to the binary DAS file attached to HANDLE. */
+
+ nchars = 0;
+ i__1 = *n;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+
+/* Get the length of the significant portion of a comment line. */
+
+ length = lastnb_(buffer + (i__ - 1) * buffer_len, buffer_len);
+
+/* Scan the comment line for non printing characters. */
+
+ i__2 = length;
+ for (j = 1; j <= i__2; ++j) {
+
+/* Check to see that the characters in the buffer are all */
+/* printing ASCII characters. The bounds for printing ASCII */
+/* characters are given by MAXPCH and MINPCH, which are */
+/* defined in the $ Local Parameters section of the header. */
+
+ if (*(unsigned char *)&buffer[(i__ - 1) * buffer_len + (j - 1)] >
+ 126 || *(unsigned char *)&buffer[(i__ - 1) * buffer_len +
+ (j - 1)] < 32) {
+ setmsg_("A nonprinting character was encountered in the comm"
+ "ent buffer. Value: #", (ftnlen)71);
+ i__3 = *(unsigned char *)&buffer[(i__ - 1) * buffer_len + (j
+ - 1)];
+ errint_("#", &i__3, (ftnlen)1);
+ sigerr_("SPICE(ILLEGALCHARACTER)", (ftnlen)23);
+ chkout_("DASAC", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Increment the number of characters by the length of the */
+/* significant portion of the current line in the buffer. */
+
+ nchars += length;
+ }
+
+/* We need to include the number of end of line markers in the */
+/* number of characters, so add the number of comment lines to */
+/* be added, N, to the number of characters, NCHARS. This is where */
+/* the contribution of any blank lines gets added to the character */
+/* count. */
+
+ nchars += *n;
+
+/* Get the current number of comment records and comment characters */
+/* from the DAS file attached to HANDLE. We will also get back some */
+/* extra stuff that we do not use. */
+
+ dasrfr_(handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (ftnlen)
+ 8, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DASAC", (ftnlen)5);
+ return 0;
+ }
+
+/* Determine the amount of free space in the comment area. If */
+/* there are some comment records allocated, the space available */
+/* is the number of comment records allocated times the length of */
+/* a comment record, minus the number of comment characters already */
+/* used. Otherwise, the space available is zero. */
+
+ if (ncomr > 0) {
+ space = (ncomr << 10) - ncomc;
+ } else {
+ space = 0;
+ }
+
+/* Determine the number of new comment records which are necessary */
+/* to store all of the comments from the buffer. */
+
+ if (nchars > space) {
+
+/* If there are more characters to store than available space */
+/* we need at least one new record. */
+
+ newrec = (nchars - space - 1) / 1024 + 1;
+ } else {
+
+/* Otherwise, we do not need any new records. */
+
+ newrec = 0;
+ }
+
+/* Now add the necessary number of comment records to the file, */
+/* if we need to add any. */
+
+ if (newrec > 0) {
+ dasacr_(handle, &newrec);
+ if (failed_()) {
+ chkout_("DASAC", (ftnlen)5);
+ return 0;
+ }
+
+/* Update the value for the number of comment records to include */
+/* those that were just added. We need this value when we write */
+/* the file record at the end of the routine to update the number */
+/* comment characters, NCOMC. */
+
+ ncomr += newrec;
+ }
+
+/* At this point, we know that we have enough space to write all of */
+/* the comments in BUFFER to the comment area. Either there was */
+/* enough space already there, or we figured out how many new comment */
+/* records were needed, and we added them to the file. So, now we */
+/* begin ``packing'' the comments into DAS character records and */
+/* writing them to the file. */
+
+/* We begin by reading the last comment record if there is one. */
+/* Otherwise we just initialize the appropriate variables. */
+
+ if (ncomc == 0) {
+
+/* If there are no comments in the comment area, then we need to */
+/* skip the file record and the reserved records, if any. The */
+/* first available comment record is the record immediately */
+/* after the last reserved record, so we set RECNO accordingly. */
+/* We also initialize the current position in the comment record, */
+/* and the comment record itself. */
+
+ recno = nresvr + 2;
+ curpos = 1;
+ s_copy(crecrd, " ", (ftnlen)1024, (ftnlen)1);
+ } else {
+
+/* If there are comments in the comment area, then we need to skip */
+/* the file record, the reserved records, if any, and any comment */
+/* records which have been filled. The first comment record */
+/* with space available is the record immediately following the */
+/* last completely filled comment record. So calculate the number */
+/* of comment records in use, and set RECNO appropriately. Then */
+/* calculate the initial position and read in the comment record. */
+
+ rinuse = ncomc / 1024 + 1;
+ recno = nresvr + 1 + rinuse;
+ curpos = ncomc - (rinuse - 1 << 10) + 1;
+ dasioc_("READ", &daslun, &recno, crecrd, (ftnlen)4, (ftnlen)1024);
+ if (failed_()) {
+ chkout_("DASAC", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Begin ``packing'' the comments from the input buffer into the */
+/* comment records, writing the comment records to the DAS file */
+/* as they become filled. */
+
+ i__1 = *n;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+
+/* Get the length of the significant portion of a comment line. */
+
+ length = lastnb_(buffer + (i__ - 1) * buffer_len, buffer_len);
+
+/* Process the comment line. */
+
+ i__2 = length;
+ for (j = 1; j <= i__2; ++j) {
+
+/* If we have filled the comment record while processing */
+/* comment line BUFFER(I), write out the comment record, */
+/* increment the record number, RECNO, and reset the values */
+/* of the current position and the comment record. */
+
+ if (curpos > 1024) {
+ dasioc_("WRITE", &daslun, &recno, crecrd, (ftnlen)5, (ftnlen)
+ 1024);
+ if (failed_()) {
+ chkout_("DASAC", (ftnlen)5);
+ return 0;
+ }
+ ++recno;
+ curpos = 1;
+ s_copy(crecrd, " ", (ftnlen)1024, (ftnlen)1);
+ }
+ *(unsigned char *)&crecrd[curpos - 1] = *(unsigned char *)&buffer[
+ (i__ - 1) * buffer_len + (j - 1)];
+ ++curpos;
+ }
+
+/* Check to see if we happened to exactly fill the comment record */
+/* when we finished processing comment line BUFFER(I). If we */
+/* did, CURPOS will be 1 greater than MXCREC, and we will need */
+/* to write the comment record to the file, increment the record */
+/* number, RECNO, and reset the values of the current position */
+/* and the comment record. */
+
+ if (curpos > 1024) {
+ dasioc_("WRITE", &daslun, &recno, crecrd, (ftnlen)5, (ftnlen)1024)
+ ;
+ if (failed_()) {
+ chkout_("DASAC", (ftnlen)5);
+ return 0;
+ }
+ ++recno;
+ curpos = 1;
+ s_copy(crecrd, " ", (ftnlen)1024, (ftnlen)1);
+ }
+
+/* Append the end-of-line marker to the comment line that we just */
+/* placed into the comment record. */
+
+ *(unsigned char *)&crecrd[curpos - 1] = *(unsigned char *)eolmrk;
+ ++curpos;
+ }
+
+/* We have now finished processing all of the comment lines in */
+/* BUFFER, so we need write the current record to the file. This */
+/* record will always contain something, so we always need to write */
+/* it. */
+
+ dasioc_("WRITE", &daslun, &recno, crecrd, (ftnlen)5, (ftnlen)1024);
+ if (failed_()) {
+ chkout_("DASAC", (ftnlen)5);
+ return 0;
+ }
+
+/* And finally, we need to update the number of comment characters */
+/* in the file record by adding NCHARS, and writing the file record. */
+
+ ncomc += nchars;
+ daswfr_(handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (ftnlen)
+ 8, (ftnlen)60);
+
+/* Check out and leave DASAC. A test of FAILED should be done by */
+/* the calling routine to catch an error that may occur during */
+/* the call to DASWFR. */
+
+ chkout_("DASAC", (ftnlen)5);
+ return 0;
+} /* dasac_ */
+
diff --git a/ext/spice/src/cspice/dasac_c.c b/ext/spice/src/cspice/dasac_c.c
new file mode 100644
index 0000000000..a7d46931d7
--- /dev/null
+++ b/ext/spice/src/cspice/dasac_c.c
@@ -0,0 +1,273 @@
+/*
+
+-Procedure dasac_c ( DAS add comments )
+
+-Abstract
+
+ Add comments from a buffer of character strings to the comment
+ area of a binary DAS file, appending them to any comments which
+ are already present in the file's comment area.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAS
+
+-Keywords
+
+ FILES
+ UTILITY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+ #undef dasac_c
+
+
+ void dasac_c ( SpiceInt handle,
+ SpiceInt n,
+ SpiceInt buflen,
+ const void * buffer )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I DAS handle of a file opened with write access.
+ n I Number of comments to put into the comment area.
+ buflen I Line length associated with buffer.
+ buffer I Buffer of lines to be put into the comment area.
+
+-Detailed_Input
+
+ handle The file handle of a binary DAS file which has been
+ opened with write access.
+
+ n The number of strings in buffer that are to be
+ appended to the comment area of the binary DAS file
+ attached to handle.
+
+ buflen is the common length of the strings in buffer, including the
+ terminating nulls.
+
+ buffer A buffer containing comments which are to be added
+ to the comment area of the binary DAS file attached
+ to handle. buffer should be declared as follows:
+
+ ConstSpiceChar buffer [n][buflen]
+
+ Each string in buffer is null-terminated.
+
+-Detailed_Output
+
+ None.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the number of comments to be added is not positive, the
+ error SPICE(INVALIDARGUMENT) will be signaled.
+
+ 2) If a non-null, non printing ASCII character is encountered in the
+ comments, the error SPICE(ILLEGALCHARACTER) will be
+ signaled.
+
+ 3) If the binary DAS file attached to handle is not open for
+ write access, an error will be signaled by a routine called
+ by this routine.
+
+ 4) If the input buffer pointer is null, the error SPICE(NULLPOINTER)
+ will be signaled.
+
+ 5) If the input buffer string length buflen is not at least 2,
+ the error SPICE(STRINGTOOSHORT) will be signaled.
+
+-Files
+
+ See argument handle in Detailed_Input.
+
+-Particulars
+
+ Binary DAS files contain a data area which is reserved for storing
+ annotations or descriptive textual information about the data
+ contained in a file. This area is referred to as the "comment
+ area" of the file. The comment area of a DAS file is a line
+ oriented medium for storing textual information. The comment
+ area preserves any leading or embedded white space in the line(s)
+ of text which are stored so that the appearance of the
+ information will be unchanged when it is retrieved (extracted) at
+ some other time. Trailing blanks, however, are NOT preserved,
+ due to the way that character strings are represented in
+ standard Fortran 77.
+
+ This routine will take a buffer of text lines and add (append)
+ them to the comment area of a binary DAS file. If there are no
+ comments in the comment area of the file, then space will be
+ allocated and the text lines in buffer will then placed into the
+ comment area. The text lines may contain only printable ASCII
+ characters (decimal values 32 - 126).
+
+ There is no maximum length imposed on the significant portion
+ of a text line that may be placed into the comment area of a
+ DAS file. The maximum length of a line stored in the comment
+ area should be reasonable, however, so that they may be easily
+ extracted. A good value for this would be 255 characters, as
+ this can easily accommodate "screen width" lines as well as
+ long lines which may contain some other form of information.
+
+-Examples
+
+ Let
+
+ handle be the handle for a DAS file which has been opened
+ with write access.
+
+ n be the number of lines of text to be added to the
+ comment area of the binary DAS file attached to
+ handle.
+
+ BUFLEN be the declared line length of the buffer.
+
+ buffer is a list of text lines to be added to the comment
+ area of the binary DAS file attached to handle.
+
+ The call
+
+ dasac_c ( handle, n, BUFLEN, buffer );
+
+ will append the first n line(s) in buffer to the comment area
+ of the binary DAS file attached to handle.
+
+-Restrictions
+
+ 1) This routine uses constants that are specific to the ASCII
+ character sequence. The results of using this routine with
+ a different character sequence are unpredictable.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+
+-Version
+
+ -CSPICE Version 1.1.0, 02-MAR-2003 (NJB)
+
+ Added error check in wrapper for non-positive
+ buffer line count.
+
+ -CSPICE Version 1.0.0, 25-FEB-2003 (NJB) (KRG)
+
+-Index_Entries
+
+ add comments to a binary das file
+ append comments to a das file comment area
+
+-&
+*/
+
+{ /* Begin dasac_c */
+
+
+ /*
+ Local variables
+ */
+
+ SpiceChar * fCvalsArr;
+
+ SpiceInt fCvalsLen;
+
+
+ /*
+ Participate in error tracing.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+ chkin_c ( "dasac_c" );
+
+ /*
+ Check the line count of the input buffer.
+ */
+ if ( n < 1 )
+ {
+ setmsg_c ( "Comment buffer line count n = #; must be positive." );
+ errint_c ( "#", n );
+ sigerr_c ( "SPICE(INVALIDARGUMENT)" );
+ chkout_c ( "dasac_c" );
+ return;
+ }
+
+ /*
+ Check the input buffer for null pointer or short lines.
+ */
+ CHKOSTR ( CHK_STANDARD, "dasac_c", buffer, buflen );
+
+
+ /*
+ Map the input buffer to a Fortran-style buffer.
+ */
+ C2F_MapStrArr ( "dasac_c", n, buflen, buffer, &fCvalsLen, &fCvalsArr );
+
+ if ( failed_c() )
+ {
+ chkout_c ( "dasac_c" );
+ return;
+ }
+
+
+ /*
+ Call the f2c'd routine.
+ */
+ dasac_ ( ( integer * ) &handle,
+ ( integer * ) &n,
+ ( char * ) fCvalsArr,
+ ( ftnlen ) fCvalsLen );
+
+
+ /*
+ Free the dynamically allocated array.
+ */
+ free ( fCvalsArr );
+
+
+ chkout_c ( "dasac_c" );
+
+} /* End dasac_c */
diff --git a/ext/spice/src/cspice/dasacr.c b/ext/spice/src/cspice/dasacr.c
new file mode 100644
index 0000000000..3534146928
--- /dev/null
+++ b/ext/spice/src/cspice/dasacr.c
@@ -0,0 +1,502 @@
+/* dasacr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__3 = 3;
+static integer c__256 = 256;
+
+/* $Procedure DASACR ( DAS, add comment records ) */
+/* Subroutine */ int dasacr_(integer *handle, integer *n)
+{
+ /* Initialized data */
+
+ static integer next[3] = { 2,3,1 };
+ static integer prev[3] = { 3,1,2 };
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer base;
+ char recc[1024];
+ doublereal recd[128];
+ integer free, reci[256], lrec, nrec, prec, unit, type__, i__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc;
+ extern /* Subroutine */ int maxai_(integer *, integer *, integer *,
+ integer *);
+ integer ncomr, lword, ltype;
+ extern logical failed_(void);
+ extern /* Subroutine */ int cleari_(integer *, integer *), dasioc_(char *,
+ integer *, integer *, char *, ftnlen, ftnlen), dasiod_(char *,
+ integer *, integer *, doublereal *, ftnlen);
+ integer dirrec[256];
+ extern /* Subroutine */ int dashfs_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *, integer *, integer *),
+ dassih_(integer *, char *, ftnlen), dasioi_(char *, integer *,
+ integer *, integer *, ftnlen);
+ integer lastla[3];
+ extern /* Subroutine */ int dashlu_(integer *, integer *), daswbr_(
+ integer *);
+ integer lindex;
+ extern /* Subroutine */ int dasufs_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *, integer *, integer *);
+ integer lastrc[3];
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen);
+ integer lastwd[3], nresvc;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ extern logical return_(void);
+ integer nresvr, nxttyp, loc, pos;
+
+/* $ Abstract */
+
+/* Increase the size of the comment area in a DAS file to accommodate */
+/* a specified number of additional comment records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I A DAS file handle. */
+/* N I Number of comment records to append to the comment */
+/* area of the specified file. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of an existing DAS file opened for */
+/* comment area modification by DASOPC. */
+
+/* N is the number of records to append to the comment */
+/* area. If NCOMR is the number of comment records */
+/* present in the file on input, then on output the */
+/* number of comment records will be NCOMR + N. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the effect of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input handle is invalid, the error will be diagnosed by */
+/* routines called by this routine. */
+
+/* 2) If an I/O error occurs during the addition process, the error */
+/* will be diagnosed by routines called by this routine. The */
+/* DAS file will probably be corrupted in this case. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine is used to create space in the comment area of a DAS */
+/* file to allow addition of comments to the file. If there are */
+/* comment records present in the file at the time this routine is */
+/* called, the number of comment records specified by the input */
+/* argument N will be appended to the existing comment records. */
+/* In any case, any existing directory records and data records will */
+/* be shifted down by N records. */
+
+/* This routine updates the file record of the specified DAS file */
+/* to reflect the addition of records to the file's comment area. */
+/* Also, the file summary obtainable from DASHFS will be updated to */
+/* reflect the addition of comment records. */
+
+/* This routine may be used only on existing DAS files opened by */
+/* DASOPW. */
+
+/* The association of DAS logical addresses and data within the */
+/* specified file will remain unaffected by use of this routine. */
+
+/* Normally, SPICELIB applications will not call this routine */
+/* directly, but will add comments by calling DASAC. */
+
+/* This routine has an inverse DASRCR, which removes a specified */
+/* number of records from the end of the comment area. */
+
+/* $ Examples */
+
+/* 1) Make room for 10 comment records in the comment area of a */
+/* new DAS file. */
+
+/* C */
+/* C Create a new DAS file. */
+/* C */
+/* CALL DASOPW ( DAS, HANDLE ) */
+
+/* C */
+/* C Now add 10 comment records to the comment area. */
+/* C */
+/* CALL DASACR ( HANDLE, 10 ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 11-OCT-1996 (NJB) */
+
+/* Bug fix: backward and forward directory record pointers */
+/* are now updated when directory records are moved. */
+
+/* - SPICELIB Version 1.0.0, 01-FEB-1993 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* add comment records to a DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 11-OCT-1996 (NJB) */
+
+/* Bug fix: backward and forward directory record pointers */
+/* are now updated when directory records are moved. */
+
+/* Because these pointers are not used by the DAS sofware */
+/* once a DAS file is segregated, this bug had no effect on */
+/* DAS files that were created and closed via DASCLS, then */
+/* commented via the commnt utility. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Words per data record, for each data type: */
+
+
+/* Data type parameters */
+
+
+/* Directory pointer locations (backward and forward): */
+
+
+/* Directory address range locations */
+
+
+/* Location of first type descriptor */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* NEXT and PREV map the DAS data type codes to their */
+/* successors and predecessors, respectively. */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASACR", (ftnlen)6);
+ }
+
+/* Make sure this DAS file is open for writing. Signal an error if */
+/* not. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+
+/* Get the logical unit for this DAS file. */
+
+ dashlu_(handle, &unit);
+ if (failed_()) {
+ chkout_("DASACR", (ftnlen)6);
+ return 0;
+ }
+
+/* It's a mistake to use a negative value of N. */
+
+ if (*n < 0) {
+ setmsg_("Number of comment records to add must be non-negative. Act"
+ "ual number requested was #.", (ftnlen)86);
+ errint_("#", n, (ftnlen)1);
+ sigerr_("SPICE(DASINVALIDCOUNT)", (ftnlen)22);
+ chkout_("DASACR", (ftnlen)6);
+ return 0;
+ }
+
+/* Before doing anything to the file, make sure that the DASRWR */
+/* data buffers do not contain any updated records for this file. */
+/* All of the record numbers that pertain to this file and remain */
+/* in the DASRWR buffers will be invalidated after this routine */
+/* returns. */
+
+/* DASWBR flushes buffered records to the file. */
+
+ daswbr_(handle);
+
+/* Grab the file summary for this DAS file. Find the number of */
+/* comment records and the number of the first free record. */
+
+ dashfs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla, lastrc,
+ lastwd);
+
+/* Find the record and word positions LREC and LWORD of the last */
+/* descriptor in the file, and also find the type of the descriptor */
+/* LTYPE. */
+
+ maxai_(lastrc, &c__3, &lrec, &loc);
+ lword = 0;
+ for (i__ = 1; i__ <= 3; ++i__) {
+ if (lastrc[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("lastrc",
+ i__1, "dasacr_", (ftnlen)371)] == lrec && lastwd[(i__2 = i__
+ - 1) < 3 && 0 <= i__2 ? i__2 : s_rnge("lastwd", i__2, "dasac"
+ "r_", (ftnlen)371)] > lword) {
+ lword = lastwd[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastwd", i__1, "dasacr_", (ftnlen)374)];
+ ltype = i__;
+ }
+ }
+
+/* LREC, LWORD, and LTYPE are now the record, word, and data type */
+/* of the last descriptor in the file. If LREC is zero, there are */
+/* no directories in the file yet. However, even DAS files that */
+/* don't contain any data have their first directory records */
+/* zeroed out, and this should remain true after the addition of */
+/* the comment records. */
+
+ if (lrec == 0) {
+
+/* Just write the zero-filled record to record number */
+
+/* NRESVR + NCOMR + N + 2 */
+
+ cleari_(&c__256, dirrec);
+ i__1 = nresvr + ncomr + *n + 2;
+ dasioi_("WRITE", &unit, &i__1, dirrec, (ftnlen)5);
+ } else {
+
+/* There really is stuff to move. For each directory record, */
+/* move all of the records described by that directory. We start */
+/* with the last directory and work our way toward the beginning */
+/* of the file. */
+
+ nrec = lrec;
+ while(nrec > 0) {
+
+/* For each descriptor in the current directory, move the */
+/* cluster of data records it refers to. */
+
+/* Read the current directory record. */
+
+ dasioi_("READ", &unit, &nrec, dirrec, (ftnlen)4);
+
+/* Find the data type, size, and base record number of the */
+/* last cluster in the current directory. To do this, */
+/* traverse the directory record, keeping track of the record */
+/* count and data types of descriptors as we go. */
+
+ type__ = dirrec[8];
+ base = nrec + 1;
+ if (nrec == lrec) {
+ lindex = lword;
+ } else {
+ lindex = 256;
+ }
+ i__1 = lindex;
+ for (i__ = 11; i__ <= i__1; ++i__) {
+ if (dirrec[(i__2 = i__ - 1) < 256 && 0 <= i__2 ? i__2 :
+ s_rnge("dirrec", i__2, "dasacr_", (ftnlen)434)] < 0) {
+ type__ = prev[(i__2 = type__ - 1) < 3 && 0 <= i__2 ? i__2
+ : s_rnge("prev", i__2, "dasacr_", (ftnlen)435)];
+ } else {
+ type__ = next[(i__2 = type__ - 1) < 3 && 0 <= i__2 ? i__2
+ : s_rnge("next", i__2, "dasacr_", (ftnlen)437)];
+ }
+ base += (i__3 = dirrec[(i__2 = i__ - 2) < 256 && 0 <= i__2 ?
+ i__2 : s_rnge("dirrec", i__2, "dasacr_", (ftnlen)440)]
+ , abs(i__3));
+ }
+
+/* TYPE and BASE are now the data type and base record number */
+/* of the last cluster described by the current directory. */
+
+/* We'll now traverse the directory in reverse order, keeping */
+/* track of cluster sizes and types as we go. */
+
+/* POS will be the index of the descriptor of the current */
+/* cluster. */
+
+ pos = lindex;
+ while(pos > 9) {
+ if (pos < lindex) {
+
+/* We'll need to determine the type of the current */
+/* cluster. If the next descriptor contains a positive */
+/* value, the data type of the cluster it refers to is */
+/* the successor of the current type, according to our */
+/* ordering of types. */
+
+ if (dirrec[(i__1 = pos) < 256 && 0 <= i__1 ? i__1 :
+ s_rnge("dirrec", i__1, "dasacr_", (ftnlen)466)] >
+ 0) {
+ type__ = prev[(i__1 = nxttyp - 1) < 3 && 0 <= i__1 ?
+ i__1 : s_rnge("prev", i__1, "dasacr_", (
+ ftnlen)467)];
+ } else {
+ type__ = next[(i__1 = nxttyp - 1) < 3 && 0 <= i__1 ?
+ i__1 : s_rnge("next", i__1, "dasacr_", (
+ ftnlen)469)];
+ }
+
+/* Update the cluster base record number. */
+
+ base -= (i__2 = dirrec[(i__1 = pos - 1) < 256 && 0 <=
+ i__1 ? i__1 : s_rnge("dirrec", i__1, "dasacr_", (
+ ftnlen)475)], abs(i__2));
+ }
+
+/* Move the current cluster. */
+
+ i__3 = base;
+ for (i__ = base + (i__2 = dirrec[(i__1 = pos - 1) < 256 && 0
+ <= i__1 ? i__1 : s_rnge("dirrec", i__1, "dasacr_", (
+ ftnlen)482)], abs(i__2)) - 1; i__ >= i__3; --i__) {
+ if (type__ == 1) {
+ dasioc_("READ", &unit, &i__, recc, (ftnlen)4, (ftnlen)
+ 1024);
+ i__1 = i__ + *n;
+ dasioc_("WRITE", &unit, &i__1, recc, (ftnlen)5, (
+ ftnlen)1024);
+ } else if (type__ == 2) {
+ dasiod_("READ", &unit, &i__, recd, (ftnlen)4);
+ i__1 = i__ + *n;
+ dasiod_("WRITE", &unit, &i__1, recd, (ftnlen)5);
+ } else {
+ dasioi_("READ", &unit, &i__, reci, (ftnlen)4);
+ i__1 = i__ + *n;
+ dasioi_("WRITE", &unit, &i__1, reci, (ftnlen)5);
+ }
+ }
+
+/* The next descriptor to look at is the preceding one in */
+/* the directory. */
+
+ --pos;
+ nxttyp = type__;
+ }
+
+/* Find the preceding directory record. */
+
+ prec = dirrec[0];
+
+/* Update the backward and forward pointers in the current */
+/* directory record. However, don't modify null pointers. */
+
+ if (dirrec[1] > 0) {
+ dirrec[1] += *n;
+ }
+ if (dirrec[0] > 0) {
+ dirrec[0] += *n;
+ }
+
+/* Move the current directory record. */
+
+ i__3 = nrec + *n;
+ dasioi_("WRITE", &unit, &i__3, dirrec, (ftnlen)5);
+
+/* Consider the previous directory. */
+
+ nrec = prec;
+ }
+ }
+
+/* Update the file summary. The number of comment records and the */
+/* number of the first free record have been incremented by N. */
+/* The numbers of the records containing the last descriptor of each */
+/* type have been incremented by N only if they were non-zero. */
+
+/* The call to DASUFS will update the file record as well as the */
+/* file summary. */
+
+ ncomr += *n;
+ free += *n;
+ for (i__ = 1; i__ <= 3; ++i__) {
+ if (lastrc[(i__3 = i__ - 1) < 3 && 0 <= i__3 ? i__3 : s_rnge("lastrc",
+ i__3, "dasacr_", (ftnlen)557)] != 0) {
+ lastrc[(i__3 = i__ - 1) < 3 && 0 <= i__3 ? i__3 : s_rnge("lastrc",
+ i__3, "dasacr_", (ftnlen)558)] = lastrc[(i__1 = i__ - 1)
+ < 3 && 0 <= i__1 ? i__1 : s_rnge("lastrc", i__1, "dasacr_"
+ , (ftnlen)558)] + *n;
+ }
+ }
+ dasufs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla, lastrc,
+ lastwd);
+ chkout_("DASACR", (ftnlen)6);
+ return 0;
+} /* dasacr_ */
+
diff --git a/ext/spice/src/cspice/dasacu.c b/ext/spice/src/cspice/dasacu.c
new file mode 100644
index 0000000000..86d6a940d2
--- /dev/null
+++ b/ext/spice/src/cspice/dasacu.c
@@ -0,0 +1,799 @@
+/* dasacu.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__22 = 22;
+static integer c__1 = 1;
+
+/* $Procedure DASACU ( DAS add comments from a logical unit ) */
+/* Subroutine */ int dasacu_(integer *comlun, char *begmrk, char *endmrk,
+ logical *insbln, integer *handle, ftnlen begmrk_len, ftnlen
+ endmrk_len)
+{
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+ olist o__1;
+ cllist cl__1;
+ alist al__1;
+
+ /* Builtin functions */
+ integer f_open(olist *);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_cmp(char *, char *, ftnlen, ftnlen), f_clos(cllist *), s_rnge(
+ char *, integer, char *, integer), f_rew(alist *);
+
+ /* Local variables */
+ char line[255];
+ logical more;
+ integer i__, j;
+ extern /* Subroutine */ int dasac_(integer *, integer *, char *, ftnlen),
+ chkin_(char *, ftnlen);
+ integer ncomc;
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
+ integer ncomr;
+ extern /* Subroutine */ int ljust_(char *, char *, ftnlen, ftnlen);
+ extern logical failed_(void);
+ extern /* Subroutine */ int readla_(integer *, integer *, integer *, char
+ *, logical *, ftnlen);
+ char ifname[60];
+ extern /* Subroutine */ int readln_(integer *, char *, logical *, ftnlen);
+ char combuf[255*22];
+ extern /* Subroutine */ int dassih_(integer *, char *, ftnlen);
+ extern integer lastnb_(char *, ftnlen);
+ integer length, intchr;
+ char idword[8];
+ extern /* Subroutine */ int dasrfr_(integer *, char *, char *, integer *,
+ integer *, integer *, integer *, ftnlen, ftnlen), errfnm_(char *,
+ integer *, ftnlen), sigerr_(char *, ftnlen);
+ integer numcom;
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ integer nresvc;
+ extern /* Subroutine */ int getlun_(integer *);
+ integer iostat;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ integer scrlun;
+ extern /* Subroutine */ int writla_(integer *, char *, integer *, ftnlen);
+ extern logical return_(void);
+ integer nresvr;
+ logical eof;
+
+/* $ Abstract */
+
+/* Add comments to a previously opened binary DAS file from a */
+/* previously opened text file attached to a Fortran logical unit. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* None. */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* COMLUN I Logical unit of the open comment text file. */
+/* BEGMRK I The begin comments marker in the comment text file. */
+/* ENDMRK I The end comments marker in the comment text file. */
+/* INSBLN I A flag indicating whether to insert a blank line. */
+/* HANDLE I Handle of a DAS file opened with write access. */
+
+/* $ Detailed_Input */
+
+/* COMLUN The Fortran logical unit of a previously opened text */
+/* file which contains comments that are to be added to */
+/* the comment area of a binary E-Kernel file. */
+
+/* BEGMRK A marker which identifies the beginning of the comments */
+/* in the comment text file. This marker must appear on a */
+/* line by itself, and leading and trailing blanks are not */
+/* significant. */
+
+/* The line immediately following this marker is the first */
+/* comment line to be placed into the comment area of the */
+/* binary DAS file. */
+
+/* If the begin marker is blank, BEGMRK .EQ. ' ', then the */
+/* comments are assumed to start at the current location */
+/* in the comment text file. */
+
+/* ENDMRK A marker which identifies the end of the comments in the */
+/* comment text file. This marker must appear on a line by */
+/* itself, and leading and trailing blanks are not */
+/* significant. */
+
+/* The line immediately preceeding this marker is the last */
+/* comment line to be placed into the comment area of the */
+/* binary DAS file. */
+
+/* If the end marker is blank, ENDMRK .EQ. ' ', then the */
+/* comments are assumed to stop at the end of the comment */
+/* text file. */
+
+/* INSBLN A logical flag which indicates whether a blank line is */
+/* to be inserted into the comment area of the binary DAS */
+/* file attached to HANDLE before any comments are added */
+/* to the comment area of the DAS file. This is to provide */
+/* a simple mechanism for separating any comments already */
+/* contained in the comment area of a DAS file from those */
+/* comments that are being added. */
+
+/* If the comment area of a binary DAS file is empty, the */
+/* value of this flag is not significant, the comments will */
+/* simply be placed into the comment area. */
+
+/* HANDLE The file handle for a binary DAS file that has been */
+/* opened with write access. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the scratch file for temporarily holding the comments */
+/* culled from the text file cannot be opened, then the */
+/* error SPICE(FILEOPENFAILED) will be signalled. */
+
+/* 2) If a non printing ASCII character is encountered in the */
+/* comments, the error SPICE(ILLEGALCHARACTER) will be */
+/* signalled. */
+
+/* 3) If the begin marker cannot be found in the text file, the */
+/* error SPICE(MARKERNOTFOUND) will be signalled. */
+
+/* 4) If the end marker cannot be found in the text file, the */
+/* error SPICE(MARKERNOTFOUND) will be signalled. */
+
+/* $ Files */
+
+/* 1) See parameters COMLUN and HANDLE in the $ Detailed_Inputs */
+/* section. */
+
+/* 2) A scratch file is used to temporarily hold the comments */
+/* culled from the comment text file. This is so we do not */
+/* have to find the place where we started searching for */
+/* comments in the original file. */
+
+/* $ Particulars */
+
+/* This routine will place all lines between two specified markers, */
+/* a `begin comments marker' and an `end comments marker,' in a */
+/* text file into the comment area of a binary DAS file attached to */
+/* HANDLE. If the `begin comments marker' is blank, then the */
+/* comments are asumed to start at the current location of the */
+/* comment text file attached to COMLUN. If the `end comments */
+/* marker' is blank, then the comments are assumed to stop at the */
+/* end of the comment text file attached to COMLUN. */
+
+/* $ Examples */
+
+/* We will be using the files `jabber.txt', 'batty.txt', and */
+/* `wndrland.das' in the example which follows. */
+
+/* `wndrland.das' is a binary DAS file with an empty comment area */
+/* into which we are going to place the entire file */
+/* `jabber.txt' and a selected portion of the file */
+/* `batty.txt'. */
+
+/* `jabber.txt' is a text file that is to be placed into the */
+/* comment area of the binary DAS file `wndrland.das'. */
+
+/* `batty.txt' is a text file from which will have a selected */
+/* portion of its text placed into the comment area */
+/* of the binary DAS file `wndrland.das'. */
+
+/* Let -BOF- and -EOF- denote the beginning and end of a file, */
+/* respectively. */
+
+/* The file `jabber.txt' contains: */
+
+/* -BOF- */
+/* The Jabberwock */
+
+/* 'Twas brillig, and the slithy toves */
+/* Did gyre and gimble in the wabe; */
+/* All mimsy were the borogoves, */
+/* And the mome raths outgrabe. */
+
+/* ``Beware the Jabberwock, my son! */
+/* The jaws that bite, the claws that catch!'' */
+
+/* And as in uffish thought he stood, */
+/* The Jabberwock, with eyes of flame, */
+/* Came whiffling through the tulgey wood, */
+/* And burbled as it came! */
+
+/* One, two! One, two! And through and through */
+/* The vorpal blade went snicker-snack! */
+/* He left it dead, and with its head */
+/* He went galumphing back. */
+
+/* ``And hast thou slain the Jabberwock? */
+/* Come to my arms, my beamish boy! */
+/* O frabjous day! Callooh! Callay!'' */
+/* He chortled in his joy. */
+
+/* Through the Looking-Glass */
+/* Lewis Carroll */
+/* -EOF- */
+
+/* The file `batty.txt' contains: */
+
+/* -BOF- */
+/* This file contains a brief poem about bats. */
+
+/* BEGIN bat poem */
+/* Twinkle, twinkle, little bat! */
+/* How I wonder what you're at! */
+/* Up above the world you fly! */
+/* Like a teatray in the sky. */
+
+/* Alice's Adventures in Wonderland */
+/* Lewis Carroll */
+/* END bat poem */
+
+/* And that's that for bats. */
+/* -EOF- */
+
+/* Let */
+
+/* JABLUN be the logical unit for the file `jabber.txt' */
+/* BATLUN be the logical unit for the file `batty.txt' */
+/* and */
+/* HANDLE be the DAS handle for the file `wndrland.das' */
+
+/* The code fragment */
+
+/* C */
+/* C Open the files. */
+/* C */
+/* CALL DASOPW ( `wndrland.das', HANDLE ) */
+/* CALL TXTOPN ( `jabber.txt' , JABLUN ) */
+/* CALL TXTOPN ( `batty.txt' , BATLUN ) */
+/* C */
+/* C Initialize the markers for the file `jabber.txt'. We want */
+/* C to include the entire file, so both markers are blank. */
+/* C */
+/* BEGMRK = ' ' */
+/* ENDMRK = ' ' */
+/* INSBLN = .TRUE. */
+/* C */
+/* C Add the comments from the file 'jabber.txt' */
+/* C */
+/* CALL DASACU ( JABLUN, BEGMRK, ENDMRK, INSBLN, HANDLE ) */
+/* C */
+/* C Initialize the markers for the file `batty.txt'. We want */
+/* C to include the bat poem only, so we define the begin and */
+/* C end markere accordingly. */
+/* C */
+/* BEGMRK = 'BEGIN bat poem' */
+/* ENDMRK = 'END bat poem' */
+/* INSBLN = .TRUE. */
+/* C */
+/* C Add the comments from the file 'batty.txt' */
+/* C */
+/* CALL DASACU ( BATLUN, BEGMRK, ENDMRK, INSBLN, HANDLE ) */
+/* C */
+/* C Close the files. */
+
+/* CLOSE ( JABLUN ) */
+/* CLOSE ( BATLUN ) */
+/* CALL DASCLS ( HANDLE ) */
+
+/* will create a comment area in `wndrland.das' which contains: */
+
+/* -BOC- */
+/* The Jabberwock */
+
+/* 'Twas brillig, and the slithy toves */
+/* Did gyre and gimble in the wabe; */
+/* All mimsy were the borogoves, */
+/* And the mome raths outgrabe. */
+
+/* ``Beware the Jabberwock, my son! */
+/* The jaws that bite, the claws that catch!'' */
+
+/* And as in uffish thought he stood, */
+/* The Jabberwock, with eyes of flame, */
+/* Came whiffling through the tulgey wood, */
+/* And burbled as it came! */
+
+/* One, two! One, two! And through and through */
+/* The vorpal blade went snicker-snack! */
+/* He left it dead, and with its head */
+/* He went galumphing back. */
+
+/* ``And hast thou slain the Jabberwock? */
+/* Come to my arms, my beamish boy! */
+/* O frabjous day! Callooh! Callay!'' */
+/* He chortled in his joy. */
+
+/* Through the Looking-Glass */
+/* Lewis Carroll */
+
+/* Twinkle, twinkle, little bat! */
+/* How I wonder what you're at! */
+/* Up above the world you fly! */
+/* Like a teatray in the sky. */
+
+/* Alice's Adventures in Wonderland */
+/* Lewis Carroll */
+/* -EOC- */
+
+/* where -BOC- and -EOC- represent the beginning and end of the */
+/* comments, respectively. */
+
+/* $ Restrictions */
+
+/* 1) The begin comments marker, BEGMRK, and the end comments marker, */
+/* ENDMRK, must each appear alone on a line in the comment text */
+/* file if they are not blank. */
+
+/* 2) The maximum length of a text line in a comment file is */
+/* specified by the LINLEN parameter defined below. Currently */
+/* this values is 255 characters. */
+
+/* 3) The maximum length of a single line comment in the comment */
+/* area is specified by the parameter LINLEN defined below. */
+/* Currently this value is 255 characters. */
+
+/* 4) This routine uses constants that are specific to the ASCII */
+/* character sequence. The results of using this routine with */
+/* a different character sequence are unpredictable. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB 1.2.0, 07-JUL-1996 (NJB) */
+
+/* Removed declaration, DATA and SAVE statements for unused */
+/* variable FIRST. */
+
+/* - Beta Version 1.1.0, 20-SEP-1995 (KRG) */
+
+/* Added a check of FAILED after the call to GETLUN to trap */
+/* an error, if one is signalled by GETLUN, before attempting to */
+/* open the SCRATCH file. */
+
+/* - Beta Version 1.0.0, 4-JAN-1993 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* add comments from a logical unit to a das file */
+
+/* -& */
+/* $ Revisions */
+
+
+/* - SPICELIB 1.2.0, 07-JUL-1996 (NJB) */
+
+/* Removed declaration, DATA and SAVE statements for unused */
+/* variable FIRST. */
+
+/* - Beta Version 1.1.0, 20-SEP-1995 (KRG) */
+
+/* Added a check of FAILED after the call to GETLUN to trap */
+/* an error, if one is signalled by GETLUN, before attempting to */
+/* open the SCRATCH file. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* Set the value for the maximum length of a text line. */
+
+
+/* Set the length of a DAS file ID word. */
+
+
+/* Set the length of a DAS file internal filename. */
+
+
+/* Set the size of the comment buffer. */
+
+
+/* Maximum and minimum decimal values for the printable ASCII */
+/* characters. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASACU", (ftnlen)6);
+ }
+
+/* Verify that the DAS file attached to HANDLE is opened with write */
+/* access. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+
+/* Get the number of comment characters, and some other stuff that */
+/* we will not be using. */
+
+ dasrfr_(handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (ftnlen)
+ 8, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+
+/* Get an available logical unit for the comment scratch file. */
+
+ getlun_(&scrlun);
+ if (failed_()) {
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+
+/* Attempt to open the comment scratch file. */
+
+ o__1.oerr = 1;
+ o__1.ounit = scrlun;
+ o__1.ofnm = 0;
+ o__1.orl = 0;
+ o__1.osta = "SCRATCH";
+ o__1.oacc = 0;
+ o__1.ofm = 0;
+ o__1.oblnk = 0;
+ iostat = f_open(&o__1);
+ if (iostat != 0) {
+ setmsg_("Attempt to open a temporary file failed. IOSTAT = #.", (
+ ftnlen)52);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEOPENFAILED)", (ftnlen)21);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+
+/* Start looking for the begin comment marker. If the begin marker */
+/* is a blank line, then the comments begin on the first line of the */
+/* comment file. Otherwise, the comments begin on the line */
+/* immediately following the line which contains the begin comments */
+/* marker. */
+
+ s_copy(line, " ", (ftnlen)255, (ftnlen)1);
+ eof = FALSE_;
+ while(s_cmp(line, begmrk, (ftnlen)255, begmrk_len) != 0) {
+ readln_(comlun, line, &eof, (ftnlen)255);
+ ljust_(line, line, (ftnlen)255, (ftnlen)255);
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = scrlun;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+
+/* If we have encountered the end of file here, we have a */
+/* problem: We did not find the begin comments marker in the */
+/* text file. So, set an appropriate error message and signal */
+/* the error. don't forget to close the scratch file. */
+
+ if (eof) {
+ cl__1.cerr = 0;
+ cl__1.cunit = scrlun;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("The begin comments marker '#' was not found in the comm"
+ "ent file '#'.", (ftnlen)68);
+ errch_("#", begmrk, (ftnlen)1, begmrk_len);
+ errfnm_("#", comlun, (ftnlen)1);
+ sigerr_("SPICE(MARKERNOTFOUND)", (ftnlen)21);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* Begin reading in the comment lines from the comment file, */
+/* placing them a buffer at a time into the temporary file. */
+/* We also scan each line for non printing characters. */
+
+ s_copy(line, " ", (ftnlen)255, (ftnlen)1);
+ if (s_cmp(endmrk, " ", endmrk_len, (ftnlen)1) == 0) {
+
+/* If the end mark is blank, then we want to go until we hit the */
+/* end of the comment file. */
+
+ while(! eof) {
+ numcom = 0;
+ readla_(comlun, &c__22, &numcom, combuf, &eof, (ftnlen)255);
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = scrlun;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+
+/* If we got some comments, we need to scan them for non */
+/* printing characters. */
+
+ if (numcom > 0) {
+ i__1 = numcom;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ length = lastnb_(combuf + ((i__2 = i__ - 1) < 22 && 0 <=
+ i__2 ? i__2 : s_rnge("combuf", i__2, "dasacu_", (
+ ftnlen)570)) * 255, (ftnlen)255);
+
+/* Scan the comment line for non printinig characters. */
+
+ i__2 = length;
+ for (j = 1; j <= i__2; ++j) {
+
+/* Check to see that the characters in the buffer */
+/* are all printing ASCII characters. The bounds */
+/* for printing ASCII characters are given by */
+/* MAXPCH and MINPCH, which are defined in the */
+/* $ Local Parameters section of the header. */
+
+ intchr = *(unsigned char *)&combuf[((i__3 = i__ - 1) <
+ 22 && 0 <= i__3 ? i__3 : s_rnge("combuf",
+ i__3, "dasacu_", (ftnlen)582)) * 255 + (j - 1)
+ ];
+ if (intchr > 126 || intchr < 32) {
+ cl__1.cerr = 0;
+ cl__1.cunit = scrlun;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("A nonprinting character was encountered"
+ " in the comments. Value: #", (ftnlen)65);
+ errint_("#", &intchr, (ftnlen)1);
+ sigerr_("SPICE(ILLEGALCHARACTER)", (ftnlen)23);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+ }
+ }
+
+/* Write the comments to the temporary file. */
+
+ writla_(&numcom, combuf, &scrlun, (ftnlen)255);
+ }
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = scrlun;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+ }
+ } else {
+
+/* The endmark is non blank, then we want to go until we find a */
+/* line in the comment file that matches the end mark that was */
+/* entered. */
+
+ more = TRUE_;
+ while(more) {
+ numcom = 0;
+ readla_(comlun, &c__22, &numcom, combuf, &eof, (ftnlen)255);
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = scrlun;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+
+/* Look for ENDMRK in the current buffer if we got some */
+/* comments. */
+
+ if (numcom > 0) {
+ i__ = 1;
+ while(more && i__ <= numcom) {
+ s_copy(line, combuf + ((i__1 = i__ - 1) < 22 && 0 <= i__1
+ ? i__1 : s_rnge("combuf", i__1, "dasacu_", (
+ ftnlen)645)) * 255, (ftnlen)255, (ftnlen)255);
+ ljust_(line, line, (ftnlen)255, (ftnlen)255);
+ if (s_cmp(line, endmrk, (ftnlen)255, endmrk_len) == 0) {
+ more = FALSE_;
+ numcom = i__ - 1;
+ } else {
+ ++i__;
+ }
+ }
+ }
+
+/* If we still have some comments, we need to scan them for */
+/* non printing characters. */
+
+ if (numcom > 0) {
+ i__1 = numcom;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ length = lastnb_(combuf + ((i__2 = i__ - 1) < 22 && 0 <=
+ i__2 ? i__2 : s_rnge("combuf", i__2, "dasacu_", (
+ ftnlen)670)) * 255, (ftnlen)255);
+
+/* Scan the comment line for non printinig characters. */
+
+ i__2 = length;
+ for (j = 1; j <= i__2; ++j) {
+
+/* Check to see that the characters in the buffer */
+/* are all printing ASCII characters. The bounds */
+/* for printing ASCII characters are given by */
+/* MAXPCH and MINPCH, which are defined in the */
+/* $ Local Parameters section of the header. */
+
+ intchr = *(unsigned char *)&combuf[((i__3 = i__ - 1) <
+ 22 && 0 <= i__3 ? i__3 : s_rnge("combuf",
+ i__3, "dasacu_", (ftnlen)682)) * 255 + (j - 1)
+ ];
+ if (intchr > 126 || intchr < 32) {
+ cl__1.cerr = 0;
+ cl__1.cunit = scrlun;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("A nonprinting character was encountered"
+ " in the comment buffer. Value: #", (
+ ftnlen)71);
+ errint_("#", &intchr, (ftnlen)1);
+ sigerr_("SPICE(ILLEGALCHARACTER)", (ftnlen)23);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+ }
+ }
+
+/* Write the comments to the temporary file. */
+
+ writla_(&numcom, combuf, &scrlun, (ftnlen)255);
+ }
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = scrlun;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+
+/* If we have encountered the end of file here, we have a */
+/* problem: We did not find the end comments marker in the */
+/* text file. So, set an appropriate error message and */
+/* signal the error. */
+
+ if (more && eof) {
+ cl__1.cerr = 0;
+ cl__1.cunit = scrlun;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("The end comments marker '#' was not found in the co"
+ "mment file '#'.", (ftnlen)66);
+ errch_("#", endmrk, (ftnlen)1, endmrk_len);
+ errfnm_("#", comlun, (ftnlen)1);
+ sigerr_("SPICE(MARKERNOTFOUND)", (ftnlen)21);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+ }
+ }
+
+/* If we made it to here, we have culled all of the comments out of */
+/* the text file and they were all OK. So we need to add all of the */
+/* comments to the DAS comment area now. */
+
+/* If we are supposed to insert a blank line to separate the current */
+/* addition from any previously stored comments, and there are */
+/* comments already in the comment area, indicated by NCOMC > 0, then */
+/* we insert the blank line. Otherwise, just add the comments. */
+
+ if (*insbln && ncomc > 0) {
+ dasac_(handle, &c__1, " ", (ftnlen)1);
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = scrlun;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* Rewind the scratch file to get ready to put the comments into the */
+/* comment area. */
+
+ al__1.aerr = 0;
+ al__1.aunit = scrlun;
+ f_rew(&al__1);
+
+/* Begin reading through the scratch file, placing the comment lines */
+/* into the comment area of the DAS file a buffer at a time */
+
+ eof = FALSE_;
+ while(! eof) {
+ numcom = 0;
+
+/* Read in a buffer of comment lines. */
+
+ readla_(&scrlun, &c__22, &numcom, combuf, &eof, (ftnlen)255);
+
+/* If we got some, add them to the comment area of the DAS file. */
+
+ if (numcom > 0) {
+ dasac_(handle, &numcom, combuf, (ftnlen)255);
+ }
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = scrlun;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* Close the scratch file before exiting, it's the only one we */
+/* opened. */
+
+ cl__1.cerr = 0;
+ cl__1.cunit = scrlun;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DASACU", (ftnlen)6);
+ return 0;
+} /* dasacu_ */
+
diff --git a/ext/spice/src/cspice/dasadc.c b/ext/spice/src/cspice/dasadc.c
new file mode 100644
index 0000000000..893b526d85
--- /dev/null
+++ b/ext/spice/src/cspice/dasadc.c
@@ -0,0 +1,532 @@
+/* dasadc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+
+/* $Procedure DASADC ( DAS, add data, character ) */
+/* Subroutine */ int dasadc_(integer *handle, integer *n, integer *bpos,
+ integer *epos, char *data, ftnlen data_len)
+{
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer free;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc, lastc, recno, ncomr, nmove, rcpos;
+ extern /* Subroutine */ int dasa2l_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *);
+ extern logical failed_(void);
+ integer clbase;
+ extern /* Subroutine */ int dascud_(integer *, integer *, integer *),
+ dashfs_(integer *, integer *, integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *);
+ char record[1024];
+ integer lastla[3];
+ extern /* Subroutine */ int dasurc_(integer *, integer *, integer *,
+ integer *, char *, ftnlen), daswrc_(integer *, integer *, char *,
+ ftnlen);
+ integer lastrc[3], clsize, nmoved;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ integer numchr;
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ integer lastwd[3], nresvc;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ integer wordno;
+ extern logical return_(void);
+ integer nresvr, nwritn, chr, elt;
+
+/* $ Abstract */
+
+/* Add character data to a DAS file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ARRAY */
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* N I Number of characters to add to file. */
+/* BPOS, */
+/* EPOS I Begin and end positions of substrings. */
+/* DATA I Array of character strings. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a file handle of a DAS file opened for writing. */
+
+/* N is the number of characters, in the specified set */
+/* of substrings, to add to the specified DAS file. */
+
+/* BPOS, */
+/* EPOS are begin and end character positions that define */
+/* a set of substrings in the input array. This */
+/* routine writes characters from the specified set */
+/* of substrings to the specified DAS file. */
+
+/* DATA is an array of character strings, some portion of */
+/* whose contents are to be added to the specified */
+/* DAS file. Specifically, the first N characters of */
+/* the substrings */
+
+/* DATA(I) (BPOS:EPOS), I = 1, ... */
+
+/* are appended to the character data in the file. */
+/* The order of characters in the input substrings */
+/* is considered to increase from left to right */
+/* within each element of DATA, and to increase */
+/* with the indices of the elements of DATA. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the effect of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. */
+
+/* 2) If EPOS or BPOS are outside of the range */
+
+/* [ 1, LEN( DATA(1) ) ] */
+
+/* or if EPOS < BPOS, the error SPICE(BADSUBSTRINGBOUNDS) will */
+/* be signalled. */
+
+/* 3) If the input count N is less than 1, no data will be */
+/* added to the specified DAS file. */
+
+/* 4) If an I/O error occurs during the data addition attempted */
+/* by this routine, the error will be diagnosed by routines */
+/* called by this routine. */
+
+/* 5) If N is greater than the number of characters in the */
+/* specified set of input substrings, the results of calling */
+/* this routine are unpredictable. This routine cannot */
+/* detect this error. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine adds character data to a DAS file by `appending' it */
+/* after any character data already in the file. The sense in which */
+/* the data is `appended' is that the data will occupy a range of */
+/* logical addresses for character data that immediately follow the */
+/* last logical address of a character that is occupied at the time */
+/* this routine is called. The diagram below illustrates this */
+/* addition: */
+
+/* +-------------------------+ */
+/* | (already in use) | Character logical address 1 */
+/* +-------------------------+ */
+/* . */
+/* . */
+/* . */
+/* +-------------------------+ Last character logical address */
+/* | (already in use) | in use before call to DASADC */
+/* +-------------------------+ */
+/* | DATA(1) (BPOS:BPOS) | First added character */
+/* +-------------------------+ */
+/* | DATA(1) (BPOS+1:BPOS+1) | */
+/* +-------------------------+ */
+/* . */
+/* . */
+/* . */
+/* +-------------------------+ */
+/* | DATA(1) (EPOS:EPOS) | */
+/* +-------------------------+ */
+/* | DATA(2) (BPOS:BPOS) | */
+/* +-------------------------+ */
+/* . */
+/* . */
+/* . */
+/* +-------------------------+ */
+/* | DATA(R) (C:C) | Nth added character---here R is */
+/* +-------------------------+ */
+/* INT ( (N+L-1)/L ) */
+
+/* where L = EPOS - BPOS + 1, and */
+/* C is */
+
+/* N - (R-1)*L */
+
+
+/* The logical organization of the characters in the DAS file is */
+/* independent of the order of addition to the file or physical */
+/* location of any data of integer or double precision type. */
+
+/* The actual physical write operations that add the input array */
+/* DATA to the indicated DAS file may not take place before this */
+/* routine returns, since the DAS system buffers data that is */
+/* written as well as data that is read. In any case, the data */
+/* will be flushed to the file at the time the file is closed, if */
+/* not earlier. A physical write of all buffered records can be */
+/* forced by calling the SPICELIB routine DASWUR ( DAS, write */
+/* updated records ). */
+
+/* In order to update character logical addresses that already */
+/* contain data, the SPICELIB routine DASUDC (DAS, update data, */
+/* character) should be used. */
+
+/* $ Examples */
+
+/* 1) Create the new DAS file TEST.DAS and add 120 characters to it. */
+/* Close the file, then re-open it and read the data back out. */
+
+
+/* PROGRAM TEST_ADD */
+
+/* CHARACTER*(80) LINES ( 3 ) */
+/* CHARACTER*(4) TYPE */
+
+/* INTEGER HANDLE */
+/* INTEGER I */
+
+/* DATA LINES / 'Here is the first line.', */
+/* . 'Here is the second line.', */
+/* . 'Here is the third line.' / */
+
+/* C */
+/* C Open a new DAS file. Use the file name as */
+/* C the internal file name. */
+/* C */
+/* TYPE = 'TEST' */
+/* CALL DASONW ( 'TEST.DAS', TYPE, 'TEST.DAS', HANDLE ) */
+
+/* C */
+/* C Add the contents of the array LINES to the file. */
+/* C Since the lines are short, just use the first 40 */
+/* C characters of each one. */
+/* C */
+/* CALL DASADC ( HANDLE, 120, 1, 40, LINES ) */
+
+/* C */
+/* C Close the file. */
+/* C */
+/* CALL DASCLS ( HANDLE ) */
+
+/* C */
+/* C Now verify the addition of data by opening the */
+/* C file for read access and retrieving the data. */
+/* C */
+/* CALL DASOPR ( 'TEST.DAS', HANDLE ) */
+
+/* DO I = 1, 3 */
+/* LINES(I) = ' ' */
+/* END DO */
+
+/* CALL DASRDC ( HANDLE, 1, 120, 1, 40, LINES ) */
+
+/* C */
+/* C Dump the data to the screen. We should see the */
+/* C sequence */
+/* C */
+/* C Here is the first line. */
+/* C Here is the second line. */
+/* C Here is the third line. */
+/* C */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) 'Data from TEST.DAS: ' */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) LINES */
+
+/* END */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1 19-DEC-1995 (NJB) */
+
+/* Corrected title of permuted index entry section. */
+
+/* - SPICELIB Version 1.1.0 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination condition. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new, which makes use of the file */
+/* type. Also, a variable for the type of the file to be created */
+/* was added. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* add character data to a DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination condition. Without */
+/* this test, an infinite loop could result if DASA2L, DASURC or */
+/* DASWRC signaled an error inside the loop. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new, which makes use of the file */
+/* type. Also, a variable for the type of the file to be created */
+/* was added. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASADC", (ftnlen)6);
+ }
+
+/* Make sure BPOS and EPOS are OK; stop here if not. */
+
+ if (*bpos < 1 || *epos < 1 || *bpos > i_len(data, data_len) || *epos >
+ i_len(data, data_len)) {
+ setmsg_("Substring bounds must be in range [1,#]. Actual range [BPOS"
+ ",EPOS] was [#,#].", (ftnlen)76);
+ i__1 = i_len(data, data_len);
+ errint_("#", &i__1, (ftnlen)1);
+ errint_("#", bpos, (ftnlen)1);
+ errint_("#", epos, (ftnlen)1);
+ sigerr_("SPICE(BADSUBSTRINGBOUNDS)", (ftnlen)25);
+ chkout_("DASADC", (ftnlen)6);
+ return 0;
+ } else if (*epos < *bpos) {
+ setmsg_("Substring upper bound must not be less than lower bound. A"
+ "ctual range [BPOS,EPOS] was [#,#].", (ftnlen)93);
+ errint_("#", bpos, (ftnlen)1);
+ errint_("#", epos, (ftnlen)1);
+ sigerr_("SPICE(BADSUBSTRINGBOUNDS)", (ftnlen)25);
+ chkout_("DASADC", (ftnlen)6);
+ return 0;
+ }
+
+/* Get the file summary for this DAS. */
+
+ dashfs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla, lastrc,
+ lastwd);
+ lastc = lastla[0];
+
+/* We will keep track of the location that we wish to write to */
+/* with the variables RECNO and WORDNO. RECNO will be the record */
+/* number of the record we'll write to; WORDNO will be the number */
+/* preceding the word index, within record number RECNO, that we'll */
+/* write to. For example, if we're about to write to the first */
+/* character in record 10, RECNO will be 10 and WORDNO will be 0. Of */
+/* course, when WORDNO reaches NWC, we'll have to find a free record */
+/* before writing anything. */
+
+/* Prepare the variables RECNO and WORDNO: use the physical location */
+/* of the last character address, if there are any character data in */
+/* the file. Otherwise, RECNO becomes the first record available for */
+/* character data. */
+
+ if (lastc >= 1) {
+ dasa2l_(handle, &c__1, &lastc, &clbase, &clsize, &recno, &wordno);
+ } else {
+ recno = free;
+ wordno = 0;
+ }
+
+/* Set the number of character words already written. Keep */
+/* writing to the file until this number equals the number of */
+/* elements in DATA. */
+
+/* Note that if N is non-positive, the loop doesn't get */
+/* exercised. */
+
+/* Also initialize the array element index and position of the */
+/* character to be moved next. */
+
+ nwritn = 0;
+ elt = 1;
+ chr = *bpos;
+ while(nwritn < *n && ! failed_()) {
+
+/* Write as much data as we can (or need to) into the current */
+/* record. We assume that RECNO, WORDNO, and NWRITN have */
+/* been set correctly at this point. */
+
+/* Find out how many words to write into the current record. */
+/* There may be no space left in the current record. */
+
+/* Computing MIN */
+ i__1 = *n - nwritn, i__2 = 1024 - wordno;
+ numchr = min(i__1,i__2);
+ if (numchr > 0) {
+
+/* Write NUMCHR words into the current record. If the record */
+/* is new, write the entire record. Otherwise, just update */
+/* the part we're interested in. */
+
+/* In either case, we'll first fill in characters WORDNO+1 */
+/* through WORDNO + NUMCHR of the string RECORD. */
+
+
+/* So far, we haven't moved any characters. */
+
+ nmoved = 0;
+ rcpos = wordno;
+ while(nmoved < numchr) {
+
+/* Find out how many characters in the current array */
+/* element we should move. */
+
+ if (chr > *epos) {
+ ++elt;
+ chr = *bpos;
+ }
+/* Computing MIN */
+ i__1 = numchr - nmoved, i__2 = *epos - chr + 1;
+ nmove = min(i__1,i__2);
+ i__1 = rcpos;
+ s_copy(record + i__1, data + ((elt - 1) * data_len + (chr - 1)
+ ), rcpos + nmove - i__1, data_len - (chr - 1));
+ nmoved += nmove;
+ rcpos += nmove;
+ chr += nmove;
+ }
+
+/* Now we can write or update the file with RECORD. */
+
+ if (wordno == 0) {
+
+/* The record has not yet been written, so write out the */
+/* entire record. */
+
+ daswrc_(handle, &recno, record, (ftnlen)1024);
+ } else {
+
+/* Update elements WORDNO+1 through WORDNO+NUMCHR. */
+
+ i__1 = wordno;
+ i__2 = wordno + 1;
+ i__3 = wordno + numchr;
+ dasurc_(handle, &recno, &i__2, &i__3, record + i__1, wordno +
+ numchr - i__1);
+ }
+ nwritn += numchr;
+ wordno += numchr;
+ } else {
+
+/* It's time to start on a new record. If the record we */
+/* just finished writing to (or just attempted writing to, */
+/* if it was full) was FREE or a higher-numbered record, */
+/* then we are writing to a contiguous set of data records: */
+/* the next record to write to is the immediate successor */
+/* of the last one. Otherwise, FREE is the next record */
+/* to write to. */
+
+/* We intentionally leave FREE at the value it had before */
+/* we starting adding data to the file. */
+
+ if (recno >= free) {
+ ++recno;
+ } else {
+ recno = free;
+ }
+ wordno = 0;
+ }
+ }
+
+/* Update the DAS file directories to reflect the addition of N */
+/* character words. DASCUD will also update the file summary */
+/* accordingly. */
+
+ dascud_(handle, &c__1, n);
+ chkout_("DASADC", (ftnlen)6);
+ return 0;
+} /* dasadc_ */
+
diff --git a/ext/spice/src/cspice/dasadd.c b/ext/spice/src/cspice/dasadd.c
new file mode 100644
index 0000000000..413b6edd91
--- /dev/null
+++ b/ext/spice/src/cspice/dasadd.c
@@ -0,0 +1,412 @@
+/* dasadd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+
+/* $Procedure DASADD ( DAS, add data, double precision ) */
+/* Subroutine */ int dasadd_(integer *handle, integer *n, doublereal *data)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer free;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc, recno, lastd;
+ extern /* Subroutine */ int moved_(doublereal *, integer *, doublereal *);
+ integer ncomr, numdp;
+ extern /* Subroutine */ int dasa2l_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *);
+ extern logical failed_(void);
+ integer clbase;
+ extern /* Subroutine */ int dascud_(integer *, integer *, integer *),
+ dashfs_(integer *, integer *, integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *);
+ doublereal record[128];
+ integer lastla[3];
+ extern /* Subroutine */ int dasurd_(integer *, integer *, integer *,
+ integer *, doublereal *), daswrd_(integer *, integer *,
+ doublereal *);
+ integer lastrc[3], clsize;
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ integer lastwd[3], nresvc, wordno;
+ extern logical return_(void);
+ integer nresvr, nwritn;
+
+/* $ Abstract */
+
+/* Add an array of double precision numbers to a DAS file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ARRAY */
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* N I Number of d.p. numbers to add to DAS file. */
+/* DATA I Array of d.p. numbers to add. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a file handle of a DAS file opened for writing. */
+
+/* N is a the number of double precision `words' to */
+/* add to the DAS file specified by HANDLE. */
+
+/* DATA is an array of double precision numbers to be */
+/* added to the specified DAS file. Elements */
+/* 1 through N are appended to the double precision */
+/* data in the file. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the effect of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. */
+
+/* 2) If an I/O error occurs during the data addition attempted */
+/* by this routine, the error will be diagnosed by routines */
+/* called by this routine. */
+
+/* 3) If the input count N is less than 1, no data will be */
+/* added to the specified DAS file. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine adds double precision data to a DAS file by */
+/* `appending' it after any double precision data already in the */
+/* file. The sense in which the data is `appended' is that the */
+/* data will occupy a range of logical addresses for double precision */
+/* data that immediately follow the last logical address of a double */
+/* precision number that is occupied at the time this routine is */
+/* called. The diagram below illustrates this addition: */
+
+/* +-------------------------+ */
+/* | (already in use) | D.p. logical address 1 */
+/* +-------------------------+ */
+/* . */
+/* . */
+/* . */
+/* +-------------------------+ */
+/* | (already in use) | Last d.p. logical address */
+/* +-------------------------+ in use before call to DASADD */
+/* | DATA(1) | */
+/* +-------------------------+ */
+/* . */
+/* . */
+/* . */
+/* +-------------------------+ */
+/* | DATA(N) | */
+/* +-------------------------+ */
+
+
+/* The logical organization of the double precision numbers in the */
+/* DAS file is independent of the order of addition to the file or */
+/* physical location of any data of integer or character type. */
+
+/* The actual physical write operations that add the input array */
+/* DATA to the indicated DAS file may not take place before this */
+/* routine returns, since the DAS system buffers data that is */
+/* written as well as data that is read. In any case, the data */
+/* will be flushed to the file at the time the file is closed, if */
+/* not earlier. A physical write of all buffered records can be */
+/* forced by calling the SPICELIB routine DASWUR ( DAS, write */
+/* updated records ). */
+
+/* In order to update double precision logical addresses that */
+/* already contain data, the SPICELIB routine DASUDD */
+/* ( DAS update data, double precision ) should be used. */
+
+/* $ Examples */
+
+/* 1) Create the new DAS file TEST.DAS and add 200 double */
+/* precision numbers to it. Close the file, then re-open */
+/* it and read the data back out. */
+
+
+/* PROGRAM TEST_ADD */
+
+/* CHARACTER*(4) TYPE */
+
+/* DOUBLE PRECISION DATA ( 200 ) */
+
+/* INTEGER HANDLE */
+/* INTEGER I */
+/* C */
+/* C Open a new DAS file. Use the file name as */
+/* C the internal file name. */
+/* C */
+/* TYPE = 'TEST' */
+/* CALL DASONW ( 'TEST.DAS', TYPE, 'TEST.DAS', HANDLE ) */
+
+/* C */
+/* C Fill the array DATA with the double precision */
+/* C numbers 1.D0 through 100.D0, and add this array */
+/* C to the file. */
+/* C */
+/* DO I = 1, 100 */
+/* DATA(I) = DBLE(I) */
+/* END DO */
+
+/* CALL DASADD ( HANDLE, 100, DATA ) */
+
+/* C */
+/* C Now append the array DATA to the file again. */
+/* C */
+/* CALL DASADD ( HANDLE, 100, DATA ) */
+
+/* C */
+/* C Close the file. */
+/* C */
+/* CALL DASCLS ( HANDLE ) */
+
+/* C */
+/* C Now verify the addition of data by opening the */
+/* C file for read access and retrieving the data. */
+/* C */
+/* CALL DASRDD ( HANDLE, 1, 200, DATA ) */
+
+/* C */
+/* C Dump the data to the screen. We should see the */
+/* C sequence 1, 2, ..., 100, 1, 2, ... , 100. The */
+/* C numbers will be represented as double precision */
+/* C numbers in the output. */
+/* C */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) 'Data from TEST.DAS: ' */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) DATA */
+
+/* END */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1 19-DEC-1995 (NJB) */
+
+/* Corrected title of permuted index entry section. */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination condition. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new, which makes use of the file */
+/* type. Also, a variable for the type of the file to be created */
+/* was added. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* add double precision data to a DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination condition. Without */
+/* this test, an infinite loop could result if DASA2L, DASURD or */
+/* DASWRD signaled an error inside the loop. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new, which makes use of the file */
+/* type. Also, a variable for the type of the file to be created */
+/* was added. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASADD", (ftnlen)6);
+ }
+
+/* Get the file summary for this DAS. */
+
+ dashfs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla, lastrc,
+ lastwd);
+ lastd = lastla[1];
+
+/* We will keep track of the location that we wish to write to */
+/* with the variables RECNO and WORDNO. RECNO will be the record */
+/* number of the record we'll write to; WORDNO will be the number */
+/* preceding the word index, within record number RECNO, that we'll */
+/* write to. For example, if we're about to write to the first */
+/* double precision number in record 10, RECNO will be 10 and */
+/* WORDNO will be 0. Of course, when WORDNO reaches NWD, we'll */
+/* have to find a free record before writing anything. */
+
+/* Prepare the variables RECNO and WORDNO: use the physical */
+/* location of the last double precision address, if there are any */
+/* double precision data in the file. Otherwise, RECNO becomes the */
+/* first record available for double precision data. */
+
+ if (lastd >= 1) {
+ dasa2l_(handle, &c__2, &lastd, &clbase, &clsize, &recno, &wordno);
+ } else {
+ recno = free;
+ wordno = 0;
+ }
+
+/* Set the number of double precision words already written. Keep */
+/* writing to the file until this number equals the number of */
+/* elements in DATA. */
+
+/* Note that if N is non-positive, the loop doesn't get exercised. */
+
+
+ nwritn = 0;
+ while(nwritn < *n && ! failed_()) {
+
+/* Write as much data as we can (or need to) into the current */
+/* record. We assume that RECNO, WORDNO, and NWRITN have been */
+/* set correctly at this point. */
+
+/* Find out how many words to write into the current record. */
+/* There may be no space left in the current record. */
+
+/* Computing MIN */
+ i__1 = *n - nwritn, i__2 = 128 - wordno;
+ numdp = min(i__1,i__2);
+ if (numdp > 0) {
+
+/* Write NUMDP words into the current record. If the record */
+/* is new, write the entire record. Otherwise, just update */
+/* the part we're interested in. */
+
+ if (wordno == 0) {
+ moved_(&data[nwritn], &numdp, record);
+ daswrd_(handle, &recno, record);
+ } else {
+ i__1 = wordno + 1;
+ i__2 = wordno + numdp;
+ dasurd_(handle, &recno, &i__1, &i__2, &data[nwritn]);
+ }
+ nwritn += numdp;
+ wordno += numdp;
+ } else {
+
+/* It's time to start on a new record. If the record we */
+/* just finished writing to (or just attempted writing to, */
+/* if it was full) was FREE or a higher-numbered record, */
+/* then we are writing to a contiguous set of data records: */
+/* the next record to write to is the immediate successor */
+/* of the last one. Otherwise, FREE is the next record */
+/* to write to. */
+
+/* We intentionally leave FREE at the value it had before */
+/* we starting adding data to the file. */
+
+ if (recno >= free) {
+ ++recno;
+ } else {
+ recno = free;
+ }
+ wordno = 0;
+ }
+ }
+
+/* Update the DAS file directories to reflect the addition of N */
+/* double precision words. DASCUD will also update the file summary */
+/* accordingly. */
+
+ dascud_(handle, &c__2, n);
+ chkout_("DASADD", (ftnlen)6);
+ return 0;
+} /* dasadd_ */
+
diff --git a/ext/spice/src/cspice/dasadi.c b/ext/spice/src/cspice/dasadi.c
new file mode 100644
index 0000000000..47381d1961
--- /dev/null
+++ b/ext/spice/src/cspice/dasadi.c
@@ -0,0 +1,391 @@
+/* dasadi.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__3 = 3;
+
+/* $Procedure DASADI ( DAS, add data, integer ) */
+/* Subroutine */ int dasadi_(integer *handle, integer *n, integer *data)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer free;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc, recno, lasti, ncomr;
+ extern /* Subroutine */ int movei_(integer *, integer *, integer *),
+ dasa2l_(integer *, integer *, integer *, integer *, integer *,
+ integer *, integer *);
+ extern logical failed_(void);
+ integer clbase;
+ extern /* Subroutine */ int dascud_(integer *, integer *, integer *),
+ dashfs_(integer *, integer *, integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *);
+ integer record[256], lastla[3];
+ extern /* Subroutine */ int dasuri_(integer *, integer *, integer *,
+ integer *, integer *);
+ integer lastrc[3], clsize;
+ extern /* Subroutine */ int daswri_(integer *, integer *, integer *),
+ chkout_(char *, ftnlen);
+ integer lastwd[3], nresvc, wordno, numint;
+ extern logical return_(void);
+ integer nresvr, nwritn;
+
+/* $ Abstract */
+
+/* Add an array of integers to a DAS file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ARRAY */
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* N I Number of integers to add to DAS file. */
+/* DATA I Array of integers to add. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a file handle of a DAS file opened for writing. */
+
+/* N is a the number of integer `words' to */
+/* add to the DAS file specified by HANDLE. */
+
+/* DATA is an array of integers to be added to the */
+/* specified DAS file. Elements 1 through N are */
+/* appended to the integer data in the file. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the effect of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. */
+
+/* 2) If an I/O error occurs during the data addition attempted */
+/* by this routine, the error will be diagnosed by routines */
+/* called by this routine. */
+
+/* 3) If the input count N is less than 1, no data will be */
+/* added to the specified DAS file. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine adds integer data to a DAS file by `appending' it */
+/* after any integer data already in the file. The sense in which */
+/* the data is `appended' is that the data will occupy a range of */
+/* logical addresses for integer data that immediately follow the */
+/* last logical address of a integer that is occupied at the time */
+/* this routine is called. The diagram below illustrates this */
+/* addition: */
+
+/* +-------------------------+ */
+/* | (already in use) | Integer logical address 1 */
+/* +-------------------------+ */
+/* . */
+/* . */
+/* . */
+/* +-------------------------+ */
+/* | (already in use) | Last integer logical address */
+/* +-------------------------+ in use before call to DASADI */
+/* | DATA(1) | */
+/* +-------------------------+ */
+/* . */
+/* . */
+/* . */
+/* +-------------------------+ */
+/* | DATA(N) | */
+/* +-------------------------+ */
+
+
+/* The logical organization of the integers in the DAS file is */
+/* independent of the order of addition to the file or physical */
+/* location of any data of double precision or character type. */
+
+/* The actual physical write operations that add the input array */
+/* DATA to the indicated DAS file may not take place before this */
+/* routine returns, since the DAS system buffers data that is */
+/* written as well as data that is read. In any case, the data */
+/* will be flushed to the file at the time the file is closed, if */
+/* not earlier. A physical write of all buffered records can be */
+/* forced by calling the SPICELIB routine DASWUR ( DAS, write */
+/* updated records ). */
+
+/* In order to update integer logical addresses that already contain */
+/* data, the SPICELIB routine DASUDI ( DAS update data, integer ) */
+/* should be used. */
+
+/* $ Examples */
+
+/* 1) Create the new DAS file TEST.DAS and add 200 integers to it. */
+/* Close the file, then re-open it and read the data back out. */
+
+
+/* PROGRAM TEST_ADD */
+
+/* CHARACTER*(4) TYPE */
+
+/* INTEGER DATA ( 200 ) */
+
+/* INTEGER HANDLE */
+/* INTEGER I */
+/* C */
+/* C Open a new DAS file. Use the file name as */
+/* C the internal file name. */
+/* C */
+/* TYPE = 'TEST' */
+/* CALL DASONW ( 'TEST.DAS', TYPE, 'TEST.DAS', HANDLE ) */
+
+/* C */
+/* C Fill the array DATA with the integers 1 through */
+/* C 100, and add this array to the file. */
+/* C */
+/* DO I = 1, 100 */
+/* DATA(I) = I */
+/* END DO */
+
+/* CALL DASADI ( HANDLE, 100, DATA ) */
+
+/* C */
+/* C Now append the array DATA to the file again. */
+/* C */
+/* CALL DASADI ( HANDLE, 100, DATA ) */
+
+/* C */
+/* C Close the file. */
+/* C */
+/* CALL DASCLS ( HANDLE ) */
+
+/* C */
+/* C Now verify the addition of data by opening the */
+/* C file for read access and retrieving the data. */
+/* C */
+/* CALL DASRDI ( HANDLE, 1, 200, DATA ) */
+
+/* C */
+/* C Dump the data to the screen. We should see the */
+/* C sequence 1, 2, ..., 100, 1, 2, ... , 100. */
+/* C */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) 'Data from TEST.DAS: ' */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) DATA */
+
+/* END */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1 19-DEC-1995 (NJB) */
+
+/* Corrected title of permuted index entry section. */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination conditions. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new, which makes use of the file */
+/* type. Also, a variable for the type of the file to be created */
+/* was added. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* add integer data to a DAS file */
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination condition. Without */
+/* this test, an infinite loop could result if DASA2L, DASURI or */
+/* DASWRI signaled an error inside the loop. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASADI", (ftnlen)6);
+ }
+
+/* Get the file summary for this DAS. */
+
+ dashfs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla, lastrc,
+ lastwd);
+ lasti = lastla[2];
+
+/* We will keep track of the location that we wish to write to */
+/* with the variables RECNO and WORDNO. RECNO will be the record */
+/* number of the record we'll write to; WORDNO will be the number */
+/* preceding the word index, within record number RECNO, that we'll */
+/* write to. For example, if we're about to write to the first */
+/* integer in record 10, RECNO will be 10 and WORDNO will be 0. Of */
+/* course, when WORDNO reaches NWI, we'll have to find a free record */
+/* before writing anything. */
+
+/* Prepare the variables RECNO and WORDNO: use the physical */
+/* location of the last integer address, if there are any integer */
+/* data in the file. Otherwise, RECNO becomes the first record */
+/* available for integer data. */
+
+ if (lasti >= 1) {
+ dasa2l_(handle, &c__3, &lasti, &clbase, &clsize, &recno, &wordno);
+ } else {
+ recno = free;
+ wordno = 0;
+ }
+
+/* Set the number of integer words already written. Keep */
+/* writing to the file until this number equals the number of */
+/* elements in DATA. */
+
+/* Note that if N is non-positive, the loop doesn't get exercised. */
+
+
+ nwritn = 0;
+ while(nwritn < *n && ! failed_()) {
+
+/* Write as much data as we can (or need to) into the current */
+/* record. We assume that RECNO, WORDNO, and NWRITN have been */
+/* set correctly at this point. */
+
+/* Find out how many words to write into the current record. */
+/* There may be no space left in the current record. */
+
+/* Computing MIN */
+ i__1 = *n - nwritn, i__2 = 256 - wordno;
+ numint = min(i__1,i__2);
+ if (numint > 0) {
+
+/* Write NUMINT words into the current record. If the record */
+/* is new, write the entire record. Otherwise, just update */
+/* the part we're interested in. */
+
+ if (wordno == 0) {
+ movei_(&data[nwritn], &numint, record);
+ daswri_(handle, &recno, record);
+ } else {
+ i__1 = wordno + 1;
+ i__2 = wordno + numint;
+ dasuri_(handle, &recno, &i__1, &i__2, &data[nwritn]);
+ }
+ nwritn += numint;
+ wordno += numint;
+ } else {
+
+/* It's time to start on a new record. If the record we */
+/* just finished writing to (or just attempted writing to, */
+/* if it was full) was FREE or a higher-numbered record, */
+/* then we are writing to a contiguous set of data records: */
+/* the next record to write to is the immediate successor */
+/* of the last one. Otherwise, FREE is the next record */
+/* to write to. */
+
+/* We intentionally leave FREE at the value it had before */
+/* we starting adding data to the file. */
+
+ if (recno >= free) {
+ ++recno;
+ } else {
+ recno = free;
+ }
+ wordno = 0;
+ }
+ }
+
+/* Update the DAS file directories to reflect the addition of N */
+/* integer words. DASCUD will also update the file summary */
+/* accordingly. */
+
+ dascud_(handle, &c__3, n);
+ chkout_("DASADI", (ftnlen)6);
+ return 0;
+} /* dasadi_ */
+
diff --git a/ext/spice/src/cspice/dasbt.c b/ext/spice/src/cspice/dasbt.c
new file mode 100644
index 0000000000..a46dcfe99c
--- /dev/null
+++ b/ext/spice/src/cspice/dasbt.c
@@ -0,0 +1,1311 @@
+/* dasbt.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static integer c__3 = 3;
+static integer c__4 = 4;
+
+/* $Procedure DASBT ( DAS, convert binary file to transfer file ) */
+/* Subroutine */ int dasbt_(char *binfil, integer *xfrlun, ftnlen binfil_len)
+{
+ /* System generated locals */
+ address a__1[3];
+ integer i__1[3], i__2;
+ char ch__1[10], ch__2[62];
+ cilist ci__1;
+
+ /* Builtin functions */
+ integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
+ /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen),
+ s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ char line[80];
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc, recno;
+ extern /* Subroutine */ int repmi_(char *, char *, integer *, char *,
+ ftnlen, ftnlen, ftnlen);
+ integer ncomr;
+ extern integer rtrim_(char *, ftnlen);
+ extern logical failed_(void);
+ integer dtabeg, ncdata, handle, nddata;
+ char ifname[60];
+ integer nidata;
+ extern /* Subroutine */ int daslla_(integer *, integer *, integer *,
+ integer *);
+ char crecrd[1024];
+ extern /* Subroutine */ int dasioc_(char *, integer *, integer *, char *,
+ ftnlen, ftnlen), dasrdc_(integer *, integer *, integer *, integer
+ *, integer *, char *, ftnlen);
+ char cbuffr[4*1024];
+ doublereal dbuffr[1024];
+ extern /* Subroutine */ int dascls_(integer *);
+ integer ibuffr[1024];
+ extern /* Subroutine */ int dasrdd_(integer *, integer *, integer *,
+ doublereal *), dashlu_(integer *, integer *);
+ integer daslun;
+ extern /* Subroutine */ int dasrfr_(integer *, char *, char *, integer *,
+ integer *, integer *, integer *, ftnlen, ftnlen);
+ char idword[8];
+ integer numblk, numdta;
+ extern /* Subroutine */ int dasopr_(char *, integer *, ftnlen), chkout_(
+ char *, ftnlen), errfnm_(char *, integer *, ftnlen);
+ integer nresvc;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen);
+ integer numlft;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen), wrenci_(
+ integer *, integer *, integer *), wrencc_(integer *, integer *,
+ char *, ftnlen), wrencd_(integer *, integer *, doublereal *),
+ dasrdi_(integer *, integer *, integer *, integer *);
+ extern logical return_(void);
+ integer nresvr;
+
+/* $ Abstract */
+
+/* Convert the contents of a binary DAS file to an equivalent DAS */
+/* transfer file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* BINFIL I Name of the binary DAS file to be converted. */
+/* XFRLUN I Logical unit of a previously opened file. */
+
+/* $ Detailed_Input */
+
+/* BINFIL The name of a binary DAS file which is to be converted */
+/* to an equivalent DAS transfer file. */
+
+/* XFRLUN The Fortran logical unit number of a previously opened */
+/* file. The DAS transfer file will be written to the */
+/* file attached to this logical unit beginning at the */
+/* current position in the file. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See arguments BINFIL, XFRLUN. */
+
+/* $ Exceptions */
+
+/* 1) If the binary DAS file specified by the filename BINFIL */
+/* cannot be opened for read access, an appropriate error */
+/* message will be signalled by a DAS file access routine that */
+/* is called by this routine. */
+
+/* 2) If for some reason the DAS transfer file cannot be written */
+/* to, the error SPICE(FILEWRITEFAILED) is signalled. */
+
+/* 3) If, for any reason, the DAS file cannot be read, a DAS file */
+/* access routine will signal an error with appropriate error */
+/* message. */
+
+/* 4) The binary DAS file opened by this routine, BINFIL, is only */
+/* GUARANTEED to be closed upon successful completion of the */
+/* binary to transfer conversion process. In the event of an */
+/* error, the caller of this routine is required to close the */
+/* binary DAS file BINFIL. */
+
+/* 5) If the values for the number of reserved records or the */
+/* number of reserved characters in a DAS file is nonzero, */
+/* the error SPICE(BADDASFILE) will be signalled. THIS ERROR */
+/* IS SIGNALLED ONLY BECAUSE THE RESERVED RECORD AREA HAS */
+/* NOT YET BEEN IMPLEMENTED. */
+
+/* $ Particulars */
+
+/* Any binary DAS file may be transferred between heterogeneous */
+/* Fortran environments by converting it to an equivalent file */
+/* containing only ASCII characters called a DAS transfer file. */
+/* Such a file can be transferred almost universally using any number */
+/* of established protocols. Once transferred, the DAS transfer file */
+/* can be converted to a binary file using the representations native */
+/* to the new host environment. */
+
+/* This routine provides a mechanism for converting a binary DAS */
+/* file into an equivalent DAS transfer file. It is one of a pair of */
+/* routines for performing conversions between the binary format of a */
+/* DAS file and the DAS transfer file. The inverse of this routine is */
+/* the routine DASTB. */
+
+/* Upon successful completion, the DAS transfer file attached to */
+/* Fortran logical unit XFRLUN will contain the same data as the */
+/* binary DAS file BINFIL in an encoded ASCII format. The binary DAS */
+/* file BINFIL will be closed when this routine exits successfully. */
+/* The DAS transfer file will remain open, as it was on entry, and it */
+/* will be positioned to write on the first line following the */
+/* encoded data from the binary DAS file. */
+
+/* $ Examples */
+
+/* Let */
+
+/* BINFIL be the name of a binary DAS file which is to be */
+/* converted to an equivalent DAS transfer file. This */
+/* could be for purposes of porting the data to a */
+/* different computer platform, or possibly for */
+/* archival storage of the data. */
+
+/* XFRLUN be the Fortran logical unit to which the DAS transfer */
+/* file is to be written. */
+
+/* Then, the following subroutine call would read the binary DAS */
+/* file BINFIL, convert its contents into an encoded format, and */
+/* then write that data to the DAS transfer file attached to XFRLUN, */
+/* beginning at the current position in that file. */
+
+/* CALL DASBT ( BINFIL, XFRLUN ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 13-AUG-1994 (KRG) */
+
+/* Updated the header and in line comments to reflect the change */
+/* from calling files text files to calling them transfer files. */
+
+/* Changed the variable name TXTLUN to XFRLUN to make it */
+/* compatible with the change in terminology. */
+
+/* - SPICELIB Version 2.0.0, 13-AUG-1994 (KRG) */
+
+/* A potential problem with list directed writes was fixed. Some */
+/* compilers have list directed writes that write multiple comma */
+/* separated items to one line and other compilers write these to */
+/* multiple lines even when all of the output will fit on a single */
+/* line. This was fixed by replacing all of the affected list */
+/* directed write statements with code to put the desired data */
+/* into a character string and then write the character string. */
+
+/* - SPICELIB Version 1.0.0, 29-OCT-1992 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* convert binary das to das transfer file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 3.0.0, 13-AUG-1994 (KRG) */
+
+/* Updated the header and in line comments to reflect the change */
+/* from calling files text files to calling them transfer files. */
+
+/* Changed the variable name TXTLUN to XFRLUN to make it */
+/* compatible with the change in terminology. */
+
+/* - SPICELIB Version 2.0.0, 13-AUG-1994 (KRG) */
+
+/* A potential problem with list directed writes was fixed. Some */
+/* compilers have list directed writes that write multiple comma */
+/* separated items to one line and other compilers write these to */
+/* multiple lines even when all of the output will fit on a single */
+/* line. This was fixed by replacing all of the affected list */
+/* directed write statements with code to put the desired data */
+/* into a character string and then write the character string. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* CHARACTER*(*) BEGRES */
+/* PARAMETER ( BEGRES = 'BEGIN_RESERVED_BLOCK' ) */
+
+/* CHARACTER*(*) ENDRES */
+/* PARAMETER ( ENDRES = 'END_RESERVED_BLOCK' ) */
+
+/* CHARACTER*(*) TRRBLK */
+/* PARAMETER ( TRRBLK = 'TOTAL_RESERVED_BLOCKS' ) */
+
+
+/* Some parameters for writing the array markers */
+
+
+/* Length of a character buffer array element. */
+
+
+/* Length of a DAS file ID word. */
+
+
+/* Length of a DAS internal filename. */
+
+
+/* Length of a DAS comment record, in characters. */
+
+
+/* Size of the character, double precision, and integer data buffers. */
+
+
+/* Beginning and ending string positions for reading/writing */
+/* character data from/to a DAS file using the character data */
+/* buffer. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASBT", (ftnlen)5);
+ }
+
+/* When converting a binary DAS file into its DAS transfer file */
+/* equivalent, all of the data contained in the binary file is */
+/* placed into the DAS transfer file by this routine. This includes */
+/* the reserved record area, the comment area, and the character, */
+/* double precision, and integer data arrays as well. */
+
+/* Currently, the reserved record area has not been implemented, as */
+/* there is no need for it at this time. If, or when, the reserved */
+/* record area is implemented, this routine will need to be modified */
+/* in order to support it. See the code for details. */
+
+/* The data from the binary file are written to the DAS transfer */
+/* file as sequences of small blocks of data. This is to provide */
+/* a means for performing some error detection when converting a */
+/* DAS transfer file into its binary equivalent. Each block of */
+/* data is enclosed within begin and end block markers which hold */
+/* the count of data items in a data block. When all of the data */
+/* blocks for a data area have been written, a total blocks line is */
+/* written to the DAS transfer file. */
+
+/* The data from the binary DAS file MUST appear in the following */
+/* order in the DAS transfer file. */
+
+/* 1) Reserved records (when/if implemented) */
+/* 2) Comment area */
+/* 3) Character data array */
+/* 4) Double precision data array */
+/* 5) Integer data array */
+
+/* If the data count for any of these DAS data areas is zero, no */
+/* data or markers for it are placed into the DAS transfer file. */
+/* Conversion proceeds with the next DAS data area in the list. */
+
+/* For example, suppose that we have a binary DAS file where there */
+/* are 0 reserved characters in the reserved record area, 5000 */
+/* comment characters in the comment area, and that the character, */
+/* double precision, and integer array counts are 0, 2300, and */
+/* 6900, respectively. Then, the DAS transfer file will contain */
+/* no reserved record data blocks, 2 comment data blocks, no */
+/* character data blocks, 3 double precision data blocks, and 7 */
+/* integer data blocks, in that order. */
+
+/* DAS transfer file description. */
+/* ---------------------------------- */
+
+/* A brief description of the DAS encoded file format and its */
+/* intended use follows. This description is intended to provide a */
+/* simple ``picture'' of the DAS transfer file format to aid in the */
+/* understanding of this routine. This description is NOT intended to */
+/* be a detailed specification of the file format. */
+
+/* A DAS transfer file contains all of the data from a binary */
+/* DAS file in an encoded ASCII format. It also contains some */
+/* bookkeeping information for maintaining the integrity of the */
+/* data. The DAS transfer file format allows the full precision of */
+/* character, integer, and floating point numeric data to be */
+/* maintained in a portable fashion. The DAS transfer file format is */
+/* intended to provide a reliable and accurate means for porting data */
+/* among multiple computer systems and for the archival storage of */
+/* data. */
+
+/* A DAS transfer file is not intended to be used directly to provide */
+/* data to a program. The equivalent binary DAS file is to be used */
+/* for this purpose. In no way should any program, other than a DAS */
+/* binary <-> transfer conversion program, rely on the DAS transfer */
+/* file format. */
+
+/* To correctly understand the DAS transfer file description the */
+/* reader should be familiar with the DAS file architecture. Items */
+/* enclosed in angle brackets, '<' and '>', are used to represent the */
+/* data which are to be placed at that position in the file. The */
+/* bookkeeping information which appears is represented exactly as it */
+/* would appear in a DAS transfer file. */
+
+/* Let */
+
+/* denote the beginning of the file */
+/* denote the end of the file */
+
+/* and */
+
+/* nresvb denote the number of encoded reserved record data */
+/* blocks generated */
+/* nresvc denote the total number of reserved record characters */
+/* in the reserved record area of a DAS file */
+/* ncomb denote the number of encoded comment data blocks */
+/* generated */
+/* ncomc denote the total number of comment characters in the */
+/* comment area of a DAS file */
+/* nchrb denote the number of encoded character data blocks */
+/* generated */
+/* nchrs denote the count of characters in the DAS character */
+/* data array */
+/* ndpb denote the number of encoded double precision data */
+/* blocks generated */
+/* ndps denote the count of double precision numbers in the DAS */
+/* double precision data array */
+/* nintb denote the number of encoded integer data blocks */
+/* generated */
+/* nints denote the count of integers in the DAS integer data */
+/* array */
+
+/* A DAS encoded transfer file has the following format: */
+
+/* */
+/* < Information line > */
+/* < DAS file ID word > */
+/* < Internal filename > */
+/* < Encoded count of reserved records > */
+/* < Encoded count of reserved characters > */
+/* < Encoded count of comment records > */
+/* < Encoded count of comment characters > */
+/* < Blocks of encoded reserved record data, if nresvc > 0 > */
+/* TOTAL_RESERVED_BLOCKS nresvb nresvc */
+/* < Blocks of encoded comment data, if ncomc > 0 > */
+/* TOTAL_COMMENT_BLOCKS ncomb ncomc */
+/* < Encoded count of character data > */
+/* < Encoded count of double precision data > */
+/* < Encoded count of integer data > */
+/* < Blocks of encoded character data, if nchrs > 0 > */
+/* TOTAL_CHARACTER_BLOCKS nchrb nchrs */
+/* < Blocks of encoded double precision data, if ndps > 0 > */
+/* TOTAL_DP_BLOCKS ndpb ndps */
+/* < Blocks of encoded integer data, if nints > 0 > */
+/* TOTAL_INTEGER_BLOCKS nintb nints */
+/* */
+
+/* This routine will check the SPICELIB function FAILED() after */
+/* each call, or consecutive sequence of calls, to data encoding */
+/* routines, and if an error was signalled it will simply check out */
+/* and return to the caller. */
+
+/* This routine will check the SPICELIB function FAILED() after */
+/* each DAS file access call, and if an error was signalled it will */
+/* simply check out and return to the caller. */
+
+/* We begin by opening the binary DAS file specified by BINFIL for */
+/* read access, obtaining a file handle. */
+
+ dasopr_(binfil, &handle, binfil_len);
+ if (failed_()) {
+
+/* If an error occurred while opening the file check out and */
+/* return to the caller. */
+
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Get the contents of the DAS file record. */
+
+ dasrfr_(&handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (
+ ftnlen)8, (ftnlen)60);
+
+/* Convert the DAS file handle into its equivalent Fortran logical */
+/* unit. We need the logical unit so that we can read the reserved */
+/* records and the comment records. */
+
+ dashlu_(&handle, &daslun);
+ if (failed_()) {
+
+/* If an error occurred while converting the DAS file handle to */
+/* a logical unit, attempt to close the binary file, then check */
+/* out and return. */
+
+ dascls_(&handle);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to be sure that the number of reserved records and the */
+/* number of reserved characters are not being used. The DAS */
+/* reserved record area is not currently implemented, so nobody */
+/* should be using it. */
+
+ if (nresvc != 0) {
+
+/* Set the error message, close the file, signal the error, and */
+/* exit. */
+
+ setmsg_("The number of reserved characters was nonzero (#) in file: "
+ "#, but the DAS reserved record area has NOT been implemented"
+ " yet!", (ftnlen)124);
+ errint_("#", &nresvc, (ftnlen)1);
+ errfnm_("#", &daslun, (ftnlen)1);
+ dascls_(&handle);
+ sigerr_("SPICE(BADDASFILE)", (ftnlen)17);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+ if (nresvr != 0) {
+
+/* Set the error message, close the file, signal the error, and */
+/* exit. */
+
+ setmsg_("The number of reserved records was nonzero (#) in file: #, "
+ "but the DAS reserved record area has NOT been implemented ye"
+ "t!", (ftnlen)121);
+ errint_("#", &nresvr, (ftnlen)1);
+ errfnm_("#", &daslun, (ftnlen)1);
+ dascls_(&handle);
+ sigerr_("SPICE(BADDASFILE)", (ftnlen)17);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write the information line containing the file type information */
+/* and format version for the DAS transfer to the current position in */
+/* the file. The file format version information must be the first */
+/* ``word'' on the information line. The rest of the line may be used */
+/* for other purposes. Right now, it simply contains an expanded */
+/* description of the file format version information ``word.'' */
+
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_fio(&c__1, "DASETF NAIF DAS ENCODED TRANSFER FILE", (ftnlen)
+ 37);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_wsfe();
+L100001:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT = #.", (
+ ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write the DAS ID word to the DAS transfer file. */
+
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100002;
+ }
+/* Writing concatenation */
+ i__1[0] = 1, a__1[0] = "'";
+ i__1[1] = 8, a__1[1] = idword;
+ i__1[2] = 1, a__1[2] = "'";
+ s_cat(ch__1, a__1, i__1, &c__3, (ftnlen)10);
+ iostat = do_fio(&c__1, ch__1, (ftnlen)10);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_wsfe();
+L100002:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT = #.", (
+ ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write the internal file name of the DAS file to the DAS transfer */
+/* file. */
+
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100003;
+ }
+/* Writing concatenation */
+ i__1[0] = 1, a__1[0] = "'";
+ i__1[1] = 60, a__1[1] = ifname;
+ i__1[2] = 1, a__1[2] = "'";
+ s_cat(ch__2, a__1, i__1, &c__3, (ftnlen)62);
+ iostat = do_fio(&c__1, ch__2, (ftnlen)62);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = e_wsfe();
+L100003:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT = #.", (
+ ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write the number of reserved records and reserved characters to */
+/* the DAS transfer file. */
+
+ wrenci_(xfrlun, &c__1, &nresvr);
+ wrenci_(xfrlun, &c__1, &nresvc);
+ if (failed_()) {
+
+/* If an error occurred while writing the number of reserved */
+/* records or number of reserved characters, attempt to close */
+/* the binary file, then check out and return. */
+
+ dascls_(&handle);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write the number of comment records and comment characters to */
+/* the DAS transfer file. */
+
+ wrenci_(xfrlun, &c__1, &ncomr);
+ wrenci_(xfrlun, &c__1, &ncomc);
+ if (failed_()) {
+
+/* If an error occurred while writing the number of comment */
+/* records or number of comment characters, attempt to close */
+/* the binary file, then check out and return. */
+
+ dascls_(&handle);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* ************************************************************** */
+/* When/if the reserved record area is implemented, the code to */
+/* convert it and place it into the DAS transfer file should go */
+/* here. It should be possible to simply copy the code for the */
+/* comment area, making all of the necessary variable name changes, */
+/* etc., since the reserved record area is going to contain ONLY */
+/* character data. */
+/* ************************************************************** */
+
+/* Write out the comment area of the DAS file, if there are any */
+/* comment characters stored in it. */
+
+ if (ncomc > 0) {
+
+/* Write out the comment records, one at a time. */
+
+ s_copy(crecrd, " ", (ftnlen)1024, (ftnlen)1);
+ numlft = ncomc;
+ numblk = 0;
+ recno = nresvr + 1;
+ while(numlft > 0) {
+ ++numblk;
+ ++recno;
+ if (numlft > 1024) {
+ numdta = 1024;
+ } else {
+ numdta = numlft;
+ }
+
+/* Write out the begin comment block marker and the number of */
+/* comment characters. */
+
+ s_copy(line, "BEGIN_COMMENT_BLOCK # #", (ftnlen)80, (ftnlen)23);
+ repmi_(line, "#", &numblk, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ repmi_(line, "#", &numdta, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = e_wsfe();
+L100004:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT ="
+ " #.", (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Read a comment record and then encode and write it. */
+
+ dasioc_("READ", &daslun, &recno, crecrd, (ftnlen)4, (ftnlen)1024);
+ wrencc_(xfrlun, &numdta, crecrd, (ftnlen)1024);
+ if (failed_()) {
+
+/* We want to check failed here because were in a loop. */
+/* We should exit the loop, and the routine, as soon as */
+/* an error is detected, so we don't continue doing things */
+/* for a long time. Attempt to close the binary DAS file */
+/* that we opened and then return to the caller. */
+
+ dascls_(&handle);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write out the end comment block marker and the number of */
+/* comment characters. */
+
+ s_copy(line, "END_COMMENT_BLOCK # #", (ftnlen)80, (ftnlen)21);
+ repmi_(line, "#", &numblk, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ repmi_(line, "#", &numdta, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = e_wsfe();
+L100005:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT ="
+ " #.", (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Update the number of comment characters remaining to be */
+/* written. */
+
+ numlft -= numdta;
+ }
+
+/* Write out the number of comment blocks processed, and the */
+/* count of comment characters */
+
+ s_copy(line, "TOTAL_COMMENT_BLOCKS # #", (ftnlen)80, (ftnlen)24);
+ repmi_(line, "#", &numblk, line, (ftnlen)80, (ftnlen)1, (ftnlen)80);
+ repmi_(line, "#", &ncomc, line, (ftnlen)80, (ftnlen)1, (ftnlen)80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100006;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100006;
+ }
+ iostat = e_wsfe();
+L100006:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT = #.",
+ (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Read in the data counts for each of the data types from the binary */
+/* DAS file. */
+
+ daslla_(&handle, &ncdata, &nddata, &nidata);
+
+/* Write the data counts to the DAS transfer file. These will be */
+/* useful in determining which data types to expect in the DAS */
+/* transfer file when converting it back to binary. */
+
+ wrenci_(xfrlun, &c__1, &ncdata);
+ wrenci_(xfrlun, &c__1, &nddata);
+ wrenci_(xfrlun, &c__1, &nidata);
+ if (failed_()) {
+
+/* If an error occurred while writing any of the data counts to */
+/* the DAS transfer file, attempt to close the binary file, then */
+/* check out and return. */
+
+ dascls_(&handle);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Encode and write the CHARACTER data to the DAS transfer file, if */
+/* there is any character data. */
+
+ if (ncdata > 0) {
+ numblk = 0;
+ dtabeg = 1;
+ numlft = ncdata;
+ while(numlft > 0) {
+ ++numblk;
+ if (numlft >= 4096) {
+ numdta = 4096;
+ } else {
+ numdta = numlft;
+ }
+
+/* Write out the begin data block identifier, the block */
+/* number, and the data count for the block. */
+
+ s_copy(line, "BEGIN_CHARACTER_BLOCK # #", (ftnlen)80, (ftnlen)25);
+ repmi_(line, "#", &numblk, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ repmi_(line, "#", &numdta, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100007;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100007;
+ }
+ iostat = e_wsfe();
+L100007:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT ="
+ " #.", (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Read in NUMDTA characters. The desired data are specified by */
+/* beginning and ending indices into the array, inclusive: thus */
+/* the subtraction of 1 in the call. */
+
+ i__2 = dtabeg + numdta - 1;
+ dasrdc_(&handle, &dtabeg, &i__2, &c__1, &c__4, cbuffr, (ftnlen)4);
+
+/* Encode and write out a buffer of characters. */
+
+ wrencc_(xfrlun, &numdta, cbuffr, (ftnlen)4);
+ if (failed_()) {
+
+/* We want to check failed here because were in a loop. */
+/* We should exit the loop, and the routine, as soon as */
+/* an error is detected, so we don't continue doing things */
+/* for a long time. Attempt to close the binary DAS file */
+/* that we opened and then returrn to the caller. */
+
+ dascls_(&handle);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write out the end data block identifier, the block number, */
+/* and the data count for the block. */
+
+ s_copy(line, "END_CHARACTER_BLOCK # #", (ftnlen)80, (ftnlen)23);
+ repmi_(line, "#", &numblk, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ repmi_(line, "#", &numdta, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100008;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100008;
+ }
+ iostat = e_wsfe();
+L100008:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT ="
+ " #.", (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Increment the data pointer and decrement the amount of data */
+/* left to move. */
+
+ dtabeg += numdta;
+ numlft -= numdta;
+ }
+
+/* Write out the number of character data blocks processed */
+/* processed, and the count of double precision data items. */
+
+ s_copy(line, "TOTAL_CHARACTER_BLOCKS # #", (ftnlen)80, (ftnlen)26);
+ repmi_(line, "#", &numblk, line, (ftnlen)80, (ftnlen)1, (ftnlen)80);
+ repmi_(line, "#", &ncdata, line, (ftnlen)80, (ftnlen)1, (ftnlen)80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100009;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100009;
+ }
+ iostat = e_wsfe();
+L100009:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT = #.",
+ (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Encode and write the DOUBLE PRECISION data to the DAS transfer */
+/* file. */
+
+ if (nddata > 0) {
+ numblk = 0;
+ dtabeg = 1;
+ numlft = nddata;
+ while(numlft > 0) {
+ ++numblk;
+ if (numlft >= 1024) {
+ numdta = 1024;
+ } else {
+ numdta = numlft;
+ }
+
+/* Write out the begin data block identifier, the block */
+/* number, and the data count for the block. */
+
+ s_copy(line, "BEGIN_DP_BLOCK # #", (ftnlen)80, (ftnlen)18);
+ repmi_(line, "#", &numblk, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ repmi_(line, "#", &numdta, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100010;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100010;
+ }
+ iostat = e_wsfe();
+L100010:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT ="
+ " #.", (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Read in NUMDTA double precision numbers.The desired data are */
+/* specified by beginning and ending indices into the array, */
+/* inclusive: thus the subtraction of 1 in the call. */
+
+ i__2 = dtabeg + numdta - 1;
+ dasrdd_(&handle, &dtabeg, &i__2, dbuffr);
+
+/* Encode and write out a buffer of double precision numbers. */
+
+ wrencd_(xfrlun, &numdta, dbuffr);
+ if (failed_()) {
+
+/* We want to check failed here because were in a loop. */
+/* We should exit the loop, and the routine, as soon as */
+/* an error is detected, so we don't continue doing things */
+/* for a long time. Attempt to close the binary DAS file */
+/* that we opened and then returrn to the caller. */
+
+ dascls_(&handle);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write out the end data block identifier, the block number, */
+/* and the data count for the block. */
+
+ s_copy(line, "END_DP_BLOCK # #", (ftnlen)80, (ftnlen)16);
+ repmi_(line, "#", &numblk, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ repmi_(line, "#", &numdta, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100011;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100011;
+ }
+ iostat = e_wsfe();
+L100011:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT ="
+ " #.", (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Increment the data pointer and decrement the amount of data */
+/* left to move. */
+
+ dtabeg += numdta;
+ numlft -= numdta;
+ }
+
+/* Write out the number of double precision processed data blocks */
+/* processed, and the count of double precision data items. */
+
+ s_copy(line, "TOTAL_DP_BLOCKS # #", (ftnlen)80, (ftnlen)19);
+ repmi_(line, "#", &numblk, line, (ftnlen)80, (ftnlen)1, (ftnlen)80);
+ repmi_(line, "#", &nddata, line, (ftnlen)80, (ftnlen)1, (ftnlen)80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100012;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100012;
+ }
+ iostat = e_wsfe();
+L100012:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT = #.",
+ (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Encode and write the INTEGER data to the DAS transfer file, if */
+/* there is any. */
+
+ if (nidata > 0) {
+ numblk = 0;
+ dtabeg = 1;
+ numlft = nidata;
+ while(numlft > 0) {
+ ++numblk;
+ if (numlft >= 1024) {
+ numdta = 1024;
+ } else {
+ numdta = numlft;
+ }
+
+/* Write out the begin data block identifier, the block number, */
+/* and the data count for the block. */
+
+ s_copy(line, "BEGIN_INTEGER_BLOCK # #", (ftnlen)80, (ftnlen)23);
+ repmi_(line, "#", &numblk, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ repmi_(line, "#", &numdta, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100013;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100013;
+ }
+ iostat = e_wsfe();
+L100013:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT ="
+ " #.", (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Read in NUMDTA integers. The desired data are specified by */
+/* beginning and ending indices into the array,inclusive: thus */
+/* the subtraction of 1 in the call. */
+
+ i__2 = dtabeg + numdta - 1;
+ dasrdi_(&handle, &dtabeg, &i__2, ibuffr);
+
+/* Encode and write out a buffer of integers. */
+
+ wrenci_(xfrlun, &numdta, ibuffr);
+ if (failed_()) {
+
+/* We want to check failed here because were in a loop. */
+/* We should exit the loop, and the routine, as soon as */
+/* an error is detected, so we don't continue doing things */
+/* for a long time. Attempt to close the binary DAS file */
+/* that we opened and then returrn to the caller. */
+
+ dascls_(&handle);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Write out the end data block identifier, the block number, */
+/* and the data count for the block. */
+
+ s_copy(line, "END_INTEGER_BLOCK # #", (ftnlen)80, (ftnlen)21);
+ repmi_(line, "#", &numblk, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ repmi_(line, "#", &numdta, line, (ftnlen)80, (ftnlen)1, (ftnlen)
+ 80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100014;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100014;
+ }
+ iostat = e_wsfe();
+L100014:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT ="
+ " #.", (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+
+/* Increment the data pointers and decrement the amount of data */
+/* left. */
+
+ dtabeg += numdta;
+ numlft -= numdta;
+ }
+
+/* Write out the number of processed integer data blocks */
+/* processed, and the count of double precision data items. */
+
+ s_copy(line, "TOTAL_INTEGER_BLOCKS # #", (ftnlen)80, (ftnlen)24);
+ repmi_(line, "#", &numblk, line, (ftnlen)80, (ftnlen)1, (ftnlen)80);
+ repmi_(line, "#", &nidata, line, (ftnlen)80, (ftnlen)1, (ftnlen)80);
+ ci__1.cierr = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_wsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100015;
+ }
+ iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)80));
+ if (iostat != 0) {
+ goto L100015;
+ }
+ iostat = e_wsfe();
+L100015:
+ if (iostat != 0) {
+
+/* An error occurred, so close the binary DAS file, set an */
+/* appropriate error message, and return to the caller. */
+
+ dascls_(&handle);
+ setmsg_("Error writing to the DAS transfer file: #. IOSTAT = #.",
+ (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* Close only the binary DAS file. */
+
+ dascls_(&handle);
+ chkout_("DASBT", (ftnlen)5);
+ return 0;
+} /* dasbt_ */
+
diff --git a/ext/spice/src/cspice/dascls.c b/ext/spice/src/cspice/dascls.c
new file mode 100644
index 0000000000..e6bbe106f5
--- /dev/null
+++ b/ext/spice/src/cspice/dascls.c
@@ -0,0 +1,363 @@
+/* dascls.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__21 = 21;
+
+/* $Procedure DASCLS ( DAS, close file ) */
+/* Subroutine */ int dascls_(integer *handle)
+{
+ /* Initialized data */
+
+ static logical pass1 = TRUE_;
+
+ /* System generated locals */
+ inlist ioin__1;
+
+ /* Builtin functions */
+ integer s_cmp(char *, char *, ftnlen, ftnlen), f_inqu(inlist *);
+
+ /* Local variables */
+ integer unit;
+ extern logical elemi_(integer *, integer *);
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ static integer fhset[27];
+ extern logical failed_(void);
+ extern /* Subroutine */ int dasham_(integer *, char *, ftnlen), dasllc_(
+ integer *), dashof_(integer *);
+ char method[10];
+ extern /* Subroutine */ int dashlu_(integer *, integer *), daswbr_(
+ integer *), dassdr_(integer *), sigerr_(char *, ftnlen), chkout_(
+ char *, ftnlen), setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen), ssizei_(
+ integer *, integer *);
+ logical notscr;
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Close a DAS file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of an open DAS file. */
+/* FTSIZE P Maximum number of simultaneously open DAS files. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the file handle of an open DAS file. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the effect of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* FTSIZE is the maximum number of DAS files that can be */
+/* open at any one time. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* 1) If HANDLE is not the handle of an open DAS file, no error */
+/* is signalled. */
+
+/* $ Files */
+
+/* See the description of input argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine provides the primary recommended method of closing an */
+/* open DAS file. It is also possible to close a DAS file without */
+/* segregating it by calling DASWBR and DASLLC. Closing a DAS file by */
+/* any other means may cause the DAS mechanism for keeping track of */
+/* which files are open to fail. Closing a DAS file that has been */
+/* opened for writing by any other means may result in the production */
+/* of something other than a DAS file. */
+
+/* $ Examples */
+
+/* 1) Open a new DAS file called TEST.DAS, add 100 d.p. numbers */
+/* to it, and then close the file. */
+
+/* C */
+/* C We'll give the file the same internal file name */
+/* C as the file's actual name. We don't require any */
+/* C reserved records. */
+/* C */
+/* FNAME = 'TEST.DAS' */
+/* FTYPE = 'TEST' */
+
+/* CALL DASONW ( FNAME, FTYPE, FNAME, 0, HANDLE ) */
+
+/* DO I = 1, 100 */
+/* DATAD(I) = DBLE(I) */
+/* END DO */
+
+/* CALL DASADD ( HANDLE, 100, DATAD ) */
+
+/* CALL DASCLS ( HANDLE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.3.3, 05-OCT-2006 (NJB) */
+
+/* Corrected DASADD calling sequence error in code example. */
+/* Updated Particulars header section to mention closing DAS */
+/* files without segregation via calls to DASWBR and DASLLC. */
+
+/* - SPICELIB Version 1.3.2, 24-MAR-2003 (NJB) */
+
+/* DASWBR call has been reinstated for scratch DAS case. */
+/* This call has the side effect of freeing buffer records */
+/* owned by the file DASWBR writes to. Failing to free these */
+/* records can cause write errors on HP/Fortran systems. */
+
+/* - SPICELIB Version 1.2.2, 27-FEB-2003 (NJB) */
+
+/* Tests whether file to be closed is a scratch DAS; if */
+/* so, buffer flushes and record segregation are omitted. */
+
+/* - EKLIB Version 1.1.1, 26-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* Changed the value of the parameter FTSIZE from 20 to 21. This */
+/* change makes the value of FTSIZE in DASCLS compatible with the */
+/* value in DASFM. See DASFM for a discussion of the reasons for */
+/* the increase in the value. */
+
+/* - EKLIB Version 1.1.0, 08-JUL-1993 (NJB) */
+
+/* FHSET is now saved. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* close an open DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.3.2, 24-MAR-2003 (NJB) */
+
+/* DASWBR call has been reinstated for scratch DAS case. */
+/* This call has the side effect of freeing buffer records */
+/* owned by the file DASWBR writes to. Failing to free these */
+/* records can cause write errors on HP/Fortran systems. */
+
+/* - SPICELIB Version 1.2.2, 27-FEB-2003 (NJB) */
+
+/* Tests whether file to be closed is a scratch DAS; if */
+/* so, buffer flushes and record segregation are omitted. */
+
+/* - EKLIB Version 1.1.1, 26-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* Changed the value of the parameter FTSIZE from 20 to 21. This */
+/* change makes the value of FTSIZE in DASCLS compatible with the */
+/* value in DASFM. See DASFM for a discussion of the reasons for */
+/* the increase in the value. */
+
+/* - EKLIB Version 1.1.0, 08-JUL-1993 (NJB) */
+
+/* FHSET is now saved. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASCLS", (ftnlen)6);
+ }
+ if (pass1) {
+ ssizei_(&c__21, fhset);
+ pass1 = FALSE_;
+ }
+
+/* There are only four items on our worklist: */
+
+/* 1) Determine whether the file open for reading or writing, */
+/* and if it's open for writing, whether it's a scratch */
+/* file. */
+
+/* 2) If the DAS file is open for writing, flush any updated */
+/* records from the data buffers to the file. */
+
+/* 3) If the DAS file is open for writing, re-order the records */
+/* in the file so that the data is segregated by data type. */
+
+/* 4) Close the file. */
+
+
+/* See whether the input handle designates an open DAS file. If not, */
+/* return now. */
+
+ dashof_(fhset);
+ if (! elemi_(handle, fhset)) {
+ chkout_("DASCLS", (ftnlen)6);
+ return 0;
+ }
+
+/* If the file is open for writing, flush any buffered */
+/* records that belong to it. */
+
+ dasham_(handle, method, (ftnlen)10);
+ if (s_cmp(method, "WRITE ", (ftnlen)10, (ftnlen)6) == 0) {
+
+/* Make sure that all buffered records belonging to the */
+/* indicated file are written out. */
+
+ daswbr_(handle);
+
+/* We cannot directly test the status of the file, but if */
+/* the file is unnamed, it must be a scratch file. */
+
+ dashlu_(handle, &unit);
+ if (failed_()) {
+ chkout_("DASCLS", (ftnlen)6);
+ return 0;
+ }
+ ioin__1.inerr = 1;
+ ioin__1.inunit = unit;
+ ioin__1.infile = 0;
+ ioin__1.inex = 0;
+ ioin__1.inopen = 0;
+ ioin__1.innum = 0;
+ ioin__1.innamed = ¬scr;
+ ioin__1.inname = 0;
+ ioin__1.inacc = 0;
+ ioin__1.inseq = 0;
+ ioin__1.indir = 0;
+ ioin__1.infmt = 0;
+ ioin__1.inform = 0;
+ ioin__1.inunf = 0;
+ ioin__1.inrecl = 0;
+ ioin__1.innrec = 0;
+ ioin__1.inblank = 0;
+ iostat = f_inqu(&ioin__1);
+ if (iostat != 0) {
+ setmsg_("Error occurred while performing an INQUIRE on a DAS fi"
+ "le about to be closed. IOSTAT = #. File handle was #. "
+ "Logical unit was #.", (ftnlen)130);
+ errint_("#", &iostat, (ftnlen)1);
+ errint_("#", handle, (ftnlen)1);
+ errint_("#", &unit, (ftnlen)1);
+ sigerr_("SPICE(INQUIREFAILED)", (ftnlen)20);
+ chkout_("DASCLS", (ftnlen)6);
+ return 0;
+ }
+ if (notscr) {
+
+/* Segregate the data records in the file according to data */
+/* type. */
+
+ dassdr_(handle);
+ }
+ }
+
+/* Close the file. */
+
+ dasllc_(handle);
+ chkout_("DASCLS", (ftnlen)6);
+ return 0;
+} /* dascls_ */
+
diff --git a/ext/spice/src/cspice/dascls_c.c b/ext/spice/src/cspice/dascls_c.c
new file mode 100644
index 0000000000..16f5a5836f
--- /dev/null
+++ b/ext/spice/src/cspice/dascls_c.c
@@ -0,0 +1,202 @@
+/*
+
+-Procedure dascls_c ( DAS, close file )
+
+-Abstract
+
+ Close a DAS file.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAS
+
+-Keywords
+
+ DAS
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+
+ void dascls_c ( SpiceInt handle )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of an open DAS file.
+ FTSIZE P Maximum number of simultaneously open DAS files.
+
+-Detailed_Input
+
+ handle is the file handle of an open DAS file.
+
+-Detailed_Output
+
+ None. See $Particulars for a description of the effect of this
+ routine.
+
+-Parameters
+
+ FTSIZE is the maximum number of DAS files that can be
+ open at any one time. See the file dasfm.c
+ for details.
+
+-Exceptions
+
+ Error free.
+
+ 1) If `handle' is not the handle of an open DAS file, no error
+ is signaled.
+
+-Files
+
+ See the description of input argument `handle' in $Detailed_Input.
+
+-Particulars
+
+ This routine provides the primary recommended method of closing an
+ open DAS file. It is also possible to close a DAS file without
+ segregating it by calling daswbr_ and dasllc_. Closing a DAS file by
+ any other means may cause the DAS mechanism for keeping track of
+ which files are open to fail. Closing a DAS file that has been
+ opened for writing by any other means may result in the production
+ of something other than a DAS file.
+
+-Examples
+
+ 1) Open a new DAS file called TEST.DAS, add 100 d.p. numbers
+ to it, and then close the file.
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include
+
+ int main()
+ {
+ #define NMAX 100
+
+ SpiceChar * fname;
+ SpiceChar * ftype;
+ SpiceChar * ifname;
+
+ SpiceDouble ddata [ NMAX ];
+
+ SpiceInt handle;
+ SpiceInt i;
+ SpiceInt n;
+ SpiceInt ncomch;
+
+
+ /.
+ We'll give the file the same internal file name
+ as the file's actual name. We don't require any
+ comment records.
+ ./
+ fname = "TEST.DAS";
+ ftype = "TEST";
+ ifname = fname;
+ ncomch = 0;
+
+ dasonw_ ( (SpiceChar *) fname,
+ (SpiceChar *) ftype,
+ (SpiceChar *) ifname,
+ (integer *) &ncomch,
+ (integer *) &handle,
+ (ftnlen ) strlen(fname),
+ (ftnlen ) strlen(ftype),
+ (ftnlen ) strlen(ifname) );
+
+
+ for ( i = 0; i < NMAX; i++ )
+ {
+ ddata[i] = (SpiceDouble)i;
+ }
+
+ n = NMAX;
+
+ dasadd_ ( &handle, &n, ddata );
+
+ dascls_c ( handle );
+
+ return ( 0 );
+ }
+
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ W.L. Taber (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 05-OCT-2006 (NJB) (KRG) (WLT)
+
+-Index_Entries
+
+ close a DAS file
+
+-&
+*/
+
+{ /* Begin dascls_c */
+
+
+
+ /*
+ Participate in error tracing.
+ */
+
+ chkin_c ( "dascls_c" );
+
+ /*
+ Call the f2c'd Fortran routine. Use explicit type casts for every
+ type defined by f2c.
+ */
+ dascls_ ( ( integer * ) &handle );
+
+
+ chkout_c ( "dascls_c" );
+
+} /* End dascls_c */
+
diff --git a/ext/spice/src/cspice/dascud.c b/ext/spice/src/cspice/dascud.c
new file mode 100644
index 0000000000..0e2dbaeb93
--- /dev/null
+++ b/ext/spice/src/cspice/dascud.c
@@ -0,0 +1,828 @@
+/* dascud.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__3 = 3;
+static integer c__256 = 256;
+static integer c__2 = 2;
+
+/* $Procedure DASCUD ( DAS, create or update directories ) */
+/* Subroutine */ int dascud_(integer *handle, integer *type__, integer *
+ nwords)
+{
+ /* Initialized data */
+
+ static integer next[3] = { 2,3,1 };
+
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer free, lrec, last, room, i__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc, descr;
+ extern /* Subroutine */ int maxai_(integer *, integer *, integer *,
+ integer *);
+ integer recno, ncomr, lword, ltype, needed;
+ extern /* Subroutine */ int cleari_(integer *, integer *);
+ integer dscrec, nw, dirrec[256];
+ extern /* Subroutine */ int dashfs_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *, integer *, integer *);
+ integer minadr, maxadr, lastla[3], rngloc;
+ extern /* Subroutine */ int dasufs_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *, integer *, integer *),
+ dasrri_(integer *, integer *, integer *, integer *, integer *),
+ dasuri_(integer *, integer *, integer *, integer *, integer *);
+ integer lastrc[3];
+ extern /* Subroutine */ int daswri_(integer *, integer *, integer *),
+ sigerr_(char *, ftnlen), chkout_(char *, ftnlen);
+ integer lastwd[3], nresvc;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ extern logical return_(void);
+ integer nresvr, loc;
+
+/* $ Abstract */
+
+/* Create or update directories in a DAS file to reflect addition */
+/* of a specified number of words of a specified data type. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* TYPE I Data type specifier. */
+/* NWORDS I Number of words of data being added. */
+/* CHAR P Parameter indicating character data type. */
+/* DP P Parameter indicating double precision data type. */
+/* INT P Parameter indicating integer data type. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the file handle of a DAS file open for writing. */
+
+/* TYPE is a data type specifier. TYPE may be any of */
+/* the parameters */
+
+/* CHAR */
+/* DP */
+/* INT */
+
+/* which indicate `character', `double precision', */
+/* and `integer' respectively. */
+
+/* NWORDS is the number of words of data of the data type */
+/* indicated by TYPE whose addition to the indicated */
+/* DAS file is to be accounted for. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the action */
+/* of this routine. */
+
+/* $ Parameters */
+
+/* CHAR, */
+/* DP, */
+/* INT are data type specifiers which indicate */
+/* `character', `double precision', and `integer' */
+/* respectively. These parameters are used in */
+/* all DAS routines that require a data type */
+/* specifier as input. */
+
+/* $ Exceptions */
+
+/* 1) If the input handle is invalid, the error will be diagnosed */
+/* by routines called by this routine. */
+
+/* 2) If TYPE is not recognized, the error SPICE(DASINVALIDTYPE) */
+/* will be signalled. */
+
+/* 3) If NWORDS is negative, the error SPICE(VALUEOUTOFRANGE) will */
+/* be signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine operates by side effects: the directories in the */
+/* indicated DAS file will be updated to reflect the addition of */
+/* the indicated number of words of the specified data type. */
+/* If necessary, a new directory record will be added to the file */
+/* to hold a new cluster descriptor. */
+
+/* In addition, the file summary for the indicated DAS file will be */
+/* updated with the new values of the descriptor location and last */
+/* logical address of the indicated type, as well as with the new */
+/* value of the free record pointer. */
+
+/* This routine is used by the DASADx routines: after each data */
+/* addition, they call this routine to update the directories of the */
+/* affected DAS file. */
+
+/* Normally, there will be no need for routines outside of SPICELIB */
+/* to call this routine directly. To add data to or update a DAS */
+/* file, the DASADx and DASUDx routines should be used; these */
+/* routines take care of directory creation and updates. */
+
+/* $ Examples */
+
+/* 1) Update directories after writing N integer words to a */
+/* DAS file designated by HANDLE: */
+
+/* CALL DASCUD ( HANDLE, INT, N ) */
+
+/* $ Restrictions */
+
+/* 1) This routine is intended for use by the SPICELIB DAS routines. */
+/* Non-SPICELIB software normally will not need to call this */
+/* routine. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.4.0 07-AUG-2006 (NJB) */
+
+/* Bug fix: added intialization of variable LTYPE to support */
+/* operation under the Macintosh Intel Fortran */
+/* compiler. Note that this bug did not affect */
+/* operation of this routine on other platforms. */
+
+/* - SPICELIB Version 1.3.0 16-JAN-2003 (NJB) */
+
+/* Bug fix: fixed previous bug fix. */
+
+/* - SPICELIB Version 1.2.0 10-DEC-2002 (NJB) */
+
+/* Bug fix: now a new, empty directory record with valid */
+/* backward and forward pointers is written immediately */
+/* when it is created. */
+
+/* - SPICELIB Version 1.1.1 19-DEC-1995 (NJB) */
+
+/* Corrected title of permuted index entry section. */
+
+/* - SPICELIB Version 1.0.1, 26-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Removed an unused variable. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* update DAS cluster directories */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.4.0 07-AUG-2006 (NJB) */
+
+/* Bug fix: added intialization of variable LTYPE to support */
+/* operation under the Macintosh Intel Fortran */
+/* compiler. Note that this bug did not affect */
+/* operation of this routine on other platforms. The */
+/* statement referencing the uninitialized variable */
+/* was: */
+
+/* ELSE IF ( ( TYPE .EQ. LTYPE ) */
+/* . .AND. ( DSCREC .GT. 0 ) */
+/* . .AND. ( LWORD .LT. NWI ) ) THEN */
+
+
+/* In the previous version of the code, LTYPE is uninitialized */
+/* when the DAS file is empty, which implies DSCREC is 0. */
+/* Otherwise LTYPE is initialized. So the value of the logical */
+/* expression is not affected by the uninitialized value of */
+/* LTYPE. */
+
+/* However, the Intel Fortran compiler for the Mac flags a runtime */
+/* error when the above code is exercised. So LTYPE is now */
+/* initialized to an invalid value prior to execution of this */
+/* code. If the invalid value is ever used, a runtime error */
+/* should result. */
+
+
+/* - SPICELIB Version 1.3.0 16-JAN-2003 (NJB) */
+
+/* Bug fix: fixed previous bug fix. */
+
+
+/* The offending line (#778) in previous version) of code is: */
+
+/* CALL DASWRI ( HANDLE, RECNO, DIRREC ) */
+
+/* The correct line of code is: */
+
+/* CALL DASWRI ( HANDLE, FREE, DIRREC ) */
+
+
+/* - SPICELIB Version 1.2.0 10-DEC-2002 (NJB) */
+
+/* Bug fix: now a new, empty directory record with valid */
+/* backward and forward pointers is written immediately */
+/* when it is created. This prevents an unsegregated file */
+/* from being left with an invalid forward pointer. */
+
+/* - SPICELIB Version 1.0.1, 26-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Removed an unused variable, PREV. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Words per data record, for each data type: */
+
+
+/* Directory pointer locations (backward and forward): */
+
+
+/* Directory address range locations */
+
+
+/* Location of first type descriptor */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+
+/* NEXT maps the DAS data type codes to their successors. */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASCUD", (ftnlen)6);
+ }
+
+/* Here's a preview of coming attractions: */
+
+/* We're going to update the directories in the indicated */
+/* DAS file to reflect the addition of NWORDS new data words. */
+/* This data is supposed to have been added to the file BEFORE */
+/* this routine is called. There are several possible states */
+/* the file can be in at the point this routine is called. */
+
+
+/* 1) There is already a descriptor of TYPE in the file, and */
+/* the addition of data does not require this descriptor */
+/* to be modified. */
+
+/* We can tell that we have this case when the file */
+/* summary indicates that, before the addition of data, */
+/* there was room for NWORDS of data in the last data */
+/* record in the file. Since no new data records were */
+/* required to accommodate the new data, the descriptor */
+/* for TYPE does not have to be updated. */
+
+/* However, even though the descriptor need not be */
+/* modified, the address range for TYPE covered by the */
+/* directory record containing this last descriptor must be */
+/* updated, as must be the file summary. */
+
+
+/* 2) There is already a descriptor of TYPE in the file, and */
+/* in order to describe the new data added to the file, */
+/* it suffices to update this descriptor and the address */
+/* range in the directory containing it. */
+
+/* This happens when case (1) doesn't apply, and the */
+/* descriptor of TYPE is the last descriptor in the last */
+/* directory, and the descriptor is not in the last */
+/* position (index NWI) of the directory. */
+
+/* Note that we never update the last descriptor in a */
+/* directory record. The reason for this is that after */
+/* this descriptor is written, we build a new directory */
+/* record. All subsequent additions of data are made to */
+/* records that follow this new directory record; */
+/* otherwise, the new directory would get overwritten */
+/* with data. */
+
+
+/* 3) A new descriptor of TYPE is needed. */
+
+/* This can happen in several ways: */
+
+/* a) There are no directories in the file yet, in which */
+/* case space has been reserved for the first */
+/* directory. */
+
+/* This can happen only when the file had no data at */
+/* all in it before the last addition of data. */
+
+/* In this case, we must fill in the first descriptor */
+/* and the address range for TYPE. We must also update */
+/* the file summary, because the descriptor location, */
+/* last logical address of TYPE, and the free pointer */
+/* have changed. */
+
+/* b) The conditions for cases (1) and (2) are not */
+/* satisfied, and the current last directory record */
+/* has room for a new descriptor. In this case, if */
+/* the data addition filled in the last data record */
+/* described by the current last descriptor of type, */
+/* (which will usually be the case), we must update */
+/* the appropriate address range in the directory */
+/* record containing that descriptor. We will then */
+/* add a new descriptor to the last directory record */
+/* and update the address range for TYPE in that */
+/* record. The file summary must be updated as well. */
+
+/* If the new descriptor we've added went into the */
+/* last slot in a directory record (index NWI), we */
+/* also create a new, empty directory record and */
+/* update the forward pointer of the current directory */
+/* to point to it. We also update the file summary */
+/* so that the free pointer points to the record */
+/* following the empty directory record. */
+
+
+/* c) The conditions for cases (1) and (2) are not */
+/* satisfied, and the current last directory record */
+/* has no room for a new descriptor. */
+
+/* In this case, if the data addition filled in the */
+/* last data record described by the current last */
+/* descriptor of TYPE, (which will usually be the */
+/* case), we must update the appropriate address range */
+/* in the directory record containing that descriptor. */
+/* We will then add a new descriptor to the empty */
+/* directory record and initialize the address range */
+/* for TYPE in that record. The file summary must be */
+/* updated as well. */
+
+
+/* To start out, we'll need to find out how the file is currently */
+/* disposed. We'll need the location of the last descriptor of */
+/* TYPE, the last logical address of TYPE, and the location of */
+/* the last descriptor of any type. */
+
+/* Get the file summary. */
+
+ dashfs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla, lastrc,
+ lastwd);
+
+/* Now do all of the data-type-dependent work: */
+
+/* -- Set the last address of the indicated data type LAST. */
+
+/* -- Set the physical record of the last descriptor of TYPE. */
+
+/* -- Set the number of words of data of the specified type per */
+/* physical record NW. */
+
+/* -- Set the address range location used to pick address ranges */
+/* out of directory records. */
+
+
+/* Note that the address and descriptor location information from */
+/* the file summary is assumed NOT to take into account the latest */
+/* data addition. */
+
+
+ last = lastla[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("las"
+ "tla", i__1, "dascud_", (ftnlen)513)];
+ dscrec = lastrc[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastrc", i__1, "dascud_", (ftnlen)514)];
+ if (*type__ == 2) {
+ nw = 128;
+ rngloc = 5;
+ } else if (*type__ == 3) {
+ nw = 256;
+ rngloc = 7;
+ } else if (*type__ == 1) {
+ nw = 1024;
+ rngloc = 3;
+ } else {
+ setmsg_("Invalid data type: #. ", (ftnlen)22);
+ errint_("#", type__, (ftnlen)1);
+ sigerr_("SPICE(DASINVALIDTYPE)", (ftnlen)21);
+ chkout_("DASCUD", (ftnlen)6);
+ return 0;
+ }
+
+/* Make sure that NWORDS is something sensible. */
+
+ if (*nwords < 0) {
+ setmsg_("NWORDS was #; should be non-negative.", (ftnlen)37);
+ errint_("#", nwords, (ftnlen)1);
+ sigerr_("SPICE(VALUEOUTOFRANGE)", (ftnlen)22);
+ chkout_("DASCUD", (ftnlen)6);
+ return 0;
+ }
+
+/* Find the record and word positions LREC and LWORD of the last */
+/* descriptor in the file, and also find the type of the descriptor */
+/* LTYPE. */
+
+ maxai_(lastrc, &c__3, &lrec, &loc);
+ lword = 0;
+ ltype = 0;
+ for (i__ = 1; i__ <= 3; ++i__) {
+ if (lastrc[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("lastrc",
+ i__1, "dascud_", (ftnlen)565)] == lrec && lastwd[(i__2 = i__
+ - 1) < 3 && 0 <= i__2 ? i__2 : s_rnge("lastwd", i__2, "dascu"
+ "d_", (ftnlen)565)] > lword) {
+ lword = lastwd[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastwd", i__1, "dascud_", (ftnlen)568)];
+ ltype = i__;
+ }
+ }
+
+/* LREC, LWORD, and LTYPE are now the record, word, and data type */
+/* of the last descriptor in the file. If LREC is zero, there are */
+/* no directories in the file yet. In this case, LWORD and */
+/* LTYPE are both zero. */
+
+
+/* Compute the number of words we have room for in the current */
+/* last data record of the indicated type. */
+
+ if (last > 0) {
+ room = nw - (last - (last - 1) / nw * nw);
+ } else {
+ room = 0;
+ }
+
+/* Compute the number of additional data records needed to */
+/* accommodate (NWORDS - ROOM) additional words of data of type */
+/* TYPE. */
+
+ needed = (*nwords - room + nw - 1) / nw;
+
+/* Now, update the descriptor directories. */
+
+ if (room >= *nwords && dscrec > 0) {
+
+/* This is case (1). */
+
+/* There is already a descriptor of TYPE in the file. The data */
+/* fits in the current record, so no descriptors have to change. */
+
+/* Update the address range in the directory record containing */
+/* the last descriptor of TYPE. */
+
+ maxadr = last + *nwords;
+ i__1 = rngloc + 1;
+ i__2 = rngloc + 1;
+ dasuri_(handle, &dscrec, &i__1, &i__2, &maxadr);
+
+/* The last logical address of TYPE is now MAXADR. */
+
+ lastla[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("lastla",
+ i__1, "dascud_", (ftnlen)621)] = maxadr;
+
+/* Write out the updated file summary. */
+
+ dasufs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla,
+ lastrc, lastwd);
+ } else if (*type__ == ltype && dscrec > 0 && lword < 256) {
+
+
+/* This is case (2). */
+
+/* The descriptor of TYPE is the last descriptor in the */
+/* file but is not in the last location (index NWI) of a */
+/* directory record. All we have to do is update this last */
+/* descriptor to reflect the addition of the number of needed */
+/* data records. */
+
+/* Get the old descriptor, since we're going to update it. */
+
+
+ dasrri_(handle, &dscrec, &lword, &lword, &descr);
+
+/* Update the descriptor and write it back into the file. */
+
+ if (descr < 0) {
+ descr -= needed;
+ } else {
+ descr += needed;
+ }
+ dasuri_(handle, &dscrec, &lword, &lword, &descr);
+
+/* Update the address range for this type. */
+
+ maxadr = last + *nwords;
+ i__1 = rngloc + 1;
+ i__2 = rngloc + 1;
+ dasuri_(handle, &dscrec, &i__1, &i__2, &maxadr);
+
+/* The last logical address of TYPE is now MAXADR. The first */
+/* free record follows the last data record in use. */
+
+ lastla[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("lastla",
+ i__1, "dascud_", (ftnlen)678)] = maxadr;
+ free += needed;
+
+/* Write out the updated file summary. */
+
+ dasufs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla,
+ lastrc, lastwd);
+ } else {
+
+/* This is case (3). We need a new descriptor. */
+
+ if (lrec == 0) {
+
+/* This is case (3a). We have a virgin directory record. */
+/* Set the number of this record. */
+
+ recno = nresvr + ncomr + 2;
+
+/* Start with an empty directory record. */
+
+ cleari_(&c__256, dirrec);
+
+/* Add a new descriptor to the directory. The record */
+/* count is the number of new records required: NEEDED. */
+
+ dirrec[8] = *type__;
+ dirrec[9] = needed;
+
+/* Fill in the address range for TYPE covered by this */
+/* directory. */
+
+ dirrec[(i__1 = rngloc - 1) < 256 && 0 <= i__1 ? i__1 : s_rnge(
+ "dirrec", i__1, "dascud_", (ftnlen)723)] = 1;
+ dirrec[(i__1 = rngloc) < 256 && 0 <= i__1 ? i__1 : s_rnge("dirrec"
+ , i__1, "dascud_", (ftnlen)724)] = *nwords;
+
+/* Write out this directory. */
+
+ daswri_(handle, &recno, dirrec);
+
+/* Update the file summary: the location of the descriptor */
+/* and the last logical address for this type must be set. */
+/* The count portion of the descriptor goes after the initial */
+/* data type indicator; this data type indicator is not */
+/* considered to be part of the descriptor. */
+
+/* The first free record follows the last data record in use. */
+
+ free = recno + needed + 1;
+ lastla[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastla", i__1, "dascud_", (ftnlen)741)] = *nwords;
+ lastrc[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastrc", i__1, "dascud_", (ftnlen)742)] = recno;
+ lastwd[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastwd", i__1, "dascud_", (ftnlen)743)] = 10;
+ dasufs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla,
+ lastrc, lastwd);
+ } else if (lword < 256) {
+
+/* This is case (3b). We have room for another descriptor */
+/* in the current directory record. */
+
+/* Before adding the new descriptor, we must update the */
+/* directory containing the current last descriptor of TYPE, */
+/* if the range of addresses covered by the cluster it */
+/* describes was increased by the last data addition. Of */
+/* course, this update is required only if there IS such a */
+/* descriptor, and if it is in a record that precedes LREC. */
+
+ if (dscrec > 0 && dscrec < lrec && room > 0) {
+
+/* Update the address range for TYPE in record DSCREC. */
+/* The upper bound is increased by ROOM, since that many */
+/* words of TYPE were added to the last record in the */
+/* last cluster of TYPE described by that directory. */
+
+ maxadr = last + room;
+ i__1 = rngloc + 1;
+ i__2 = rngloc + 1;
+ dasuri_(handle, &dscrec, &i__1, &i__2, &maxadr);
+ }
+
+/* Make up the new descriptor and write it to the last */
+/* directory, following the current last descriptor. The */
+/* sign of the new descriptor is a function of the type of */
+/* the current last descriptor. */
+
+ if (*type__ == next[(i__1 = ltype - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("next", i__1, "dascud_", (ftnlen)789)]) {
+
+/* TYPE is the successor in the type sequence of the type */
+/* of the previous descriptor; use a positive count. */
+
+ descr = needed;
+ } else {
+ descr = -needed;
+ }
+ i__1 = lword + 1;
+ i__2 = lword + 1;
+ dasuri_(handle, &lrec, &i__1, &i__2, &descr);
+
+/* Update the address range for this type. Some care is needed */
+/* when updating the minimum address: this value should be */
+/* assigned only if this is the first descriptor of TYPE in */
+/* this directory record. */
+
+ if (dscrec < lrec) {
+ minadr = last + room + 1;
+ dasuri_(handle, &lrec, &rngloc, &rngloc, &minadr);
+ }
+ maxadr = last + *nwords;
+ i__1 = rngloc + 1;
+ i__2 = rngloc + 1;
+ dasuri_(handle, &lrec, &i__1, &i__2, &maxadr);
+
+/* Update the file summary: the location of the descriptor */
+/* and the last logical address for this type must be set. */
+
+/* The first free record follows the last data record in use. */
+
+ free += needed;
+ lastla[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastla", i__1, "dascud_", (ftnlen)829)] = last + *nwords;
+ lastrc[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastrc", i__1, "dascud_", (ftnlen)830)] = lrec;
+ lastwd[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastwd", i__1, "dascud_", (ftnlen)831)] = lword + 1;
+
+/* Before writing out the summary, see whether we'll need */
+/* a new directory; this will decide whether the first free */
+/* record changes. */
+
+/* If we just filled in the last descriptor in a directory, */
+/* it's time to add a new directory record to the file. */
+/* All we have to do at the moment is make room for it, and */
+/* set the forward pointer of the current directory record */
+/* to point to the saved record. Initialize the pointers */
+/* of the new directory record to make the linked list valid. */
+
+ if (lword + 1 == 256) {
+
+/* Update the previous directory to point forward to the */
+/* next one. */
+
+ dasuri_(handle, &lrec, &c__2, &c__2, &free);
+
+/* Prepare the new directory record: clear it, set the */
+/* backward pointer, and write the record. */
+
+ cleari_(&c__256, dirrec);
+ dirrec[0] = lrec;
+ daswri_(handle, &free, dirrec);
+
+/* Update the free record number. */
+
+ ++free;
+ }
+
+/* Now write out the file summary. */
+
+ dasufs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla,
+ lastrc, lastwd);
+ } else {
+
+/* This is case (3c). We must put the new descriptor in */
+/* the last directory record, which is currently empty. */
+
+/* As in case (3b), we may have to update the directory */
+/* containing the current last descriptor of TYPE, if the */
+/* range of addresses covered by the cluster it describes was */
+/* increased by the last data addition. Of course, this */
+/* update is required only if there IS such a descriptor. */
+
+ if (dscrec > 0 && room > 0) {
+
+/* Update the address range for TYPE in record DSCREC. */
+/* The upper bound is increased by ROOM, since that many */
+/* words of TYPE were added to the last record in the */
+/* last cluster of TYPE described by that directory. */
+
+ maxadr = last + room;
+ i__1 = rngloc + 1;
+ i__2 = rngloc + 1;
+ dasuri_(handle, &dscrec, &i__1, &i__2, &maxadr);
+ }
+
+/* Obtain the record number for this directory. */
+
+ dasrri_(handle, &lrec, &c__2, &c__2, &recno);
+
+/* Now fill in the new directory record. Start with a clean */
+/* record. */
+
+ cleari_(&c__256, dirrec);
+
+/* Set the backward pointer, the address range for TYPE, */
+/* initial data type, and record count. */
+
+ dirrec[0] = lrec;
+ dirrec[(i__1 = rngloc - 1) < 256 && 0 <= i__1 ? i__1 : s_rnge(
+ "dirrec", i__1, "dascud_", (ftnlen)925)] = last + room +
+ 1;
+ dirrec[(i__1 = rngloc) < 256 && 0 <= i__1 ? i__1 : s_rnge("dirrec"
+ , i__1, "dascud_", (ftnlen)926)] = last + *nwords;
+ dirrec[8] = *type__;
+ dirrec[9] = needed;
+
+/* Write out the record. */
+
+ daswri_(handle, &recno, dirrec);
+
+/* Update the file summary to reflect the new record and word */
+/* offsets of the last descriptor of the indicated type. The */
+/* last address of TYPE has increased also. The first free */
+/* record lies after the added data records. */
+
+ free += needed;
+ lastla[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastla", i__1, "dascud_", (ftnlen)943)] = last + *nwords;
+ lastrc[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastrc", i__1, "dascud_", (ftnlen)944)] = recno;
+ lastwd[(i__1 = *type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastwd", i__1, "dascud_", (ftnlen)945)] = 10;
+ dasufs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla,
+ lastrc, lastwd);
+ }
+ }
+ chkout_("DASCUD", (ftnlen)6);
+ return 0;
+} /* dascud_ */
+
diff --git a/ext/spice/src/cspice/dasdc.c b/ext/spice/src/cspice/dasdc.c
new file mode 100644
index 0000000000..cf77593bf0
--- /dev/null
+++ b/ext/spice/src/cspice/dasdc.c
@@ -0,0 +1,251 @@
+/* dasdc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DASDC ( DAS delete comments ) */
+/* Subroutine */ int dasdc_(integer *handle)
+{
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc, ncomr;
+ extern logical failed_(void);
+ char ifname[60];
+ extern /* Subroutine */ int dassih_(integer *, char *, ftnlen), dasrcr_(
+ integer *, integer *), dasrfr_(integer *, char *, char *, integer
+ *, integer *, integer *, integer *, ftnlen, ftnlen), daswfr_(
+ integer *, char *, char *, integer *, integer *, integer *,
+ integer *, ftnlen, ftnlen);
+ char idword[8];
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ integer nresvc;
+ extern logical return_(void);
+ integer nresvr;
+
+/* $ Abstract */
+
+/* Delete the entire comment area of a previously opened binary */
+/* DAS file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* None. */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I The handle of a binary DAS file opened for writing. */
+
+/* $ Detailed_Input */
+
+/* HANDLE The handle of a binary DAS file that is to have its */
+/* entire comment area deleted. The DAS file should have */
+/* been opened with write access. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the binary DAS file attached to HANDLE is not open with */
+/* write access, an error will be signalled by a routine called */
+/* by this routine. */
+
+/* $ Files */
+
+/* See argument HANDLE in $ Detailed_Input. */
+
+/* $ Particulars */
+
+/* Binary DAS files contain an area which is reserved for storing */
+/* annotations or descriptive textual information about the data */
+/* contained in a file. This area is referred to as the ``comment */
+/* area'' of the file. The comment area of a DAS file is a line */
+/* oriented medium for storing textual information. The comment */
+/* area preserves any leading or embedded white space in the line(s) */
+/* of text which are stored, so that the appearance of the of */
+/* information will be unchanged when it is retrieved (extracted) at */
+/* some other time. Trailing blanks, however, are NOT preserved, */
+/* due to the way that character strings are represented in */
+/* standard Fortran 77. */
+
+/* This routine will delete the entire comment area from the binary */
+/* DAS file attached to HANDLE. The size of the binary DAS file will */
+/* remain unchanged. The space that was used by the comment records */
+/* is reclaimed. */
+
+/* $ Examples */
+
+/* Let */
+
+/* HANDLE be the handle for a DAS file which has been opened */
+/* with write access. */
+
+/* The call */
+
+/* CALL DASDC ( HANDLE ) */
+
+/* will delete the entire comment area of the binary DAS file */
+/* attached to HANDLE. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 26-OCT-1993 (KRG) */
+
+/* Changed the $Brief_I/O description of handle. It now mentions */
+/* that the file must be open for writing. Also added a statement */
+/* to the $ Detailed_Input section to the effect that the DAS file */
+/* should have been opened with write access. */
+
+/* - SPICELIB Version 1.0.0, 24-NOV-1992 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* delete das comment area */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 26-OCT-1993 (KRG) */
+
+/* Changed the $Brief_I/O description of handle. It now mentions */
+/* that the file must be open for writing. Also added a statement */
+/* to the $ Detailed_Input section to the effect that the DAS file */
+/* should have been opened with write access. */
+
+/* - SPICELIB Version 1.0.0, 24-NOV-1992 (KRG) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* Length of a DAS file ID word. */
+
+
+/* Length of a DAS file internal filename. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASDC", (ftnlen)5);
+ }
+
+/* Verify that the DAS file attached to HANDLE is opened with write */
+/* access. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DASDC", (ftnlen)5);
+ return 0;
+ }
+
+/* Read the file record to obtain the current number of comment */
+/* records in the DAS file attached to HANDLE. We will also get */
+/* back some extra stuff that we do not use. */
+
+ dasrfr_(handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (ftnlen)
+ 8, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DASDC", (ftnlen)5);
+ return 0;
+ }
+
+/* Now we will attempt to remove the comment records, if there are */
+/* any, otherwise we do nothing. */
+
+ if (ncomr > 0) {
+ dasrcr_(handle, &ncomr);
+ if (failed_()) {
+ chkout_("DASDC", (ftnlen)5);
+ return 0;
+ }
+
+/* Now we need to update the DAS file record. */
+
+/* Read in the updated file record since it has been modified: */
+/* we deleted all of the comment records. */
+
+ dasrfr_(handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (
+ ftnlen)8, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DASDC", (ftnlen)5);
+ return 0;
+ }
+
+/* Zero out the number of comment characters, and write the */
+/* updated file record to the file. */
+
+ ncomc = 0;
+ daswfr_(handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (
+ ftnlen)8, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DASDC", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* We're done now, so goodbye. */
+
+ chkout_("DASDC", (ftnlen)5);
+ return 0;
+} /* dasdc_ */
+
diff --git a/ext/spice/src/cspice/dasec.c b/ext/spice/src/cspice/dasec.c
new file mode 100644
index 0000000000..952e3e4f92
--- /dev/null
+++ b/ext/spice/src/cspice/dasec.c
@@ -0,0 +1,752 @@
+/* dasec.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__21 = 21;
+
+/* $Procedure DASEC ( DAS extract comments ) */
+/* Subroutine */ int dasec_(integer *handle, integer *bufsiz, integer *n,
+ char *buffer, logical *done, ftnlen buffer_len)
+{
+ /* Initialized data */
+
+ static logical first = TRUE_;
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer), i_len(char *, ftnlen);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer i__, j, k;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc, recno, index, ncomr;
+ char ch[1];
+ extern logical failed_(void);
+ char ifname[60];
+ static integer filhan[21];
+ static char crecrd[1024];
+ extern /* Subroutine */ int dasioc_(char *, integer *, integer *, char *,
+ ftnlen, ftnlen);
+ static integer filchr[21];
+ extern /* Subroutine */ int dassih_(integer *, char *, ftnlen);
+ extern integer isrchi_(integer *, integer *, integer *);
+ integer linlen, nchars, daslun;
+ static integer filcnt[21];
+ char idword[8];
+ static integer lsthan, nfiles, lstrec[21];
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ integer numcom;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ integer nresvc;
+ extern /* Subroutine */ int dashlu_(integer *, integer *), setmsg_(char *,
+ ftnlen), errint_(char *, integer *, ftnlen), dasrfr_(integer *,
+ char *, char *, integer *, integer *, integer *, integer *,
+ ftnlen, ftnlen), errfnm_(char *, integer *, ftnlen);
+ integer curpos;
+ extern logical return_(void);
+ integer nresvr;
+ static integer lstpos[21];
+ logical eol;
+
+/* $ Abstract */
+
+/* Extract comments from the comment area of a binary DAS file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of binary DAS file open with read access. */
+/* BUFSIZ I Maximum size, in lines, of BUFFER. */
+/* N O Number of comments extracted from the DAS file. */
+/* BUFFER O Buffer in which extracted comments are placed. */
+/* DONE O Indicates whether all comments have been extracted. */
+
+/* $ Detailed_Input */
+
+/* HANDLE The file handle of a binary DAS file which has been */
+/* opened with read access. */
+
+/* BUFSIZ The maximum number of comments that may be placed into */
+/* BUFFER. This would typically be the declared array size */
+/* for the Fortran character string array passed into this */
+/* routine. */
+
+/* $ Detailed_Output */
+
+/* N The number of comment lines extracted from the comment */
+/* area of the binary DAS file attached to HANDLE. This */
+/* number will be <= BUFSIZ on output. If N = BUFSIZ and */
+/* DONE <> .TRUE. then there are more comments left to to */
+/* extract. If N = 0, then DONE = .TRUE., i.e., there were */
+/* no comments in the comment area. If there are comments */
+/* in the comment area, or comments remaining after the */
+/* extraction process has begun, N > 0, always. */
+
+/* BUFFER A list of at most BUFSIZ comments which have been */
+/* extracted from the comment area of the binary DAS */
+/* file attached to HANDLE. */
+
+/* DONE A logical flag indicating whether or not all of the */
+/* comment lines from the comment area of the DAS file have */
+/* been read. This variable has the value .TRUE. after the */
+/* last comment line has been read. It will have the value */
+/* .FALSE. otherwise. */
+
+/* If there are no comments in the comment area, this */
+/* variable will have the value .TRUE., and N = 0. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the size of the output line buffer is is not positive, */
+/* the error SPICE(INVALIDARGUMENT) will be signalled. */
+
+/* 3) If a comment line in a DAS file is longer than the length */
+/* of a character string array element of BUFFER, the error */
+/* SPICE(COMMENTTOOLONG) will be signalled. */
+
+/* 3) If there is a mismatch between the number of comment */
+/* characters found and the number of comment characters */
+/* expected, the error SPICE(BADDASCOMMENTAREA) will be */
+/* signalled. */
+
+/* 4) If the binary DAS file attached to HANDLE is not open for */
+/* reading, an error will be signalled by a routine called by */
+/* this routine. */
+
+/* $ Files */
+
+/* See argument HANDLE in $ Detailed_Input. */
+
+/* $ Particulars */
+
+/* Binary DAS files contain an area which is reserved for storing */
+/* annotations or descriptive textual information describing the data */
+/* contained in a file. This area is referred to as the ``comment */
+/* area'' of the file. The comment area of a DAS file is a line */
+/* oriented medium for storing textual information. The comment */
+/* area preserves any leading or embedded white space in the line(s) */
+/* of text which are stored, so that the appearance of the of */
+/* information will be unchanged when it is retrieved (extracted) at */
+/* some other time. Trailing blanks, however, are NOT preserved, */
+/* due to the way that character strings are represented in */
+/* standard Fortran 77. */
+
+/* This routine will read the comments from the comment area of */
+/* a binary DAS file, placing them into a line buffer. If the line */
+/* buffer is not large enough to hold the entire comment area, */
+/* the portion read will be returned to the caller, and the DONE */
+/* flag will be set to .FALSE.. This allows the comment area to be */
+/* read in ``chunks,'' a buffer at a time. After all of the comment */
+/* lines have been read, the DONE flag will be set to .TRUE.. */
+
+/* This routine can be used to ``simultaneously'' extract comments */
+/* from the comment areas of multiple binary DAS files. See Example */
+/* 2 in the $ Examples section. */
+
+/* $ Examples */
+
+/* Example 1 */
+/* --------- */
+
+/* The following example will extract the entire comment area of a */
+/* binary DAS file attached to HANDLE, displaying the comments on */
+/* the terminal screen. */
+
+/* Let */
+
+/* BUFFER have the following declaration: */
+
+/* CHARACTER*(80) BUFFER(25) */
+
+/* HANDLE be the handle of an open binary DAS file. */
+
+/* then */
+
+/* BUFSIZ = 25 */
+/* DONE = .FALSE. */
+
+/* DO WHILE ( .NOT. DONE ) */
+
+/* CALL DASEC( HANDLE, BUFSIZ, N, BUFFER, DONE ) */
+
+/* DO I = 1, N */
+
+/* WRITE (*,*) BUFFER(I) */
+
+/* END DO */
+
+/* END DO */
+
+/* Example 2 */
+/* --------- */
+
+/* The following example demonstrates the use of this routine to */
+/* simultaneously read the comment areas of multiple DAS files. */
+/* For each file, the comments will be displayed on the screen as */
+/* they are extracted. */
+
+/* Let */
+
+/* BUFFER have the following declaration: */
+
+/* CHARACTER*(80) BUFFER(25) */
+
+/* NUMFIL be the number of binary DAS files that are to have */
+/* their comment areas displayed. */
+
+/* DASNAM(I) Be a list of filenames for the DAS files which are */
+/* to have their comment areas displayed. */
+
+/* HANDLE(I) be a list of handles for the DAS files which are */
+/* to have their comment areas displayed. */
+
+/* DONE(I) be a list of logical flags indicating whether */
+/* we are done extracting the comment area from the */
+/* DAS file attached to HANDLE(I) */
+
+/* then */
+
+/* BUFSIZ = 25 */
+
+/* DO I = 1, NUMFIL */
+
+/* DONE(I) = .FALSE. */
+/* HANDLE(I) = 0 */
+
+/* END DO */
+/* C */
+/* C Open the DAS files. */
+/* C */
+/* DO I = 1, NUMFIL */
+
+/* CALL DASOPR ( DASNAM(I), HANDLE(I) ) */
+
+/* END DO */
+/* C */
+/* C While there are still some comments left to read in at */
+/* C least one of the files, read them and display them. */
+/* C */
+/* DO WHILE ( .NOT. ALLTRU( DONE, NUMFIL ) ) */
+
+/* DO I = 1, NUMFIL */
+
+/* IF ( .NOT. DONE(I) ) THEN */
+
+/* WRITE (*,*) */
+/* WRITE (*,*) 'File: ', DASNAM(I)(:RTRIM(DASNAM(I))) */
+/* WRITE (*,*) */
+/* N = 0 */
+
+/* CALL DASEC ( HANDLE(I), */
+/* . BUFSIZ, */
+/* . N, */
+/* . BUFFER, */
+/* . DONE(I) ) */
+
+/* DO J = 1, N */
+
+/* WRITE (*,*) BUFFER(J)(:RTRIM(BUFFER(J))) */
+
+/* END DO */
+
+/* END IF */
+
+/* END DO */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* 1) The comment area may consist only of printing ASCII characters, */
+/* decimal values 32 - 126. See the MAXPCH and MINPCH parameters */
+/* defined in the $ Local Parameters section. */
+
+/* 2) There is NO maximum length imposed on the significant portion */
+/* of a text line that may be placed into the comment area of a */
+/* DAS file. The maximum length of a line stored in the comment */
+/* area should be kept reasonable, so that they may be easily */
+/* extracted. A good value for this would be 255 characters, as */
+/* this can easily accomodate ``screen width'' lines as well as */
+/* long lines which may contain some other form of information. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.3.0, 18-JUN-1999 (WLT) */
+
+/* Changed name used in CHKOUT to be consistent with the CHKIN */
+/* value. */
+
+/* - SPICELIB Version 1.2.0, 04-AUG-1994 (KRG) */
+
+/* Rearranged some of the code to avoid always reading the file */
+/* record. Now we look for the input HANDLE in the file table */
+/* first, and only read the file record if we do not find it. Also */
+/* added a new array to be saved: FILCNT. This is the number of */
+/* comment characters in a file; we save it now rather than */
+/* reading it every time. */
+
+/* Fixed a bug. If the Fortran character string array elements */
+/* have exactly the same length as a comment in the comment area, */
+/* this routine would halt rather unexpectedly from a memory over */
+/* run. */
+
+/* - SPICELIB Version 1.1.0, 22-NOV-1993 (KRG) */
+
+/* Changed the value of the parameter FTSIZE from 20 to 21. This */
+/* change makes the value of FTSIZE in DASEC compatible with the */
+/* value in DASFM. See DASFM for a discussion of the reasons for */
+/* the increase in the value. */
+
+/* - SPICELIB Version 1.0.0, 23-NOV-1992 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* extract comments from a das file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.2.0, 04-AUG-1994 (KRG) */
+
+/* Rearranged some of the code to avoid always reading the file */
+/* record. Now we look for the input HANDLE in the file table */
+/* first, and only read the file record if we do not find it. Also */
+/* added a new array to be saved: FILCNT. This is the number of */
+/* comment characters in a file; we save it now rather than */
+/* reading it every time. */
+
+/* Fixed a bug. If the Fortran character string array elements */
+/* have exactly the same length as a comment in the comment area, */
+/* this routine would halt rather unexpectedly from a memory over */
+/* run. This occurred when attempting to clear, i.e., blank pad, */
+/* the portion of a character string element that extended beyond */
+/* the text in a comment line. A test has been added to verify */
+/* that blank padding can be performed. */
+
+/* - SPICELIB Version 1.1.0, 22-NOV-1993 (KRG) */
+
+/* Changed the value of the parameter FTSIZE from 20 to 21. This */
+/* change makes the value of FTSIZE in DASEC compatible with the */
+/* value in DASFM. See DASFM for a discussion of the reasons for */
+/* the increase in the value. */
+
+/* - SPICELIB Version 1.0.0, 23-NOV-1992 (KRG) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* The maximum number of DAS files that may be open simultaneously. */
+
+
+/* Length of a DAS character record, in characters. */
+
+
+/* Maximum and minimum decimal values for the printable ASCII */
+/* characters. */
+
+
+/* Decimal value for the DAS comment area end-of-line (EOL) marker. */
+
+
+/* Maximum length of a filename. */
+
+
+/* Length of a DAS file ID word. */
+
+
+/* Length of a DAS file internal filename. */
+
+
+/* Local variables */
+
+
+/* The file table declarations for keeping track of which files */
+/* are currently in the process of having comments extracted. */
+
+
+/* Saved variables */
+
+
+/* Save all of the file table information. */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASEC", (ftnlen)5);
+ }
+
+/* If this is the first time that this routine has been called, */
+/* we need to initialize the character value of the end-of-line */
+/* marker, and the file table variables. */
+
+ if (first) {
+ first = FALSE_;
+ nfiles = 0;
+ lsthan = -1;
+ for (i__ = 1; i__ <= 21; ++i__) {
+ filcnt[(i__1 = i__ - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("filcnt"
+ , i__1, "dasec_", (ftnlen)478)] = 0;
+ filchr[(i__1 = i__ - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("filchr"
+ , i__1, "dasec_", (ftnlen)479)] = 0;
+ filhan[(i__1 = i__ - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("filhan"
+ , i__1, "dasec_", (ftnlen)480)] = 0;
+ lstrec[(i__1 = i__ - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("lstrec"
+ , i__1, "dasec_", (ftnlen)481)] = 0;
+ lstpos[(i__1 = i__ - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("lstpos"
+ , i__1, "dasec_", (ftnlen)482)] = 0;
+ }
+ }
+
+/* Verify that the DAS file attached to HANDLE is opened for reading */
+/* by calling the routine to signal an invalid access mode on a */
+/* handle. */
+
+ dassih_(handle, "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DASEC", (ftnlen)5);
+ return 0;
+ }
+
+/* Check for a nonpositive BUFFER size. */
+
+ if (*bufsiz <= 0) {
+ setmsg_("The output buffer size was not positive: #.", (ftnlen)43);
+ errint_("#", bufsiz, (ftnlen)1);
+ sigerr_("SPICE(INVALIDARGUMENT)", (ftnlen)22);
+ chkout_("DASEC", (ftnlen)5);
+ return 0;
+ }
+
+/* Convert the DAS file handle to its corresponding Fortran logical */
+/* unit number for reading the comment records. */
+
+ dashlu_(handle, &daslun);
+ if (failed_()) {
+ chkout_("DASEC", (ftnlen)5);
+ return 0;
+ }
+
+/* Get the length of a single character string in the buffer. */
+
+ linlen = i_len(buffer, buffer_len);
+
+/* If we have extracted comments from at least one file and we */
+/* didn't finish, get the index for that file in the file table. */
+
+ if (nfiles > 0) {
+ index = isrchi_(handle, &nfiles, filhan);
+ } else {
+ index = 0;
+ }
+
+/* Check to see if we found HANDLE in the file handle table. If */
+/* we did, INDEX will be > 0. */
+
+ if (index > 0) {
+
+/* Set the record number and the starting position accordingly, */
+/* i.e., where we left off when we last read from that file. */
+
+ recno = lstrec[(i__1 = index - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "lstrec", i__1, "dasec_", (ftnlen)550)];
+ curpos = lstpos[(i__1 = index - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "lstpos", i__1, "dasec_", (ftnlen)551)];
+ nchars = filchr[(i__1 = index - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "filchr", i__1, "dasec_", (ftnlen)552)];
+ ncomc = filcnt[(i__1 = index - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "filcnt", i__1, "dasec_", (ftnlen)553)];
+ } else {
+
+/* We have not yet read any comments from this file, so start at */
+/* the start. To get to the first comment record, we need to skip */
+/* the file record and any reserved records that are in the file. */
+/* The first comment record immediately follows the last reserved */
+/* record. */
+
+/* Get the current number of comment records and comment */
+/* characters from the DAS file attached to HANDLE. We will also */
+/* get back some extra stuff that we do not use. */
+
+ dasrfr_(handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (
+ ftnlen)8, (ftnlen)60);
+ if (failed_()) {
+ chkout_("DASEC", (ftnlen)5);
+ return 0;
+ }
+
+/* If the number of comment characters, NCOMC, is equal to zero, */
+/* then we have no comments to read, so set the number of comments */
+/* to zero, set DONE to .TRUE., check out, and return. */
+
+ if (ncomc == 0) {
+ *n = 0;
+ *done = TRUE_;
+ chkout_("DASEC", (ftnlen)5);
+ return 0;
+ }
+ recno = nresvr + 2;
+ curpos = 1;
+ nchars = 0;
+ }
+
+/* Begin reading the comment area into the buffer. */
+
+ if (*handle != lsthan) {
+
+/* If the current DAS handle is not the same as the handle on */
+/* the last call, then we need to read in the appropriate record */
+/* from the DAS file comment area. Otherwise the record was saved, */
+/* so we don't need to read it in. */
+
+ dasioc_("READ", &daslun, &recno, crecrd, (ftnlen)4, (ftnlen)1024);
+ }
+
+/* Initialize the BUFFER line counter, I, and the line position */
+/* counter, J. */
+
+ i__ = 1;
+ j = 1;
+ *done = FALSE_;
+ while(i__ <= *bufsiz && ! (*done)) {
+ eol = FALSE_;
+ while(! eol) {
+ ++nchars;
+ *(unsigned char *)ch = *(unsigned char *)&crecrd[curpos - 1];
+ if (*(unsigned char *)ch == 0) {
+ eol = TRUE_;
+ if (j <= linlen) {
+ s_copy(buffer + ((i__ - 1) * buffer_len + (j - 1)), " ",
+ buffer_len - (j - 1), (ftnlen)1);
+ }
+ } else {
+ if (j <= linlen) {
+ *(unsigned char *)&buffer[(i__ - 1) * buffer_len + (j - 1)
+ ] = *(unsigned char *)ch;
+ ++j;
+ } else {
+ setmsg_("The output buffer line length (#) was not long "
+ "enough to contain a comment line with length #.",
+ (ftnlen)94);
+ errint_("#", &linlen, (ftnlen)1);
+ errint_("#", &i__, (ftnlen)1);
+ sigerr_("SPICE(COMMENTTOOLONG)", (ftnlen)21);
+ chkout_("DASEC", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* If we have reached the end of the current comment record, */
+/* read in the next one and reset the current position. */
+/* Otherwise, just increment the current position. */
+
+ if (curpos == 1024) {
+ ++recno;
+ dasioc_("READ", &daslun, &recno, crecrd, (ftnlen)4, (ftnlen)
+ 1024);
+ curpos = 1;
+ } else {
+ ++curpos;
+ }
+
+/* Check to make sure that it is safe to continue, i.e., */
+/* that the number of comment characters we have processed */
+/* has not exceeded the number of comment characters in the */
+/* comment area of the DAS file. */
+
+ if (nchars > ncomc) {
+ setmsg_("Count of comment characters (#) exceeds the number "
+ "of comment characters (#) in the DAS file #.", (
+ ftnlen)95);
+ errint_("#", &nchars, (ftnlen)1);
+ errint_("#", &ncomc, (ftnlen)1);
+ errfnm_("#", &daslun, (ftnlen)1);
+ sigerr_("SPICE(BADDASCOMMENTAREA)", (ftnlen)24);
+ chkout_("DASEC", (ftnlen)5);
+ return 0;
+ }
+ }
+
+/* We have just completed a comment line, so we save the comment */
+/* number, increment the buffer line counter, I, and reset the */
+/* buffer line position counter, J. */
+
+ numcom = i__;
+ ++i__;
+ j = 1;
+
+/* Check for the end of the comments. */
+
+ if (nchars == ncomc) {
+
+/* If we have reached the end of the comments, signalled */
+/* by having processed all of the comment characters, NCOMC, */
+/* then we are done. So, set DONE to .TRUE. and remove the */
+/* entry for this file from the file table. */
+
+ *done = TRUE_;
+ lsthan = -1;
+
+/* 0 <= INDEX <= NFILES, and we only want to remove things */
+/* from the file table if: */
+
+/* 1) There are files in the file table, NFILES > 0 */
+/* 2) The file we are currently reading from is in the */
+/* file table, INDEX > 0. */
+
+/* So, if INDEX > 0, we know that there are files in the file */
+/* table, and that we are currently reading from one of them. */
+
+ if (index > 0) {
+ i__1 = nfiles - 1;
+ for (k = index; k <= i__1; ++k) {
+ filcnt[(i__2 = k - 1) < 21 && 0 <= i__2 ? i__2 : s_rnge(
+ "filcnt", i__2, "dasec_", (ftnlen)729)] = filcnt[(
+ i__3 = k) < 21 && 0 <= i__3 ? i__3 : s_rnge("fil"
+ "cnt", i__3, "dasec_", (ftnlen)729)];
+ filchr[(i__2 = k - 1) < 21 && 0 <= i__2 ? i__2 : s_rnge(
+ "filchr", i__2, "dasec_", (ftnlen)730)] = filchr[(
+ i__3 = k) < 21 && 0 <= i__3 ? i__3 : s_rnge("fil"
+ "chr", i__3, "dasec_", (ftnlen)730)];
+ filhan[(i__2 = k - 1) < 21 && 0 <= i__2 ? i__2 : s_rnge(
+ "filhan", i__2, "dasec_", (ftnlen)731)] = filhan[(
+ i__3 = k) < 21 && 0 <= i__3 ? i__3 : s_rnge("fil"
+ "han", i__3, "dasec_", (ftnlen)731)];
+ lstrec[(i__2 = k - 1) < 21 && 0 <= i__2 ? i__2 : s_rnge(
+ "lstrec", i__2, "dasec_", (ftnlen)732)] = lstrec[(
+ i__3 = k) < 21 && 0 <= i__3 ? i__3 : s_rnge("lst"
+ "rec", i__3, "dasec_", (ftnlen)732)];
+ lstpos[(i__2 = k - 1) < 21 && 0 <= i__2 ? i__2 : s_rnge(
+ "lstpos", i__2, "dasec_", (ftnlen)733)] = lstpos[(
+ i__3 = k) < 21 && 0 <= i__3 ? i__3 : s_rnge("lst"
+ "pos", i__3, "dasec_", (ftnlen)733)];
+ }
+ --nfiles;
+ }
+ }
+ }
+
+/* Set the number of comment lines in the buffer */
+
+ *n = numcom;
+
+/* At this point, we have either filled the buffer or we have */
+/* finished reading in the comment area. Find out what has */
+/* happened and act accordingly. */
+
+ if (! (*done)) {
+
+/* If we are not done, then we have filled the buffer, so save */
+/* everything that needs to be saved in the file table before */
+/* exiting. */
+
+ if (index == 0) {
+
+/* This was the first time that the comment area of this file */
+/* has been read, so add it to the file table and save all of */
+/* its information if there is room in the file table. */
+
+ if (nfiles >= 21) {
+ setmsg_("The file table is full with # files, and another fi"
+ "le could not be added.", (ftnlen)73);
+ errint_("#", &c__21, (ftnlen)1);
+ sigerr_("SPICE(FILETABLEFULL)", (ftnlen)20);
+ chkout_("DASEC", (ftnlen)5);
+ return 0;
+ }
+ ++nfiles;
+ filcnt[(i__1 = nfiles - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "filcnt", i__1, "dasec_", (ftnlen)777)] = ncomc;
+ filchr[(i__1 = nfiles - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "filchr", i__1, "dasec_", (ftnlen)778)] = nchars;
+ filhan[(i__1 = nfiles - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "filhan", i__1, "dasec_", (ftnlen)779)] = *handle;
+ lstrec[(i__1 = nfiles - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "lstrec", i__1, "dasec_", (ftnlen)780)] = recno;
+ lstpos[(i__1 = nfiles - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "lstpos", i__1, "dasec_", (ftnlen)781)] = curpos;
+ lsthan = *handle;
+ } else {
+
+/* The comment area of this file is already in the file table, */
+/* so just update its information. */
+
+ filchr[(i__1 = index - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fil"
+ "chr", i__1, "dasec_", (ftnlen)789)] = nchars;
+ lstrec[(i__1 = index - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("lst"
+ "rec", i__1, "dasec_", (ftnlen)790)] = recno;
+ lstpos[(i__1 = index - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("lst"
+ "pos", i__1, "dasec_", (ftnlen)791)] = curpos;
+ lsthan = *handle;
+ }
+ }
+ chkout_("DASEC", (ftnlen)5);
+ return 0;
+} /* dasec_ */
+
diff --git a/ext/spice/src/cspice/dasec_c.c b/ext/spice/src/cspice/dasec_c.c
new file mode 100644
index 0000000000..0757d4531f
--- /dev/null
+++ b/ext/spice/src/cspice/dasec_c.c
@@ -0,0 +1,306 @@
+/*
+
+-Procedure dasec_c ( DAS extract comments )
+
+-Abstract
+
+ Extract comments from the comment area of a binary DAS file.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAS
+
+-Keywords
+
+ FILES
+ UTILITY
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+ #undef dasec_c
+
+ void dasec_c ( SpiceInt handle,
+ SpiceInt bufsiz,
+ SpiceInt buflen,
+ SpiceInt * n,
+ void * buffer,
+ SpiceBoolean * done )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ handle I Handle of binary DAS file open with read access.
+ bufsiz I Maximum size, in lines, of buffer.
+ buflen I Line length associated with buffer.
+ n O Number of comments extracted from the DAS file.
+ buffer O Buffer in which extracted comments are placed.
+ done O Indicates whether all comments have been extracted.
+
+-Detailed_Input
+
+ handle The file handle of a binary DAS file which has been
+ opened with read access.
+
+ bufsiz The maximum number of comments that may be placed into
+ buffer. This would typically be the declared array size
+ for the C character string array passed into this
+ routine.
+
+ buflen is the common length of the strings in buffer, including the
+ terminating nulls.
+
+-Detailed_Output
+
+ n The number of comment lines extracted from the comment area
+ of the binary DAS file attached to handle. This number will
+ be <= bufsiz on output. If n == bufsiz and done !=
+ SPICETRUE then there are more comments left to extract. If
+ n == 0, then done == SPICETRUE, i.e., there were no
+ comments in the comment area. If there are comments in the
+ comment area, or comments remaining after the extraction
+ process has begun, n > 0, always.
+
+ buffer A list of at most bufsiz comments which have been
+ extracted from the comment area of the binary DAS
+ file attached to handle. buffer should be declared as
+ follows:
+
+ ConstSpiceChar buffer [bufsiz][buflen]
+
+ Each string in buffer is null-terminated.
+
+ done A boolean flag indicating whether or not all of the
+ comment lines from the comment area of the DAS file have
+ been read. This variable has the value SPICETRUE after the
+ last comment line has been read. It will have the value
+ SPICEFALSE otherwise.
+
+ If there are no comments in the comment area, this
+ variable will have the value SPICETRUE, and n == 0.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the size of the output line buffer is is not positive,
+ the error SPICE(INVALIDARGUMENT) will be signaled.
+
+ 2) If a comment line in a DAS file is longer than the length
+ of a character string array element of BUFFER, the error
+ SPICE(COMMENTTOOLONG) will be signaled.
+
+ 3) If there is a mismatch between the number of comment
+ characters found and the number of comment characters
+ expected, the error SPICE(BADDASCOMMENTAREA) will be
+ signaled.
+
+ 4) If the binary DAS file attached to HANDLE is not open for
+ reading, an error will be signaled by a routine called by
+ this routine.
+
+ 5) If the input buffer pointer is null, the error SPICE(NULLPOINTER)
+ will be signaled.
+
+ 6) If the input buffer string length buflen is not at least 2,
+ the error SPICE(STRINGTOOSHORT) will be signaled.
+
+-Files
+
+ See argument handle in $ Detailed_Input.
+
+-Particulars
+
+ Binary DAS files contain an area which is reserved for storing
+ annotations or descriptive textual information describing the data
+ contained in a file. This area is referred to as the "comment
+ area" of the file. The comment area of a DAS file is a line
+ oriented medium for storing textual information. The comment
+ area preserves any leading or embedded white space in the line(s)
+ of text which are stored, so that the appearance of the of
+ information will be unchanged when it is retrieved (extracted) at
+ some other time. Trailing blanks, however, are NOT preserved,
+ due to the way that character strings are represented in
+ standard Fortran 77.
+
+ This routine will read the comments from the comment area of
+ a binary DAS file, placing them into a line buffer. If the line
+ buffer is not large enough to hold the entire comment area,
+ the portion read will be returned to the caller, and the done
+ flag will be set to SPICEFALSE. This allows the comment area to be
+ read in "chunks," a buffer at a time. After all of the comment
+ lines have been read, the done flag will be set to SPICETRUE.
+
+ After all of the comments in DAS file have been read, the next
+ call to this routine will start reading comments at the start
+ of the comment area.
+
+ This routine can be used to "simultaneously" extract comments
+ from the comment areas of multiple binary DAS files.
+
+-Examples
+
+ 1) The following example will extract the entire comment area of a
+ binary DAS file attached to HANDLE, displaying the comments on
+ the terminal screen.
+
+ #include
+ #include "SpiceUsr.h"
+
+ int main( int argc, char ** argv )
+ {
+
+ #define LNSIZE 81
+ #define MAXBUF 25
+
+ SpiceBoolean done;
+
+ SpiceChar buffer [MAXBUF][LNSIZE];
+ SpiceChar * filename;
+
+ SpiceInt handle;
+ SpiceInt i;
+ SpiceInt n;
+
+
+ filename = argv[1];
+
+ dasopr_ ( filename, &handle, (ftnlen)strlen(filename) );
+
+ done = SPICEFALSE;
+
+ while ( !done )
+ {
+ dasec_c( handle, MAXBUF, LNSIZE, &n, buffer, &done );
+
+ for ( i = 0; i < n; i++ )
+ {
+ printf ( "%s\n", buffer[i] );
+ }
+ }
+
+ return ( 0 );
+ }
+
+
+-Restrictions
+
+ 1) The comment area may consist only of printing ASCII characters,
+ decimal values 32 - 126.
+
+ 2) There is NO maximum length imposed on the significant portion
+ of a text line that may be placed into the comment area of a
+ DAS file. The maximum length of a line stored in the comment
+ area should be kept reasonable, so that they may be easily
+ extracted. A good value for this would be 255 characters, as
+ this can easily accommodate "screen width" lines as well as
+ long lines which may contain some other form of information.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 24-FEB-2003 (NJB) (KRG)
+
+-Index_Entries
+
+ extract comments from a das file
+
+-&
+*/
+
+{ /* Begin dasec_c */
+
+
+ /*
+ Local variables
+ */
+ logical locDone;
+
+
+ /*
+ Participate in error tracing.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+ chkin_c ( "dasec_c" );
+
+
+ /*
+ Make sure the output string has at least enough room for one output
+ character and a null terminator. Also check for a null pointer.
+ */
+ CHKOSTR ( CHK_STANDARD, "dasec_c", buffer, buflen );
+
+
+ /*
+ Call the f2c'd routine.
+ */
+ dasec_ ( (integer *) &handle,
+ (integer *) &bufsiz,
+ (integer *) n,
+ (char *) buffer,
+ (logical *) &locDone,
+ (ftnlen ) buflen-1 );
+
+ /*
+ Convert the output array from Fortran to C style.
+ */
+ if ( *n > 0 );
+ {
+ F2C_ConvertTrStrArr ( *n, buflen, (SpiceChar *)buffer );
+ }
+
+
+ /*
+ Set the "done" flag.
+ */
+
+ *done = (SpiceBoolean) locDone;
+
+
+ chkout_c ( "dasec_c" );
+
+} /* End dasec_c */
diff --git a/ext/spice/src/cspice/dasecu.c b/ext/spice/src/cspice/dasecu.c
new file mode 100644
index 0000000000..84c9aa2027
--- /dev/null
+++ b/ext/spice/src/cspice/dasecu.c
@@ -0,0 +1,235 @@
+/* dasecu.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__22 = 22;
+
+/* $Procedure DASECU ( DAS extract comments to a logical unit ) */
+/* Subroutine */ int dasecu_(integer *handle, integer *comlun, logical *
+ comnts)
+{
+ extern /* Subroutine */ int dasec_(integer *, integer *, integer *, char *
+ , logical *, ftnlen), chkin_(char *, ftnlen);
+ extern logical failed_(void);
+ char combuf[255*22];
+ extern /* Subroutine */ int dassih_(integer *, char *, ftnlen);
+ integer numcom;
+ extern /* Subroutine */ int chkout_(char *, ftnlen), writla_(integer *,
+ char *, integer *, ftnlen);
+ logical gotsom;
+ extern logical return_(void);
+ logical eoc;
+
+/* $ Abstract */
+
+/* Extract comments from a previously opened binary DAS file to a */
+/* previously opened text file attached to a Fortran logical unit. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* None. */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of a DAS file opened with read access. */
+/* COMLUN I Logical unit of an opened text file. */
+/* COMNTS O Logical flag, indicating comments were found. */
+
+/* $ Detailed_Input */
+
+/* HANDLE The file handle for a binary DAS file that has been */
+/* opened with read access. */
+
+/* COMLUN The Fortran logical unit of a previously opened text */
+/* file to which the comments from a binary DAS file are */
+/* to be written. */
+
+/* The comments will be placed into the text file beginning */
+/* at the current location in the file, and continuing */
+/* until all of the comments have been written. */
+
+/* $ Detailed_Output */
+
+/* COMNTS A logical flag indicating whether or not any comments */
+/* were found in the comment area of a DAS file. COMNTS will */
+/* have the value .TRUE. if there were some comments, and */
+/* the value .FALSE. otherwise. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If an error occurs while reading from the binary DAS file */
+/* attached to HANDLE, a routine called by this routine will */
+/* signal an error. */
+
+/* 2) If an error occurs while writing to the text file attached */
+/* to COMLUN, a routine called by this routine will signal an */
+/* error. */
+
+/* $ Files */
+
+/* See parameters COMLUN and HANDLE in the $ Detailed_Inputs section. */
+
+/* $ Particulars */
+
+/* This routine will extract all of the comments from the comment */
+/* area of a binary DAS file, placing them into a text file */
+/* attached to COMLUN, beginning at the current position in the */
+/* text file. If there are no comments in the DAS file, nothing is */
+/* written to the text file attached to COMLUN. */
+
+/* $ Examples */
+
+/* Let */
+
+/* HANDLE be the DAS file handle of a previously opened binary */
+/* DAS file. */
+
+/* COMLUN be the Fortran logical unit of a previously opened */
+/* text file that is to accept the comments from the */
+/* DAS comment area. */
+
+/* The subroutine call */
+
+/* CALL DASECU ( HANDLE, COMLUN, COMNTS ) */
+
+/* will extract the comments from the comment area of the binary */
+/* DAS file attached to HANDLE, if there are any, and write them */
+/* to the logical unit COMLUN. Upun successfur completion, the */
+/* value of COMNTS will be .TRUE. if there were some comments */
+/* in the comment area and .FALSE. otherwise. */
+
+/* $ Restrictions */
+
+/* The maximum length of a single line comment in the comment area is */
+/* specified by the parameter LINLEN defined below. Currently this */
+/* value is 255 characters. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - Beta Version 1.0.0, 5-JAN-1993 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* extract comments from a DAS file to a logical unit */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+/* Set the value for the maximum length of a text line. */
+
+
+/* Set the size of the comment buffer. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASECU", (ftnlen)6);
+ }
+
+/* Verify that the DAS file attached to HANDLE is opened for reading. */
+
+ dassih_(handle, "READ", (ftnlen)4);
+ if (failed_()) {
+ chkout_("DASECU", (ftnlen)6);
+ return 0;
+ }
+
+/* Initialize some things before the loop. */
+
+ numcom = 0;
+ eoc = FALSE_;
+ gotsom = FALSE_;
+ while(! eoc) {
+
+/* While we have not reached the end of the comments, get some */
+/* more. */
+
+ dasec_(handle, &c__22, &numcom, combuf, &eoc, (ftnlen)255);
+ if (failed_()) {
+ chkout_("DASECU", (ftnlen)6);
+ return 0;
+ }
+ if (numcom > 0) {
+
+/* If NUMCOM .GT. 0 then we did get some comments, and we need */
+/* to write them out, but first, set the flag indicating that */
+/* we got some comments. */
+
+ if (! gotsom) {
+ gotsom = TRUE_;
+ }
+ writla_(&numcom, combuf, comlun, (ftnlen)255);
+ if (failed_()) {
+ chkout_("DASECU", (ftnlen)6);
+ return 0;
+ }
+ }
+ }
+
+/* Set the output flag indicating whether or not we got any comments. */
+
+ *comnts = gotsom;
+ chkout_("DASECU", (ftnlen)6);
+ return 0;
+} /* dasecu_ */
+
diff --git a/ext/spice/src/cspice/dasfm.c b/ext/spice/src/cspice/dasfm.c
new file mode 100644
index 0000000000..fef5359773
--- /dev/null
+++ b/ext/spice/src/cspice/dasfm.c
@@ -0,0 +1,6452 @@
+/* dasfm.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__21 = 21;
+static integer c__2 = 2;
+static integer c__4 = 4;
+static integer c__1 = 1;
+static integer c__14 = 14;
+static integer c__3 = 3;
+static integer c__0 = 0;
+static integer c__256 = 256;
+
+/* $Procedure DASFM ( DAS, file manager ) */
+/* Subroutine */ int dasfm_0_(int n__, char *fname, char *ftype, char *ifname,
+ integer *handle, integer *unit, integer *free, integer *lastla,
+ integer *lastrc, integer *lastwd, integer *nresvr, integer *nresvc,
+ integer *ncomr, integer *ncomc, integer *fhset, char *access, ftnlen
+ fname_len, ftnlen ftype_len, ftnlen ifname_len, ftnlen access_len)
+{
+ /* Initialized data */
+
+ static logical pass1 = TRUE_;
+ static integer fthead = 0;
+ static integer nxthan = 0;
+ static integer next[3] = { 2,3,1 };
+ static integer prev[3] = { 3,1,2 };
+ static integer nw[3] = { 1024,128,256 };
+ static char bfflst[8*4] = "BIG-IEEE" "LTL-IEEE" "VAX-GFLT" "VAX-DFLT";
+
+ /* System generated locals */
+ address a__1[2];
+ integer i__1, i__2, i__3, i__4[2], i__5;
+ olist o__1;
+ cllist cl__1;
+ inlist ioin__1;
+
+ /* Builtin functions */
+ integer s_cmp(char *, char *, ftnlen, ftnlen), f_inqu(inlist *), s_rnge(
+ char *, integer, char *, integer), f_open(olist *), f_clos(cllist
+ *);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_rdue(cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void);
+ /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
+ integer s_wdue(cilist *), e_wdue(void);
+
+ /* Local variables */
+ static integer nrec;
+ static char tail[932];
+ static integer last, pool[54] /* was [2][27] */, type__;
+ extern /* Subroutine */ int zzddhppf_(integer *, integer *, integer *),
+ zzdasnfr_(integer *, char *, char *, integer *, integer *,
+ integer *, integer *, char *, ftnlen, ftnlen, ftnlen), zzplatfm_(
+ char *, char *, ftnlen, ftnlen);
+ static integer i__, ftacc[21], ldrec[3];
+ extern logical elemi_(integer *, integer *);
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ static integer fthan[21];
+ static char tarch[3];
+ extern /* Subroutine */ int maxai_(integer *, integer *, integer *,
+ integer *), errch_(char *, char *, ftnlen, ftnlen), lnkan_(
+ integer *, integer *), ucase_(char *, char *, ftnlen, ftnlen);
+ static logical found;
+ static integer ftlnk[21];
+ extern /* Subroutine */ int copyi_(integer *, integer *);
+ extern integer ltrim_(char *, ftnlen);
+ static integer ftlun[21];
+ extern integer rtrim_(char *, ftnlen);
+ static integer ftsum[294] /* was [14][21] */;
+ extern /* Subroutine */ int ljust_(char *, char *, ftnlen, ftnlen);
+ static char ttype[4];
+ extern /* Subroutine */ int idw2at_(char *, char *, char *, ftnlen,
+ ftnlen, ftnlen);
+ extern logical failed_(void);
+ static char dasfil[255];
+ static integer endrec, loccch, dirrec[256], loccrc;
+ extern integer isrchc_(char *, integer *, char *, ftnlen, ftnlen),
+ lnknfn_(integer *);
+ static char format[8], idword[8], lngmsg[1840], locifn[60], locfmt[8];
+ static integer dsctyp, fhlist[27], findex, iostat, ldrmax, locrrc;
+ extern integer lnknxt_(integer *, integer *);
+ extern logical exists_(char *, ftnlen), return_(void);
+ static integer locrch, maxadr, number, curtyp, nxtdir, nxtrec;
+ static logical opened;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), lnkini_(integer *, integer *), ssizei_(integer *,
+ integer *), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen), getlun_(integer *);
+ static integer prvtyp;
+ extern /* Subroutine */ int lnkilb_(integer *, integer *, integer *),
+ cleari_(integer *, integer *);
+ static char acc[10];
+ extern /* Subroutine */ int dasioi_(char *, integer *, integer *, integer
+ *, ftnlen), insrti_(integer *, integer *);
+ static integer bff;
+ extern /* Subroutine */ int lnkfsl_(integer *, integer *, integer *),
+ removi_(integer *, integer *), errfnm_(char *, integer *, ftnlen);
+ static integer fnb, loc, new__, pos;
+
+ /* Fortran I/O blocks */
+ static cilist io___22 = { 1, 0, 1, 0, 1 };
+ static cilist io___48 = { 1, 0, 1, 0, 1 };
+ static cilist io___52 = { 1, 0, 0, 0, 1 };
+ static cilist io___53 = { 1, 0, 1, 0, 1 };
+ static cilist io___55 = { 1, 0, 0, 0, 1 };
+
+
+/* $ Abstract */
+
+/* Manage open DAS files. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+
+/* Include File: SPICELIB Error Handling Parameters */
+
+/* errhnd.inc Version 2 18-JUN-1997 (WLT) */
+
+/* The size of the long error message was */
+/* reduced from 25*80 to 23*80 so that it */
+/* will be accepted by the Microsoft Power Station */
+/* FORTRAN compiler which has an upper bound */
+/* of 1900 for the length of a character string. */
+
+/* errhnd.inc Version 1 29-JUL-1997 (NJB) */
+
+
+
+/* Maximum length of the long error message: */
+
+
+/* Maximum length of the short error message: */
+
+
+/* End Include File: SPICELIB Error Handling Parameters */
+
+/* The record length should be big enough to hold the greatest of the */
+/* following: */
+/* -- NWD double precision numbers. */
+/* -- NWI integers. */
+/* -- NWC characters. */
+/* These parameters are named to enhance ease of maintenance of */
+/* the code; the values should not be changed. */
+/* For the following environments, record length is measured in */
+/* characters (bytes) with eight characters per double precision */
+/* number. */
+/* Environment: Sun, Sun FORTRAN */
+/* Source: Sun Fortran Programmer's Guide */
+/* Environment: PC, MS FORTRAN */
+/* Source: Microsoft Fortran Optimizing Compiler User's Guide */
+/* Environment: Macintosh, Language Systems FORTRAN */
+/* Source: Language Systems FORTRAN Reference Manual, */
+/* Version 1.2, page 12-7 */
+/* Environment: PC/Linux, Fort77 */
+/* Source: Determined by experiment. */
+/* Environment: PC, Lahey F77 EM/32 Version 4.0 */
+/* Source: Lahey F77 EM/32 Language Reference Manual, */
+/* page 144 */
+/* Environment: HP-UX 9000/750, FORTRAN/9000 Series 700 computers */
+/* Source: FORTRAN/9000 Reference-Series 700 Computers, */
+/* page 5-110 */
+/* Environment: NeXT Mach OS (Black Hardware), */
+/* Absoft Fortran Version 3.2 */
+/* Source: NAIF Program */
+/* FTSIZE is the maximum number of DAS files that a user can have */
+/* open simultaneously. See the description in the $ Parameters */
+/* section for details. */
+/* $ Brief_I/O */
+
+/* Variable I/O Entry points */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I,O OPR, OPW, ONW, OPN (Obsolete), HFN, FNH */
+/* FTYPE I ONW */
+/* IFNAME I ONW, OPN (Obsolete) */
+/* SUM I,O UFS, HFS */
+/* HANDLE I,O OPR, OPW, ONW, OPN (Obsolete), OPS, LLC, HLU, LUH, */
+/* HFN, FNH, HAM, SIH */
+/* UNIT I,O HLU, LUH */
+/* FREE I,O HFS, UFS */
+/* LASTLA I,O HFS, UFS */
+/* LASTRC I,O HFS, UFS */
+/* LASTWD I,O HFS, UFS */
+/* NRESVR O HFS */
+/* NRESVC O HFS */
+/* NCOMR O HFS */
+/* NCOMC O HFS */
+/* FHSET O HOF */
+/* ACCESS I,O SIH, HAM */
+/* RECL P OPR, OPW, ONW, OPN (Obsolete) */
+/* FTSIZE P OPR, OPW, ONW, OPN (Obsolete), LLC, HLU, LUH, HFN, */
+/* FNH */
+
+/* $ Detailed_Input */
+
+/* FNAME on input is the name of a DAS file to be opened, or */
+/* the name of a DAS file about which some information */
+/* (handle, logical unit) is requested. */
+
+/* FTYPE on input is a code for the type of data that is */
+/* contained in the DAS file. This code has no meaning or */
+/* interpretation at the level of the DAS file */
+/* architecture, but is provided as a convenience for */
+/* higher level software. The maximum length for the file */
+/* type is four (4) characters. If the input string is */
+/* longer than four characters, the first nonblank */
+/* character and its three, at most, immediate successors */
+/* will be used as the file type. The file type may not */
+/* contain nonprinting characters, and it IS case */
+/* sensitive. */
+
+/* IFNAME is the internal file name for a DAS file to be */
+/* created. */
+
+/* HANDLE on input is the handle of a DAS file about which some */
+/* information (file name, logical unit) is requested, */
+/* or the handle of a DAS file to be closed. */
+
+/* UNIT on input is the logical unit connected to a DAS file */
+/* about which some information (file name, handle) is */
+/* requested. */
+
+/* FREE is the Fortran record number of the first free record */
+/* in a specified DAS file. */
+
+/* LASTLA is an array containing the highest current logical */
+/* addresses, in the specified DAS file, of data of */
+/* character, double precision, and integer types, in */
+/* that order. */
+
+/* LASTRC is an array containing the Fortran record numbers, in */
+/* the specified DAS file, of the directory records */
+/* containing the current last descriptors of clusters */
+/* of character, double precision, and integer data */
+/* records, in that order. */
+
+/* LASTWD is an array containing the word positions, in the */
+/* specified DAS file, of the current last descriptors */
+/* of clusters of character, double precision, and */
+/* integer data records, in that order. */
+
+/* ACCESS is the type of access for which a DAS file is open. */
+/* The values of ACCESS may be */
+
+/* 'READ' */
+/* 'WRITE' */
+
+/* Leading and trailing blanks are ignored, and case */
+/* is not significant. */
+
+/* DAS files that are open for writing may also be read. */
+
+/* $ Detailed_Output */
+
+/* FNAME on output is the name of a DAS file for which */
+/* the corresponding handle or logical unit has been */
+/* supplied. */
+
+
+/* HANDLE on output is the handle of a DAS file for which */
+/* the corresponding file name or logical unit has been */
+/* supplied. */
+
+/* UNIT on output is the logical unit connected to a DAS file */
+/* for which the corresponding file name or handle has */
+/* been supplied. */
+
+/* FREE is the Fortran record number of the first free record */
+/* in a specified DAS file. */
+
+/* LASTLA is an array containing the highest current logical */
+/* addresses, in the specified DAS file, of data of */
+/* character, double precision, and integer types, in */
+/* that order. */
+
+/* LASTRC is an array containing the Fortran record numbers, in */
+/* the specified DAS file, of the directory records */
+/* containing the current last descriptors of clusters */
+/* of character, double precision, and integer data */
+/* records, in that order. */
+
+/* LASTWD is an array containing the word positions, in the */
+/* specified DAS file, of the current last descriptors */
+/* of clusters of character, double precision, and */
+/* integer data records, in that order. */
+
+/* NRESVR is the number of reserved records in a specified DAS */
+/* file. */
+
+/* NRESVC is the number of characters in use in the reserved */
+/* record area of a specified DAS file. */
+
+/* NCOMR is the number of comment records in a specified DAS */
+/* file. */
+
+/* NCOMC is the number of characters in use in the comment area */
+/* of a specified DAS file. */
+
+/* FHSET is a SPICELIB set containing the handles of the */
+/* currently open DAS files. */
+
+/* $ Parameters */
+
+/* RECL is the record length of a DAS file. Each record */
+/* must be large enough to hold the greatest of NWI */
+/* integers, NWD double precision numbers, or NWC */
+/* characters, whichever is greater. The units in which */
+/* the record length must be specified vary from */
+/* environment to environment. For example, VAX Fortran */
+/* requires record lengths to be specified in longwords, */
+/* where two longwords equal one double precision */
+/* number. */
+
+/* FTSIZE is the maximum number of DAS files that a user can */
+/* have open simultaneously. This includes any files used */
+/* by the DAS system when closing files opened with write */
+/* access. Currently, DASCLS (via DASSDR) opens a scratch */
+/* DAS file using DASOPS to segregate (sort by data */
+/* type) the records in the DAS file being closed. */
+/* Segregating the data by type improves the speed of */
+/* access to the data. */
+
+/* In order to avoid the possibility of overflowing the */
+/* DAS file table we recommend, when at least one DAS */
+/* file is open with write access, that users of this */
+/* software limit themselves to at most FTSIZE - 2 other */
+/* open DAS files. If no files are to be open with write */
+/* access, then users may open FTSIZE files with no */
+/* possibility of overflowing the DAS file table. */
+
+/* $ Exceptions */
+
+/* 1) If DASFM is called directly, the error SPICE(BOGUSENTRY) */
+/* is signaled. */
+
+/* 2) See entry points DASOPR, DASOPW, DASONW, DASOPN, DASOPS, */
+/* DASLLC, DASHFS, DASUFS, DASHLU, DASLUH, DASHFN, DASFNH, DASHOF, */
+/* and DASSIH for exceptions specific to those entry points. */
+
+/* $ Files */
+
+/* This set of routines is intended to support the creation, */
+/* updating, and reading of Fortran direct access files that */
+/* conform to the DAS file format. This format is described in */
+/* detail in the DAS Required Reading. */
+
+/* See FTSIZE in the $ Parameters section for a description of a */
+/* potential problem with overflowing the DAS file table when at */
+/* least one DAS file is opened with write access. */
+
+/* $ Particulars */
+
+/* DASFM serves as an umbrella, allowing data to be shared by its */
+/* entry points: */
+
+/* DASOPR Open for read. */
+/* DASOPW Open for write. */
+/* DASONW Open new. */
+/* DASOPN Open new. (Obsolete: Use DASONW instead.) */
+/* DASOPS Open as scratch file. */
+
+/* DASLLC Low-level close. */
+
+/* DASHFS Handle to file summary. */
+/* DASUFS Update file summary. */
+
+/* DASHLU Handle to logical unit. */
+/* DASLUH Logical to handle. */
+
+/* DASHFN Handle to name. */
+/* DASFNH File name to handle. */
+
+/* DASHAM Handle to access method. */
+
+/* DASHOF Handles of open files. */
+/* DASSIH Signal invalid handles. */
+
+
+/* Before a DAS file can be used, it must be opened. Entry points */
+/* DASOPR and DASOPW provide the only means for opening an */
+/* existing DAS file. */
+
+/* Several files may be opened for use simultaneously. (This makes */
+/* it convenient to combine data from several files to produce a */
+/* single result, or to route subsets of data from a single source */
+/* to multiple DAS files.) As each DAS file is opened, it is */
+/* assigned a file handle, which is used to keep track of the file */
+/* internally, and which is used by the calling program to refer to */
+/* the file in all subsequent calls to DAS routines. */
+
+/* DAS files may be opened for either read or write access. Files */
+/* open for read access may not be changed in any way. Files opened */
+/* for write access may be both read from and written to. */
+
+/* DASONW is used to open a new DAS file. This routine extends the */
+/* functionality of DASOPN by providing a mechanism for associating a */
+/* type with the data in the DAS file. The use of this entry over */
+/* DASOPN is highly recommended. */
+
+/* Since the only reason for creating a new file is to write */
+/* something in it, all new files are opened for write access. */
+
+/* Entry point DASOPN, for opening a new DAS file, has been rendered */
+/* obsolete by the new entry point DASONW. The entry point DASOPN */
+/* will continue to be supported for purposes of backward */
+/* compatibility, but its use in new software development is strongly */
+/* discouraged. */
+
+/* Entry point DASOPS creates a new scratch DAS file. As with new */
+/* permanent files, these files are opened for write access. DAS */
+/* files opened by DASOPS are automatically deleted when they are */
+/* closed. */
+
+/* Entry point DASLLC is used by DASCLS ( DAS, close file ) to close */
+/* an open DAS file and update DASFM's bookkeeping information */
+/* accordingly. DASCLS provides the only official means of closing */
+/* a DAS file that is currently open. Closing a DAS file any other */
+/* way (for example, by determining its logical unit and using the */
+/* Fortran CLOSE statement directly) may affect your calling program */
+/* in mysterious ways. Normally, DASLLC should not be called by */
+/* non-SPICELIB routines; these should call DASCLS instead. */
+
+/* Entry point DASHFS allows you to obtain a file summary for any */
+/* DAS file that is currently open, without calling DASRFR to */
+/* re-read the file record. Entry point DASUFS can be used to */
+/* update a file summary at run-time. Normally, there is no */
+/* need for routines outside of SPICELIB to modify a DAS file's */
+/* summary. */
+
+/* Entry point DASHAM allows you to determine which access method */
+/* a DAS file has been opened for. */
+
+/* Entry point DASHOF allows you to determine which DAS files are */
+/* open at any time. In particular, you can use DASHOF to determine */
+/* whether any file handle points to an open DAS file. */
+
+/* Entry point DASSIH signals errors when it is supplied with invalid */
+/* handles, so it serves to centralize error handling associated */
+/* with invalid handles. */
+
+/* The remaining entry points exist mainly to translate between */
+/* alternative representations of DAS files. There are three ways to */
+/* identify any open DAS file: by name, by handle, and by logical */
+/* unit. Given any one of these, you may use these entry points to */
+/* find the other two. */
+
+/* $ Examples */
+
+/* See entry points DASOPR, DASOPW, DASONW, DASOPN (Obsolete), */
+/* DASLLC, DASHFS, DASUFS, DASHLU, DASLUH, DASHFN, DASFNH, DASHAM, */
+/* DASHOF, and DASSIH for examples specific to those entry points. */
+
+/* $ Restrictions */
+
+/* 1) The value of parameter RECL may need to be changed when DASFM */
+/* and its entry points are ported to a new environment (CPU and */
+/* compiler). */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* H.A. Neilan (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 7.18.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL. */
+
+/* - SPICELIB Version 7.17.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL-CC_C. */
+
+/* - SPICELIB Version 7.16.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-INTEL-64BIT-CC_C. */
+
+/* - SPICELIB Version 7.15.0, 13-MAY-2010 (BVS) */
+
+/* Updated for SUN-SOLARIS-64BIT-NATIVE_C. */
+
+/* - SPICELIB Version 7.14.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-WINDOWS-64BIT-IFORT. */
+
+/* - SPICELIB Version 7.13.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-LINUX-64BIT-GFORTRAN. */
+
+/* - SPICELIB Version 7.12.0, 13-MAY-2010 (BVS) */
+
+/* Updated for PC-64BIT-MS_C. */
+
+/* - SPICELIB Version 7.11.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-INTEL_C. */
+
+/* - SPICELIB Version 7.10.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-IFORT. */
+
+/* - SPICELIB Version 7.9.0, 13-MAY-2010 (BVS) */
+
+/* Updated for MAC-OSX-64BIT-GFORTRAN. */
+
+/* - SPICELIB Version 7.8.0, 18-MAR-2009 (BVS) */
+
+/* Updated for PC-LINUX-GFORTRAN. */
+
+/* - SPICELIB Version 7.7.0, 18-MAR-2009 (BVS) */
+
+/* Updated for MAC-OSX-GFORTRAN. */
+
+/* - SPICELIB Version 7.6.0, 19-FEB-2008 (BVS) */
+
+/* Updated for PC-LINUX-IFORT. */
+
+/* - SPICELIB Version 7.5.0, 14-NOV-2006 (BVS) */
+
+/* Updated for PC-LINUX-64BIT-GCC_C. */
+
+/* - SPICELIB Version 7.4.0, 14-NOV-2006 (BVS) */
+
+/* Updated for MAC-OSX-INTEL_C. */
+
+/* - SPICELIB Version 7.3.0, 14-NOV-2006 (BVS) */
+
+/* Updated for MAC-OSX-IFORT. */
+
+/* - SPICELIB Version 7.2.0, 14-NOV-2006 (BVS) */
+
+/* Updated for PC-WINDOWS-IFORT. */
+
+/* - SPICELIB Version 7.1.0, 26-OCT-2005 (BVS) */
+
+/* Updated for SUN-SOLARIS-64BIT-GCC_C. */
+
+/* - SPICELIB Version 7.0.0, 28-SEP-2005 (NJB) */
+
+/* Error handling for non-native files was added to */
+/* entry points DASOPR and DASOPW. */
+
+/* Bug in code for constructing long error message in entry */
+/* point DASUFS was corrected. */
+
+/* - SPICELIB Version 6.2.0, 03-JAN-2005 (BVS) */
+
+/* Updated for PC-CYGWIN_C. */
+
+/* - SPICELIB Version 6.1.0, 03-JAN-2005 (BVS) */
+
+/* Updated for PC-CYGWIN. */
+
+/* - SPICELIB Version 6.0.3, 24-APR-2003 (EDW) */
+
+/* Added MAC-OSX-F77 to the list of platforms */
+/* that require READONLY to read write protected */
+/* kernels. */
+
+/* - SPICELIB Version 6.0.2, 21-FEB-2003 (NJB) */
+
+/* Corrected inline comment in DASLLC: determination of */
+/* whether file is open is done by searching the handle column of */
+/* the file table, not the unit column. */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 6.0.0, 11-DEC-2001 (NJB) (FST) */
+
+/* To accomodate future updates to the DAS system, including */
+/* integration with the handle manager and FTP validation */
+/* checks, the following entry points were modified: */
+
+/* DASONW, DASOPN */
+
+/* See their headers and code for the details of the changes. */
+
+/* Bug fix: removed local buffering of the DAS file ID word */
+/* and the internal file name, as this was causing DASWFR */
+/* to exhibit improper behavior. */
+
+/* Bug fix: missing call to CHKIN was added to an error */
+/* handling branch in entry point DASUFS. This call is */
+/* required because DASUFS uses discovery check-in. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 5.0.0, 05-APR-1998 (NJB) */
+
+/* Added references to the PC-LINUX environment. Repaired some */
+/* format errors involving placement of comment markers in */
+/* column 1. */
+
+/* - SPICELIB Version 4.0.1, 19-DEC-1995 (NJB) */
+
+/* Added permuted index entry section. */
+
+/* - SPICELIB Version 4.0.0, 31-AUG-1995 (NJB) */
+
+/* Changed argument list of the entry point DASONW. The input */
+/* argument NCOMR, which indicates the number of comment records */
+/* to reserve, was added to the argument list. */
+
+/* - SPICELIB Version 3.1.0, 5-JAN-1995 (HAN) */
+
+/* Removed Sun Solaris environment since it is now the same */
+/* as the Sun OS 4.1.x environment. */
+/* Removed DEC Alpha/OpenVMS environment since it is now the same */
+/* as the VAX environment. */
+/* Entry points affected are: DASFM, DASOPR. */
+
+/* - SPICELIB Version 3.0.0, 15-JUN-1994 (KRG) */
+
+/* Modified the umbrella routine DASFM to allow the inclusion of */
+/* a file type in the creation and manipulation of DAS files. */
+
+/* - SPICELIB Version 2.0.0, 11-APR-1994 (HAN) */
+
+/* Updated module to include values for the Silicon Graphics/IRIX, */
+/* DEC Alpha-OSF/1, and Next/Absoft Fortran platforms. Entry */
+/* points affected are: DASFM, DASOPR. */
+
+/* - SPICELIB Version 1.0.0, 15-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* manage open DAS files */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 7.0.0, 28-SEP-2005 (NJB) */
+
+/* Error handling for non-native files was added to */
+/* entry points DASOPR and DASOPW. */
+
+/* Bug in code for constructing long error message in entry */
+/* point DASUFS was corrected. */
+
+/* Local variable DAS was renamed to DASFIL in DASSIH. */
+
+/* - SPICELIB Version 6.0.0, 11-DEC-2001 (NJB) (FST) */
+
+/* Binary File Format Identification: */
+
+/* The file record now contains an 8 character string that */
+/* identifies the binary file format utilized by DAS files. */
+/* The purpose of this string's inclusion in the file record */
+/* is preparatory in nature, to accelerate the migration to */
+/* files that support the runtime translation update that */
+/* is scheduled. */
+
+/* FTP Validation: */
+
+/* The file record now contains a sequence of characters */
+/* commonly corrupted by improper FTP transfers. These */
+/* characters will be examined by the handle manager when */
+/* existing files are opened. */
+
+/* FTIDW and FTIFN have been removed from the elements of */
+/* the DAS file table. Their presence and use in DASUFS */
+/* was causing DASWFR difficulties in updating the internal */
+/* filename under situations where changes to the comment and */
+/* reserved record parameters in the file record were updated. */
+/* This change effects DASOPR, DASOPN, DASONW, DASOPW, and */
+/* DASUFS. */
+
+/* - SPICELIB Version 3.0.0, 15-JUN-1994 (KRG) */
+
+/* Modified the umbrella routine DASFM to allow the inclusion of */
+/* a file type in the creation and manipulation of DAS files. In */
+/* particular, the following changes were made: */
+
+/* 1) Added variable FTYPE to the SUBROUTINE declaration, and */
+/* added appropriate entries for this variable in the */
+/* $Brief_I/O and $ Detailed_Input sections of the header. */
+
+/* 2) Removed erroneous references to OPC from the $ Brief_I/O */
+/* section. */
+
+/* 3) Added a new entry point, DASONW, which will support the */
+/* ability to associate a data type with a new DAS file */
+/* when it is created. The addition of this new entry point */
+/* makes the entry point DASOPN obsolete. */
+
+/* 4) Added a description of the new entry point DASONW to the */
+/* $ Particulars section. Also added a statement that the */
+/* entry point DASOPN has been made obsolete by this new */
+/* entry point, and its use in new code development is */
+/* discouraged. */
+
+/* 5) Added a new variable to the file table, FTIDW, which */
+/* will be used to store the ID words from successfully */
+/* opened DAS files. We need to maintain this information */
+/* when writing the file record, as we do not want to */
+/* modify the ID word in the file. */
+
+/* 6) Removed the parameter DASID as it is no longer needed. */
+
+/* 7) Added new variables TARCH and TTYPE for temporary */
+/* storage of the file architecture and type. Also added a */
+/* new variable FNB for storing the position of the first */
+/* nonblank in a string. */
+
+/* 8) Added new parameters: */
+
+/* ARCLEN The maximum length of a file architecture */
+/* TYPLEN The maximum length of a file type */
+/* MAXPC Decimal value for the upper limit of printable */
+/* ASCII characters. */
+/* MINPC Decimal value for the lower limit of printable */
+/* ASCII characters. */
+
+/* 9) Modified entry points which open DAS files: OPR, OPW, */
+/* OPS, OPN, ONW to support the new file ID word format. */
+
+/* 10) Made all occurrences of error message formatting of */
+/* filenames consistent. All filenames will be single */
+/* quoted in output error messages. */
+
+/* 11) Added a test for a blank filename before the inquire */
+/* to obtain information about a file in the entry points: */
+/* DASOPR, DASOPW, DASONW, and DASOPN. */
+
+/* 12) Modified the description of FTSIZE in the $ Parameters */
+/* section to reflect the possibility of overflowing the */
+/* DAS file table when at least one DAS file had been */
+/* opened with write access. */
+
+/* The problem occurs when the file table is full, the */
+/* number of open DAS files equals FTSIZE, and at least one */
+/* of the open files was opened with write access. If an */
+/* attempt to close a file opened with write access is made */
+/* under these conditions, by calling DASCLS, it will fail. */
+/* DASCLS (via DASSDR) calls DASOPS to open a scratch DAS */
+/* file, but the scratch file CANNOT be opened because the */
+/* file table is full. If this occurs, close a file open */
+/* for read access, or restrict the number of open files */
+/* in use to be at most FTSIZE - 1 when there will be at */
+/* least one file opened with write access. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Access method parameters: */
+
+
+/* File summary parameters: */
+
+/* A DAS file summary has the following structure: */
+
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+/* | | */
+/* +----------------------------------------+ */
+
+
+/* Base indices for: */
+
+/* -- last logical addresses */
+/* -- records containing last descriptor for a given type */
+/* -- word containing last descriptor for a given type */
+
+/* The offset into the file summary for any of these items */
+/* is obtained by adding the appropriate data type parameter */
+/* (DP, INT, or CHAR) to the base index for the item. */
+
+
+/* Descriptor record pointer locations (within descriptor records): */
+
+
+/* Directory address range location parameters: */
+
+
+/* First descriptor position in descriptor record: */
+
+
+/* Length of the Binary File Format string: */
+
+
+/* The parameter TAILEN determines the tail length of a DAS file */
+/* record. This is the number of bytes (characters) that */
+/* occupy the portion of the file record that follows the */
+/* integer holding the first free address. For environments */
+/* with a 32 bit word length, 1 byte characters, and DAS */
+/* record sizes of 1024 bytes, we have: */
+
+/* 8 bytes - IDWORD */
+/* 60 bytes - IFNAME */
+/* 4 bytes - NRESVR (32 bit integer) */
+/* 4 bytes - NRESVC (32 bit integer) */
+/* 4 bytes - NCOMR (32 bit integer) */
+/* + 4 bytes - NCOMC (32 bit integer) */
+/* --------- */
+/* 84 bytes - (All file records utilize this space.) */
+
+/* So the size of the remaining portion (or tail) of the DAS */
+/* file record for computing enviroments as described above */
+/* would be: */
+
+/* 1024 bytes - DAS record size */
+/* - 8 bytes - DAS Binary File Format Word */
+/* - 84 bytes - (from above) */
+/* ------------ */
+/* 932 bytes - DAS file record tail length */
+
+/* Note: environments that do not have a 32 bit word length, */
+/* 1 byte characters, and a DAS record size of 1024 bytes, will */
+/* require the adjustment of this parameter. */
+
+
+/* Local variables */
+
+
+/* The file table consists of a set of arrays which serve as */
+/* `columns' of the table. The sets of elements having the same */
+/* index in the arrays form the `rows' of the table. Each column */
+/* contains a particular type of information; each row contains */
+/* all of the information pertaining to a particular DAS file. */
+
+/* All column names in the file table begin with `FT'. The */
+/* columns are: */
+
+/* HAN Handle */
+/* LUN Logical unit */
+/* ACC Access method */
+/* LNK Number of links */
+/* SUM File summary */
+
+/* The rows of the file table are indexed by a doubly linked */
+/* list pool. The pool contains an active list and a free list. */
+/* when a file is opened, a pointer to the file (the pointer */
+/* is called a `node'). it is placed at the head of the active */
+/* list; when a file is closed, the node in the active list that */
+/* pointed to the file is placed on the free list. */
+
+/* NEXT is incremented each time a file is opened to become the */
+/* next file handle assigned. */
+
+
+/* FTHEAD is a pointer to the head of the active file list. */
+
+
+/* NEXT and PREV map the DAS data type codes to their */
+/* successors and predecessors, respectively. */
+
+
+/* Length of binary file format name. */
+
+
+/* Number of binary file formats. */
+
+
+/* Other local variables */
+
+
+/* Save everything between calls. */
+
+
+/* Initial values */
+
+ /* Parameter adjustments */
+ if (lastla) {
+ }
+ if (lastrc) {
+ }
+ if (lastwd) {
+ }
+ if (fhset) {
+ }
+
+ /* Function Body */
+ switch(n__) {
+ case 1: goto L_dasopr;
+ case 2: goto L_dasopw;
+ case 3: goto L_dasonw;
+ case 4: goto L_dasopn;
+ case 5: goto L_dasops;
+ case 6: goto L_dasllc;
+ case 7: goto L_dashfs;
+ case 8: goto L_dasufs;
+ case 9: goto L_dashlu;
+ case 10: goto L_dasluh;
+ case 11: goto L_dashfn;
+ case 12: goto L_dasfnh;
+ case 13: goto L_dashof;
+ case 14: goto L_dassih;
+ case 15: goto L_dasham;
+ }
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASFM", (ftnlen)5);
+ sigerr_("SPICE(BOGUSENTRY)", (ftnlen)17);
+ chkout_("DASFM", (ftnlen)5);
+ }
+ return 0;
+/* $Procedure DASOPR ( DAS, open for read ) */
+
+L_dasopr:
+/* $ Abstract */
+
+/* Open a DAS file for reading. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) FNAME */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I Name of a DAS file to be opened. */
+/* HANDLE O Handle assigned to the opened DAS file. */
+
+/* $ Detailed_Input */
+
+/* FNAME is the name of a DAS file to be opened with read */
+/* access. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the handle that is associated with the file. This */
+/* handle is used to identify the file in subsequent */
+/* calls to other DAS routines. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input filename is blank, the error SPICE(BLANKFILENAME) */
+/* will be signaled. */
+
+/* 2) If the specified file does not exist, the error */
+/* SPICE(FILENOTFOUND) will be signaled. */
+
+/* 3) If the specified file has already been opened for read */
+/* access, the handle already associated with the file is */
+/* returned. */
+
+/* 4) If the specified file has already been opened for write */
+/* access, the error SPICE(DASRWCONFLICT) is signaled. */
+
+/* 5) If the specified file has already been opened by a non-DAS */
+/* routine, the error SPICE(DASIMPROPOPEN) is signaled. */
+
+/* 6) If the specified file cannot be opened without exceeding */
+/* the maximum allowed number of open DAS files, the error */
+/* SPICE(DASFTFULL) is signaled. */
+
+/* 7) If the named file cannot be opened properly, the error */
+/* SPICE(DASOPENFAIL) is signaled. */
+
+/* 8) If the file record cannot be read, the error */
+/* SPICE(FILEREADFAILED) will be signaled. */
+
+/* 9) If the specified file is not a DAS file, as indicated by the */
+/* file's ID word, the error SPICE(NOTADASFILE) is signaled. */
+
+/* 10) If no logical units are available, the error will be */
+/* signaled by routines called by this routine. */
+
+/* $ Files */
+
+/* See argument FNAME. */
+
+/* $ Particulars */
+
+/* Most DAS files require only read access. If you do not need to */
+/* change the contents of a file, you should open it using DASOPR. */
+
+/* $ Examples */
+
+/* 1) Open the existing DAS file TEST.DAS for reading. */
+
+/* CALL DASOPR ( 'TEST.DAS', HANDLE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 7.0.0, 28-SEP-2005 (NJB) */
+
+/* Error handling for non-native files was added. */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 6.0.0, 14-DEC-2001 (FST) */
+
+/* The DAS file ID word and internal file name are no longer */
+/* buffered by this routine. See DASFM's Revisions section */
+/* for details. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 3.0.0, 15-JUN-1994 (KRG) */
+
+/* Modified the entry point to use the new file ID format which */
+/* contains a mnemonic code for the data type. Added error */
+/* checks on file names. Fixed bug involving use of sign of */
+/* file handles. Improved some error messages. (delete rest) */
+
+/* - SPICELIB Version 2.0.0, 11-APR-1994 (HAN) */
+
+/* Updated module to include values for the Silicon Graphics/IRIX, */
+/* DEC Alpha-OSF/1, and Next/Absoft Fortran platforms. Entry */
+/* points affected are: DASFM, DASOPR. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* open a DAS file for reading */
+/* open a DAS file for read access */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 7.0.0, 28-SEP-2005 (NJB) */
+
+/* Error handling for non-native files was added. */
+
+/* - SPICELIB Version 3.0.1, 24-APR-2003 (EDW) */
+
+/* Added MAC-OSX-F77 to the list of platforms */
+/* that require READONLY to read write protected */
+/* kernels. */
+
+/* - SPICELIB Version 3.0.0, 15-JUN-1994 (KRG) */
+
+/* Modified the entry point to use the new file ID format which */
+/* contains a mnemonic code for the data type. */
+
+/* Split an IF ... ELSE IF ... statement into 2 IF statements of */
+/* equivalent behavior to allow testing of the file architecture. */
+
+/* Added code to test the file architecture and to verify that the */
+/* file is a DAS file. */
+
+/* Removed the error SPICE(DASNOIDWORD) as it was no longer */
+/* relevant. */
+
+/* Added the error SPICE(NOTADASFILE) if this routine is called */
+/* with a file that does not contain an ID word identifying the */
+/* file as a DAS file. */
+
+/* Added a test for a blank filename before attempting to use the */
+/* filename in the routine. If the filename is blank, the error */
+/* SPICE(BLANKFILENAME) will be signaled. */
+
+/* Fixed a bug when dealing with a read/write open conflict for */
+/* DAS files: the code used the DAF positive/negative handle */
+/* method to determine read/write access rather than the DAS file */
+/* table column FTACC. Replaced the code: */
+
+/* IF ( FTHAN(FINDEX) .LT. 0 ) THEN */
+
+/* with */
+
+/* IF ( FTACC(FINDEX) .EQ. WRITE ) THEN */
+
+/* Changed the long error message when the error */
+/* SPICE(NOTADASFILE) is signaled to suggest that a common error */
+/* is attempting to use a text version of the desired file rather */
+/* than the binary version. */
+
+/* - SPICELIB Version 2.0.0, 11-APR-1994 (HAN) */
+
+/* Updated module to include values for the Silicon Graphics/IRIX, */
+/* DEC Alpha-OSF/1, and Next/Absoft Fortran platforms. Entry */
+/* points affected are: DASFM, DASOPR. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASOPR", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+
+/* Check to see whether the filename is blank. If it is, signal an */
+/* error, check out, and return. */
+
+ if (s_cmp(fname, " ", fname_len, (ftnlen)1) == 0) {
+ setmsg_("The file name is blank. ", (ftnlen)24);
+ sigerr_("SPICE(BLANKFILENAME)", (ftnlen)20);
+ chkout_("DASOPR", (ftnlen)6);
+ return 0;
+ }
+
+/* If the file doesn't exist, we can't continue. */
+
+ if (! exists_(fname, rtrim_(fname, fname_len))) {
+ setmsg_("The file '#' was not found.", (ftnlen)27);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(FILENOTFOUND)", (ftnlen)19);
+ chkout_("DASOPR", (ftnlen)6);
+ return 0;
+ }
+
+/* The file may or may not already be open. If so, it should have */
+/* not been opened for writing FTACC .EQ. WRITE. If opened for */
+/* reading, just increment the number of links and return the handle. */
+/* If opened elsewhere, panic. */
+
+ ioin__1.inerr = 0;
+ ioin__1.infilen = rtrim_(fname, fname_len);
+ ioin__1.infile = fname;
+ ioin__1.inex = 0;
+ ioin__1.inopen = &opened;
+ ioin__1.innum = &number;
+ ioin__1.innamed = 0;
+ ioin__1.inname = 0;
+ ioin__1.inacc = 0;
+ ioin__1.inseq = 0;
+ ioin__1.indir = 0;
+ ioin__1.infmt = 0;
+ ioin__1.inform = 0;
+ ioin__1.inunf = 0;
+ ioin__1.inrecl = 0;
+ ioin__1.innrec = 0;
+ ioin__1.inblank = 0;
+ f_inqu(&ioin__1);
+ if (opened) {
+
+/* Peruse the `unit' column of the file table; see whether this */
+/* unit is present. */
+
+ findex = fthead;
+ found = FALSE_;
+ while(! found && findex > 0) {
+ if (ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftlun", i__1, "dasfm_", (ftnlen)1412)] == number) {
+ found = TRUE_;
+ } else {
+ findex = lnknxt_(&findex, pool);
+ }
+ }
+ if (found) {
+ if (ftacc[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftacc", i__1, "dasfm_", (ftnlen)1422)] == 2) {
+ setmsg_("'#' already opened for write access.", (ftnlen)36);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(DASRWCONFLICT)", (ftnlen)20);
+ chkout_("DASOPR", (ftnlen)6);
+ return 0;
+ } else {
+
+/* The file is open for read access. Increment the number */
+/* of links to this file. */
+
+ ftlnk[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftlnk", i__1, "dasfm_", (ftnlen)1435)] = ftlnk[(i__2
+ = findex - 1) < 21 && 0 <= i__2 ? i__2 : s_rnge("ftl"
+ "nk", i__2, "dasfm_", (ftnlen)1435)] + 1;
+ *handle = fthan[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 :
+ s_rnge("fthan", i__1, "dasfm_", (ftnlen)1436)];
+ }
+ } else {
+
+/* The file is open, but it wasn't opened by DAS routines. */
+
+ setmsg_("'#' is already connected to unit #.", (ftnlen)35);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &number, (ftnlen)1);
+ sigerr_("SPICE(DASIMPROPOPEN)", (ftnlen)20);
+ chkout_("DASOPR", (ftnlen)6);
+ return 0;
+ }
+
+/* If it hasn't been opened, it needs to be, but only if there */
+/* is room for another file. */
+
+ } else if (lnknfn_(pool) == 0) {
+ setmsg_("The file table is full, with # entries. Could not open '#'.",
+ (ftnlen)59);
+ errint_("#", &c__21, (ftnlen)1);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(DASFTFULL)", (ftnlen)16);
+ chkout_("DASOPR", (ftnlen)6);
+ return 0;
+
+/* To open for reading: get a free unit, open the file, get the */
+/* internal file name, and increment the number of links. */
+
+/* Look out for: */
+
+/* -- No free logical units. */
+
+/* -- Error opening the file. */
+
+/* -- No ID word in the first record. */
+
+ } else {
+ getlun_(&number);
+ if (failed_()) {
+ chkout_("DASOPR", (ftnlen)6);
+ return 0;
+ }
+ o__1.oerr = 1;
+ o__1.ounit = number;
+ o__1.ofnmlen = rtrim_(fname, fname_len);
+ o__1.ofnm = fname;
+ o__1.orl = 1024;
+ o__1.osta = "OLD";
+ o__1.oacc = "DIRECT";
+ o__1.ofm = 0;
+ o__1.oblnk = 0;
+ iostat = f_open(&o__1);
+ if (iostat != 0) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("Attempt to open file '#' failed. Value of IOSTAT was #.",
+ (ftnlen)55);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASOPENFAIL)", (ftnlen)18);
+ chkout_("DASOPR", (ftnlen)6);
+ return 0;
+ } else {
+
+/* Try to determine the binary file format of this file. */
+
+ zzddhppf_(&number, &c__2, &bff);
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DASOPR", (ftnlen)6);
+ return 0;
+ }
+
+/* Find the local binary file format. */
+
+ zzplatfm_("FILE_FORMAT", locfmt, (ftnlen)11, (ftnlen)8);
+
+/* Compare binary format to local format. These must match. */
+
+ if (bff != isrchc_(locfmt, &c__4, bfflst, (ftnlen)8, (ftnlen)8)) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ s_copy(lngmsg, "File '#' has the non-native binary format #."
+ " The SPICE Toolkit does not support reading non-nati"
+ "ve files, such as E-kernels, that are based on SPICE"
+ "'s DAS architecture. To port a DAS file between plat"
+ "forms having incompatible binary formats, for exampl"
+ "e big-endian (Sun) vs little-endian (PC), use the SP"
+ "ICE utility toxfr to create a transfer format versio"
+ "n of the file, then move (ftp) the transfer file in "
+ "ASCII mode. You will need to perform line terminator"
+ " conversion when moving files between Windows and Un"
+ "ix systems if the ASCII mode of ftp is unavailable; "
+ "the freeware utilities dos2unix and unix2dos are mea"
+ "ns for doing this. Then transform the file to binary"
+ " format on the target system using the SPICE utility"
+ " tobin. See the SPICE document convert.ug for detail"
+ "s on using the SPICE utility programs.", (ftnlen)1840,
+ (ftnlen)810);
+ setmsg_(lngmsg, (ftnlen)1840);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errch_("#", bfflst + (((i__1 = bff - 1) < 4 && 0 <= i__1 ?
+ i__1 : s_rnge("bfflst", i__1, "dasfm_", (ftnlen)1556))
+ << 3), (ftnlen)1, (ftnlen)8);
+ sigerr_("SPICE(NONNATIVEFILE)", (ftnlen)20);
+ chkout_("DASOPR", (ftnlen)6);
+ return 0;
+ }
+ io___22.ciunit = number;
+ iostat = s_rdue(&io___22);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, idword, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, locifn, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&locrrc, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&locrch, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&loccrc, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&loccch, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rdue();
+L100001:
+ if (iostat != 0) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("Could not read file record. File was '#'. IOSTAT "
+ "was #.", (ftnlen)57);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DASOPR", (ftnlen)6);
+ return 0;
+ }
+
+/* Check the ID word to see if we have opened a DAS file. First */
+/* separate the ID word into its components and verify that we */
+/* are looking at a DAS file. If we're not, then this routine */
+/* should not be used. */
+
+ idw2at_(idword, tarch, ttype, (ftnlen)8, (ftnlen)3, (ftnlen)4);
+ if (s_cmp(tarch, "DAS", (ftnlen)3, (ftnlen)3) != 0) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("File '#' is not a DAS file. A common error is attem"
+ "pting to open a text version of the file rather than"
+ " the binary version of the file.", (ftnlen)135);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(NOTADASFILE)", (ftnlen)18);
+ chkout_("DASOPR", (ftnlen)6);
+ return 0;
+ }
+
+/* At this point, we know that we have a valid DAS file, and */
+/* we're set up to read from it, so ... */
+
+/* Update the file table to include information about */
+/* our newly opened DAS file. Link the information */
+/* for this file at the head of the file table list. */
+
+/* Set the output argument HANDLE as well. */
+
+ lnkan_(pool, &new__);
+ lnkilb_(&new__, &fthead, pool);
+ fthead = new__;
+ ++nxthan;
+ fthan[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fth"
+ "an", i__1, "dasfm_", (ftnlen)1622)] = nxthan;
+ ftlun[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftl"
+ "un", i__1, "dasfm_", (ftnlen)1623)] = number;
+ ftacc[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fta"
+ "cc", i__1, "dasfm_", (ftnlen)1624)] = 1;
+ ftlnk[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftl"
+ "nk", i__1, "dasfm_", (ftnlen)1625)] = 1;
+
+/* Fill in the file summary. We already know how many */
+/* reserved records and comment records there are. To find */
+/* the number of the first free record, the last logical */
+/* address of each type, and the locations of the last */
+/* descriptors of each type, we must examine the directory */
+/* records. Note that we do not assume that the data records */
+/* in the DAS file have been segregated: we could be */
+/* restoring a DAS file whose creation was interrupted. */
+
+ cleari_(&c__14, &ftsum[(i__1 = fthead * 14 - 14) < 294 && 0 <=
+ i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (ftnlen)
+ 1637)]);
+ ftsum[(i__1 = fthead * 14 - 14) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)1639)] = locrrc;
+ ftsum[(i__1 = fthead * 14 - 13) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)1640)] = locrch;
+ ftsum[(i__1 = fthead * 14 - 12) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)1641)] = loccrc;
+ ftsum[(i__1 = fthead * 14 - 11) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)1642)] = loccch;
+
+/* We'll find the values for each data type separately. */
+
+ for (type__ = 1; type__ <= 3; ++type__) {
+
+/* The first directory record is located right after the */
+/* last comment record. */
+
+ nrec = locrrc + loccrc + 2;
+
+/* Keep track of the record number of the last data */
+/* record of the current type. */
+
+ ldrec[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "ldrec", i__1, "dasfm_", (ftnlen)1658)] = 0;
+
+/* Find the last directory containing a descriptor of a */
+/* record cluster of the current type. */
+
+ dasioi_("READ", &number, &nrec, dirrec, (ftnlen)4);
+ maxadr = dirrec[(i__1 = (type__ << 1) + 1) < 256 && 0 <= i__1
+ ? i__1 : s_rnge("dirrec", i__1, "dasfm_", (ftnlen)
+ 1666)];
+ nxtdir = dirrec[1];
+ while(nxtdir > 0) {
+
+/* Read the directory record. If this record contains */
+/* descriptors for clusters we're interested in, update */
+/* the directory record number. */
+
+ dasioi_("READ", &number, &nxtdir, dirrec, (ftnlen)4);
+ if (dirrec[(i__1 = (type__ << 1) + 1) < 256 && 0 <= i__1 ?
+ i__1 : s_rnge("dirrec", i__1, "dasfm_", (ftnlen)
+ 1678)] > 0) {
+ maxadr = dirrec[(i__1 = (type__ << 1) + 1) < 256 && 0
+ <= i__1 ? i__1 : s_rnge("dirrec", i__1, "das"
+ "fm_", (ftnlen)1679)];
+ nrec = nxtdir;
+ }
+ nxtdir = dirrec[1];
+ }
+
+/* At this point, NREC is the record number of the directory */
+/* containing the last descriptor for clusters of TYPE, if */
+/* there are any such descriptors. */
+
+/* MAXADR is the maximum logical address of TYPE. */
+
+ ftsum[(i__1 = type__ + 5 + fthead * 14 - 15) < 294 && 0 <=
+ i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (ftnlen)
+ 1694)] = maxadr;
+ if (maxadr > 0) {
+ ftsum[(i__1 = type__ + 8 + fthead * 14 - 15) < 294 && 0 <=
+ i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (
+ ftnlen)1697)] = nrec;
+ } else {
+ ftsum[(i__1 = type__ + 8 + fthead * 14 - 15) < 294 && 0 <=
+ i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (
+ ftnlen)1699)] = 0;
+ }
+
+/* We still need to set the word location of the final */
+/* descriptor of TYPE, if there are any descriptors of TYPE. */
+
+ if (maxadr > 0) {
+
+/* Re-read the directory record containing the last */
+/* descriptor of the current type. */
+
+ dasioi_("READ", &number, &nrec, dirrec, (ftnlen)4);
+
+/* Traverse the directory record, looking for the last */
+/* descriptor of TYPE. We'll keep track of the maximum */
+/* logical address of TYPE for each cluster of TYPE */
+/* whose descriptor we examine. When this value is */
+/* the maximum logical address of TYPE, we've found */
+/* the last descriptor of TYPE. */
+
+/* Also keep track of the end record numbers for each */
+/* cluster. */
+
+ last = dirrec[(i__1 = type__ << 1) < 256 && 0 <= i__1 ?
+ i__1 : s_rnge("dirrec", i__1, "dasfm_", (ftnlen)
+ 1722)] - 1;
+ dsctyp = dirrec[8];
+ prvtyp = prev[(i__1 = dsctyp - 1) < 3 && 0 <= i__1 ? i__1
+ : s_rnge("prev", i__1, "dasfm_", (ftnlen)1724)];
+ endrec = nrec;
+ pos = 9;
+ while(last < maxadr) {
+ ++pos;
+ if (dirrec[(i__1 = pos - 1) < 256 && 0 <= i__1 ? i__1
+ : s_rnge("dirrec", i__1, "dasfm_", (ftnlen)
+ 1732)] > 0) {
+ curtyp = next[(i__1 = prvtyp - 1) < 3 && 0 <=
+ i__1 ? i__1 : s_rnge("next", i__1, "dasf"
+ "m_", (ftnlen)1733)];
+ } else {
+ curtyp = prev[(i__1 = prvtyp - 1) < 3 && 0 <=
+ i__1 ? i__1 : s_rnge("prev", i__1, "dasf"
+ "m_", (ftnlen)1735)];
+ }
+ if (curtyp == type__) {
+ last += nw[(i__1 = type__ - 1) < 3 && 0 <= i__1 ?
+ i__1 : s_rnge("nw", i__1, "dasfm_", (
+ ftnlen)1739)] * (i__3 = dirrec[(i__2 =
+ pos - 1) < 256 && 0 <= i__2 ? i__2 :
+ s_rnge("dirrec", i__2, "dasfm_", (ftnlen)
+ 1739)], abs(i__3));
+ }
+ endrec += (i__2 = dirrec[(i__1 = pos - 1) < 256 && 0
+ <= i__1 ? i__1 : s_rnge("dirrec", i__1, "das"
+ "fm_", (ftnlen)1742)], abs(i__2));
+ prvtyp = curtyp;
+ }
+
+/* At this point, POS is the word position of the last */
+/* descriptor of TYPE, and ENDREC is the record number */
+/* of the last data record of TYPE. */
+
+ ftsum[(i__1 = type__ + 11 + fthead * 14 - 15) < 294 && 0
+ <= i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (
+ ftnlen)1751)] = pos;
+ ldrec[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("ldrec", i__1, "dasfm_", (ftnlen)1752)] =
+ endrec;
+ } else {
+
+/* There's no data of TYPE in the file. */
+
+ ftsum[(i__1 = type__ + 11 + fthead * 14 - 15) < 294 && 0
+ <= i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (
+ ftnlen)1759)] = 0;
+ ldrec[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("ldrec", i__1, "dasfm_", (ftnlen)1760)] =
+ 0;
+ }
+ }
+
+/* We're almost done; we need to find the number of the first */
+/* free record. This record follows all of the data records */
+/* and all of the directory records. It may happen that the */
+/* last record in use is an empty directory. */
+
+ maxai_(ldrec, &c__3, &ldrmax, &loc);
+ nrec = locrrc + loccrc + 2;
+ dasioi_("READ", &number, &nrec, dirrec, (ftnlen)4);
+ nxtrec = dirrec[1];
+ while(nxtrec != 0) {
+ nrec = nxtrec;
+ dasioi_("READ", &number, &nrec, dirrec, (ftnlen)4);
+ nxtrec = dirrec[1];
+ }
+
+/* Now NREC is the last directory record. */
+
+ ftsum[(i__1 = fthead * 14 - 10) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)1795)] = max(
+ ldrmax,nrec) + 1;
+
+/* Insert the new handle into our handle set. */
+
+ *handle = fthan[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 :
+ s_rnge("fthan", i__1, "dasfm_", (ftnlen)1800)];
+ insrti_(handle, fhlist);
+ }
+ }
+ chkout_("DASOPR", (ftnlen)6);
+ return 0;
+/* $Procedure DASOPW ( DAS, open for write ) */
+
+L_dasopw:
+/* $ Abstract */
+
+/* Open a DAS file for writing. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) FNAME */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I Name of a DAS file to be opened. */
+/* HANDLE O Handle assigned to the opened DAS file. */
+
+/* $ Detailed_Input */
+
+/* FNAME is the name of a DAS file to be opened with write */
+/* access. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the handle that is associated with the file. This */
+/* handle is used to identify the file in subsequent */
+/* calls to other DAS routines. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input filename is blank, the error SPICE(BLANKFILENAME) */
+/* will be signaled. */
+
+/* 2) If the specified file does not exist, the error */
+/* SPICE(FILENOTFOUND) will be signaled. */
+
+/* 3) If the specified file has already been opened, either by */
+/* the DAS file routines or by other code, the error */
+/* SPICE(DASOPENCONFLICT) is signaled. Note that this */
+/* response is not paralleled by DASOPR, which allows you */
+/* to open a DAS file for reading even if it is already open for */
+/* reading. */
+
+/* 4) If the specified file cannot be opened without exceeding */
+/* the maximum allowed number of open DAS files, the error */
+/* SPICE(DASFTFULL) is signaled. */
+
+/* 5) If the specified file cannot be opened properly, the error */
+/* SPICE(DASOPENFAIL) is signaled. */
+
+/* 6) If the file record cannot be read, the error */
+/* SPICE(FILEREADFAILED) will be signaled. */
+
+/* 7) If the specified file is not a DAS file, as indicated by the */
+/* file's ID word, the error SPICE(NOTADASFILE) is signaled. */
+
+/* 8) If no logical units are available, the error will be */
+/* signaled by routines called by this routine. */
+
+/* $ Files */
+
+/* See argument FNAME. */
+
+/* $ Particulars */
+
+/* Most DAS files require only read access. If you do not need to */
+/* change the contents of a file, you should open it with DASOPR. */
+
+/* $ Examples */
+
+/* 1) Open the existing DAS file TEST.DAS in order to add data */
+/* to it. */
+
+/* CALL DASOPW ( 'TEST.DAS', HANDLE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 7.0.0, 28-SEP-2005 (NJB) */
+
+/* Error handling for non-native files was added. */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 6.0.0, 14-DEC-2001 (FST) */
+
+/* The DAS file ID word and internal file name are no longer */
+/* buffered by this routine. See DASFM's Revisions section */
+/* for details. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 2.0.0, 29-OCT-1993 (KRG) */
+
+/* Modified the entry point to use the new file ID format which */
+/* contains a mnemonic code for the data type. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* open a DAS file for writing */
+/* open a DAS file for write access */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 7.0.0, 28-SEP-2005 (NJB) */
+
+/* Error handling for non-native files was added. */
+
+/* - SPICELIB Version 2.0.0, 29-OCT-1993 (KRG) */
+
+/* Modified the entry point to use the new file ID format which */
+/* contains a mnemonic code for the data type. */
+
+/* Split an IF ... ELSE IF ... statement into 2 IF statements of */
+/* equivalent behavior to allow testing of the file architecture. */
+
+/* Added code to test the file architecture and to verify that the */
+/* file is a DAS file. */
+
+/* Removed the error SPICE(DASNOIDWORD) as it was no longer */
+/* relevant. */
+
+/* Added the error SPICE(NOTADASFILE) if this routine is called */
+/* with a file that does not contain an ID word identifying the */
+/* file as a DAF file. */
+
+/* Added a test for a blank filename before attempting to use the */
+/* filename in the routine. If the filename is blank, the error */
+/* SPICE(BLANKFILENAME) will be signaled. */
+
+/* Changed the long error message when the error */
+/* SPICE(NOTADASFILE) is signaled to suggest that a common error */
+/* is attempting to load a text version of the desired file rather */
+/* than the binary version. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASOPW", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+
+/* Check to see whether the filename is blank. If it is, signal an */
+/* error, check out, and return. */
+
+ if (s_cmp(fname, " ", fname_len, (ftnlen)1) == 0) {
+ setmsg_("The file name is blank. ", (ftnlen)24);
+ sigerr_("SPICE(BLANKFILENAME)", (ftnlen)20);
+ chkout_("DASOPW", (ftnlen)6);
+ return 0;
+ }
+
+/* If the file doesn't exist, we can't continue. */
+
+ if (! exists_(fname, rtrim_(fname, fname_len))) {
+ setmsg_("The file '#' was not found.", (ftnlen)27);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(FILENOTFOUND)", (ftnlen)19);
+ chkout_("DASOPW", (ftnlen)6);
+ return 0;
+ }
+
+/* A file may not be opened for writing if it is already open. */
+
+ ioin__1.inerr = 0;
+ ioin__1.infilen = rtrim_(fname, fname_len);
+ ioin__1.infile = fname;
+ ioin__1.inex = 0;
+ ioin__1.inopen = &opened;
+ ioin__1.innum = &number;
+ ioin__1.innamed = 0;
+ ioin__1.inname = 0;
+ ioin__1.inacc = 0;
+ ioin__1.inseq = 0;
+ ioin__1.indir = 0;
+ ioin__1.infmt = 0;
+ ioin__1.inform = 0;
+ ioin__1.inunf = 0;
+ ioin__1.inrecl = 0;
+ ioin__1.innrec = 0;
+ ioin__1.inblank = 0;
+ f_inqu(&ioin__1);
+ if (opened) {
+ setmsg_("File '#' already opened.", (ftnlen)24);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(DASOPENCONFLICT)", (ftnlen)22);
+ chkout_("DASOPW", (ftnlen)6);
+ return 0;
+
+/* If it hasn't been opened, it needs to be, but only if there */
+/* is room for another file. */
+
+ } else if (lnknfn_(pool) == 0) {
+ setmsg_("The file table is full, with # entries. Could not open '#'.",
+ (ftnlen)59);
+ errint_("#", &c__21, (ftnlen)1);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(DASFTFULL)", (ftnlen)16);
+ chkout_("DASOPW", (ftnlen)6);
+ return 0;
+
+/* To open for writing: get a free unit, open the file, get the */
+/* internal file name, and set the number of links to one. */
+
+/* Look out for: */
+
+/* -- No free logical units. */
+
+/* -- Error opening the file. */
+
+ } else {
+ getlun_(&number);
+ if (failed_()) {
+ chkout_("DASOPW", (ftnlen)6);
+ return 0;
+ }
+ o__1.oerr = 1;
+ o__1.ounit = number;
+ o__1.ofnmlen = rtrim_(fname, fname_len);
+ o__1.ofnm = fname;
+ o__1.orl = 1024;
+ o__1.osta = "OLD";
+ o__1.oacc = "DIRECT";
+ o__1.ofm = 0;
+ o__1.oblnk = 0;
+ iostat = f_open(&o__1);
+ if (iostat != 0) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("Attempt to open file '#' failed. Value of IOSTAT was #.",
+ (ftnlen)55);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASOPENFAIL)", (ftnlen)18);
+ chkout_("DASOPW", (ftnlen)6);
+ return 0;
+ } else {
+
+/* Try to determine the binary file format of this file. */
+
+ zzddhppf_(&number, &c__2, &bff);
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ chkout_("DASOPW", (ftnlen)6);
+ return 0;
+ }
+
+/* Find the local binary file format. */
+
+ zzplatfm_("FILE_FORMAT", locfmt, (ftnlen)11, (ftnlen)8);
+
+/* Compare binary format to local format. These must match. */
+
+ if (bff != isrchc_(locfmt, &c__4, bfflst, (ftnlen)8, (ftnlen)8)) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ s_copy(lngmsg, "File '#' has the non-native binary format #."
+ " The SPICE Toolkit does not support writing to non-n"
+ "ative files, such as E-kernels, that are based on SP"
+ "ICE's DAS architecture. To port a DAS file between p"
+ "latforms having incompatible binary formats, for exa"
+ "mple big-endian (Sun) vs little-endian (PC), use the"
+ " SPICE utility toxfr to create a transfer format ver"
+ "sion of the file, then move (ftp) the transfer file "
+ "in ASCII mode. You will need to perform line termina"
+ "tor conversion when moving files between Windows and"
+ " Unix systems if the ASCII mode of ftp is unavailabl"
+ "e; the freeware utilities dos2unix and unix2dos are "
+ "means for doing this. Then transform the file to bin"
+ "ary format on the target system using the SPICE util"
+ "ity tobin. See the SPICE document convert.ug for det"
+ "ails on using the SPICE utility programs.", (ftnlen)
+ 1840, (ftnlen)813);
+ setmsg_(lngmsg, (ftnlen)1840);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errch_("#", bfflst + (((i__1 = bff - 1) < 4 && 0 <= i__1 ?
+ i__1 : s_rnge("bfflst", i__1, "dasfm_", (ftnlen)2199))
+ << 3), (ftnlen)1, (ftnlen)8);
+ sigerr_("SPICE(NONNATIVEFILE)", (ftnlen)20);
+ chkout_("DASOPW", (ftnlen)6);
+ return 0;
+ }
+
+/* Read the file record. */
+
+ io___48.ciunit = number;
+ iostat = s_rdue(&io___48);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, idword, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, locifn, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&locrrc, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&locrch, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&loccrc, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&loccch, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_rdue();
+L100002:
+ if (iostat != 0) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("Could not read file record. File was '#'. IOSTAT "
+ "was #.", (ftnlen)57);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DASOPW", (ftnlen)6);
+ return 0;
+ }
+
+/* Check the ID word to see if we have opened a DAS file. First */
+/* separate the ID word into its components and verify that we */
+/* are looking at a DAS file. If we're not, then this routine */
+/* should not be used. */
+
+ idw2at_(idword, tarch, ttype, (ftnlen)8, (ftnlen)3, (ftnlen)4);
+ if (s_cmp(tarch, "DAS", (ftnlen)3, (ftnlen)3) != 0) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("File '#' is not a DAS file. A common error is attem"
+ "pting to open a text version of the file rather than"
+ " the binary version of the file.", (ftnlen)135);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(NOTADASFILE)", (ftnlen)18);
+ chkout_("DASOPW", (ftnlen)6);
+ return 0;
+ }
+
+/* At this point, we know that we have a valid DAS file, and */
+/* we're set up to read from it, so ... */
+
+/* Update the file table to include information about */
+/* our newly opened DAS file. Link the information */
+/* for this file at the head of the file table list. */
+
+/* Set the output argument HANDLE as well. */
+
+ lnkan_(pool, &new__);
+ lnkilb_(&new__, &fthead, pool);
+ fthead = new__;
+ ++nxthan;
+ fthan[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fth"
+ "an", i__1, "dasfm_", (ftnlen)2270)] = nxthan;
+ ftlun[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftl"
+ "un", i__1, "dasfm_", (ftnlen)2271)] = number;
+ ftacc[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fta"
+ "cc", i__1, "dasfm_", (ftnlen)2272)] = 2;
+ ftlnk[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftl"
+ "nk", i__1, "dasfm_", (ftnlen)2273)] = 1;
+
+/* Fill in the file summary. We already know how many */
+/* reserved records and comment records there are. To find */
+/* the number of the first free record, the last logical */
+/* address of each type, and the locations of the last */
+/* descriptors of each type, we must examine the directory */
+/* records. Note that we do not assume that the data records */
+/* in the DAS file have been segregated: we could be */
+/* restoring a DAS file whose creation was interrupted. */
+
+ cleari_(&c__14, &ftsum[(i__1 = fthead * 14 - 14) < 294 && 0 <=
+ i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (ftnlen)
+ 2285)]);
+ ftsum[(i__1 = fthead * 14 - 14) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)2287)] = locrrc;
+ ftsum[(i__1 = fthead * 14 - 13) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)2288)] = locrch;
+ ftsum[(i__1 = fthead * 14 - 12) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)2289)] = loccrc;
+ ftsum[(i__1 = fthead * 14 - 11) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)2290)] = loccch;
+
+/* We'll find the values for each data type separately. */
+
+ for (type__ = 1; type__ <= 3; ++type__) {
+
+/* The first directory record is located right after the */
+/* last comment record. The directory may be empty. */
+
+ nrec = locrrc + loccrc + 2;
+
+/* Keep track of the record number of the last data */
+/* record of the current type. */
+
+ ldrec[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "ldrec", i__1, "dasfm_", (ftnlen)2306)] = 0;
+
+/* Find the last directory containing a descriptor of a */
+/* record cluster of the current type. */
+
+ dasioi_("READ", &number, &nrec, dirrec, (ftnlen)4);
+ maxadr = dirrec[(i__1 = (type__ << 1) + 1) < 256 && 0 <= i__1
+ ? i__1 : s_rnge("dirrec", i__1, "dasfm_", (ftnlen)
+ 2314)];
+ nxtdir = dirrec[1];
+ while(nxtdir > 0) {
+
+/* Read the directory record. If this record contains */
+/* descriptors for clusters we're interested in, update */
+/* the directory record number. */
+
+ dasioi_("READ", &number, &nxtdir, dirrec, (ftnlen)4);
+ if (dirrec[(i__1 = (type__ << 1) + 1) < 256 && 0 <= i__1 ?
+ i__1 : s_rnge("dirrec", i__1, "dasfm_", (ftnlen)
+ 2326)] > 0) {
+ maxadr = dirrec[(i__1 = (type__ << 1) + 1) < 256 && 0
+ <= i__1 ? i__1 : s_rnge("dirrec", i__1, "das"
+ "fm_", (ftnlen)2327)];
+ nrec = nxtdir;
+ }
+ nxtdir = dirrec[1];
+ }
+
+/* At this point, NREC is the record number of the directory */
+/* containing the last descriptor for clusters of TYPE, if */
+/* there are any such descriptors. */
+
+/* MAXADR is the maximum logical address of TYPE. */
+
+ ftsum[(i__1 = type__ + 5 + fthead * 14 - 15) < 294 && 0 <=
+ i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (ftnlen)
+ 2342)] = maxadr;
+ if (maxadr > 0) {
+ ftsum[(i__1 = type__ + 8 + fthead * 14 - 15) < 294 && 0 <=
+ i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (
+ ftnlen)2345)] = nrec;
+ } else {
+ ftsum[(i__1 = type__ + 8 + fthead * 14 - 15) < 294 && 0 <=
+ i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (
+ ftnlen)2347)] = 0;
+ }
+
+/* We still need to set the word location of the final */
+/* descriptor of TYPE, if there are any descriptors of TYPE. */
+
+ if (maxadr > 0) {
+
+/* Re-read the directory record containing the last */
+/* descriptor of the current type. */
+
+ dasioi_("READ", &number, &nrec, dirrec, (ftnlen)4);
+
+/* Traverse the directory record, looking for the last */
+/* descriptor of TYPE. We'll keep track of the maximum */
+/* logical address of TYPE for each cluster of TYPE */
+/* whose descriptor we examine. When this value is */
+/* the maximum logical address of TYPE, we've found */
+/* the last descriptor of TYPE. */
+
+/* Also keep track of the end record numbers for each */
+/* cluster. */
+
+ last = dirrec[(i__1 = type__ << 1) < 256 && 0 <= i__1 ?
+ i__1 : s_rnge("dirrec", i__1, "dasfm_", (ftnlen)
+ 2371)] - 1;
+ dsctyp = dirrec[8];
+ prvtyp = prev[(i__1 = dsctyp - 1) < 3 && 0 <= i__1 ? i__1
+ : s_rnge("prev", i__1, "dasfm_", (ftnlen)2373)];
+ endrec = nrec;
+ pos = 9;
+ while(last < maxadr) {
+ ++pos;
+ if (dirrec[(i__1 = pos - 1) < 256 && 0 <= i__1 ? i__1
+ : s_rnge("dirrec", i__1, "dasfm_", (ftnlen)
+ 2381)] > 0) {
+ curtyp = next[(i__1 = prvtyp - 1) < 3 && 0 <=
+ i__1 ? i__1 : s_rnge("next", i__1, "dasf"
+ "m_", (ftnlen)2382)];
+ } else {
+ curtyp = prev[(i__1 = prvtyp - 1) < 3 && 0 <=
+ i__1 ? i__1 : s_rnge("prev", i__1, "dasf"
+ "m_", (ftnlen)2384)];
+ }
+ if (curtyp == type__) {
+ last += nw[(i__1 = type__ - 1) < 3 && 0 <= i__1 ?
+ i__1 : s_rnge("nw", i__1, "dasfm_", (
+ ftnlen)2388)] * (i__3 = dirrec[(i__2 =
+ pos - 1) < 256 && 0 <= i__2 ? i__2 :
+ s_rnge("dirrec", i__2, "dasfm_", (ftnlen)
+ 2388)], abs(i__3));
+ }
+ endrec += (i__2 = dirrec[(i__1 = pos - 1) < 256 && 0
+ <= i__1 ? i__1 : s_rnge("dirrec", i__1, "das"
+ "fm_", (ftnlen)2391)], abs(i__2));
+ prvtyp = curtyp;
+ }
+
+/* At this point, POS is the word position of the last */
+/* descriptor of TYPE, and ENDREC is the record number */
+/* of the last data record of TYPE. */
+
+ ftsum[(i__1 = type__ + 11 + fthead * 14 - 15) < 294 && 0
+ <= i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (
+ ftnlen)2400)] = pos;
+ ldrec[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("ldrec", i__1, "dasfm_", (ftnlen)2401)] =
+ endrec;
+ } else {
+
+/* There's no data of TYPE in the file. */
+
+ ftsum[(i__1 = type__ + 11 + fthead * 14 - 15) < 294 && 0
+ <= i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (
+ ftnlen)2407)] = 0;
+ ldrec[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 :
+ s_rnge("ldrec", i__1, "dasfm_", (ftnlen)2408)] =
+ 0;
+ }
+ }
+
+/* We're almost done; we need to find the number of the first */
+/* free record. This record follows all of the data records */
+/* and all of the directory records. It may happen that the */
+/* last record in use is an empty directory. */
+
+ maxai_(ldrec, &c__3, &ldrmax, &loc);
+ nrec = locrrc + loccrc + 2;
+ dasioi_("READ", &number, &nrec, dirrec, (ftnlen)4);
+ nxtrec = dirrec[1];
+ while(nxtrec != 0) {
+ nrec = nxtrec;
+ dasioi_("READ", &number, &nrec, dirrec, (ftnlen)4);
+ nxtrec = dirrec[1];
+ }
+
+/* Now NREC is the last directory record. */
+
+ ftsum[(i__1 = fthead * 14 - 10) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)2443)] = max(
+ ldrmax,nrec) + 1;
+
+/* Insert the new handle into our handle set. */
+
+ *handle = fthan[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 :
+ s_rnge("fthan", i__1, "dasfm_", (ftnlen)2448)];
+ insrti_(handle, fhlist);
+ }
+ }
+ chkout_("DASOPW", (ftnlen)6);
+ return 0;
+/* $Procedure DASONW ( DAS, open new file ) */
+
+L_dasonw:
+/* $ Abstract */
+
+/* Open a new DAS file and set the file type. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) FNAME */
+/* CHARACTER*(*) FTYPE */
+/* CHARACTER*(*) IFNAME */
+/* INTEGER NCOMR */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I Name of a DAS file to be opened. */
+/* FTYPE I Mnemonic code for type of data in the DAF file. */
+/* IFNAME I Internal file name. */
+/* NCOMR I Number of comment records to allocate. */
+/* HANDLE O Handle assigned to the opened DAS file. */
+
+/* $ Detailed_Input */
+
+/* FNAME is the name of a new DAS file to be created (and */
+/* consequently opened for write access). */
+
+/* FTYPE is a code for type of data placed into a DAS file. */
+/* The first nonblank character and the three (3), or */
+/* fewer, characters immediately following it, giving */
+/* four (4) characters, are used to represent the type of */
+/* the data placed in the DAF file. This is provided as a */
+/* convenience for higher level software. It is an error */
+/* if this string is blank. Also, the file type may not */
+/* contain any nonprinting characters. When written to */
+/* the DAS file, the value for the type IS case */
+/* sensitive. */
+
+/* NAIF has reserved for its own use file types */
+/* consisting of the upper case letters (A-Z) and the */
+/* digits 0-9. NAIF recommends lower case or mixed case */
+/* file types be used by all others in order to avoid any */
+/* conflicts with NAIF file types. */
+
+/* IFNAME is the internal file name for the new file. The name */
+/* may contain as many as 60 characters. This should */
+/* uniquely identify the file. */
+
+
+/* NCOMR is the number of comment records to allocate. */
+/* Allocating comment records at file creation time may */
+/* reduce the likelihood of having to expand the */
+/* comment area later. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the file handle associated with the file. This */
+/* handle is used to identify the file in subsequent */
+/* calls to other DAS routines. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input filename is blank, the error SPICE(BLANKFILENAME) */
+/* is signaled. */
+
+/* 2) If the specified file cannot be opened without exceeding */
+/* the maximum allowed number of open DAS files, the error */
+/* SPICE(DASFTFULL) is signaled. No file will be created. */
+
+/* 3) If the file cannot be opened properly, the error */
+/* SPICE(DASOPENFAIL) is signaled. No file will be created. */
+
+/* 4) If the initial records in the file cannot be written, the */
+/* error is diagnosed by routines called by this routine. No */
+/* file will be created. */
+
+/* 5) If no logical units are available, the error will be */
+/* signaled by routines called by this routine. No file will be */
+/* created. */
+
+/* 6) If the file type is blank, the error SPICE(BLANKFILETYPE) will */
+/* be signaled. */
+
+/* 7) If the file type contains nonprinitng characters, decimal */
+/* 0-31 and 127-255, the error SPICE(ILLEGALCHARACTER) is */
+/* signaled. */
+
+/* 8) If the number of comment records allocated NCOMR is negative, */
+/* the error SPICE(INVALIDCOUNT) is signaled. */
+
+/* $ Files */
+
+/* See argument FNAME. */
+
+/* $ Particulars */
+
+/* The DAS files created by this routine have initialized file */
+/* records. */
+
+/* This entry point creates a new DAS file and sets the type of the */
+/* file to the mnemonic code passed to it. */
+
+/* $ Examples */
+
+/* 1) Create a new DAS file, using an internal file name that */
+/* attempts to serve as an unique identifier, and give the file a */
+/* type of 'TEST'. */
+
+/* FNAME = 'TEST.DAS' */
+/* FTYPE = 'TEST' */
+/* IFNAME = 'TEST.DAS/NAIF/NJB/11-NOV-1992-20:12:20' */
+
+/* CALL DASONW ( FNAME, FTYPE, IFNAME, HANDLE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 6.0.0, 11-DEC-2001 (FST) */
+
+/* The DAS file ID word and internal file name are no longer */
+/* buffered by this routine. See DASFM's Revisions section */
+/* for details. */
+
+/* The entry point was modified to insert the FTP validation */
+/* string, as well as the binary file format into the file record. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 2.0.0, 31-AUG-1995 (NJB) */
+
+/* Changed argument list of the entry point DASONW. The input */
+/* argument NCOMR, which indicates the number of comment records */
+/* to reserve, was added to the argument list. */
+
+/* - SPICELIB Version 1.0.0, 29-OCT-1993 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* open a new DAS file */
+/* open a new DAS file with write access */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 6.0.0, 11-DEC-2001 (NJB) (FST) */
+
+/* See the Revisions section under DASFM for a discussion of */
+/* the various changes made for this version. */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASONW", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+
+/* Check to see whether the filename is blank. If it is, signal an */
+/* error, check out, and return. */
+
+ if (s_cmp(fname, " ", fname_len, (ftnlen)1) == 0) {
+ setmsg_("The file name is blank. ", (ftnlen)24);
+ sigerr_("SPICE(BLANKFILENAME)", (ftnlen)20);
+ chkout_("DASONW", (ftnlen)6);
+ return 0;
+ }
+
+/* Check if the file type is blank. */
+
+ if (s_cmp(ftype, " ", ftype_len, (ftnlen)1) == 0) {
+ setmsg_("The file type is blank. ", (ftnlen)24);
+ sigerr_("SPICE(BLANKFILETYPE)", (ftnlen)20);
+ chkout_("DASONW", (ftnlen)6);
+ return 0;
+ }
+
+/* Check for nonprinting characters in the file type. */
+
+ fnb = ltrim_(ftype, ftype_len);
+ i__1 = rtrim_(ftype, ftype_len);
+ for (i__ = fnb; i__ <= i__1; ++i__) {
+ if (*(unsigned char *)&ftype[i__ - 1] > 126 || *(unsigned char *)&
+ ftype[i__ - 1] < 32) {
+ setmsg_("The file type contains nonprinting characters. ", (
+ ftnlen)47);
+ sigerr_("SPICE(ILLEGALCHARACTER)", (ftnlen)23);
+ chkout_("DASONW", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* Validate the comment record count. */
+
+ if (*ncomr < 0) {
+ setmsg_("The number of comment records allocated must be non-negativ"
+ "e but was #.", (ftnlen)71);
+ errint_("#", ncomr, (ftnlen)1);
+ sigerr_("SPICE(INVALIDCOUNT)", (ftnlen)19);
+ chkout_("DASONW", (ftnlen)6);
+ return 0;
+ }
+
+/* Set the value the file type in a temporary variable to be sure of */
+/* its length and then set the value of the ID word. Only 4 */
+/* characters are allowed for the file type, and they are the first */
+/* nonblank character and its three (3) immediate successors in the */
+/* input string FTYPE. */
+
+ s_copy(ttype, ftype + (fnb - 1), (ftnlen)4, ftype_len - (fnb - 1));
+/* Writing concatenation */
+ i__4[0] = 4, a__1[0] = "DAS/";
+ i__4[1] = 4, a__1[1] = ttype;
+ s_cat(idword, a__1, i__4, &c__2, (ftnlen)8);
+
+/* The file can be opened only if there is room for another file. */
+
+ if (lnknfn_(pool) == 0) {
+ setmsg_("The file table is full, with # entries. Could not open '#'.",
+ (ftnlen)59);
+ errint_("#", &c__21, (ftnlen)1);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(DASFTFULL)", (ftnlen)16);
+ chkout_("DASONW", (ftnlen)6);
+ return 0;
+ } else {
+
+/* To open a new file: get a free unit, open the file, write */
+/* the file record, and set the number of links to one. */
+
+/* Look out for: */
+
+/* -- No free logical units. */
+
+/* -- Error opening the file. */
+
+/* -- Error writing to the file. */
+
+/* If anything goes wrong after the file has been opened, delete */
+/* the file. */
+
+
+ getlun_(&number);
+ if (failed_()) {
+ chkout_("DASONW", (ftnlen)6);
+ return 0;
+ }
+ o__1.oerr = 1;
+ o__1.ounit = number;
+ o__1.ofnmlen = rtrim_(fname, fname_len);
+ o__1.ofnm = fname;
+ o__1.orl = 1024;
+ o__1.osta = "NEW";
+ o__1.oacc = "DIRECT";
+ o__1.ofm = 0;
+ o__1.oblnk = 0;
+ iostat = f_open(&o__1);
+ if (iostat != 0) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("Attempt to open file '#' failed. Value of IOSTAT was #.",
+ (ftnlen)55);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASOPENFAIL)", (ftnlen)18);
+ chkout_("DASONW", (ftnlen)6);
+ return 0;
+ } else {
+
+/* Fetch the system file format. */
+
+ zzplatfm_("FILE_FORMAT", format, (ftnlen)11, (ftnlen)8);
+
+/* Prepare to write the file record. Clear out the file */
+/* summary, except for the number of reserved records and */
+/* the free record pointer. The free record pointer should */
+/* point to the first record AFTER the first directory. */
+
+/* Use a local variable for the internal file name to ensure */
+/* that IFNLEN characters are written. The remaining */
+/* elements of the file record are: */
+
+/* -- the number of reserved records */
+
+/* -- the number of characters in use in the reserved */
+/* record area */
+
+/* -- the number of comment records */
+
+/* -- the number of characters in use in the comment */
+/* area */
+
+/* Initially, all of these counts are zero, except for the */
+/* comment record count, which is set by the caller. */
+
+
+ s_copy(locifn, ifname, (ftnlen)60, ifname_len);
+ zzdasnfr_(&number, idword, locifn, &c__0, &c__0, ncomr, &c__0,
+ format, (ftnlen)8, (ftnlen)60, (ftnlen)8);
+
+/* Check to see whether or not ZZDASNFR generated an error */
+/* writing the file record to the logical unit. In the event */
+/* an error occurs, checkout and return. */
+
+ if (failed_()) {
+ chkout_("DASONW", (ftnlen)6);
+ return 0;
+ }
+
+/* Zero out the first directory record in the file. If this */
+/* write fails, close the file with delete status and return */
+/* immediately. The first directory record follows the */
+/* comment records and reserved records. Currently there */
+/* are no reserved records, so the directory occupies record */
+/* NCOMR+2. */
+
+ cleari_(&c__256, dirrec);
+ i__1 = *ncomr + 2;
+ dasioi_("WRITE", &number, &i__1, dirrec, (ftnlen)5);
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = "DELETE";
+ f_clos(&cl__1);
+ chkout_("DASONW", (ftnlen)6);
+ return 0;
+ }
+
+/* Update the file table to include information about */
+/* our newly opened DAS file. Link the information */
+/* for this file at the head of the file table list. */
+
+/* Set the output argument HANDLE as well. */
+
+ lnkan_(pool, &new__);
+ lnkilb_(&new__, &fthead, pool);
+ ++nxthan;
+ fthead = new__;
+ cleari_(&c__14, &ftsum[(i__1 = fthead * 14 - 14) < 294 && 0 <=
+ i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (ftnlen)
+ 2926)]);
+ fthan[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fth"
+ "an", i__1, "dasfm_", (ftnlen)2928)] = nxthan;
+ ftlun[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftl"
+ "un", i__1, "dasfm_", (ftnlen)2929)] = number;
+ ftacc[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fta"
+ "cc", i__1, "dasfm_", (ftnlen)2930)] = 2;
+ ftlnk[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftl"
+ "nk", i__1, "dasfm_", (ftnlen)2931)] = 1;
+ ftsum[(i__1 = fthead * 14 - 10) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)2932)] = *ncomr +
+ 3;
+ ftsum[(i__1 = fthead * 14 - 12) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)2933)] = *ncomr;
+ *handle = fthan[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 :
+ s_rnge("fthan", i__1, "dasfm_", (ftnlen)2935)];
+
+/* Insert the new handle into our handle set. */
+
+ insrti_(handle, fhlist);
+ }
+ }
+ chkout_("DASONW", (ftnlen)6);
+ return 0;
+/* $Procedure DASOPN ( DAS, open new ) */
+
+L_dasopn:
+/* $ Abstract */
+
+/* Open a new DAS file for writing. */
+/* Obsolete: This routine has been superceded by DASONW, and it is */
+/* supported for purposes of backward compatibility only. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) FNAME */
+/* CHARACTER*(*) IFNAME */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I Name of a DAS file to be opened. */
+/* IFNAME I Internal file name. */
+/* HANDLE O Handle assigned to the opened DAS file. */
+
+/* $ Detailed_Input */
+
+/* FNAME is the name of a new DAS file to be created (and */
+/* consequently opened for write access). */
+
+/* IFNAME is the internal file name for the new file. The name */
+/* may contain as many as 60 characters. This should */
+/* uniquely identify the file. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the file handle associated with the file. This */
+/* handle is used to identify the file in subsequent */
+/* calls to other DAS routines. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input filename is blank, the error SPICE(BLANKFILENAME) */
+/* will be signaled. */
+
+/* 2) If the specified file cannot be opened without exceeding */
+/* the maximum allowed number of open DAS files, the error */
+/* SPICE(DASFTFULL) is signaled. No file will be created. */
+
+/* 3) If the file cannot be opened properly, the error */
+/* SPICE(DASOPENFAIL) is signaled. No file will be created. */
+
+/* 4) If the initial records in the file cannot be written, the */
+/* error is diagnosed by routines called by this routine. No */
+/* file will be created. */
+
+/* 5) If no logical units are available, the error will be */
+/* signaled by routines called by this routine. No file will be */
+/* created. */
+
+/* $ Files */
+
+/* See argument FNAME. */
+
+/* $ Particulars */
+
+/* The DAS files created by this routine have initialized file */
+/* records. */
+
+/* This entry point has been made obsolete by the entry point DASONW, */
+/* and it is supported for reasons of backward compatibility only. */
+/* New software development should use the entry point DASONW. */
+
+/* $ Examples */
+
+/* 1) Create a new DAS file, using an internal file name that */
+/* attempts to serve as an unique identifier. */
+
+/* FNAME = 'TEST.DAS' */
+/* IFNAME = 'TEST.DAS/NAIF/NJB/11-NOV-1992-20:12:20' */
+
+/* CALL DASOPN ( FNAME, IFNAME, HANDLE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 6.0.0, 11-DEC-2001 (FST) */
+
+/* The DAS file ID word and internal file name are no longer */
+/* buffered by this routine. See DASFM's Revisions section */
+/* for details. */
+
+/* This entry point was modified to insert the FTP validation */
+/* string, as well as the binary file format into the file record. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 2.0.0, 29-OCT-1993 (KRG) */
+
+/* The effect of this routine is unchanged. It still uses the ID */
+/* word 'NAIF/DAS'. This is for backward compatibility only. */
+
+/* Added statements to the $ Abstract and $ Particulars sections */
+/* to document that this entry is now considered to be obsolete, */
+/* and that it has been superceded by the entry point DASONW. */
+
+/* Added a test for a blank filename before attempting to use the */
+/* filename in the routine. If the filename is blank, the error */
+/* SPICE(BLANKFILENAME) will be signaled. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* open a new DAS file for writing */
+/* open a new DAS file for write access */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 6.0.0, 11-DEC-2001 (FST) */
+
+/* See the Revisions section under DASFM for a discussion */
+/* of the changes made for this version. */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASOPN", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+
+/* Check to see whether the filename is blank. If it is, signal an */
+/* error, check out, and return. */
+
+ if (s_cmp(fname, " ", fname_len, (ftnlen)1) == 0) {
+ setmsg_("The file name is blank. ", (ftnlen)24);
+ sigerr_("SPICE(BLANKFILENAME)", (ftnlen)20);
+ chkout_("DASOPN", (ftnlen)6);
+ return 0;
+ }
+
+/* The file can be opened only if there is room for another file. */
+
+ if (lnknfn_(pool) == 0) {
+ setmsg_("The file table is full, with # entries. Could not open '#'.",
+ (ftnlen)59);
+ errint_("#", &c__21, (ftnlen)1);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(DASFTFULL)", (ftnlen)16);
+ chkout_("DASOPN", (ftnlen)6);
+ return 0;
+ } else {
+
+/* To open a new file: get a free unit, open the file, write */
+/* the file record, and set the number of links to one. */
+
+/* Look out for: */
+
+/* -- No free logical units. */
+
+/* -- Error opening the file. */
+
+/* -- Error writing to the file. */
+
+/* If anything goes wrong after the file has been opened, delete */
+/* the file. */
+
+
+ getlun_(&number);
+ if (failed_()) {
+ chkout_("DASOPN", (ftnlen)6);
+ return 0;
+ }
+ o__1.oerr = 1;
+ o__1.ounit = number;
+ o__1.ofnmlen = rtrim_(fname, fname_len);
+ o__1.ofnm = fname;
+ o__1.orl = 1024;
+ o__1.osta = "NEW";
+ o__1.oacc = "DIRECT";
+ o__1.ofm = 0;
+ o__1.oblnk = 0;
+ iostat = f_open(&o__1);
+ if (iostat != 0) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("Attempt to open file '#' failed. Value of IOSTAT was #.",
+ (ftnlen)55);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASOPENFAIL)", (ftnlen)18);
+ chkout_("DASOPN", (ftnlen)6);
+ return 0;
+ } else {
+
+/* Fetch the system file format. */
+
+ zzplatfm_("FILE_FORMAT", format, (ftnlen)11, (ftnlen)8);
+
+/* Prepare to write the file record. Clear out the file */
+/* summary, except for the number of reserved records and */
+/* the free record pointer. The free record pointer should */
+/* point to the first record AFTER the first directory. */
+
+/* Use a local variable for the internal file name to ensure */
+/* that IFNLEN characters are written. The remaining */
+/* elements of the file record are: */
+
+/* -- the number of reserved records */
+
+/* -- the number of characters in use in the reserved */
+/* record area */
+
+/* -- the number of comment records */
+
+/* -- the number of characters in use in the comment */
+/* area */
+
+/* Initially, all of these counts are zero. */
+
+
+ s_copy(locifn, ifname, (ftnlen)60, ifname_len);
+ s_copy(idword, "NAIF/DAS", (ftnlen)8, (ftnlen)8);
+ zzdasnfr_(&number, idword, locifn, &c__0, &c__0, &c__0, &c__0,
+ format, (ftnlen)8, (ftnlen)60, (ftnlen)8);
+ if (failed_()) {
+ chkout_("DASOPN", (ftnlen)6);
+ return 0;
+ }
+
+/* Zero out the first directory record (record #2) in the */
+/* file. If this write fails, close the file with delete */
+/* status and return immediately. */
+
+ cleari_(&c__256, dirrec);
+ dasioi_("WRITE", &number, &c__2, dirrec, (ftnlen)5);
+ if (failed_()) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = "DELETE";
+ f_clos(&cl__1);
+ chkout_("DASOPN", (ftnlen)6);
+ return 0;
+ }
+
+/* Update the file table to include information about */
+/* our newly opened DAS file. Link the information */
+/* for this file at the head of the file table list. */
+
+/* Set the output argument HANDLE as well. */
+
+ lnkan_(pool, &new__);
+ lnkilb_(&new__, &fthead, pool);
+ ++nxthan;
+ fthead = new__;
+ cleari_(&c__14, &ftsum[(i__1 = fthead * 14 - 14) < 294 && 0 <=
+ i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (ftnlen)
+ 3324)]);
+ fthan[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fth"
+ "an", i__1, "dasfm_", (ftnlen)3326)] = nxthan;
+ ftlun[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftl"
+ "un", i__1, "dasfm_", (ftnlen)3327)] = number;
+ ftacc[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fta"
+ "cc", i__1, "dasfm_", (ftnlen)3328)] = 2;
+ ftlnk[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftl"
+ "nk", i__1, "dasfm_", (ftnlen)3329)] = 1;
+ ftsum[(i__1 = fthead * 14 - 10) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)3330)] = 3;
+ *handle = fthan[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 :
+ s_rnge("fthan", i__1, "dasfm_", (ftnlen)3332)];
+
+/* Insert the new handle into our handle set. */
+
+ insrti_(handle, fhlist);
+ }
+ }
+ chkout_("DASOPN", (ftnlen)6);
+ return 0;
+/* $Procedure DASOPS ( DAS, open scratch ) */
+
+L_dasops:
+/* $ Abstract */
+
+/* Open a scratch DAS file for writing. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE O Handle assigned to a scratch DAS file. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the file handle associated with the scratch file */
+/* opened by this routine. This handle is used to */
+/* identify the file in subsequent calls to other DAS */
+/* routines. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified file cannot be opened without exceeding */
+/* the maximum allowed number of open DAS files, the error */
+/* SPICE(DASFTFULL) is signaled. No file will be created. */
+
+/* 2) If file cannot be opened properly, the error */
+/* SPICE(DASOPENFAIL) is signaled. No file will be created. */
+
+/* 3) If the initial records in the file cannot be written, the */
+/* error SPICE(DASWRITEFAIL) is signaled. No file will be */
+/* created. */
+
+/* 4) If no logical units are available, the error will be */
+/* signaled by routines called by this routine. No file will be */
+/* created. */
+
+/* $ Files */
+
+/* See output argument HANDLE. */
+
+/* See FTSIZE in the $ Parameters section for a description of a */
+/* potential problem with overflowing the DAS file table when at */
+/* least one DAS file is opened with write access. */
+
+/* $ Particulars */
+
+/* This routine is a utility used by the DAS system to provide */
+/* work space needed when creating new DAS files. */
+
+/* The DAS files created by this routine have initialized file */
+/* records. The file type for a DAS scratch file is 'SCR ', so the */
+/* file type 'SCR ' is not available for general use. */
+
+/* $ Examples */
+
+/* 1) Create a scratch DAS file to use as a temporary storage */
+/* area. */
+
+/* CALL DASOPS ( HANDLE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 2.0.0, 29-OCT-1993 (KRG) */
+
+/* Modified the entry point to use the new file ID format which */
+/* contains a mnemonic code for the data type. */
+
+/* Put meaningful values into the type and internal filename */
+/* for a DAS scratch file, rather than leaving them blank. */
+
+/* Documented the potential problem of overflowing the DAS file */
+/* table when attempting to close a DAS file opened with write */
+/* access when the file table is full. Modified the long error */
+/* message to indicate this as a cause of the problem. */
+
+/* - SPICELIB Version 1.1.0, 04-MAY-1993 (NJB) */
+
+/* Bug fix: removed file name variable from error message. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* open a scratch DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.0.0, 29-OCT-1993 (KRG) */
+
+/* Modified the entry point to use the new file ID format which */
+/* contains a mnemonic code for the data type. */
+
+/* DAS scratch files use the type 'SCR ', so the ID word for a DAS */
+/* scratch file would be: 'DAS/SCR ' */
+
+/* Changed the internal fielname from blank to the string: */
+
+/* 'DAS SCRATCH FILE' */
+
+/* It's probably better to have something written there than */
+/* nothing. */
+
+/* Documented the potential problem of overflowing the DAS file */
+/* table when attempting to close a DAS file opened with write */
+/* access when the file table is full. Modified the long error */
+/* message to indicate this as a cause of the problem. */
+
+/* The problem occurs when the file table is full, the number of */
+/* open DAS files equals FTSIZE, and at least one of the open */
+/* files was opened with write access. If an attempt to close a */
+/* file opened with write access is made under these conditions, */
+/* by calling DASCLS, it will fail. DASCLS (via DASSDR) calls */
+/* DASOPS to open a scratch DAS file, but the scratch file CANNOT */
+/* be opened because the file table is full. If this occurs, close */
+/* a file open for read access, or restrict the number of open */
+/* files in use to be at most FTSIZE - 1 when there will be at */
+/* least one file opened with write access. */
+
+/* - SPICELIB Version 1.1.0, 04-MAY-1993 (NJB) */
+
+/* Bug fix: removed unneeded file name variable FNAME from */
+/* error message. */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASOPS", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+
+/* The file can be opened only if there is room for another file. */
+
+ if (lnknfn_(pool) == 0) {
+ setmsg_("The file table is full, with # entries. Could not open a sc"
+ "ratch file. If a call to DASOPS was not made and this error "
+ "occurred, it is likely that the DAS file table was full and "
+ "an attempt to close a file opened with write access was made"
+ ". See the DAS required reading and DASFM for details.", (
+ ftnlen)292);
+ errint_("#", &c__21, (ftnlen)1);
+ sigerr_("SPICE(DASFTFULL)", (ftnlen)16);
+ chkout_("DASOPS", (ftnlen)6);
+ return 0;
+ } else {
+
+/* To open a new file: get a free unit, open the file, write */
+/* the file record, and set the number of links to one. */
+
+/* Look out for: */
+
+/* -- No free logical units. */
+
+/* -- Error opening the file. */
+
+/* -- Error writing to the file. */
+
+/* If anything goes wrong after the file has been opened, delete */
+/* the file. */
+
+
+ getlun_(&number);
+ if (failed_()) {
+ chkout_("DASOPS", (ftnlen)6);
+ return 0;
+ }
+ o__1.oerr = 1;
+ o__1.ounit = number;
+ o__1.ofnm = 0;
+ o__1.orl = 1024;
+ o__1.osta = "SCRATCH";
+ o__1.oacc = "DIRECT";
+ o__1.ofm = 0;
+ o__1.oblnk = 0;
+ iostat = f_open(&o__1);
+ if (iostat != 0) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("Attempt to open scratch file failed. IOSTAT was #.", (
+ ftnlen)51);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASOPENFAIL)", (ftnlen)18);
+ chkout_("DASOPS", (ftnlen)6);
+ return 0;
+ } else {
+
+/* Prepare to write the file record. Clear out the file */
+/* summary, the free record pointer. The free record pointer */
+/* should point to the first record AFTER the first directory. */
+
+ s_copy(locifn, "DAS SCRATCH FILE", (ftnlen)60, (ftnlen)16);
+ s_copy(idword, "DAS/SCR ", (ftnlen)8, (ftnlen)8);
+ io___52.ciunit = number;
+ iostat = s_wdue(&io___52);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_uio(&c__1, idword, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_uio(&c__1, locifn, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_uio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_uio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_uio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_uio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = e_wdue();
+L100003:
+ if (iostat != 0) {
+ cl__1.cerr = 0;
+ cl__1.cunit = number;
+ cl__1.csta = "DELETE";
+ f_clos(&cl__1);
+ setmsg_("Attempt to write scratch file failed. Value of IOST"
+ "AT was #.", (ftnlen)60);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASWRITEFAIL)", (ftnlen)19);
+ chkout_("DASOPS", (ftnlen)6);
+ return 0;
+ } else {
+
+/* Update the file table to include information about */
+/* our newly opened DAS file. Link the information */
+/* for this file at the head of the file table list. */
+
+/* Set the output argument HANDLE as well. */
+
+ lnkan_(pool, &new__);
+ lnkilb_(&new__, &fthead, pool);
+ ++nxthan;
+ fthead = new__;
+ cleari_(&c__14, &ftsum[(i__1 = fthead * 14 - 14) < 294 && 0 <=
+ i__1 ? i__1 : s_rnge("ftsum", i__1, "dasfm_", (
+ ftnlen)3690)]);
+ fthan[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "fthan", i__1, "dasfm_", (ftnlen)3692)] = nxthan;
+ ftlun[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftlun", i__1, "dasfm_", (ftnlen)3693)] = number;
+ ftacc[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftacc", i__1, "dasfm_", (ftnlen)3694)] = 2;
+ ftlnk[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftlnk", i__1, "dasfm_", (ftnlen)3695)] = 1;
+ ftsum[(i__1 = fthead * 14 - 10) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)3696)] = 3;
+ *handle = fthan[(i__1 = fthead - 1) < 21 && 0 <= i__1 ? i__1 :
+ s_rnge("fthan", i__1, "dasfm_", (ftnlen)3698)];
+
+/* Insert the new handle into our handle set. */
+
+ insrti_(handle, fhlist);
+ }
+ }
+ }
+ chkout_("DASOPS", (ftnlen)6);
+ return 0;
+/* $Procedure DASLLC ( DAS, low-level close ) */
+
+L_dasllc:
+/* $ Abstract */
+
+/* Close the DAS file associated with a given handle. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of a DAS file to be closed. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a previously opened DAS file. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the effect of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified handle does not belong to a DAS file */
+/* that is currently open, nothing happens. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Normally, routines outside of SPICELIB will not need to call this */
+/* routine. Application programs should close DAS files by calling */
+/* the SPICELIB routine DASCLS. This routine is a lower-level */
+/* routine that is called by DASCLS, but (obviously) does not have */
+/* the full functionality of DASCLS. */
+
+/* This routine closes a DAS file and updates DASFM's bookkeeping */
+/* information on open DAS files. Because DASFM and its entry */
+/* points must keep track of what files are open at any given time, */
+/* it is important that DAS files be closed only with DASCLS or */
+/* DASLLC, to prevent the remaining DAS routines from failing, */
+/* sometimes mysteriously. */
+
+/* Note that when a file is opened more than once for read or write */
+/* access, DASOPR returns the same handle each time it is re-opened. */
+/* Each time the file is closed, DASLLC checks to see if any other */
+/* claims on the file are still active before physically closing */
+/* the file. */
+
+/* Unlike DASCLS, this routine does not force a write of updated, */
+/* buffered records to the indicated file, nor does it segregate the */
+/* data records in the file. */
+
+/* $ Examples */
+
+/* 1) Here's how DASCLS uses this routine: */
+
+
+/* C */
+/* C If the file is open for writing, flush any buffered */
+/* C records that belong to it. */
+/* C */
+/* CALL DASHAM ( HANDLE, METHOD ) */
+
+/* IF ( METHOD .EQ. WRITE ) THEN */
+
+/* Make sure that all updated, buffered records are */
+/* written out to the indicated file. */
+
+/* CALL DASWUR ( HANDLE ) */
+
+/* Segregate the data records in the file according */
+/* to data type. */
+
+/* CALL DASSDR ( HANDLE ) */
+
+/* END IF */
+
+/* C */
+/* C Close the file. */
+/* C */
+/* CALL DASLLC ( HANDLE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.0.2, 21-FEB-2003 (NJB) */
+
+/* Corrected inline comment: determination of whether file */
+/* is open is done by searching the handle column of the file */
+/* table, not the unit column. */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* close a DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASLLC", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+
+/* Is this file even open? Peruse the `handle' column of the file */
+/* table; see whether this handle is present. */
+
+ findex = fthead;
+ found = FALSE_;
+ while(! found && findex > 0) {
+ if (fthan[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fth"
+ "an", i__1, "dasfm_", (ftnlen)3956)] == *handle) {
+ found = TRUE_;
+ } else {
+ findex = lnknxt_(&findex, pool);
+ }
+ }
+
+/* If the file is not open: no harm, no foul. Otherwise, decrement */
+/* the number of links to the file. If the number of links drops to */
+/* zero, physically close the file and remove it from the file */
+/* buffer. */
+
+ if (found) {
+ ftlnk[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftlnk",
+ i__1, "dasfm_", (ftnlen)3972)] = ftlnk[(i__2 = findex - 1) <
+ 21 && 0 <= i__2 ? i__2 : s_rnge("ftlnk", i__2, "dasfm_", (
+ ftnlen)3972)] - 1;
+ if (ftlnk[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftl"
+ "nk", i__1, "dasfm_", (ftnlen)3974)] == 0) {
+
+/* Close this file and delete it from the active list. */
+/* If this was the head node of the list, the head node */
+/* becomes the successor of this node (which may be NIL). */
+/* Delete the handle from our handle set. */
+
+ cl__1.cerr = 0;
+ cl__1.cunit = ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 :
+ s_rnge("ftlun", i__1, "dasfm_", (ftnlen)3981)];
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ if (findex == fthead) {
+ fthead = lnknxt_(&findex, pool);
+ }
+ lnkfsl_(&findex, &findex, pool);
+ removi_(handle, fhlist);
+ }
+ }
+ chkout_("DASLLC", (ftnlen)6);
+ return 0;
+/* $Procedure DASHFS ( DAS, handle to file summary ) */
+
+L_dashfs:
+/* $ Abstract */
+
+/* Return a file summary for a specified DAS file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER NRESVR */
+/* INTEGER NRESVC */
+/* INTEGER NCOMR */
+/* INTEGER NCOMC */
+/* INTEGER FREE */
+/* INTEGER LASTLA ( 3 ) */
+/* INTEGER LASTRC ( 3 ) */
+/* INTEGER LASTWD ( 3 ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of a DAS file. */
+/* NRESVR O Number of reserved records in file. */
+/* NRESVC O Number of characters in use in reserved rec. area. */
+/* NCOMR O Number of comment records in file. */
+/* NCOMC O Number of characters in use in comment area. */
+/* FREE O Number of first free record. */
+/* LASTLA O Array of last logical addresses for each data type. */
+/* LASTRC O Record number of last descriptor of each data type. */
+/* LASTWD O Word number of last descriptor of each data type. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a previously opened DAS file. */
+
+/* $ Detailed_Output */
+
+/* NRESVR is the number of reserved records in a specified DAS */
+/* file. */
+
+/* NRESVC is the number of characters in use in the reserved */
+/* record area of a specified DAS file. */
+
+/* NCOMR is the number of comment records in a specified DAS */
+/* file. */
+
+/* NCOMC is the number of characters in use in the comment area */
+/* of a specified DAS file. */
+
+/* FREE is the Fortran record number of the first free record */
+/* in a specified DAS file. */
+
+/* LASTLA is an array containing the highest current logical */
+/* addresses, in the specified DAS file, of data of */
+/* character, double precision, and integer types, in */
+/* that order. */
+
+/* LASTRC is an array containing the Fortran record numbers, in */
+/* the specified DAS file, of the directory records */
+/* containing the current last descriptors of clusters */
+/* of character, double precision, and integer data */
+/* records, in that order. */
+
+/* LASTWD is an array containing the word positions, in the */
+/* specified DAS file, of the current last descriptors */
+/* of clusters of character, double precision, and */
+/* integer data records, in that order. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified handle does not belong to any file that is */
+/* currently known to be open, the error SPICE(DASNOSUCHHANDLE) */
+/* is signaled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The quantities NRESVR, NRESRC, NCOMR, NCOMC, FREE, LASTLA, */
+/* LASTRC, and LASTWD define the `state' of a DAS file, and in */
+/* particular the state of the directory structure of the file. */
+/* This information is needed by other DAS routines, but application */
+/* programs will usually have no need for it. The one exception is */
+/* the array of `last' logical addresses LASTLA: these addresses */
+/* indicate how many words of data of each type are contained in the */
+/* specified DAS file. The elements of LASTLA can be conveniently */
+/* retrieved by calling DASLLA. */
+
+/* $ Examples */
+
+/* 1) Dump the data from a DAS file. */
+
+/* C */
+/* C Open the DAS file for reading. */
+/* C */
+/* CALL DASOPR ( FILE, HANDLE ) */
+
+/* C */
+/* C Obtain the file summary. */
+/* C */
+/* CALL DASHFS ( HANDLE, */
+/* . NRESVR, */
+/* . RRESVC, */
+/* . NCOMR, */
+/* . NCOMC, */
+/* . FREE, */
+/* . LASTLA, */
+/* . LASTRC, */
+/* . LASTWD ) */
+
+/* C */
+/* C Read the integers and dump them. */
+/* C */
+/* DO I = 1, LASTLA(INT) */
+/* CALL DASRDI ( HANDLE, I, I, N ) */
+/* WRITE (*,*) N */
+/* END DO */
+
+/* C */
+/* C Now the d.p. numbers: */
+/* C */
+/* DO I = 1, LASTLA(DP) */
+/* CALL DASRDD ( HANDLE, I, I, X ) */
+/* WRITE (*,*) X */
+/* END DO */
+
+/* C */
+/* C Now the characters. In this case, we read the */
+/* C data a line at a time. */
+/* C */
+/* FIRST = 0 */
+/* LAST = 0 */
+/* REMAIN = LASTLA(CHAR) */
+
+/* DO WHILE ( REMAIN .GT. 0 ) */
+
+/* NREAD = MIN ( LINLEN, REMAIN ) */
+/* FIRST = LAST + 1 */
+/* LAST = LAST + NREAD */
+
+/* CALL DASRDC ( HANDLE, FIRST, LAST, LINE ) */
+
+/* WRITE (*,*) LINE(:NREAD) */
+
+/* REMAIN = REMAIN - NREAD */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUL-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* return the file summary of a DAS file */
+/* find the amount of data in a DAS file */
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUL-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASHFS", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+ findex = fthead;
+ found = FALSE_;
+ while(! found && findex > 0) {
+ if (fthan[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fth"
+ "an", i__1, "dasfm_", (ftnlen)4299)] == *handle) {
+ found = TRUE_;
+ } else {
+ findex = lnknxt_(&findex, pool);
+ }
+ }
+ if (found) {
+
+/* Give the caller the current summary from the file table. */
+
+ *nresvr = ftsum[(i__1 = findex * 14 - 14) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)4312)];
+ *nresvc = ftsum[(i__1 = findex * 14 - 13) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)4313)];
+ *ncomr = ftsum[(i__1 = findex * 14 - 12) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)4314)];
+ *ncomc = ftsum[(i__1 = findex * 14 - 11) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)4315)];
+ *free = ftsum[(i__1 = findex * 14 - 10) < 294 && 0 <= i__1 ? i__1 :
+ s_rnge("ftsum", i__1, "dasfm_", (ftnlen)4316)];
+ for (i__ = 1; i__ <= 3; ++i__) {
+ lastla[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("lastla",
+ i__1, "dasfm_", (ftnlen)4319)] = ftsum[(i__2 = i__ + 5 +
+ findex * 14 - 15) < 294 && 0 <= i__2 ? i__2 : s_rnge(
+ "ftsum", i__2, "dasfm_", (ftnlen)4319)];
+ lastrc[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("lastrc",
+ i__1, "dasfm_", (ftnlen)4320)] = ftsum[(i__2 = i__ + 8 +
+ findex * 14 - 15) < 294 && 0 <= i__2 ? i__2 : s_rnge(
+ "ftsum", i__2, "dasfm_", (ftnlen)4320)];
+ lastwd[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("lastwd",
+ i__1, "dasfm_", (ftnlen)4321)] = ftsum[(i__2 = i__ + 11
+ + findex * 14 - 15) < 294 && 0 <= i__2 ? i__2 : s_rnge(
+ "ftsum", i__2, "dasfm_", (ftnlen)4321)];
+ }
+ } else {
+ setmsg_("There is no DAS file open with handle = #", (ftnlen)41);
+ errint_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(DASNOSUCHHANDLE)", (ftnlen)22);
+ }
+ chkout_("DASHFS", (ftnlen)6);
+ return 0;
+/* $Procedure DASUFS ( DAS, update file summary ) */
+
+L_dasufs:
+/* $ Abstract */
+
+/* Update the file summary in a specified DAS file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER NRESVR */
+/* INTEGER NRESVC */
+/* INTEGER NCOMR */
+/* INTEGER NCOMC */
+/* INTEGER FREE */
+/* INTEGER LASTLA ( 3 ) */
+/* INTEGER LASTRC ( 3 ) */
+/* INTEGER LASTWD ( 3 ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of an open DAS file. */
+/* NRESVR I Number of reserved records in file. */
+/* NRESVC I Number of characters in use in reserved rec. area. */
+/* NCOMR I Number of comment records in file. */
+/* NCOMC I Number of characters in use in comment area. */
+/* FREE I Number of first free record. */
+/* LASTLA I Array of last logical addresses for each data type. */
+/* LASTRC I Record number of last descriptor of each data type. */
+/* LASTWD I Word number of last descriptor of each data type. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a previously opened DAS file. */
+
+/* NRESVR is the number of reserved records in a specified DAS */
+/* file. */
+
+/* NRESVC is the number of characters in use in the reserved */
+/* record area of a specified DAS file. */
+
+/* NCOMR is the number of comment records in a specified DAS */
+/* file. */
+
+/* NCOMC is the number of characters in use in the comment area */
+/* of a specified DAS file. */
+
+/* FREE is the Fortran record number of the first free record */
+/* in a specified DAS file. */
+
+/* LASTLA is an array containing the highest current logical */
+/* addresses, in the specified DAS file, of data of */
+/* character, double precision, and integer types, in */
+/* that order. */
+
+/* LASTRC is an array containing the Fortran record numbers, in */
+/* the specified DAS file, of the directory records */
+/* containing the current last descriptors of clusters */
+/* of character, double precision, and integer data */
+/* records, in that order. */
+
+/* LASTWD is an array containing the word positions, in the */
+/* specified DAS file, of the current last descriptors */
+/* of clusters of character, double precision, and */
+/* integer data records, in that order. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the effect of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified handle does not belong to any file that is */
+/* currently known to be open, the error SPICE(DASNOSUCHHANDLE) */
+/* is signaled. */
+
+/* 2) If the specified handle is not open for WRITE access, the */
+/* error SPICE(DASINVALIDACCESS) is signaled. */
+
+/* 3) If this routine's attempts to read the DAS file record */
+/* fail before an update, the error SPICE(DASREADFAIL) is */
+/* signaled. */
+
+/* 4) If the attempt to write to the DAS file record fails, the */
+/* error SPICE(DASWRITEFAIL) is signaled. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* The quantities NRESVR, NRESRC, NCOMR, NCOMC, FREE, LASTLA, */
+/* LASTRC, and LASTWD define the `state' of a DAS file, and in */
+/* particular the state of the directory structure of the file. */
+/* These quantities should normally be updated only by DAS routines. */
+
+/* The higher-level DAS routines that affect a DAS file's summary, */
+/* such as */
+
+/* DASADx */
+/* DASUDx */
+/* DASARR */
+
+/* automatically update the file summary, so there is no need for */
+/* the calling program to perform the update explicitly. */
+
+/* $ Examples */
+
+/* 1) Update the last d.p. logical address for a DAS file, leaving */
+/* the rest of the file summary intact. */
+
+/* C */
+/* C Read the file summary. */
+/* C */
+/* CALL DASHFS ( HANDLE, */
+/* . NRESVR, */
+/* . RRESVC, */
+/* . NCOMR, */
+/* . NCOMC, */
+/* . FREE, */
+/* . LASTLA, */
+/* . LASTRC, */
+/* . LASTWD ) */
+
+/* C */
+/* C Update the d.p. component of the `last logical */
+/* C address' array. */
+/* C */
+/* LASTLA(DP) = NEWVAL */
+
+/* CALL DASUFS ( HANDLE, */
+/* . NRESVR, */
+/* . RRESVC, */
+/* . NCOMR, */
+/* . NCOMC, */
+/* . FREE, */
+/* . LASTLA, */
+/* . LASTRC, */
+/* . LASTWD ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.1.0, 26-SEP-2005 (NJB) */
+
+/* Bug fix: file name is now correctly inserted into long */
+/* error message generated when target file is not open for */
+/* write access. */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 6.0.0, 15-OCT-2001 (FST) (NJB) */
+
+/* Bug fix: this routine now reads the file record */
+/* before attempting to update it. The buffered values */
+/* of IDWORD and IFN are no longer present. */
+
+/* Bug fix: missing call to CHKIN was added to an error */
+/* handling branch in entry point DASUFS. This call is */
+/* required because DASUFS uses discovery check-in. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUL-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* update the file summary of a DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 6.1.0, 26-SEP-2005 (NJB) */
+
+/* Bug fix: file name is now correctly inserted into long */
+/* error message generated when target file is not open for */
+/* write access. */
+
+/* - SPICELIB Version 5.1.0, 15-OCT-2001 (NJB) */
+
+/* Bug fix: missing call to CHKIN was added to an error */
+/* handling branch in entry point DASUFS. This call is */
+/* required because DASUFS uses discovery check-in. */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUL-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* We use discovery check-ins in this routine. */
+
+ if (return_()) {
+ return 0;
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ chkin_("DASUFS", (ftnlen)6);
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ chkout_("DASUFS", (ftnlen)6);
+ pass1 = FALSE_;
+ }
+
+/* Find the file table entries for this file. */
+
+ findex = fthead;
+ found = FALSE_;
+ while(! found && findex > 0) {
+ if (fthan[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fth"
+ "an", i__1, "dasfm_", (ftnlen)4660)] == *handle) {
+ found = TRUE_;
+ } else {
+ findex = lnknxt_(&findex, pool);
+ }
+ }
+ if (found) {
+
+/* Now check to see that HANDLE is open for write, as one has */
+/* no business updating a file summary for files that are */
+/* open for read access only. */
+
+ if (ftacc[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fta"
+ "cc", i__1, "dasfm_", (ftnlen)4675)] != 2) {
+ chkin_("DASUFS", (ftnlen)6);
+ setmsg_("DAS file not open for writing. Handle = #, file = '#'.",
+ (ftnlen)54);
+ errint_("#", handle, (ftnlen)1);
+ errfnm_("#", &ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 :
+ s_rnge("ftlun", i__1, "dasfm_", (ftnlen)4681)], (ftnlen)
+ 1);
+ sigerr_("SPICE(DASINVALIDACCESS)", (ftnlen)23);
+ chkout_("DASUFS", (ftnlen)6);
+ return 0;
+ }
+
+/* If any of the counts pertaining to the reserved record are or */
+/* the comment area were changed, we need to record the new */
+/* counts in the file record. Otherwise, leave the file alone. */
+
+ if (*nresvr != ftsum[(i__1 = findex * 14 - 14) < 294 && 0 <= i__1 ?
+ i__1 : s_rnge("ftsum", i__1, "dasfm_", (ftnlen)4693)] || *
+ nresvc != ftsum[(i__2 = findex * 14 - 13) < 294 && 0 <= i__2 ?
+ i__2 : s_rnge("ftsum", i__2, "dasfm_", (ftnlen)4693)] || *
+ ncomr != ftsum[(i__3 = findex * 14 - 12) < 294 && 0 <= i__3 ?
+ i__3 : s_rnge("ftsum", i__3, "dasfm_", (ftnlen)4693)] || *
+ ncomc != ftsum[(i__5 = findex * 14 - 11) < 294 && 0 <= i__5 ?
+ i__5 : s_rnge("ftsum", i__5, "dasfm_", (ftnlen)4693)]) {
+
+/* Read the file record. */
+
+ io___53.ciunit = ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ?
+ i__1 : s_rnge("ftlun", i__1, "dasfm_", (ftnlen)4701)];
+ iostat = s_rdue(&io___53);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_uio(&c__1, idword, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_uio(&c__1, locifn, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_uio(&c__1, (char *)&locrrc, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_uio(&c__1, (char *)&locrch, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_uio(&c__1, (char *)&loccrc, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_uio(&c__1, (char *)&loccch, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_uio(&c__1, locfmt, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_uio(&c__1, tail, (ftnlen)932);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = e_rdue();
+L100004:
+ if (iostat != 0) {
+ chkin_("DASUFS", (ftnlen)6);
+ setmsg_("Attempt to read file record failed. File was '#'. "
+ "Value of IOSTAT was '#'.", (ftnlen)75);
+ errfnm_("#", &ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ?
+ i__1 : s_rnge("ftlun", i__1, "dasfm_", (ftnlen)4718)],
+ (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASREADFAIL)", (ftnlen)18);
+ chkout_("DASUFS", (ftnlen)6);
+ return 0;
+ }
+ io___55.ciunit = ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ?
+ i__1 : s_rnge("ftlun", i__1, "dasfm_", (ftnlen)4726)];
+ iostat = s_wdue(&io___55);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_uio(&c__1, idword, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_uio(&c__1, locifn, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_uio(&c__1, (char *)&(*nresvr), (ftnlen)sizeof(integer)
+ );
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_uio(&c__1, (char *)&(*nresvc), (ftnlen)sizeof(integer)
+ );
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_uio(&c__1, (char *)&(*ncomr), (ftnlen)sizeof(integer))
+ ;
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_uio(&c__1, (char *)&(*ncomc), (ftnlen)sizeof(integer))
+ ;
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_uio(&c__1, locfmt, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_uio(&c__1, tail, (ftnlen)932);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = e_wdue();
+L100005:
+ if (iostat != 0) {
+ chkin_("DASUFS", (ftnlen)6);
+ cl__1.cerr = 0;
+ cl__1.cunit = ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ?
+ i__1 : s_rnge("ftlun", i__1, "dasfm_", (ftnlen)4741)];
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("Attempt to update file record failed. File was '#'."
+ " Value of IOSTAT was '#'.", (ftnlen)77);
+ errfnm_("#", &ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ?
+ i__1 : s_rnge("ftlun", i__1, "dasfm_", (ftnlen)4746)],
+ (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASWRITEFAIL)", (ftnlen)19);
+ chkout_("DASUFS", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* Update the file table. */
+
+ ftsum[(i__1 = findex * 14 - 14) < 294 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftsum", i__1, "dasfm_", (ftnlen)4759)] = *nresvr;
+ ftsum[(i__1 = findex * 14 - 13) < 294 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftsum", i__1, "dasfm_", (ftnlen)4760)] = *nresvc;
+ ftsum[(i__1 = findex * 14 - 12) < 294 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftsum", i__1, "dasfm_", (ftnlen)4761)] = *ncomr;
+ ftsum[(i__1 = findex * 14 - 11) < 294 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftsum", i__1, "dasfm_", (ftnlen)4762)] = *ncomc;
+ ftsum[(i__1 = findex * 14 - 10) < 294 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftsum", i__1, "dasfm_", (ftnlen)4763)] = *free;
+ for (i__ = 1; i__ <= 3; ++i__) {
+ ftsum[(i__1 = i__ + 5 + findex * 14 - 15) < 294 && 0 <= i__1 ?
+ i__1 : s_rnge("ftsum", i__1, "dasfm_", (ftnlen)4766)] =
+ lastla[(i__2 = i__ - 1) < 3 && 0 <= i__2 ? i__2 : s_rnge(
+ "lastla", i__2, "dasfm_", (ftnlen)4766)];
+ ftsum[(i__1 = i__ + 8 + findex * 14 - 15) < 294 && 0 <= i__1 ?
+ i__1 : s_rnge("ftsum", i__1, "dasfm_", (ftnlen)4767)] =
+ lastrc[(i__2 = i__ - 1) < 3 && 0 <= i__2 ? i__2 : s_rnge(
+ "lastrc", i__2, "dasfm_", (ftnlen)4767)];
+ ftsum[(i__1 = i__ + 11 + findex * 14 - 15) < 294 && 0 <= i__1 ?
+ i__1 : s_rnge("ftsum", i__1, "dasfm_", (ftnlen)4768)] =
+ lastwd[(i__2 = i__ - 1) < 3 && 0 <= i__2 ? i__2 : s_rnge(
+ "lastwd", i__2, "dasfm_", (ftnlen)4768)];
+ }
+ } else {
+ chkin_("DASUFS", (ftnlen)6);
+ setmsg_("There is no file open with handle = #", (ftnlen)37);
+ errint_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(DASNOSUCHHANDLE)", (ftnlen)22);
+ chkout_("DASUFS", (ftnlen)6);
+ }
+ return 0;
+/* $Procedure DASHLU ( DAS, handle to logical unit ) */
+
+L_dashlu:
+/* $ Abstract */
+
+/* Return the logical unit associated with a handle. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER UNIT */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of a DAS file. */
+/* UNIT O Corresponding logical unit. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a previously opened DAS file. */
+
+/* $ Detailed_Output */
+
+/* UNIT is the Fortran logical unit to which the file is */
+/* connected. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified handle does not belong to any file that is */
+/* currently known to be open, the error SPICE(DASNOSUCHHANDLE) */
+/* is signaled. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine is a utility used by the DAS system to support */
+/* file I/O. DASHLU may also prove useful to general SPICELIB */
+/* users for constructing error messages. */
+
+/* $ Examples */
+
+/* 1) Obtain the logical unit associated with a DAS file having */
+/* a known handle. */
+
+/* CALL DASHLU ( HANDLE, UNIT ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* map DAS file handle to logical unit */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+
+/* We use discovery check-ins in this routine. */
+
+ if (return_()) {
+ return 0;
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ chkin_("DASHLU", (ftnlen)6);
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ chkout_("DASHLU", (ftnlen)6);
+ pass1 = FALSE_;
+ }
+
+/* Find the file table entries for this file. */
+
+ findex = fthead;
+ found = FALSE_;
+ while(! found && findex > 0) {
+ if (fthan[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fth"
+ "an", i__1, "dasfm_", (ftnlen)4980)] == *handle) {
+ found = TRUE_;
+ } else {
+ findex = lnknxt_(&findex, pool);
+ }
+ }
+ if (found) {
+ *unit = ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "ftlun", i__1, "dasfm_", (ftnlen)4991)];
+ } else {
+ chkin_("DASHLU", (ftnlen)6);
+ setmsg_("There is no file open with handle = #", (ftnlen)37);
+ errint_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(DASNOSUCHHANDLE)", (ftnlen)22);
+ chkout_("DASHLU", (ftnlen)6);
+ }
+ return 0;
+/* $Procedure DASLUH ( DAS, logical unit to handle ) */
+
+L_dasluh:
+/* $ Abstract */
+
+/* Return the handle associated with a logical unit. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER UNIT */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* UNIT I Logical unit connected to a DAS file. */
+/* HANDLE O Corresponding handle. */
+
+/* $ Detailed_Input */
+
+/* UNIT is the logical unit to which a DAS file has been */
+/* connected when it was opened. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the handle associated with the file. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified unit is not connected to any DAS file that is */
+/* currently known to be open, the error SPICE(DASNOSUCHUNIT) */
+/* is signaled. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* It is unlikely, but possible, that a calling program would know */
+/* the logical unit to which a file is connected without knowing the */
+/* handle associated with the file. DASLUH is provided mostly for */
+/* completeness. */
+
+/* $ Examples */
+
+/* In the following code fragment, the handle associated with */
+/* a DAS file is retrieved using the logical unit to which the */
+/* file is connected. The handle is then used to determine the */
+/* name of the file. */
+
+/* CALL DASLUH ( UNIT, HANDLE ) */
+/* CALL DASHFN ( HANDLE, FNAME ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* map logical unit to DAS file handle */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASLUH", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+
+/* Find the file table entries for this file. */
+
+ findex = fthead;
+ found = FALSE_;
+ while(! found && findex > 0) {
+ if (ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftl"
+ "un", i__1, "dasfm_", (ftnlen)5205)] == *unit) {
+ found = TRUE_;
+ } else {
+ findex = lnknxt_(&findex, pool);
+ }
+ }
+ if (found) {
+ *handle = fthan[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "fthan", i__1, "dasfm_", (ftnlen)5215)];
+ } else {
+ setmsg_("There is no DAS file open with unit = #", (ftnlen)39);
+ errint_("#", unit, (ftnlen)1);
+ sigerr_("SPICE(DASNOSUCHUNIT)", (ftnlen)20);
+ }
+ chkout_("DASLUH", (ftnlen)6);
+ return 0;
+/* $Procedure DASHFN ( DAS, handle to file name ) */
+
+L_dashfn:
+/* $ Abstract */
+
+/* Return the name of the DAS file associated with a handle. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* CHARACTER*(*) FNAME */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of a DAS file. */
+/* FNAME O Corresponding file name. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a previously opened DAS file. */
+
+/* $ Detailed_Output */
+
+/* FNAME is the name of the DAS file associated with the input */
+/* file handle. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified handle does not belong to any file that is */
+/* currently known to be open, the error SPICE(DASNOSUCHHANDLE) */
+/* is signaled. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* It may be desirable to recover the names of one or more DAS */
+/* files in a different part of the program from the one in which */
+/* they were opened. Note that the names returned by DASHFN may */
+/* not be identical to the names used to open the files. Under */
+/* most operating systems, a particular file can be accessed using */
+/* many different names. DASHFN returns one of them. */
+
+/* $ Examples */
+
+/* In the following code fragment, the name of a DAS file is */
+/* recovered using the handle associated with the file. */
+
+/* CALL DASOPR ( 'sample.DAS', HANDLE ) */
+/* . */
+/* . */
+
+/* CALL DASHFN ( HANDLE, FNAME ) */
+
+/* Depending on the circumstances (operating system, compiler, */
+/* default directory) the value of FNAME might resemble any of */
+/* the following: */
+
+/* 'USER$DISK:[WYATT.IMAGES]SAMPLE.DAS;4' */
+
+/* '/wyatt/images/sample.DAS' */
+
+/* 'A:\IMAGES\SAMPLE.DAS' */
+
+/* On the other hand, it might not. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* map DAS handle to file name */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASHFN", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+
+/* Find the file table entries for this file. */
+
+ findex = fthead;
+ found = FALSE_;
+ while(! found && findex > 0) {
+ if (fthan[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fth"
+ "an", i__1, "dasfm_", (ftnlen)5443)] == *handle) {
+ found = TRUE_;
+ } else {
+ findex = lnknxt_(&findex, pool);
+ }
+ }
+ if (found) {
+ ioin__1.inerr = 0;
+ ioin__1.inunit = ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 :
+ s_rnge("ftlun", i__1, "dasfm_", (ftnlen)5453)];
+ ioin__1.infile = 0;
+ ioin__1.inex = 0;
+ ioin__1.inopen = 0;
+ ioin__1.innum = 0;
+ ioin__1.innamed = 0;
+ ioin__1.innamlen = fname_len;
+ ioin__1.inname = fname;
+ ioin__1.inacc = 0;
+ ioin__1.inseq = 0;
+ ioin__1.indir = 0;
+ ioin__1.infmt = 0;
+ ioin__1.inform = 0;
+ ioin__1.inunf = 0;
+ ioin__1.inrecl = 0;
+ ioin__1.innrec = 0;
+ ioin__1.inblank = 0;
+ f_inqu(&ioin__1);
+ } else {
+ setmsg_("There is no DAS file open with handle = #", (ftnlen)41);
+ errint_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(DASNOSUCHHANDLE)", (ftnlen)22);
+ }
+ chkout_("DASHFN", (ftnlen)6);
+ return 0;
+/* $Procedure DASFNH ( DAS, file name to handle ) */
+
+L_dasfnh:
+/* $ Abstract */
+
+/* Return handle associated with a file name. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* CHARACTER*(*) FNAME */
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FNAME I Name of a DAS file. */
+/* HANDLE O Corresponding handle. */
+
+/* $ Detailed_Input */
+
+/* FNAME is the name of a previously opened DAS file. */
+
+/* $ Detailed_Output */
+
+/* HANDLE is the handle associated with the file. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the specified name does not specify any DAS file currently */
+/* known to be open, the error SPICE(DASNOSUCHFILE) is signaled. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* It is sometimes easier to work with file names (which are */
+/* meaningful, and often predictable) than with file handles */
+/* (which are neither), especially in interactive situations. */
+/* However, nearly every DAS routine requires that you use file */
+/* handles to refer to files. DASFNH is provided to bridge the gap */
+/* between the two representations. */
+
+/* $ Examples */
+
+/* In the following code fragment, the handle associated with a */
+/* DAS file is recovered using the name of the file. */
+
+/* CALL DASOPR ( 'sample.DAS', HANDLE ) */
+/* . */
+/* . */
+
+/* CALL DASFNH ( 'sample.DAS', HANDLE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* map file name to DAS handle */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASFNH", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+ ioin__1.inerr = 0;
+ ioin__1.infilen = rtrim_(fname, fname_len);
+ ioin__1.infile = fname;
+ ioin__1.inex = 0;
+ ioin__1.inopen = &opened;
+ ioin__1.innum = &number;
+ ioin__1.innamed = 0;
+ ioin__1.inname = 0;
+ ioin__1.inacc = 0;
+ ioin__1.inseq = 0;
+ ioin__1.indir = 0;
+ ioin__1.infmt = 0;
+ ioin__1.inform = 0;
+ ioin__1.inunf = 0;
+ ioin__1.inrecl = 0;
+ ioin__1.innrec = 0;
+ ioin__1.inblank = 0;
+ f_inqu(&ioin__1);
+
+/* Find the file table entries for this file. */
+
+ findex = fthead;
+ found = FALSE_;
+ while(! found && findex > 0) {
+ if (ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftl"
+ "un", i__1, "dasfm_", (ftnlen)5671)] == number) {
+ found = TRUE_;
+ } else {
+ findex = lnknxt_(&findex, pool);
+ }
+ }
+ if (found) {
+ *handle = fthan[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "fthan", i__1, "dasfm_", (ftnlen)5681)];
+ } else {
+ setmsg_("There is no DAS file in the table with file name = '#'", (
+ ftnlen)54);
+ errch_("#", fname, (ftnlen)1, fname_len);
+ sigerr_("SPICE(DASNOSUCHFILE)", (ftnlen)20);
+ }
+ chkout_("DASFNH", (ftnlen)6);
+ return 0;
+/* $Procedure DASHOF ( DAS, handles of open files ) */
+
+L_dashof:
+/* $ Abstract */
+
+/* Return a SPICELIB set containing the handles of all currently */
+/* open DAS files. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+/* SETS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER LBCELL */
+/* PARAMETER ( LBCELL = -5 ) */
+
+/* INTEGER FHSET ( LBCELL : * ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* FHSET O A set containing handles of currently open DAS */
+/* files. */
+
+/* $ Detailed_Input */
+
+/* None. */
+
+/* $ Detailed_Output */
+
+/* FHSET is a SPICELIB set containing the file handles of */
+/* all currently open DAS files. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the set FHSET is not initialized, the error will be */
+/* diagnosed by routines called by this routine. */
+
+/* 2) If the set FHSET is too small to accommodate the set of */
+/* handles to be returned, the error will be diagnosed by */
+/* routines called by this routine. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine allows subroutines to test DAS file handles for */
+/* validity before using them. Many DAS operations that rely on */
+/* handles to identify DAS files cause errors to be signaled if */
+/* the handles are invalid. */
+
+/* $ Examples */
+
+/* 1) Find out how may DAS files are open for writing. */
+
+/* C */
+/* C Find out which DAS files are open. */
+/* C */
+/* CALL DASHOF ( FHSET ) */
+
+/* C */
+/* C Count the ones open for writing. */
+/* C */
+/* COUNT = 0 */
+
+/* DO I = 1, CARDC(FHSET) */
+
+/* CALL DASHAM ( FHSET(I), METHOD ) */
+
+/* IF ( METHOD .EQ. WRITE ) THEN */
+/* COUNT = COUNT + 1 */
+/* END IF */
+
+/* END DO */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* return set of handles of open DAS files */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASHOF", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+
+/* Just stuff our local list into the set. */
+
+ copyi_(fhlist, fhset);
+ chkout_("DASHOF", (ftnlen)6);
+ return 0;
+/* $Procedure DASSIH ( DAS, signal invalid handles ) */
+
+L_dassih:
+/* $ Abstract */
+
+/* Signal an error if a DAS file file handle does not designate a */
+/* DAS file that is open for a specified type of access. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+/* ERROR */
+/* SETS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* CHARACTER*(*) ACCESS */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I HANDLE to be validated. */
+/* ACCESS I String indicating access type. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a DAS file handle to validate. For HANDLE to be */
+/* considered valid, it must specify a DAS file that */
+/* is open for the type of access specified by the */
+/* input argument ACCESS. */
+
+
+/* ACCESS is a string indicating the type of access that */
+/* the DAS file specified by the input argument HANDLE */
+/* must be open for. The values of ACCESS may be */
+
+/* 'READ' File must be open for read access */
+/* by DAS routines. DAS files opened */
+/* for read or write access may be */
+/* read. */
+
+/* 'WRITE' File must be open for write access */
+/* by DAS routines. Note that files */
+/* open for write access may be read as */
+/* well as written. */
+
+/* Leading and trailing blanks in ACCESS are ignored, */
+/* and case is not significant. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the effect of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input argument ACCESS has an unrecognized value, */
+/* the error SPICE(INVALIDOPTION) is signaled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine signals the error SPICE(DASINVALIDACCESS) if the */
+/* DAS designated by the input argument HANDLE is not open */
+/* for the specified type of access. If HANDLE does not designate */
+/* an open DAS file, the error SPICE(DASNOSUCHHANDLE) is signaled. */
+
+/* This routine allows subroutines to test file handles for */
+/* validity before attempting to access the files they designate, */
+/* or before performing operations on the handles themselves, such */
+/* as finding the name of the file designated by a handle. This */
+/* routine should be used in situations where the appropriate action */
+/* to take upon determining that a handle is invalid is to signal */
+/* an error. DASSIH centralizes the error response for this type of */
+/* error in a single routine. */
+
+/* In cases where it is necessary to determine the validity of a */
+/* file handle, but it is not an error for the handle to refer */
+/* to a closed file, the entry point DASHOF should be used instead */
+/* of DASSIH. */
+
+/* $ Examples */
+
+/* 1) Make sure that a file handle designates a DAS file that can */
+/* be read. Signal an error if not. */
+
+/* Note that if a DAS file is open for reading or writing, read */
+/* access is allowed. */
+
+/* CALL DASSIH ( HANDLE, 'READ' ) */
+
+/* IF ( FAILED() ) THEN */
+/* RETURN */
+/* END IF */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.1.0, 26-SEP-2005 (NJB) */
+
+/* Local variable DAS was renamed to DASFIL. This */
+/* was done to avoid future conflict with parameters */
+/* in zzddhman.inc. */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* detect invalid DAS handles */
+/* validate DAS handles */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 6.1.0, 26-SEP-2005 (NJB) */
+
+/* Local variable DAS was renamed to DASFIL. This */
+/* was done to avoid future conflict with parameters */
+/* in zzddhman.inc. */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) (IMU) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASSIH", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+
+/* Get an upper case, left-justified copy of ACCESS. */
+
+ ljust_(access, acc, access_len, (ftnlen)10);
+ ucase_(acc, acc, (ftnlen)10, (ftnlen)10);
+
+/* Make sure we recognize the access type specified by the caller. */
+
+ if (s_cmp(acc, "READ", (ftnlen)10, (ftnlen)4) != 0 && s_cmp(acc, "WRITE",
+ (ftnlen)10, (ftnlen)5) != 0) {
+ setmsg_("Unrecognized access type. Type was #. ", (ftnlen)39);
+ errch_("#", access, (ftnlen)1, access_len);
+ sigerr_("SPICE(INVALIDOPTION)", (ftnlen)20);
+ chkout_("DASSIH", (ftnlen)6);
+ return 0;
+ }
+
+/* See whether the input handle is in our list at all. It's */
+/* unlawful for the handle to be absent. */
+
+ if (! elemi_(handle, fhlist)) {
+ setmsg_("Handle # is not attached to an open DAS file.", (ftnlen)45);
+ errint_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(DASNOSUCHHANDLE)", (ftnlen)22);
+ chkout_("DASSIH", (ftnlen)6);
+ return 0;
+ } else {
+
+/* Find the file table entries for this file. We know they */
+/* must exist. */
+
+ findex = fthead;
+ found = FALSE_;
+ while(! found && findex > 0) {
+ if (fthan[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge(
+ "fthan", i__1, "dasfm_", (ftnlen)6184)] == *handle) {
+ found = TRUE_;
+ } else {
+ findex = lnknxt_(&findex, pool);
+ }
+ }
+
+/* At this point, FINDEX points to the file table entries */
+/* for this file. */
+
+ if (s_cmp(acc, "WRITE", (ftnlen)10, (ftnlen)5) == 0 && ftacc[(i__1 =
+ findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftacc", i__1,
+ "dasfm_", (ftnlen)6196)] != 2) {
+
+/* If the access type is 'WRITE', the DAS file must be open */
+/* for writing. */
+
+ ioin__1.inerr = 0;
+ ioin__1.inunit = ftlun[(i__1 = findex - 1) < 21 && 0 <= i__1 ?
+ i__1 : s_rnge("ftlun", i__1, "dasfm_", (ftnlen)6202)];
+ ioin__1.infile = 0;
+ ioin__1.inex = 0;
+ ioin__1.inopen = 0;
+ ioin__1.innum = 0;
+ ioin__1.innamed = 0;
+ ioin__1.innamlen = 255;
+ ioin__1.inname = dasfil;
+ ioin__1.inacc = 0;
+ ioin__1.inseq = 0;
+ ioin__1.indir = 0;
+ ioin__1.infmt = 0;
+ ioin__1.inform = 0;
+ ioin__1.inunf = 0;
+ ioin__1.inrecl = 0;
+ ioin__1.innrec = 0;
+ ioin__1.inblank = 0;
+ f_inqu(&ioin__1);
+ setmsg_("DAS file not open for writing. Handle = #, file = '#'.",
+ (ftnlen)54);
+ errint_("#", handle, (ftnlen)1);
+ errch_("#", dasfil, (ftnlen)1, (ftnlen)255);
+ sigerr_("SPICE(DASINVALIDACCESS)", (ftnlen)23);
+ chkout_("DASSIH", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* The DAS file's handle is o.k. */
+
+ chkout_("DASSIH", (ftnlen)6);
+ return 0;
+/* $Procedure DASHAM ( DAS, handle to access method ) */
+
+L_dasham:
+/* $ Abstract */
+
+/* Return the allowed access method for a specified DAS file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* CHARACTER*(*) ACCESS */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I HANDLE of a DAS file. */
+/* ACCESS O String indicating allowed access method. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a previously opened DAS file. */
+
+/* $ Detailed_Output */
+
+/* ACCESS is a string indicating the type of access that */
+/* the DAS file specified by the input argument HANDLE */
+/* is open for. The values of ACCESS may be */
+
+/* 'READ' File is open for read access by DAS */
+/* routines. Both the data area and */
+/* the comment area may be read. The */
+/* file may not be modified. */
+
+/* 'WRITE' File is open for write access by */
+/* DAS routines. Files open for */
+/* write access may be read as well as */
+/* written. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input handle is invalid, the error SPICE(INVALIDHANDLE) */
+/* is signaled. ACCESS is not modified. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine allows subroutines to determine the access methods */
+/* allowed for a given DAS file. */
+
+/* $ Examples */
+
+/* 1) Make sure that a file handle designates a DAS file that can */
+/* be read. Signal an error if not. */
+
+/* Note that if a DAS file is open for reading or writing, read */
+/* access is allowed. */
+
+/* CALL DASHAM ( HANDLE, 'READ' ) */
+
+/* IF ( FAILED() ) THEN */
+/* RETURN */
+/* END IF */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* K.R. Gehringer (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 6.0.1, 17-JUL-2002 (BVS) */
+
+/* Added MAC-OSX environments. */
+
+/* - SPICELIB Version 5.0.4, 08-OCT-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitely given. New */
+/* environments are WIN-NT */
+
+/* - SPICELIB Version 5.0.3, 16-SEP-1999 (NJB) */
+
+/* CSPICE environments were added. Some typos were corrected. */
+
+/* - SPICELIB Version 5.0.2, 28-JUL-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. New */
+/* environments are PC-DIGITAL, SGI-O32 and SGI-N32. */
+
+/* - SPICELIB Version 5.0.1, 18-MAR-1999 (WLT) */
+
+/* The environment lines were expanded so that the supported */
+/* environments are now explicitly given. Previously, */
+/* environments such as SUN-SUNOS and SUN-SOLARIS were implied */
+/* by the environment label SUN. */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input and $ Output sections of the header. This was */
+/* done in order to minimize documentation changes if these open */
+/* routines ever change. */
+
+/* - SPICELIB Version 1.0.0, 01-FEB-1993 (NJB) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* return allowed access methods for DAS files */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 01-NOV-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input and $ Output sections of the header. This was */
+/* done in order to minimize documentation changes if these open */
+/* routines ever change. */
+
+/* - SPICELIB Version 1.0.0, 01-FEB-1993 (NJB) (WLT) (IMU) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASHAM", (ftnlen)6);
+ }
+
+/* Initialize the file table pool and handle list, if necessary. */
+
+ if (pass1) {
+ lnkini_(&c__21, pool);
+ ssizei_(&c__21, fhlist);
+ pass1 = FALSE_;
+ }
+
+/* See whether the input handle is in our list at all. It's */
+/* unlawful for the handle to be absent. */
+
+ findex = fthead;
+ found = FALSE_;
+ while(! found && findex > 0) {
+ if (fthan[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("fth"
+ "an", i__1, "dasfm_", (ftnlen)6435)] == *handle) {
+ found = TRUE_;
+ } else {
+ findex = lnknxt_(&findex, pool);
+ }
+ }
+ if (! found) {
+ setmsg_("The handle # does not designate a known DAS file ", (ftnlen)
+ 49);
+ errint_("#", handle, (ftnlen)1);
+ sigerr_("SPICE(INVALIDHANDLE)", (ftnlen)20);
+ chkout_("DASHAM", (ftnlen)6);
+ return 0;
+ }
+
+/* We know about the file if we got this far. Set the output */
+/* argument accordingly. */
+
+ if (ftacc[(i__1 = findex - 1) < 21 && 0 <= i__1 ? i__1 : s_rnge("ftacc",
+ i__1, "dasfm_", (ftnlen)6458)] == 1) {
+ s_copy(access, "READ", access_len, (ftnlen)4);
+ } else {
+ s_copy(access, "WRITE", access_len, (ftnlen)5);
+ }
+ chkout_("DASHAM", (ftnlen)6);
+ return 0;
+} /* dasfm_ */
+
+/* Subroutine */ int dasfm_(char *fname, char *ftype, char *ifname, integer *
+ handle, integer *unit, integer *free, integer *lastla, integer *
+ lastrc, integer *lastwd, integer *nresvr, integer *nresvc, integer *
+ ncomr, integer *ncomc, integer *fhset, char *access, ftnlen fname_len,
+ ftnlen ftype_len, ftnlen ifname_len, ftnlen access_len)
+{
+ return dasfm_0_(0, fname, ftype, ifname, handle, unit, free, lastla,
+ lastrc, lastwd, nresvr, nresvc, ncomr, ncomc, fhset, access,
+ fname_len, ftype_len, ifname_len, access_len);
+ }
+
+/* Subroutine */ int dasopr_(char *fname, integer *handle, ftnlen fname_len)
+{
+ return dasfm_0_(1, fname, (char *)0, (char *)0, handle, (integer *)0, (
+ integer *)0, (integer *)0, (integer *)0, (integer *)0, (integer *)
+ 0, (integer *)0, (integer *)0, (integer *)0, (integer *)0, (char *
+ )0, fname_len, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dasopw_(char *fname, integer *handle, ftnlen fname_len)
+{
+ return dasfm_0_(2, fname, (char *)0, (char *)0, handle, (integer *)0, (
+ integer *)0, (integer *)0, (integer *)0, (integer *)0, (integer *)
+ 0, (integer *)0, (integer *)0, (integer *)0, (integer *)0, (char *
+ )0, fname_len, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dasonw_(char *fname, char *ftype, char *ifname, integer *
+ ncomr, integer *handle, ftnlen fname_len, ftnlen ftype_len, ftnlen
+ ifname_len)
+{
+ return dasfm_0_(3, fname, ftype, ifname, handle, (integer *)0, (integer *)
+ 0, (integer *)0, (integer *)0, (integer *)0, (integer *)0, (
+ integer *)0, ncomr, (integer *)0, (integer *)0, (char *)0,
+ fname_len, ftype_len, ifname_len, (ftnint)0);
+ }
+
+/* Subroutine */ int dasopn_(char *fname, char *ifname, integer *handle,
+ ftnlen fname_len, ftnlen ifname_len)
+{
+ return dasfm_0_(4, fname, (char *)0, ifname, handle, (integer *)0, (
+ integer *)0, (integer *)0, (integer *)0, (integer *)0, (integer *)
+ 0, (integer *)0, (integer *)0, (integer *)0, (integer *)0, (char *
+ )0, fname_len, (ftnint)0, ifname_len, (ftnint)0);
+ }
+
+/* Subroutine */ int dasops_(integer *handle)
+{
+ return dasfm_0_(5, (char *)0, (char *)0, (char *)0, handle, (integer *)0,
+ (integer *)0, (integer *)0, (integer *)0, (integer *)0, (integer *
+ )0, (integer *)0, (integer *)0, (integer *)0, (integer *)0, (char
+ *)0, (ftnint)0, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dasllc_(integer *handle)
+{
+ return dasfm_0_(6, (char *)0, (char *)0, (char *)0, handle, (integer *)0,
+ (integer *)0, (integer *)0, (integer *)0, (integer *)0, (integer *
+ )0, (integer *)0, (integer *)0, (integer *)0, (integer *)0, (char
+ *)0, (ftnint)0, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dashfs_(integer *handle, integer *nresvr, integer *
+ nresvc, integer *ncomr, integer *ncomc, integer *free, integer *
+ lastla, integer *lastrc, integer *lastwd)
+{
+ return dasfm_0_(7, (char *)0, (char *)0, (char *)0, handle, (integer *)0,
+ free, lastla, lastrc, lastwd, nresvr, nresvc, ncomr, ncomc, (
+ integer *)0, (char *)0, (ftnint)0, (ftnint)0, (ftnint)0, (ftnint)
+ 0);
+ }
+
+/* Subroutine */ int dasufs_(integer *handle, integer *nresvr, integer *
+ nresvc, integer *ncomr, integer *ncomc, integer *free, integer *
+ lastla, integer *lastrc, integer *lastwd)
+{
+ return dasfm_0_(8, (char *)0, (char *)0, (char *)0, handle, (integer *)0,
+ free, lastla, lastrc, lastwd, nresvr, nresvc, ncomr, ncomc, (
+ integer *)0, (char *)0, (ftnint)0, (ftnint)0, (ftnint)0, (ftnint)
+ 0);
+ }
+
+/* Subroutine */ int dashlu_(integer *handle, integer *unit)
+{
+ return dasfm_0_(9, (char *)0, (char *)0, (char *)0, handle, unit, (
+ integer *)0, (integer *)0, (integer *)0, (integer *)0, (integer *)
+ 0, (integer *)0, (integer *)0, (integer *)0, (integer *)0, (char *
+ )0, (ftnint)0, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dasluh_(integer *unit, integer *handle)
+{
+ return dasfm_0_(10, (char *)0, (char *)0, (char *)0, handle, unit, (
+ integer *)0, (integer *)0, (integer *)0, (integer *)0, (integer *)
+ 0, (integer *)0, (integer *)0, (integer *)0, (integer *)0, (char *
+ )0, (ftnint)0, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dashfn_(integer *handle, char *fname, ftnlen fname_len)
+{
+ return dasfm_0_(11, fname, (char *)0, (char *)0, handle, (integer *)0, (
+ integer *)0, (integer *)0, (integer *)0, (integer *)0, (integer *)
+ 0, (integer *)0, (integer *)0, (integer *)0, (integer *)0, (char *
+ )0, fname_len, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dasfnh_(char *fname, integer *handle, ftnlen fname_len)
+{
+ return dasfm_0_(12, fname, (char *)0, (char *)0, handle, (integer *)0, (
+ integer *)0, (integer *)0, (integer *)0, (integer *)0, (integer *)
+ 0, (integer *)0, (integer *)0, (integer *)0, (integer *)0, (char *
+ )0, fname_len, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dashof_(integer *fhset)
+{
+ return dasfm_0_(13, (char *)0, (char *)0, (char *)0, (integer *)0, (
+ integer *)0, (integer *)0, (integer *)0, (integer *)0, (integer *)
+ 0, (integer *)0, (integer *)0, (integer *)0, (integer *)0, fhset,
+ (char *)0, (ftnint)0, (ftnint)0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int dassih_(integer *handle, char *access, ftnlen access_len)
+{
+ return dasfm_0_(14, (char *)0, (char *)0, (char *)0, handle, (integer *)0,
+ (integer *)0, (integer *)0, (integer *)0, (integer *)0, (integer
+ *)0, (integer *)0, (integer *)0, (integer *)0, (integer *)0,
+ access, (ftnint)0, (ftnint)0, (ftnint)0, access_len);
+ }
+
+/* Subroutine */ int dasham_(integer *handle, char *access, ftnlen access_len)
+{
+ return dasfm_0_(15, (char *)0, (char *)0, (char *)0, handle, (integer *)0,
+ (integer *)0, (integer *)0, (integer *)0, (integer *)0, (integer
+ *)0, (integer *)0, (integer *)0, (integer *)0, (integer *)0,
+ access, (ftnint)0, (ftnint)0, (ftnint)0, access_len);
+ }
+
diff --git a/ext/spice/src/cspice/dasine.c b/ext/spice/src/cspice/dasine.c
new file mode 100644
index 0000000000..68e6f51c1d
--- /dev/null
+++ b/ext/spice/src/cspice/dasine.c
@@ -0,0 +1,176 @@
+/* dasine.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DASINE (arc sine of bracketed argument) */
+doublereal dasine_(doublereal *arg, doublereal *tol)
+{
+ /* System generated locals */
+ doublereal ret_val, d__1, d__2;
+
+ /* Builtin functions */
+ double asin(doublereal);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errdp_(char *,
+ doublereal *, ftnlen), sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen);
+
+/* $ Abstract */
+
+/* This routine produces a SPICE error if the |argument| exceeds */
+/* 1.D0 by more than TOL. If ARG exceeds 1.D0, the argument is */
+/* evaluated as if it equaled 1.D0, if ARG is less than -1., */
+/* the argument is evaluated as if it equaled -1.D0. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* INTERVALS, NUMBERS, UTILITY, INVERSE TRIGONOMETRIC FUNCTION */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* ARG I Argument to be evaluated. */
+/* TOL I Tolerance. */
+/* DASINE O The function returns the arc sine of ARG. */
+
+/* $ Detailed_Input */
+
+/* ARG is the arc sine argument that is to be evaluated */
+/* such that if it is less than -1.D0 by more than TOL */
+/* or greater than 1.D0 by more than TOL, an error */
+/* results. */
+
+/* TOL is a tolerance such that |ARG| is considered to be */
+/* equal to 1.D0 if |ARG| <= 1.D0 + TOL. TOL must be */
+/* non-negative. */
+
+/* $ Detailed_Output */
+
+/* DASINE The function returns the arc sine of ARG. If |ARG| */
+/* >= 1.D0, it returns DASIN (1.D0) or DASIN (-1.D0) as */
+/* appropriate. Values range from -PI/2 to PI/2. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If |ARG| > 1.D0 + TOL, the error SPICE(INPUTOUTOFBOUNDS) is */
+/* signaled. */
+
+/* 2) If TOL is less than zero, the error SPICE(VALUEOUTOFRANGE) is */
+/* signaled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine determines whether |ARG| > 1.D0 + TOL. If */
+/* it is, an error will be flagged. In addition, */
+/* the values of ARG are constrained to [-1.D0, 1.D0]. */
+
+/* $ Examples */
+
+/* The following illustrate the operation of DASINE. */
+
+/* DASINE ( -1.D0, 1.D-7 ) = -PI/2 */
+/* DASINE ( -1.00001D0, 1.D-3 ) = -PI/2 */
+/* DASINE ( -1.00001D0, 1.D-7 ) = -PI/2 (error flagged) */
+/* DASINE ( 0.D0, 1.D-7 ) = 0.D0 */
+/* DASINE ( 1.00001D0, 1.D-3 ) = PI/2 */
+/* DASINE ( 1.00001D0, 1.D-7 ) = PI/2 (error flagged) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* L.S. Elson (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 28-FEB-2006 (LSE) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* check a d.p. argument for ASIN before evaluation */
+
+/* -& */
+
+/* Bracket ARG. */
+
+/* Computing MAX */
+ d__1 = -1., d__2 = min(1.,*arg);
+ ret_val = asin((max(d__1,d__2)));
+
+/* Check that tolerance is non negative. */
+
+ if (*tol < 0.) {
+ chkin_("DASINE", (ftnlen)6);
+ setmsg_("TOL was #; must be non-negative.", (ftnlen)32);
+ errdp_("#", tol, (ftnlen)1);
+ sigerr_("SPICE(VALUEOUTOFRANGE)", (ftnlen)22);
+ chkout_("DASINE", (ftnlen)6);
+ return ret_val;
+ }
+
+/* Check to see if |ARG| is within TOL of 1.D0. Signal error if */
+/* appropriate. */
+
+ if (abs(*arg) - *tol > 1.) {
+ chkin_("DASINE", (ftnlen)6);
+ setmsg_("The |argument| specified was greater than 1.D0 by more than"
+ " #. The value of the argument is #. ", (ftnlen)95);
+ errdp_("#", tol, (ftnlen)1);
+ errdp_("#", arg, (ftnlen)1);
+ sigerr_("SPICE(INPUTOUTOFBOUNDS)", (ftnlen)23);
+ chkout_("DASINE", (ftnlen)6);
+ return ret_val;
+ }
+ return ret_val;
+} /* dasine_ */
+
diff --git a/ext/spice/src/cspice/dasioc.c b/ext/spice/src/cspice/dasioc.c
new file mode 100644
index 0000000000..2bf20f22a9
--- /dev/null
+++ b/ext/spice/src/cspice/dasioc.c
@@ -0,0 +1,299 @@
+/* dasioc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+
+/* $Procedure DASIOC ( DAS, Fortran I/O, character ) */
+/* Subroutine */ int dasioc_(char *action, integer *unit, integer *recno,
+ char *record, ftnlen action_len, ftnlen record_len)
+{
+ /* Builtin functions */
+ integer s_rdue(cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void),
+ s_wdue(cilist *), e_wdue(void);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen);
+ extern logical eqstr_(char *, char *, ftnlen, ftnlen);
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+ /* Fortran I/O blocks */
+ static cilist io___2 = { 1, 0, 1, 0, 0 };
+ static cilist io___3 = { 1, 0, 0, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Perform Fortran reads and writes of character records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* ACTION I Action to take (read or write). */
+/* UNIT I Fortran unit connected to DAS file. */
+/* RECNO I Number of record to read or write. */
+/* RECORD I-O DAS character record. */
+
+/* $ Detailed_Input */
+
+/* ACTION is a character string specifying whether to read */
+/* from or write to the specified DAS file. Possible */
+/* values are: */
+
+/* 'READ' */
+/* 'WRITE' */
+
+/* Case and leading or trailing blanks are not */
+/* significant. */
+
+
+/* UNIT is the Fortran unit number connected to the DAS */
+/* file that is to be read or written. Given the */
+/* handle of the DAS file, the unit number can be */
+/* obtained using DASHLU. */
+
+/* RECNO is the Fortran record number of the record to be */
+/* read or written. */
+
+/* RECORD is a character array whose contents are to be */
+/* written to record RECNO, if ACTION is WRITE. */
+
+/* $ Detailed_Output */
+
+/* RECORD is a character array whose contents are to be */
+/* set equal to those of record RECNO, if ACTION is */
+/* READ. */
+
+/* $ Parameters */
+
+/* NWC is the number of characters in a DAS character */
+/* record. */
+
+/* $ Exceptions */
+
+/* 1) If the value of ACTION is not recognized, the error */
+/* SPICE(UNRECOGNIZEDACTION) is signalled. */
+
+/* 2) If a Fortran read error occurs, the error */
+/* SPICE(DASFILEREADFAILED) is signalled. */
+
+/* 3) If a Fortran write error occurs, the error */
+/* SPICE(DASFILEWRITEFAILED) is signalled. */
+
+/* $ Files */
+
+/* See the description of the argument UNIT in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Normally, routines outside of SPICELIB will not need to call this */
+/* routine directly. Writes to DAS files should be performed using */
+/* the DASADx and DASUDx routines; reads should be performed using */
+/* the DASRDx routines. */
+
+/* This routines centralizes I/O and the concommitant error handling */
+/* for DAS character records. */
+
+/* Although most DAS routines use file handles to indentify DAS */
+/* files, this routine uses Fortran logical units for this purpose. */
+/* Using unit numbers allows the DASIOx routines to be called from */
+/* any DAS routine, including entry points of DASFM. (DASFM */
+/* contains as entry points the routines DASHLU and DASLUH, which */
+/* map between handles and unit numbers.) */
+
+/* $ Examples */
+
+/* 1) Read and print to the screen character records number 10 */
+/* through 20 from the DAS file designated by HANDLE. */
+
+/* CHARACTER*(NWC) RECORD */
+
+/* . */
+/* . */
+/* . */
+
+/* CALL DASHLU ( HANDLE, UNIT ) */
+/* CALL DASHFN ( HANDLE, NAME ) */
+
+/* DO I = 1, 20 */
+
+/* CALL DASIOC ( 'READ', UNIT, 10, RECORD ) */
+
+/* LABEL = 'Contents of the # record in DAS file #: ' */
+
+/* CALL REPMOT ( LABEL, '#', I, 'L', LABEL ) */
+/* CALL REPMC ( LABEL, '#', NAME, LABEL ) */
+
+/* WRITE (*,*) LABEL */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) RECORD */
+
+/* END DO */
+
+
+
+/* 2) Write the contents of the string RECORD to record number */
+/* 10 in the DAS file designated by HANDLE. */
+
+
+/* CHARACTER*(NWC) RECORD */
+
+/* . */
+/* . */
+/* . */
+
+/* CALL DASHLU ( HANDLE, UNIT ) */
+/* CALL DASIOC ( 'WRITE', UNIT, 10, RECORD ) */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* perform Fortran reads of character records */
+/* perform Fortran writes of character records */
+/* perform low-level I/O for DAS routines */
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Use discovery check-in. */
+
+ if (return_()) {
+ return 0;
+ }
+ if (eqstr_(action, "READ", action_len, (ftnlen)4)) {
+
+/* We're supposed to read the file. */
+
+ io___2.ciunit = *unit;
+ io___2.cirec = *recno;
+ iostat = s_rdue(&io___2);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, record, (ftnlen)1024);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rdue();
+L100001:
+ if (iostat != 0) {
+ chkin_("DASIOC", (ftnlen)6);
+ setmsg_("Could not read DAS character record. File = # Record "
+ "number = #. IOSTAT = #.", (ftnlen)79);
+ errfnm_("#", unit, (ftnlen)1);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASFILEREADFAILED)", (ftnlen)24);
+ chkout_("DASIOC", (ftnlen)6);
+ return 0;
+ }
+ } else if (eqstr_(action, "WRITE", action_len, (ftnlen)5)) {
+
+/* We're supposed to write to the file. */
+
+ io___3.ciunit = *unit;
+ io___3.cirec = *recno;
+ iostat = s_wdue(&io___3);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, record, (ftnlen)1024);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_wdue();
+L100002:
+ if (iostat != 0) {
+ chkin_("DASIOC", (ftnlen)6);
+ setmsg_("Could not write DAS character record. File = # Record"
+ " number = #. IOSTAT = #.", (ftnlen)80);
+ errfnm_("#", unit, (ftnlen)1);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASFILEWRITEFAILED)", (ftnlen)25);
+ chkout_("DASIOC", (ftnlen)6);
+ return 0;
+ }
+ } else {
+
+/* The requested action is a little too weird. */
+
+ chkin_("DASIOC", (ftnlen)6);
+ setmsg_("Action was #; should be READ or WRITE", (ftnlen)37);
+ errch_("#", action, (ftnlen)1, action_len);
+ sigerr_("SPICE(UNRECOGNIZEDACTION)", (ftnlen)25);
+ chkout_("DASIOC", (ftnlen)6);
+ return 0;
+ }
+ return 0;
+} /* dasioc_ */
+
diff --git a/ext/spice/src/cspice/dasiod.c b/ext/spice/src/cspice/dasiod.c
new file mode 100644
index 0000000000..b17d4424fa
--- /dev/null
+++ b/ext/spice/src/cspice/dasiod.c
@@ -0,0 +1,301 @@
+/* dasiod.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__128 = 128;
+
+/* $Procedure DASIOD ( DAS, Fortran I/O, double precision ) */
+/* Subroutine */ int dasiod_(char *action, integer *unit, integer *recno,
+ doublereal *record, ftnlen action_len)
+{
+ /* Builtin functions */
+ integer s_rdue(cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void),
+ s_wdue(cilist *), e_wdue(void);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen);
+ extern logical eqstr_(char *, char *, ftnlen, ftnlen);
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+ /* Fortran I/O blocks */
+ static cilist io___2 = { 1, 0, 1, 0, 0 };
+ static cilist io___3 = { 1, 0, 0, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Perform Fortran reads and writes of double precision records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* ACTION I Action to take (read or write). */
+/* UNIT I Fortran unit connected to DAS file. */
+/* RECNO I Number of record to read or write. */
+/* RECORD I-O DAS double precision record. */
+
+/* $ Detailed_Input */
+
+/* ACTION is a character string specifying whether to read */
+/* from or write to the specified DAS file. Possible */
+/* values are: */
+
+/* 'READ' */
+/* 'WRITE' */
+
+/* Case and leading or trailing blanks are not */
+/* significant. */
+
+
+/* UNIT is the Fortran unit number connected to the DAS */
+/* file that is to be read or written. Given the */
+/* handle of the DAS file, the unit number can be */
+/* obtained using DASHLU. */
+
+/* RECNO is the Fortran record number of the record to be */
+/* read or written. */
+
+/* RECORD is a double precision array whose contents are to */
+/* be written to record RECNO, if ACTION is WRITE. */
+
+/* $ Detailed_Output */
+
+/* RECORD is a double precision array whose contents are to */
+/* be set equal to those of record RECNO, if ACTION */
+/* is READ. */
+
+/* $ Parameters */
+
+/* NWD is the number of elements in a DAS double precision */
+/* record. */
+
+/* $ Exceptions */
+
+/* 1) If the value of ACTION is not recognized, the error */
+/* SPICE(UNRECOGNIZEDACTION) is signalled. */
+
+/* 2) If a Fortran read error occurs, the error */
+/* SPICE(DASFILEREADFAILED) is signalled. */
+
+/* 3) If a Fortran write error occurs, the error */
+/* SPICE(DASFILEWRITEFAILED) is signalled. */
+
+/* $ Files */
+
+/* See the description of the argument UNIT in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Normally, routines outside of SPICELIB will not need to call this */
+/* routine directly. Writes to DAS files should be performed using */
+/* the DASADx and DASUDx routines; reads should be performed using */
+/* the DASRDx routines. */
+
+/* This routines centralizes I/O and the concommitant error handling */
+/* for DAS character records. */
+
+/* Although most DAS routines use file handles to indentify DAS */
+/* files, this routine uses Fortran logical units for this purpose. */
+/* Using unit numbers allows the DASIOx routines to be called from */
+/* any DAS routine, including entry points of DASFM. (DASFM */
+/* contains as entry points the routines DASHLU and DASLUH, which */
+/* map between handles and unit numbers.) */
+
+/* $ Examples */
+
+/* 1) Read and print to the screen double precision records */
+/* number 10 through 20 from the DAS file designated by HANDLE. */
+
+
+/* DOUBLE PRECISION RECORD ( NWD ) */
+/* . */
+/* . */
+/* . */
+
+/* CALL DASHLU ( HANDLE, UNIT ) */
+/* CALL DASHFN ( HANDLE, NAME ) */
+
+/* DO I = 1, 20 */
+
+/* CALL DASIOD ( 'READ', UNIT, 10, RECORD ) */
+
+/* LABEL = 'Contents of the # record in DAS file #: ' */
+
+/* CALL REPMOT ( LABEL, '#', I, 'L', LABEL ) */
+/* CALL REPMC ( LABEL, '#', NAME, LABEL ) */
+
+/* WRITE (*,*) LABEL */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) RECORD */
+
+/* END DO */
+
+
+
+/* 2) Write the contents of the array RECORD to record number */
+/* 10 in the DAS file designated by HANDLE. */
+
+
+/* DOUBLE PRECISION RECORD ( NWD ) */
+
+/* . */
+/* . */
+/* . */
+
+/* CALL DASHLU ( HANDLE, UNIT ) */
+/* CALL DASIOD ( 'WRITE', UNIT, 10, RECORD ) */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* perform Fortran reads of double precision records */
+/* perform Fortran writes of double precision records */
+/* perform low-level I/O for DAS routines */
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Use discovery check-in. */
+
+ if (return_()) {
+ return 0;
+ }
+ if (eqstr_(action, "READ", action_len, (ftnlen)4)) {
+
+/* We're supposed to read the file. */
+
+ io___2.ciunit = *unit;
+ io___2.cirec = *recno;
+ iostat = s_rdue(&io___2);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__128, (char *)&record[0], (ftnlen)sizeof(
+ doublereal));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rdue();
+L100001:
+ if (iostat != 0) {
+ chkin_("DASIOD", (ftnlen)6);
+ setmsg_("Could not read DAS double precision record. File = # Re"
+ "cord number = #. IOSTAT = #.", (ftnlen)83);
+ errfnm_("#", unit, (ftnlen)1);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASFILEREADFAILED)", (ftnlen)24);
+ chkout_("DASIOD", (ftnlen)6);
+ return 0;
+ }
+ } else if (eqstr_(action, "WRITE", action_len, (ftnlen)5)) {
+
+/* We're supposed to write to the file. */
+
+ io___3.ciunit = *unit;
+ io___3.cirec = *recno;
+ iostat = s_wdue(&io___3);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__128, (char *)&record[0], (ftnlen)sizeof(
+ doublereal));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_wdue();
+L100002:
+ if (iostat != 0) {
+ chkin_("DASIOD", (ftnlen)6);
+ setmsg_("Could not write DAS double precision record. File = # R"
+ "ecord number = #. IOSTAT = #.", (ftnlen)84);
+ errfnm_("#", unit, (ftnlen)1);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASFILEWRITEFAILED)", (ftnlen)25);
+ chkout_("DASIOD", (ftnlen)6);
+ return 0;
+ }
+ } else {
+
+/* The requested action is a little too weird. */
+
+ chkin_("DASIOD", (ftnlen)6);
+ setmsg_("Action was #; should be READ or WRITE", (ftnlen)37);
+ errch_("#", action, (ftnlen)1, action_len);
+ sigerr_("SPICE(UNRECOGNIZEDACTION)", (ftnlen)25);
+ chkout_("DASIOD", (ftnlen)6);
+ return 0;
+ }
+ return 0;
+} /* dasiod_ */
+
diff --git a/ext/spice/src/cspice/dasioi.c b/ext/spice/src/cspice/dasioi.c
new file mode 100644
index 0000000000..28c82f23cc
--- /dev/null
+++ b/ext/spice/src/cspice/dasioi.c
@@ -0,0 +1,297 @@
+/* dasioi.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__256 = 256;
+
+/* $Procedure DASIOI ( DAS, Fortran I/O, integer ) */
+/* Subroutine */ int dasioi_(char *action, integer *unit, integer *recno,
+ integer *record, ftnlen action_len)
+{
+ /* Builtin functions */
+ integer s_rdue(cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void),
+ s_wdue(cilist *), e_wdue(void);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen);
+ extern logical eqstr_(char *, char *, ftnlen, ftnlen);
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+ /* Fortran I/O blocks */
+ static cilist io___2 = { 1, 0, 1, 0, 0 };
+ static cilist io___3 = { 1, 0, 0, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Perform Fortran reads and writes of integer records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* ACTION I Action to take (read or write). */
+/* UNIT I Fortran unit connected to DAS file. */
+/* RECNO I Number of record to read or write. */
+/* RECORD I-O DAS integer record. */
+
+/* $ Detailed_Input */
+
+/* ACTION is a character string specifying whether to read */
+/* from or write to the specified DAS file. Possible */
+/* values are: */
+
+/* 'READ' */
+/* 'WRITE' */
+
+/* Case and leading or trailing blanks are not */
+/* significant. */
+
+
+/* UNIT is the Fortran unit number connected to the DAS */
+/* file that is to be read or written. Given the */
+/* handle of the DAS file, the unit number can be */
+/* obtained using DASHLU. */
+
+/* RECNO is the Fortran record number of the record to be */
+/* read or written. */
+
+/* RECORD is an integer array whose contents are to be */
+/* written to record RECNO, if ACTION is WRITE. */
+
+/* $ Detailed_Output */
+
+/* RECORD is an integer array whose contents are to be */
+/* set equal to those of record RECNO, if ACTION */
+/* is READ. */
+
+/* $ Parameters */
+
+/* NWI is the number of elements in a DAS integer record. */
+
+/* $ Exceptions */
+
+/* 1) If the value of ACTION is not recognized, the error */
+/* SPICE(UNRECOGNIZEDACTION) is signalled. */
+
+/* 2) If a Fortran read error occurs, the error */
+/* SPICE(DASFILEREADFAILED) is signalled. */
+
+/* 3) If a Fortran write error occurs, the error */
+/* SPICE(DASFILEWRITEFAILED) is signalled. */
+
+/* $ Files */
+
+/* See the description of the argument UNIT in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Normally, routines outside of SPICELIB will not need to call this */
+/* routine directly. Writes to DAS files should be performed using */
+/* the DASADx and DASUDx routines; reads should be performed using */
+/* the DASRDx routines. */
+
+/* This routines centralizes I/O and the concommitant error handling */
+/* for DAS character records. */
+
+/* Although most DAS routines use file handles to indentify DAS */
+/* files, this routine uses Fortran logical units for this purpose. */
+/* Using unit numbers allows the DASIOx routines to be called from */
+/* any DAS routine, including entry points of DASFM. (DASFM */
+/* contains as entry points the routines DASHLU and DASLUH, which */
+/* map between handles and unit numbers.) */
+
+/* $ Examples */
+
+/* 1) Read and print to the screen integer records number 10 */
+/* through 20 from the DAS file designated by HANDLE. */
+
+/* INTEGER RECORD ( NWI ) */
+/* . */
+/* . */
+/* . */
+
+/* CALL DASHLU ( HANDLE, UNIT ) */
+/* CALL DASHFN ( HANDLE, NAME ) */
+
+/* DO I = 1, 20 */
+
+/* CALL DASIOI ( 'READ', UNIT, 10, RECORD ) */
+
+/* LABEL = 'Contents of the # record in DAS file #: ' */
+
+/* CALL REPMOT ( LABEL, '#', I, 'L', LABEL ) */
+/* CALL REPMC ( LABEL, '#', NAME, LABEL ) */
+
+/* WRITE (*,*) LABEL */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) RECORD */
+
+/* END DO */
+
+
+
+/* 2) Write the contents of the array RECORD to record number */
+/* 10 in the DAS file designated by HANDLE. */
+
+
+/* INTEGER RECORD ( NWI ) */
+
+/* . */
+/* . */
+/* . */
+
+/* CALL DASHLU ( HANDLE, UNIT ) */
+/* CALL DASIOI ( 'WRITE', UNIT, 10, RECORD ) */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* perform Fortran reads of integer records */
+/* perform Fortran writes of integer records */
+/* perform low-level I/O for DAS routines */
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Use discovery check-in. */
+
+ if (return_()) {
+ return 0;
+ }
+ if (eqstr_(action, "READ", action_len, (ftnlen)4)) {
+
+/* We're supposed to read the file. */
+
+ io___2.ciunit = *unit;
+ io___2.cirec = *recno;
+ iostat = s_rdue(&io___2);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__256, (char *)&record[0], (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rdue();
+L100001:
+ if (iostat != 0) {
+ chkin_("DASIOI", (ftnlen)6);
+ setmsg_("Could not read DAS integer record. File = # Record numb"
+ "er = #. IOSTAT = #.", (ftnlen)74);
+ errfnm_("#", unit, (ftnlen)1);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASFILEREADFAILED)", (ftnlen)24);
+ chkout_("DASIOI", (ftnlen)6);
+ return 0;
+ }
+ } else if (eqstr_(action, "WRITE", action_len, (ftnlen)5)) {
+
+/* We're supposed to write to the file. */
+
+ io___3.ciunit = *unit;
+ io___3.cirec = *recno;
+ iostat = s_wdue(&io___3);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__256, (char *)&record[0], (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_wdue();
+L100002:
+ if (iostat != 0) {
+ chkin_("DASIOI", (ftnlen)6);
+ setmsg_("Could not write DAS integer record. File = # Record num"
+ "ber = #. IOSTAT = #.", (ftnlen)75);
+ errfnm_("#", unit, (ftnlen)1);
+ errint_("#", recno, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASFILEWRITEFAILED)", (ftnlen)25);
+ chkout_("DASIOI", (ftnlen)6);
+ return 0;
+ }
+ } else {
+
+/* The requested action is a little too weird. */
+
+ chkin_("DASIOI", (ftnlen)6);
+ setmsg_("Action was #; should be READ or WRITE", (ftnlen)37);
+ errch_("#", action, (ftnlen)1, action_len);
+ sigerr_("SPICE(UNRECOGNIZEDACTION)", (ftnlen)25);
+ chkout_("DASIOI", (ftnlen)6);
+ return 0;
+ }
+ return 0;
+} /* dasioi_ */
+
diff --git a/ext/spice/src/cspice/daslla.c b/ext/spice/src/cspice/daslla.c
new file mode 100644
index 0000000000..edb4c1015b
--- /dev/null
+++ b/ext/spice/src/cspice/daslla.c
@@ -0,0 +1,204 @@
+/* daslla.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DASLLA ( DAS, last logical addresses ) */
+/* Subroutine */ int daslla_(integer *handle, integer *lastc, integer *lastd,
+ integer *lasti)
+{
+ integer free;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc, ncomr;
+ extern /* Subroutine */ int dashfs_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *, integer *, integer *);
+ integer lastla[3], lastrc[3];
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ integer lastwd[3], nresvc;
+ extern logical return_(void);
+ integer nresvr;
+
+/* $ Abstract */
+
+/* Return last DAS logical addresses of character, double precision */
+/* and integer type that are currently in use in a specified DAS */
+/* file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ARRAY */
+/* DAS */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* LASTC O Last character address in use. */
+/* LASTD O Last double precision address in use. */
+/* LASTI O Last integer address in use. */
+/* CHR P Parameter indicating character data type. */
+/* DP P Parameter indicating double precision data type. */
+/* INT P Parameter indicating integerer data type. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the file handle of a DAS file whose active */
+/* logical address ranges are desired. */
+
+/* $ Detailed_Output */
+
+/* LASTC, */
+/* LASTD, */
+/* LASTI are, respectively, the last logical addresses of */
+/* character, double precision, and integer type in */
+/* use in the specified DAS file. */
+
+/* $ Parameters */
+
+/* CHR, */
+/* DP, */
+/* INT are data type specifiers which indicate */
+/* `character', `double precision', and `integer' */
+/* respectively. These parameters are used in */
+/* all DAS routines that require a data type */
+/* specifier as input. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine is a utility that allows a calling program to */
+/* find the range of logical addresses currently in use in any */
+/* DAS file. */
+
+/* $ Examples */
+
+/* 1) Create a DAS file containing 10 integers, 5 double precision */
+/* numbers, and 4 characters, then use DASLLA to find the logical */
+/* address ranges in use. */
+
+/* C */
+/* C Use a scratch file, since there's no reason to keep */
+/* C the file. */
+/* C */
+/* C */
+/* CALL DASOPS ( HANDLE ) */
+
+/* DO I = 1, 10 */
+/* CALL DASADI ( HANDLE, 1, I ) */
+/* END DO */
+
+/* DO I = 1, 5 */
+/* CALL DASADD ( HANDLE, 1, DBLE(I) ) */
+/* END DO */
+
+/* CALL DASADC ( HANDLE, 1, 'SPUD' ) */
+
+/* C */
+/* C Now check the logical address ranges. */
+/* C */
+/* CALL DASLLA ( HANDLE, LASTC, LASTD, LASTI ) */
+
+/* WRITE (*,*) 'Last character address in use: ', LASTC */
+/* WRITE (*,*) 'Last d.p. address in use: ', LASTD */
+/* WRITE (*,*) 'Last integer address in use: ', LASTI */
+
+
+/* The output of this code fragment should be: */
+
+/* Last character address in use: 4 */
+/* Last d.p. address in use: 5 */
+/* Last integer address in use: 10 */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* return last logical addresses in DAS file */
+/* return logical address range of DAS file */
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASLLA", (ftnlen)6);
+ }
+
+/* The file summary for the indicated DAS file contains all of the */
+/* information we need. */
+
+ dashfs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla, lastrc,
+ lastwd);
+ *lastc = lastla[0];
+ *lastd = lastla[1];
+ *lasti = lastla[2];
+ chkout_("DASLLA", (ftnlen)6);
+ return 0;
+} /* daslla_ */
+
diff --git a/ext/spice/src/cspice/dasopr_c.c b/ext/spice/src/cspice/dasopr_c.c
new file mode 100644
index 0000000000..59eae61dad
--- /dev/null
+++ b/ext/spice/src/cspice/dasopr_c.c
@@ -0,0 +1,180 @@
+/*
+
+-Procedure dasopr_c ( DAS, open for read )
+
+-Abstract
+
+ Open a DAS file for reading.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ DAS
+
+-Keywords
+
+ DAS
+ FILES
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ void dasopr_c ( ConstSpiceChar * fname,
+ SpiceInt * handle )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ fname I Name of a DAS file to be opened.
+ handle O Handle assigned to the opened DAS file.
+
+-Detailed_Input
+
+ fname is the name of a DAS file to be opened with read
+ access.
+
+-Detailed_Output
+
+ handle is the handle that is associated with the file. This
+ handle is used to identify the file in subsequent
+ calls to other DAS routines.
+
+-Parameters
+
+ None.
+
+-Files
+
+ See argument `fname'.
+
+-Exceptions
+
+ 1) If the input filename is blank, the error SPICE(BLANKFILENAME)
+ will be signaled.
+
+ 2) If the specified file does not exist, the error
+ SPICE(FILENOTFOUND) will be signaled.
+
+ 3) If the specified file has already been opened for read
+ access, the handle already associated with the file is
+ returned.
+
+ 4) If the specified file has already been opened for write
+ access, the error SPICE(DASRWCONFLICT) is signaled.
+
+ 5) If the specified file has already been opened by a non-DAS
+ routine, the error SPICE(DASIMPROPOPEN) is signaled.
+
+ 6) If the specified file cannot be opened without exceeding
+ the maximum allowed number of open DAS files, the error
+ SPICE(DASFTFULL) is signaled.
+
+ 7) If the named file cannot be opened properly, the error
+ SPICE(DASOPENFAIL) is signaled.
+
+ 8) If the file record cannot be read, the error
+ SPICE(FILEREADFAILED) will be signaled.
+
+ 9) If the specified file is not a DAS file, as indicated by the
+ file's ID word, the error SPICE(NOTADASFILE) is signaled.
+
+ 10) If no logical units are available, the error will be
+ signaled by routines called by this routine.
+
+-Particulars
+
+ Most DAS files require only read access. If you do not need to
+ change the contents of a file, you should open it using dasopr_c.
+
+-Examples
+
+ 1) Open the existing DAS file TEST.DAS for reading.
+
+ dasopr_c ( "TEST.DAS", &handle );
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ K.R. Gehringer (JPL)
+ W.L. Taber (JPL)
+ F.S. Turner (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 05-OCT-2006 (NJB) (KRG) (WLT) (FST) (IMU)
+
+-Index_Entries
+
+ open a DAS file for reading
+ open a DAS file for read access
+
+-&
+*/
+
+{ /* Begin dasopr_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dasopr_c" );
+
+ /*
+ Check the input string to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "dasopr_c", fname );
+
+
+ /*
+ Call the f2c'd Fortran routine. Use explicit type casts for every
+ type defined by f2c.
+ */
+ dasopr_ ( ( char * ) fname,
+ ( integer * ) handle,
+ ( ftnlen ) strlen(fname) );
+
+
+ chkout_c ( "dasopr_c" );
+
+} /* End dasopr_c */
diff --git a/ext/spice/src/cspice/dasrcr.c b/ext/spice/src/cspice/dasrcr.c
new file mode 100644
index 0000000000..18a8e65507
--- /dev/null
+++ b/ext/spice/src/cspice/dasrcr.c
@@ -0,0 +1,465 @@
+/* dasrcr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__3 = 3;
+static integer c__256 = 256;
+
+/* $Procedure DASRCR ( DAS, remove comment records ) */
+/* Subroutine */ int dasrcr_(integer *handle, integer *n)
+{
+ /* Initialized data */
+
+ static integer next[3] = { 2,3,1 };
+ static integer prev[3] = { 3,1,2 };
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer base;
+ char recc[1024];
+ doublereal recd[128];
+ integer free, reci[256], lrec, nrec, unit, type__, i__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc;
+ extern /* Subroutine */ int maxai_(integer *, integer *, integer *,
+ integer *);
+ integer ncomr, lword, ltype;
+ extern logical failed_(void);
+ extern /* Subroutine */ int cleari_(integer *, integer *), dasioc_(char *,
+ integer *, integer *, char *, ftnlen, ftnlen), dasiod_(char *,
+ integer *, integer *, doublereal *, ftnlen);
+ integer dirrec[256];
+ extern /* Subroutine */ int dashfs_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *, integer *, integer *),
+ dassih_(integer *, char *, ftnlen), dasioi_(char *, integer *,
+ integer *, integer *, ftnlen);
+ integer lastla[3];
+ extern /* Subroutine */ int dashlu_(integer *, integer *), daswbr_(
+ integer *);
+ integer lindex;
+ extern /* Subroutine */ int dasufs_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *, integer *, integer *);
+ integer lastrc[3], nshift;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen);
+ integer lastwd[3], nresvc;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ extern logical return_(void);
+ integer nresvr, loc, pos;
+
+/* $ Abstract */
+
+/* Decrease the size of the comment area in a DAS file to reclaim */
+/* space freed by the removal of a specified number of comment */
+/* records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I A DAS file handle. */
+/* N I Number of comment records to remove. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of an existing DAS file opened for */
+/* comment area modification by DASOPC. */
+
+/* N is the number of records to remove from the end of */
+/* the comment area. of the specified file. If NCOMR */
+/* is the number of comment records present in the */
+/* file on input, then on output the number of comment */
+/* records will be MAX ( 0, NCOMR - N ). */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the effect of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input handle is invalid, the error will be diagnosed by */
+/* routines called by this routine. */
+
+/* 2) If an I/O error occurs during the removal process, the error */
+/* will be diagnosed by routines called by this routine. The */
+/* DAS file will probably be corrupted in this case. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine is used to reclaim freed space in the comment area */
+/* of a DAS file subsequent to removal of comments from the file. */
+/* Any existing directory records and data records will be shifted */
+/* up by N records. */
+
+/* This routine updates the file record of the specified DAS file */
+/* to reflect the addition of records to the file's comment area. */
+/* Also, the file summary obtainable from DASHFS will be updated to */
+/* reflect the addition of comment records. */
+
+/* The disk space occupied by the specified DAS file will not */
+/* decrease as a result of calling this routine, but the number of */
+/* records occupied by meaningful data will decrease. The useful */
+/* records in the file can be copied by DAS routines to create a */
+/* new, smaller file which contains only the meaningful data. */
+
+/* This routine may be used only on existing DAS files opened by */
+/* DASOPC. */
+
+/* The association of DAS logical addresses and data within the */
+/* specified file will remain unaffected by use of this routine. */
+
+/* Normally, SPICELIB applications will not call this routine */
+/* directly, but will remove comments by calling DASRC. */
+
+/* This routine has an inverse DASACR, which appends a specified */
+/* number of records to the end of the comment area. */
+
+/* $ Examples */
+
+
+/* C */
+/* C Open an existing DAS file for modification of */
+/* C the comment area. We'll presume that the file */
+/* C contains 20 comment records. */
+/* C */
+/* CALL DASOPC ( DAS, HANDLE ) */
+
+/* C */
+/* C Remove the last 10 comment records from the file. */
+/* C */
+/* CALL DASRCR ( HANDLE, 10 ) */
+
+/* C */
+/* C Close the file. */
+/* C */
+/* CALL DASCLS ( HANDLE ) */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 15-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* remove comment records from a DAS file */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Words per data record, for each data type: */
+
+
+/* Data type parameters */
+
+
+/* Directory pointer locations (backward and forward): */
+
+
+/* Directory address range locations */
+
+
+/* Location of first type descriptor */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* NEXT and PREV map the DAS data type codes to their */
+/* successors and predecessors, respectively. */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASRCR", (ftnlen)6);
+ }
+
+/* Make sure this DAS file is open for writing. Signal an error if */
+/* not. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+
+/* Get the logical unit for this DAS file. */
+
+ dashlu_(handle, &unit);
+ if (failed_()) {
+ chkout_("DASRCR", (ftnlen)6);
+ return 0;
+ }
+
+/* It's a mistake to use a negative value of N. */
+
+ if (*n < 0) {
+ setmsg_("Number of comment records to remove must be non-negative. "
+ "Actual number requested was #.", (ftnlen)89);
+ errint_("#", n, (ftnlen)1);
+ sigerr_("SPICE(DASINVALIDCOUNT)", (ftnlen)22);
+ chkout_("DASRCR", (ftnlen)6);
+ return 0;
+ }
+
+/* Before doing anything to the file, make sure that the DASRWR */
+/* data buffers do not contain any updated records for this file. */
+/* All of the record numbers that pertain to this file and remain */
+/* in the DASRWR buffers will be invalidated after this routine */
+/* returns. */
+
+/* DASWBR flushes buffered records to the file. */
+
+ daswbr_(handle);
+
+/* Grab the file summary for this DAS file. Find the number of */
+/* reserved records and the number of the first free record. */
+
+ dashfs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla, lastrc,
+ lastwd);
+
+/* Determine the size of the record shift we'll actually perform. */
+
+ nshift = min(*n,ncomr);
+
+/* Find the record and word positions LREC and LWORD of the last */
+/* descriptor in the file, and also find the type of the descriptor */
+/* LTYPE. */
+
+ maxai_(lastrc, &c__3, &lrec, &loc);
+ lword = 0;
+ for (i__ = 1; i__ <= 3; ++i__) {
+ if (lastrc[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("lastrc",
+ i__1, "dasrcr_", (ftnlen)365)] == lrec && lastwd[(i__2 = i__
+ - 1) < 3 && 0 <= i__2 ? i__2 : s_rnge("lastwd", i__2, "dasrc"
+ "r_", (ftnlen)365)] > lword) {
+ lword = lastwd[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastwd", i__1, "dasrcr_", (ftnlen)368)];
+ ltype = i__;
+ }
+ }
+
+/* LREC, LWORD, and LTYPE are now the record, word, and data type */
+/* of the last descriptor in the file. If LREC is zero, there are */
+/* no directories in the file yet. However, even DAS files that */
+/* don't contain any data have their first directory records */
+/* zeroed out, and this should remain true after the removal of */
+/* the comment records. */
+
+ if (lrec == 0) {
+
+/* Just write the zero-filled record to record number */
+
+/* NRESVR + NCOMR + 2 - NSHIFT */
+
+ cleari_(&c__256, dirrec);
+ i__1 = nresvr + ncomr + 2 - nshift;
+ dasioi_("WRITE", &unit, &i__1, dirrec, (ftnlen)5);
+ } else {
+
+/* There really is stuff to move. For each directory record, */
+/* move the record and then all of the records described by that */
+/* record. We start at the beginning of the data area and move */
+/* downwards in the file as we go. */
+
+ nrec = nresvr + ncomr + 2;
+ while(nrec <= lrec && nrec != 0) {
+
+/* Read the current directory record and move it. */
+
+ dasioi_("READ", &unit, &nrec, dirrec, (ftnlen)4);
+ i__1 = nrec - nshift;
+ dasioi_("WRITE", &unit, &i__1, dirrec, (ftnlen)5);
+
+/* For each descriptor in the current directory, move the */
+/* cluster of data records it refers to. */
+
+/* Find the data type, size, and base record number of the */
+/* first cluster described by the current directory. Also */
+/* find the index within the directory of the directory's */
+/* last descriptor. */
+
+ type__ = dirrec[8];
+ base = nrec + 1;
+ if (nrec == lrec) {
+ lindex = lword;
+ } else {
+ lindex = 256;
+ }
+
+/* We'll now traverse the directory in forward order, keeping */
+/* track of cluster sizes and types as we go. */
+
+/* POS will be the index of the descriptor of the current */
+/* cluster. */
+
+ pos = 10;
+ while(pos <= lindex) {
+ if (pos > 10) {
+
+/* We'll need to determine the type of the current */
+/* cluster. If the descriptor contains a positive */
+/* value, the data type of the cluster it refers to is */
+/* the successor of the previous type, according to our */
+/* ordering of types. */
+
+ if (dirrec[(i__1 = pos - 1) < 256 && 0 <= i__1 ? i__1 :
+ s_rnge("dirrec", i__1, "dasrcr_", (ftnlen)445)] >
+ 0) {
+ type__ = next[(i__1 = type__ - 1) < 3 && 0 <= i__1 ?
+ i__1 : s_rnge("next", i__1, "dasrcr_", (
+ ftnlen)446)];
+ } else {
+ type__ = prev[(i__1 = type__ - 1) < 3 && 0 <= i__1 ?
+ i__1 : s_rnge("prev", i__1, "dasrcr_", (
+ ftnlen)448)];
+ }
+
+/* Update the cluster base record number. */
+
+ base += (i__2 = dirrec[(i__1 = pos - 2) < 256 && 0 <=
+ i__1 ? i__1 : s_rnge("dirrec", i__1, "dasrcr_", (
+ ftnlen)454)], abs(i__2));
+ }
+
+/* BASE and TYPE now are correctly set for the current */
+/* cluster. Move the cluster. */
+
+ i__3 = base + (i__2 = dirrec[(i__1 = pos - 1) < 256 && 0 <=
+ i__1 ? i__1 : s_rnge("dirrec", i__1, "dasrcr_", (
+ ftnlen)462)], abs(i__2)) - 1;
+ for (i__ = base; i__ <= i__3; ++i__) {
+ if (type__ == 1) {
+ dasioc_("READ", &unit, &i__, recc, (ftnlen)4, (ftnlen)
+ 1024);
+ i__1 = i__ - nshift;
+ dasioc_("WRITE", &unit, &i__1, recc, (ftnlen)5, (
+ ftnlen)1024);
+ } else if (type__ == 2) {
+ dasiod_("READ", &unit, &i__, recd, (ftnlen)4);
+ i__1 = i__ - nshift;
+ dasiod_("WRITE", &unit, &i__1, recd, (ftnlen)5);
+ } else {
+ dasioi_("READ", &unit, &i__, reci, (ftnlen)4);
+ i__1 = i__ - nshift;
+ dasioi_("WRITE", &unit, &i__1, reci, (ftnlen)5);
+ }
+ }
+
+/* The next descriptor to look at is the next one in the */
+/* current directory. */
+
+ ++pos;
+ }
+
+/* Find the next directory record. */
+
+ nrec = dirrec[1];
+ }
+ }
+
+/* Update the file summary. The number of comment records and the */
+/* number of the first free record have been decremented by NSHIFT. */
+/* The numbers of the records containing the last descriptor of each */
+/* type have been decremented by NSHIFT only if they were non-zero. */
+
+
+/* The call to DASUFS will update the file record as well as the */
+/* file summary. */
+
+ ncomr -= nshift;
+ free -= nshift;
+ for (i__ = 1; i__ <= 3; ++i__) {
+ if (lastrc[(i__3 = i__ - 1) < 3 && 0 <= i__3 ? i__3 : s_rnge("lastrc",
+ i__3, "dasrcr_", (ftnlen)515)] != 0) {
+ lastrc[(i__3 = i__ - 1) < 3 && 0 <= i__3 ? i__3 : s_rnge("lastrc",
+ i__3, "dasrcr_", (ftnlen)516)] = lastrc[(i__1 = i__ - 1)
+ < 3 && 0 <= i__1 ? i__1 : s_rnge("lastrc", i__1, "dasrcr_"
+ , (ftnlen)516)] - nshift;
+ }
+ }
+ dasufs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla, lastrc,
+ lastwd);
+ chkout_("DASRCR", (ftnlen)6);
+ return 0;
+} /* dasrcr_ */
+
diff --git a/ext/spice/src/cspice/dasrdc.c b/ext/spice/src/cspice/dasrdc.c
new file mode 100644
index 0000000000..aa7fb7341b
--- /dev/null
+++ b/ext/spice/src/cspice/dasrdc.c
@@ -0,0 +1,480 @@
+/* dasrdc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+
+/* $Procedure DASRDC ( DAS, read data, character ) */
+/* Subroutine */ int dasrdc_(integer *handle, integer *first, integer *last,
+ integer *bpos, integer *epos, char *data, ftnlen data_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen);
+
+ /* Local variables */
+ integer l, n, nread;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer recno, nmove, rcpos;
+ extern /* Subroutine */ int dasa2l_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *);
+ extern logical failed_(void);
+ integer clbase;
+ extern /* Subroutine */ int dasrrc_(integer *, integer *, integer *,
+ integer *, char *, ftnlen);
+ integer nmoved, clsize;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ integer numchr;
+ extern /* Subroutine */ int chkout_(char *, ftnlen), setmsg_(char *,
+ ftnlen), errint_(char *, integer *, ftnlen);
+ integer wordno, chr, elt;
+
+/* $ Abstract */
+
+/* Read character data from a range of DAS logical addresses. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ARRAY */
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* FIRST, */
+/* LAST I Range of DAS character logical addresses. */
+/* BPOS, */
+/* EPOS I Begin and end positions of substrings. */
+/* DATA O Data having addresses FIRST through LAST. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a file handle for an open DAS file. */
+
+/* FIRST, */
+/* LAST are a range of DAS character logical addresses. */
+/* FIRST and LAST must be greater than or equal to */
+/* 1 and less than or equal to the highest character */
+/* logical address in the DAS file designated by */
+/* HANDLE. */
+
+/* BPOS, */
+/* EPOS are begin and end character positions that define */
+/* the substrings of the elements of the output array */
+/* DATA into which character data is to be read. */
+
+/* $ Detailed_Output */
+
+/* DATA is an array of character strings. On output, the */
+/* character words in the logical address range */
+/* FIRST through LAST are copied into the characters */
+
+/* DATA(1)(BPOS:BPOS), */
+/* DATA(1)(BPOS+1:BPOS+1), */
+/* . */
+/* . */
+/* . */
+/* DATA(1)(EPOS:EPOS), */
+/* DATA(2)(BPOS:BPOS), */
+/* DATA(2)(BPOS+1:BPOS+1), */
+/* . */
+/* . */
+/* . */
+
+/* in that order. */
+
+/* DATA must have dimension at least */
+
+/* ( LAST - FIRST + L ) / L */
+
+/* where */
+
+/* L = EPOS - BPOS + 1 */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. DATA will */
+/* not be modified. */
+
+/* 2) If EPOS or BPOS are outside of the range */
+/* [ 1, LEN( DATA(1) ) ], or if EPOS < BPOS, the error */
+/* SPICE(BADSUBSTRINGBOUNDS) will be signalled. */
+
+/* 3) If FIRST or LAST are out of range, the error will be diagnosed */
+/* by routines called by this routine. DATA will not be */
+/* modified. */
+
+/* 4) If FIRST is greater than LAST, DATA is left unchanged. */
+
+/* 5) If DATA is declared with length less than */
+
+/* ( LAST - FIRST + ( EPOS-BPOS+1 ) ) / ( EPOS-BPOS+1 ) */
+
+/* the error cannot be diagnosed by this routine. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine provides random read access to the character data in */
+/* a DAS file. This data is logically structured as a */
+/* one-dimensional array of characters. */
+
+/* However, since Fortran programs usually use strings rather */
+/* than arrays of individual characters, the interface of this */
+/* routine provides for extraction of data from a DAS file into */
+/* an array of strings. */
+
+/* DASRDC allows the caller to control the amount of character data */
+/* read into each array element. This feature allows a program to */
+/* read character data into an array that has a different string */
+/* length from the one used to write the character data, without */
+/* losing the correspondence between input and output array elements. */
+/* For example, an array of strings of 32 characters can be written */
+/* to a DAS file and read back by DASRDC into a buffer of strings */
+/* having length 80 characters, mapping each 32-character string to */
+/* characters 1--32 of the output buffer. */
+
+
+/* $ Examples */
+
+/* 1) Create the new DAS file TEST.DAS and add 240 characters to it. */
+/* Close the file, then re-open it and read the data back out. */
+
+
+/* PROGRAM TEST_ADD */
+
+/* CHARACTER*(40) LINES ( 3 ) */
+/* CHARACTER*(80) BUFFER ( 3 ) */
+/* CHARACTER*(4) TYPE */
+
+/* INTEGER FIRST */
+/* INTEGER HANDLE */
+/* INTEGER I */
+/* INTEGER LAST */
+
+/* DATA LINES / 'Here is the first line.', */
+/* . 'Here is the second line.', */
+/* . 'Here is the third line.' / */
+
+/* C */
+/* C Open a new DAS file. Use the file name as */
+/* C the internal file name. */
+/* C */
+/* TYPE = 'TEST' */
+/* CALL DASONW ( 'TEST.DAS', TYPE, 'TEST.DAS', HANDLE ) */
+
+/* C */
+/* C Add the contents of the array LINES to the file. */
+/* C */
+/* CALL DASADC ( HANDLE, 120, 1, 40, LINES ) */
+
+/* C */
+/* C Close the file. */
+/* C */
+/* CALL DASCLS ( HANDLE ) */
+
+/* C */
+/* C Now verify the addition of data by opening the */
+/* C file for read access and retrieving the data. This */
+/* C time, use a buffer of 80-character strings to read */
+/* C the data. Use only the first 40 characters of each */
+/* C buffer element. */
+/* C */
+/* DO I = 1, 3 */
+/* BUFFER(I) = ' ' */
+/* END DO */
+
+/* CALL DASRDC ( HANDLE, 1, 120, 1, 40, BUFFER ) */
+
+/* C */
+/* C Dump the data to the screen. We should see the */
+/* C sequence */
+/* C */
+/* C Here is the first line. */
+/* C Here is the second line. */
+/* C Here is the third line. */
+/* C */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) 'Data from TEST.DAS: ' */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) BUFFER */
+
+/* END */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.2.2 03-JUL-1996 (NJB) */
+
+/* Various errors in the header comments were fixed. */
+
+/* - SPICELIB Version 1.2.1 19-DEC-1995 (NJB) */
+
+/* Corrected title of permuted index entry section. */
+
+/* - SPICELIB Version 1.2.0, 03-NOV-1995 (NJB) */
+
+/* Routine now uses discovery check-in. FAILED test moved inside */
+/* loops. */
+
+/* - SPICELIB Version 1.2.0, 14-SEP-1995 (NJB) */
+
+/* Bug fix: reference to DASADS in CHKOUT calls corrected. */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination conditions. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* - SPICELIB Version 1.0.0, 12-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read character data from a DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.2.0, 03-NOV-1995 (NJB) */
+
+/* Routine now uses discovery check-in. FAILED test moved inside */
+/* loops. */
+
+/* - SPICELIB Version 1.2.0, 14-SEP-1995 (NJB) */
+
+/* Bug fix: reference to DASADS in CHKOUT calls corrected. */
+/* These references have been changed to 'DASRDC'. */
+
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination conditions. Without */
+/* this test, an infinite loop could result if DASA2L or DASRRC */
+/* signaled an error inside the loops. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* - SPICELIB Version 1.0.0, 12-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Make sure BPOS and EPOS are ok; stop here if not. */
+
+ if (*bpos < 1 || *epos < 1 || *bpos > i_len(data, data_len) || *epos >
+ i_len(data, data_len)) {
+ chkin_("DASRDC", (ftnlen)6);
+ setmsg_("Substring bounds must be in range [1,#]. Actual range [BPOS"
+ ",EPOS] was [#,#].", (ftnlen)76);
+ i__1 = i_len(data, data_len);
+ errint_("#", &i__1, (ftnlen)1);
+ errint_("#", bpos, (ftnlen)1);
+ errint_("#", epos, (ftnlen)1);
+ sigerr_("SPICE(BADSUBSTRINGBOUNDS)", (ftnlen)25);
+ chkout_("DASRDC", (ftnlen)6);
+ return 0;
+ } else if (*epos < *bpos) {
+ chkin_("DASRDC", (ftnlen)6);
+ setmsg_("Substring upper bound must not be less than lower bound. A"
+ "ctual range [BPOS,EPOS] was [#,#].", (ftnlen)93);
+ errint_("#", bpos, (ftnlen)1);
+ errint_("#", epos, (ftnlen)1);
+ sigerr_("SPICE(BADSUBSTRINGBOUNDS)", (ftnlen)25);
+ chkout_("DASRDC", (ftnlen)6);
+ return 0;
+ }
+
+/* Find out the physical location of the first character to read. If */
+/* FIRST is out of range, DASA2L will cause an error to be signalled. */
+
+ dasa2l_(handle, &c__1, first, &clbase, &clsize, &recno, &wordno);
+
+/* Get the length of the elements of DATA. Count the total number */
+/* of characters to read. */
+
+ l = *epos - *bpos + 1;
+ n = *last - *first + 1;
+ nread = 0;
+
+/* Read as much data from record RECNO as is necessary and possible. */
+
+/* Computing MIN */
+ i__1 = n, i__2 = 1024 - wordno + 1;
+ numchr = min(i__1,i__2);
+ elt = 1;
+ chr = *bpos;
+ nmoved = 0;
+ rcpos = wordno;
+ while(nmoved < numchr) {
+ if (failed_()) {
+ return 0;
+ }
+ if (chr > *epos) {
+ ++elt;
+ chr = *bpos;
+ }
+
+/* Find out how many characters to move from the current record */
+/* to the current array element. */
+
+/* Computing MIN */
+ i__1 = numchr - nmoved, i__2 = *epos - chr + 1;
+ nmove = min(i__1,i__2);
+ i__1 = rcpos + nmove - 1;
+ dasrrc_(handle, &recno, &rcpos, &i__1, data + ((elt - 1) * data_len +
+ (chr - 1)), chr + nmove - 1 - (chr - 1));
+ nmoved += nmove;
+ rcpos += nmove;
+ chr += nmove;
+ }
+ nread = numchr;
+ ++recno;
+
+/* Read from as many additional records as necessary. */
+
+ while(nread < n) {
+ if (failed_()) {
+ return 0;
+ }
+
+/* At this point, RECNO is the correct number of the */
+/* record to read from next. CLBASE is the number */
+/* of the first record of the cluster we're about */
+/* to read from. */
+
+
+ if (recno < clbase + clsize) {
+
+/* We can continue reading from the current cluster. Find */
+/* out how many elements to read from the current record, */
+/* and read them. */
+
+/* Computing MIN */
+ i__1 = n - nread;
+ numchr = min(i__1,1024);
+ nmoved = 0;
+ rcpos = 1;
+ while(nmoved < numchr && ! failed_()) {
+ if (chr > *epos) {
+ ++elt;
+ chr = *bpos;
+ }
+
+/* Find out how many characters to move from the current */
+/* record to the current array element. */
+
+/* Computing MIN */
+ i__1 = numchr - nmoved, i__2 = *epos - chr + 1;
+ nmove = min(i__1,i__2);
+ i__1 = rcpos + nmove - 1;
+ dasrrc_(handle, &recno, &rcpos, &i__1, data + ((elt - 1) *
+ data_len + (chr - 1)), chr + nmove - 1 - (chr - 1));
+ nmoved += nmove;
+ rcpos += nmove;
+ chr += nmove;
+ }
+ nread += numchr;
+ ++recno;
+ } else {
+
+/* We must find the next character cluster to */
+/* read from. The first character in this */
+/* cluster has address FIRST + NREAD. */
+
+ i__1 = *first + nread;
+ dasa2l_(handle, &c__1, &i__1, &clbase, &clsize, &recno, &wordno);
+ }
+ }
+ return 0;
+} /* dasrdc_ */
+
diff --git a/ext/spice/src/cspice/dasrdd.c b/ext/spice/src/cspice/dasrdd.c
new file mode 100644
index 0000000000..c91b43c9a2
--- /dev/null
+++ b/ext/spice/src/cspice/dasrdd.c
@@ -0,0 +1,328 @@
+/* dasrdd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+static integer c__1 = 1;
+
+/* $Procedure DASRDD ( DAS, read data, double precision ) */
+/* Subroutine */ int dasrdd_(integer *handle, integer *first, integer *last,
+ doublereal *data)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer n, nread, recno, numdp;
+ extern /* Subroutine */ int dasa2l_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *);
+ extern logical failed_(void);
+ integer clbase;
+ extern /* Subroutine */ int dasrrd_(integer *, integer *, integer *,
+ integer *, doublereal *);
+ integer clsize, wordno;
+
+/* $ Abstract */
+
+/* Read double precision data from a range of DAS logical addresses. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ARRAY */
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* FIRST, */
+/* LAST I Range of DAS double precision logical addresses. */
+/* DATA O Data having addresses FIRST through LAST. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a file handle for an open DAS file. */
+
+/* FIRST, */
+/* LAST are a range of DAS double precision logical */
+/* addresses. FIRST and LAST must be greater than or */
+/* equal to 1 and less than or equal to the highest */
+/* double precision logical address in the DAS file */
+/* designated by HANDLE. */
+
+/* $ Detailed_Output */
+
+/* DATA is an array of double precision numbers. DATA */
+/* should have length at least LAST - FIRST + 1. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. DATA will */
+/* not be modified. */
+
+/* 2) If FIRST or LAST are out of range, the error will be diagnosed */
+/* by routines called by this routine. */
+
+/* 3) If FIRST is greater than LAST, DATA is left unchanged. */
+
+/* 4) If DATA is declared with length less than FIRST - LAST + 1, */
+/* the error cannot be diagnosed by this routine. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine provides random read access to the double precision */
+/* data in a DAS file. This data is logically structured as a */
+/* one-dimensional array of double precision numbers. */
+
+/* $ Examples */
+
+/* 1) Create the new DAS file TEST.DAS and add 200 double */
+/* precision numbers to it. Close the file, then re-open */
+/* it and read the data back out. */
+
+/* PROGRAM TEST_READ */
+
+/* CHARACTER*(4) TYPE */
+
+/* DOUBLE PRECISION DATA ( 200 ) */
+
+/* INTEGER FIRST */
+/* INTEGER HANDLE */
+/* INTEGER I */
+/* INTEGER LAST */
+/* C */
+/* C Open a new DAS file. Use the file name as */
+/* C the internal file name. */
+/* C */
+/* TYPE = 'TEST' */
+/* CALL DASONW ( 'TEST.DAS', TYPE, 'TEST.DAS', HANDLE ) */
+
+/* C */
+/* C Fill the array DATA with the double precision */
+/* C numbers 1.D0 through 100.D0, and add this array */
+/* C to the file. */
+/* C */
+/* DO I = 1, 100 */
+/* DATA(I) = DBLE(I) */
+/* END DO */
+
+/* CALL DASADD ( HANDLE, 100, DATA, FIRST, LAST ) */
+
+/* C */
+/* C Now append the array DATA to the file again. */
+/* C */
+/* CALL DASADD ( HANDLE, 100, DATA, FIRST, LAST ) */
+
+/* C */
+/* C Close the file. */
+/* C */
+/* CALL DASCLS ( HANDLE ) */
+
+/* C */
+/* C Now verify the addition of data by opening the */
+/* C file for read access and retrieving the data. */
+/* C */
+/* CALL DASRDD ( HANDLE, 1, 200, DATA ) */
+
+/* C */
+/* C Dump the data to the screen. We should see the */
+/* C sequence 1, 2, ..., 100, 1, 2, ... , 100. The */
+/* C numbers will be represented as double precision */
+/* C numbers in the output. */
+/* C */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) 'Data from TEST.DAS: ' */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) DATA */
+
+/* END */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1 19-DEC-1995 (NJB) */
+
+/* Corrected title of permuted index entry section. */
+
+/* - SPICELIB Version 1.2.0, 01-NOV-1995 (NJB) */
+
+/* Routine now uses discovery check-in. FAILED test moved inside */
+/* loop. */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination condition. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* - SPICELIB Version 1.0.0, 13-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read double precision data from a DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.2.0, 30-OCT-1995 (NJB) */
+
+/* Routine now uses discovery check-in. FAILED test moved inside */
+/* loop. */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination condition. Without */
+/* this test, an infinite loop could result if DASA2L or DASRRD */
+/* signaled an error inside the loop. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* - SPICELIB Version 1.0.0, 13-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Find out the physical location of the first double precision */
+/* number. If FIRST is invalid, DASA2L will take care of the */
+/* problem. */
+
+ dasa2l_(handle, &c__2, first, &clbase, &clsize, &recno, &wordno);
+
+/* Decide how many double precision numbers to read. */
+
+ numdp = *last - *first + 1;
+ nread = 0;
+
+/* Read as much data from record RECNO as necessary. */
+
+/* Computing MIN */
+ i__1 = numdp, i__2 = 128 - wordno + 1;
+ n = min(i__1,i__2);
+ i__1 = wordno + n - 1;
+ dasrrd_(handle, &recno, &wordno, &i__1, data);
+ nread = n;
+ ++recno;
+
+/* Read from as many additional records as necessary. */
+
+ while(nread < numdp) {
+ if (failed_()) {
+ return 0;
+ }
+
+/* At this point, RECNO is the correct number of the */
+/* record to read from next. CLBASE is the number */
+/* of the first record of the cluster we're about */
+/* to read from. */
+
+ if (recno < clbase + clsize) {
+
+/* We can continue reading from the current */
+/* cluster. */
+
+/* Computing MIN */
+ i__1 = numdp - nread;
+ n = min(i__1,128);
+ dasrrd_(handle, &recno, &c__1, &n, &data[nread]);
+ nread += n;
+ ++recno;
+ } else {
+
+/* We must find the next double precision cluster to */
+/* read from. The first double precision number in this */
+/* cluster has address FIRST + NREAD. */
+
+ i__1 = *first + nread;
+ dasa2l_(handle, &c__2, &i__1, &clbase, &clsize, &recno, &wordno);
+ }
+ }
+ return 0;
+} /* dasrdd_ */
+
diff --git a/ext/spice/src/cspice/dasrdi.c b/ext/spice/src/cspice/dasrdi.c
new file mode 100644
index 0000000000..ba8fd28f72
--- /dev/null
+++ b/ext/spice/src/cspice/dasrdi.c
@@ -0,0 +1,325 @@
+/* dasrdi.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__3 = 3;
+static integer c__1 = 1;
+
+/* $Procedure DASRDI ( DAS, read data, integer ) */
+/* Subroutine */ int dasrdi_(integer *handle, integer *first, integer *last,
+ integer *data)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer n, nread, recno;
+ extern /* Subroutine */ int dasa2l_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *);
+ extern logical failed_(void);
+ integer clbase;
+ extern /* Subroutine */ int dasrri_(integer *, integer *, integer *,
+ integer *, integer *);
+ integer clsize, wordno, numint;
+
+/* $ Abstract */
+
+/* Read integer data from a range of DAS logical addresses. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ARRAY */
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* FIRST, */
+/* LAST I Range of DAS integer logical addresses. */
+/* DATA O Data having addresses FIRST through LAST. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a file handle for an open DAS file. */
+
+/* FIRST, */
+/* LAST are a range of DAS integer logical addresses. */
+/* FIRST and LAST must be greater than or equal to */
+/* 1 and less than or equal to the highest integer */
+/* logical address in the DAS file designated by */
+/* HANDLE. */
+
+/* $ Detailed_Output */
+
+/* DATA is an array of integers. DATA should have length */
+/* at least LAST - FIRST + 1. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. DATA will */
+/* not be modified. */
+
+/* 2) If FIRST or LAST are out of range, the error will be diagnosed */
+/* by routines called by this routine. */
+
+/* 3) If FIRST is greater than LAST, DATA is left unchanged. */
+
+/* 4) If DATA is declared with length less than FIRST - LAST + 1, */
+/* the error cannot be diagnosed by this routine. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine provides random read access to the integer data in */
+/* a DAS file. This data is logically structured as a */
+/* one-dimensional array of integers. */
+
+/* $ Examples */
+
+
+/* 1) Create the new DAS file TEST.DAS and add 200 integers to it. */
+/* Close the file, then re-open it and read the data back out. */
+
+
+/* PROGRAM TEST_READ */
+
+/* CHARACTER*(4) TYPE */
+
+/* INTEGER DATA ( 200 ) */
+
+/* INTEGER FIRST */
+/* INTEGER HANDLE */
+/* INTEGER I */
+/* INTEGER LAST */
+/* C */
+/* C Open a new DAS file. Use the file name as */
+/* C the internal file name. */
+/* C */
+/* TYPE = 'TEST' */
+/* CALL DASONW ( 'TEST.DAS', TYPE, 'TEST.DAS', HANDLE ) */
+
+/* C */
+/* C Fill the array DATA with the integers 1 through */
+/* C 100, and add this array to the file. */
+/* C */
+/* DO I = 1, 100 */
+/* DATA(I) = I */
+/* END DO */
+
+/* CALL DASADI ( HANDLE, 100, DATA, FIRST, LAST ) */
+
+/* C */
+/* C Now append the array DATA to the file again. */
+/* C */
+/* CALL DASADI ( HANDLE, 100, DATA, FIRST, LAST ) */
+
+/* C */
+/* C Close the file. */
+/* C */
+/* CALL DASCLS ( HANDLE ) */
+
+/* C */
+/* C Now verify the addition of data by opening the */
+/* C file for read access and retrieving the data. */
+/* C */
+/* CALL DASRDI ( HANDLE, 1, 200, DATA ) */
+
+/* C */
+/* C Dump the data to the screen. We should see the */
+/* C sequence 1, 2, ..., 100, 1, 2, ... , 100. */
+/* C */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) 'Data from TEST.DAS: ' */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) DATA */
+
+/* END */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.2.1 19-DEC-1995 (NJB) */
+
+/* Corrected title of permuted index entry section. */
+
+/* - SPICELIB Version 1.2.0, 30-OCT-1995 (NJB) */
+
+/* Routine now uses discovery check-in. FAILED test moved inside */
+/* loop. */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination condition. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* - SPICELIB Version 1.0.0, 13-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read integer data from a DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.2.0, 30-OCT-1995 (NJB) */
+
+/* Routine now uses discovery check-in. FAILED test moved inside */
+/* loop. */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination condition. Without */
+/* this test, an infinite loop could result if DASA2L or DASRRI */
+/* signaled an error inside the loop. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* - SPICELIB Version 1.0.0, 13-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Find out the physical location of the first integer. If FIRST */
+/* is invalid, DASA2L will take care of the problem. */
+
+ dasa2l_(handle, &c__3, first, &clbase, &clsize, &recno, &wordno);
+
+/* Decide how many integers to read. */
+
+ numint = *last - *first + 1;
+ nread = 0;
+
+/* Read as much data from record RECNO as necessary. */
+
+/* Computing MIN */
+ i__1 = numint, i__2 = 256 - wordno + 1;
+ n = min(i__1,i__2);
+ i__1 = wordno + n - 1;
+ dasrri_(handle, &recno, &wordno, &i__1, data);
+ nread = n;
+ ++recno;
+
+/* Read from as many additional records as necessary. */
+
+ while(nread < numint) {
+ if (failed_()) {
+ return 0;
+ }
+
+/* At this point, RECNO is the correct number of the */
+/* record to read from next. CLBASE is the number */
+/* of the first record of the cluster we're about */
+/* to read from. */
+
+ if (recno < clbase + clsize) {
+
+/* We can continue reading from the current */
+/* cluster. */
+
+/* Computing MIN */
+ i__1 = numint - nread;
+ n = min(i__1,256);
+ dasrri_(handle, &recno, &c__1, &n, &data[nread]);
+ nread += n;
+ ++recno;
+ } else {
+
+/* We must find the next integer cluster to */
+/* read from. The first integer in this */
+/* cluster has address FIRST + NREAD. */
+
+ i__1 = *first + nread;
+ dasa2l_(handle, &c__3, &i__1, &clbase, &clsize, &recno, &wordno);
+ }
+ }
+ return 0;
+} /* dasrdi_ */
+
diff --git a/ext/spice/src/cspice/dasrfr.c b/ext/spice/src/cspice/dasrfr.c
new file mode 100644
index 0000000000..ff92ad94a2
--- /dev/null
+++ b/ext/spice/src/cspice/dasrfr.c
@@ -0,0 +1,322 @@
+/* dasrfr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+
+/* $Procedure DASRFR ( DAS, read file record ) */
+/* Subroutine */ int dasrfr_(integer *handle, char *idword, char *ifname,
+ integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc,
+ ftnlen idword_len, ftnlen ifname_len)
+{
+ /* Builtin functions */
+ integer s_rdue(cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer unit;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ extern logical failed_(void);
+ extern /* Subroutine */ int dashlu_(integer *, integer *), errfnm_(char *,
+ integer *, ftnlen), sigerr_(char *, ftnlen);
+ char tmpifn[60];
+ extern /* Subroutine */ int chkout_(char *, ftnlen), setmsg_(char *,
+ ftnlen);
+ integer iostat;
+ char tmpidw[8];
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+ /* Fortran I/O blocks */
+ static cilist io___3 = { 1, 0, 1, 0, 1 };
+
+
+/* $ Abstract */
+
+/* Return the contents of the file record of a specified DAS */
+/* file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* IDWORD O ID word. */
+/* IFNAME O DAS internal file name. */
+/* NRESVR O Number of reserved records in file. */
+/* NRESVC O Number of characters in use in reserved rec. area. */
+/* NCOMR O Number of comment records in file. */
+/* NCOMC O Number of characters in use in comment area. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a file handle for a previously opened DAS file. */
+
+/* $ Detailed_Output */
+
+/* IDWORD is the `ID word' contained in the first eight */
+/* characters of the file record. */
+
+/* IFNAME is the internal file name of the DAS file. The */
+/* maximum length of the internal file name is 60 */
+/* characters. */
+
+/* NRESVR is the number of reserved records in the DAS file */
+/* specified by HANDLE. */
+
+/* NRESVC is the number of characters in use in the reserved */
+/* record area of the DAS file specified by HANDLE. */
+
+/* NCOMR is the number of comment records in the DAS file */
+/* specified by HANDLE. */
+
+/* NCOMC is the number of characters in use in the comment area */
+/* of the DAS file specified by HANDLE. */
+
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the file read attempted by this routine fails, the error */
+/* SPICE(DASFILEREADFAILED) will be signalled. */
+
+/* $ Files */
+
+/* See the description of HANDLE under $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine provides a convenient way of retrieving the */
+/* information contained in the file record of a DAS file. */
+
+/* $ Examples */
+
+/* 1) Obtain the internal file name of an existing DAS file. */
+
+
+/* C */
+/* C Open the file for reading. */
+/* C */
+/* CALL DASOPR ( FNAME, HANDLE ) */
+
+/* C */
+/* C Retrieve the internal file name and print it. */
+/* C */
+
+/* CALL DASRFR ( HANDLE, */
+/* . IDWORD, */
+/* . IFNAME, */
+/* . NRESVR, */
+/* . NRESVC, */
+/* . NCOMR, */
+/* . NCOMC ) */
+
+
+/* WRITE (*,*) 'Internal file name is: ' */
+/* WRITE (*,*) IFNAME */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.1.0, 25-AUG-1995 (NJB) */
+
+/* Bug fix: local variables are now used in the direct */
+/* access of the file record. Previously, the routine read */
+/* directly into the CHARACTER*(*) arguments IDWORD and IFNAME. */
+
+/* - SPICELIB Version 2.0.0, 27-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* Removed the DASID parameter which had the value 'NAIF/DAS', as */
+/* it was not used and is also made obsolete by the change in the */
+/* format of the ID word being implemented. */
+
+/* Added a check of FAILED after the call to DASHLU which will */
+/* check out and return if DASHLU fails. This is so that when in */
+/* return mode of the error handling the READ following the call */
+/* to DASHLU will not be executed. */
+
+/* Reworded some of the descriptions contained in the */
+/* $ Detailed_Output section of the header so that they were more */
+/* clear. */
+
+/* Changed the example so that it does not set a value for IFNAME */
+/* before calling DASRFR. This appears to have been a cut and */
+/* paste bug from DASWFR. */
+
+/* - SPICELIB Version 1.0.0, 15-JUL-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read DAS file record */
+/* read DAS internal file name */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 2.1.0, 25-AUG-1995 (NJB) */
+
+/* Bug fix: local variables are now used in the direct */
+/* access of the file record. Previously, the routine read */
+/* directly into the CHARACTER*(*) arguments IDWORD and IFNAME. */
+
+/* - SPICELIB Version 2.0.0, 27-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* Removed the DASID parameter which had the value 'NAIF/DAS', as */
+/* it was not used and is also made obsolute by the change in the */
+/* format of the ID word being implemented. */
+
+/* Added a check of FAILED after the call to DASHLU which will */
+/* check out and return if DASHLU fails. This is so that when in */
+/* return mode of the error handling the READ following the call */
+/* to DASHLU will not be executed. */
+
+/* Reworded some of the descriptions contained in the */
+/* $ Detailed_Output section of the header so that they were more */
+/* clear. */
+
+/* Changed the example so that it does not set a value for IFNAME */
+/* before calling DASRFR. This appears to have been a cut and */
+/* paste bug from DASWFR. */
+
+/* - SPICELIB Version 1.0.0, 15-JUL-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASRFR", (ftnlen)6);
+ }
+
+/* Get the logical unit for this DAS file. */
+
+ dashlu_(handle, &unit);
+ if (failed_()) {
+ chkout_("DASRFR", (ftnlen)6);
+ return 0;
+ }
+ io___3.ciunit = unit;
+ iostat = s_rdue(&io___3);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, tmpidw, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, tmpifn, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&(*nresvr), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&(*nresvc), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&(*ncomr), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&(*ncomc), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rdue();
+L100001:
+ if (iostat != 0) {
+ setmsg_("Could not read file record. File was #. IOSTAT was #.", (
+ ftnlen)55);
+ errfnm_("#", &unit, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASFILEREADFAILED)", (ftnlen)24);
+ chkout_("DASRFR", (ftnlen)6);
+ return 0;
+ }
+ s_copy(idword, tmpidw, idword_len, (ftnlen)8);
+ s_copy(ifname, tmpifn, ifname_len, (ftnlen)60);
+ chkout_("DASRFR", (ftnlen)6);
+ return 0;
+} /* dasrfr_ */
+
diff --git a/ext/spice/src/cspice/dasrwr.c b/ext/spice/src/cspice/dasrwr.c
new file mode 100644
index 0000000000..7c80c7eeec
--- /dev/null
+++ b/ext/spice/src/cspice/dasrwr.c
@@ -0,0 +1,3906 @@
+/* dasrwr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__10 = 10;
+static integer c__1 = 1;
+static integer c__128 = 128;
+static integer c__256 = 256;
+static integer c__1024 = 1024;
+
+/* $Procedure DASRWR ( DAS, read/write records ) */
+/* Subroutine */ int dasrwr_0_(int n__, integer *handle, integer *recno, char
+ *recc, doublereal *recd, integer *reci, integer *first, integer *last,
+ doublereal *datad, integer *datai, char *datac, ftnlen recc_len,
+ ftnlen datac_len)
+{
+ /* Initialized data */
+
+ static logical pass1 = TRUE_;
+ static integer hnbufi[10] = { 0,0,0,0,0,0,0,0,0,0 };
+ static integer lubufc[10] = { 0,0,0,0,0,0,0,0,0,0 };
+ static integer lubufd[10] = { 0,0,0,0,0,0,0,0,0,0 };
+ static integer lubufi[10] = { 0,0,0,0,0,0,0,0,0,0 };
+ static logical upbufc[10] = { FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_ };
+ static logical upbufd[10] = { FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_ };
+ static logical upbufi[10] = { FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
+ FALSE_,FALSE_,FALSE_,FALSE_ };
+ static integer headc = 0;
+ static integer headd = 0;
+ static integer headi = 0;
+ static integer usedc = 0;
+ static integer usedd = 0;
+ static integer usedi = 0;
+ static integer rnbufc[10] = { 0,0,0,0,0,0,0,0,0,0 };
+ static integer rnbufd[10] = { 0,0,0,0,0,0,0,0,0,0 };
+ static integer rnbufi[10] = { 0,0,0,0,0,0,0,0,0,0 };
+ static integer hnbufc[10] = { 0,0,0,0,0,0,0,0,0,0 };
+ static integer hnbufd[10] = { 0,0,0,0,0,0,0,0,0,0 };
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ static integer node, next, unit;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), lnkan_(integer *,
+ integer *), moved_(doublereal *, integer *, doublereal *);
+ static integer poolc[32] /* was [2][16] */, poold[32] /* was [2][16]
+ */;
+ extern /* Subroutine */ int movei_(integer *, integer *, integer *);
+ static integer pooli[32] /* was [2][16] */;
+ extern integer lnktl_(integer *, integer *);
+ extern logical failed_(void);
+ extern /* Subroutine */ int dasioc_(char *, integer *, integer *, char *,
+ ftnlen, ftnlen), dasiod_(char *, integer *, integer *, doublereal
+ *, ftnlen);
+ static char rcbufc[1024*10];
+ static doublereal rcbufd[1280] /* was [128][10] */;
+ extern /* Subroutine */ int dasioi_(char *, integer *, integer *, integer
+ *, ftnlen);
+ static integer rcbufi[2560] /* was [256][10] */;
+ extern /* Subroutine */ int lnkilb_(integer *, integer *, integer *),
+ dassih_(integer *, char *, ftnlen), lnkini_(integer *, integer *),
+ sigerr_(char *, ftnlen), chkout_(char *, ftnlen), dashlu_(
+ integer *, integer *), errfnm_(char *, integer *, ftnlen),
+ setmsg_(char *, ftnlen), errint_(char *, integer *, ftnlen),
+ lnkxsl_(integer *, integer *, integer *);
+ extern logical return_(void);
+ extern /* Subroutine */ int lnkfsl_(integer *, integer *, integer *);
+
+/* $ Abstract */
+
+/* Read and write DAS physical records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Entry points */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I RRD, RRI, RRC, WRD, WRI, WRC, URD, URI, URC */
+/* RECNO I RRD, RRI, RRC, WRD, WRI, WRC, URD, URI, URC */
+/* RECC I WRC */
+/* RECD I WRD */
+/* RECI I WRI */
+/* FIRST I RRD, RRI, RRC, URD, URI, URC */
+/* LAST I RRD, RRI, RRC, URD, URI, URC */
+/* DATAD O RRD, URD */
+/* DATAI O RRI, URI */
+/* DATAC O RRC, URC */
+/* BUFSZD P RRD, WRD */
+/* BUFSZI P RRI, WRI */
+/* BUFSZC P RRC, WRC */
+
+/* $ Detailed_Input */
+
+/* See the entry points for a discussion of their inputs. */
+
+/* $ Detailed_Output */
+
+/* See the entry points for a discussion of their outputs. */
+
+/* $ Parameters */
+
+/* BUFSZD, */
+/* BUFSZI, */
+/* BUFSZC are, respectively, the number of records in the */
+/* data buffers for double precision, integer, and */
+/* character records. */
+
+/* $ Exceptions */
+
+/* 1) If this routine is called directly, the error */
+/* SPICE(BOGUSENTRY) will be signalled. */
+
+/* See the entry points for discussions of their exceptions. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in the headers of */
+/* the entry points for a description of files accessed by this */
+/* set of routines. */
+
+/* $ Particulars */
+
+/* This suite of routines provides buffered read and write access to */
+/* DAS files. The purpose of this feature is to increase the */
+/* performance of application programs that access DAS files: in */
+/* particular, repeated reads from or writes to a given record */
+/* should be relatively fast, because the contents of the most */
+/* recently accessed records are buffered in memory. Thus DASRWR */
+/* and its entry points act as a miniature virtual memory system for */
+/* DAS files. */
+
+/* These routines are intended primarily for use by other SPICELIB */
+/* routines; users' application programs will not normally need to */
+/* call these routines. Writing to a DAS file with these routines */
+/* demands a particularly circumspect approach: it's quite easy to */
+/* end up with something other than a DAS file if one misuses the */
+/* routines. */
+
+/* The entry points of DASRWR support writing, reading, and updating */
+/* the records in a DAS file. The distinction between writing and */
+/* updating is that any record may be written (as long as the record */
+/* belongs to a file open for writing), but only existing records */
+/* may be updated. `Writing' a record sets the values of all of */
+/* the elements of the record, while a subrange of the elements of an */
+/* existing record may be `updated'. */
+
+/* For each of these three operations, there are three DAS routines, */
+/* one for each supported data type. The names of the routines are */
+
+/* -- For writing: DASWRC, DASWRD, DASWRI */
+/* -- For updating: DASURC, DASURD, DASURI */
+/* -- For reading: DASRRC, DASRRD, DASRRI */
+
+/* Users should note that, unlike in the case of SPICELIB's DAF */
+/* routines, the DAS routines buffer data that is written as well */
+/* as data that is read. Consequently a DAS file does not */
+/* necessarily yet contain, at any moment, all of the data that */
+/* has been written to it by the DASWRx or DASURx routines. The */
+/* written data that is buffered is written out when the need */
+/* to buffer additional data requires it, and also when the user */
+/* commands the closure of a file that has been written. So, at */
+/* the time a DAS file is closed, the contents of the physical file */
+/* do reflect what has been `written' to the file by the DASWRx and */
+/* DASURx entry points. */
+
+/* At any time, an application program can force the DAS system to */
+/* write to a DAS file any buffered records maintained for that */
+/* file. The entry point DASWBR (DAS, write buffered records) */
+/* provides this capability. */
+
+/* DASRWR contains three record buffers: one of character type, */
+/* one of double precision type, and one of integer type. Each */
+/* buffer has enough room for an integer number of records. The */
+/* sizes of the buffers are parameterized and can be increased if */
+/* necessary. When contemplating the revision of the buffer */
+/* sizes selected by NAIF, SPICELIB users should take note of the */
+/* following points: */
+
+/* -- Changing values of parameters in NAIF subroutines may cause */
+/* a maintenance burden for the users of the modified NAIF */
+/* code, since any changes made to a SPICELIB routine will have */
+/* to be made to any new version of that routine released by */
+/* NAIF in a later version of SPICELIB. */
+
+/* -- The effect of buffer size on the speed with which an */
+/* application executes is highly dependent on the specific */
+/* application. In some cases, increasing the buffer sizes */
+/* may slow the application down. */
+
+/* $ Examples */
+
+/* See the entry points for examples specific to those routines. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 17-NOV-1995 (NJB) */
+
+/* Made modifications to the DASRRx routines to enhance */
+/* efficiency. Removed references to the function RETURN. */
+
+/* Removed weird spaces from ENTRY statements. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header for each entry point. */
+/* This was done in order to minimize documentation changes if the */
+/* DAS open routines ever change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read and write DAS physical records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 17-NOV-1995 (NJB) */
+
+/* Made modifications to the DASRRx routines to enhance */
+/* efficiency. Removed references to the function RETURN. */
+
+/* Removed weird spaces from ENTRY statements. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header for each entry point. */
+/* This was done in order to minimize documentation changes if the */
+/* DAS open routines ever change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* The data structure maintained by this set of routines consists */
+/* of three record buffers, one each for use with records of double */
+/* precision, integer, and character data types. */
+
+/* Each buffer consists of five parallel arrays; the arrays contain: */
+
+/* -- data records */
+/* -- Fortran record numbers */
+/* -- file handles */
+/* -- Fortran logical unit numbers */
+/* -- Update flags */
+
+/* In addition, for each buffer there is a doubly linked list that */
+/* points to the buffer and keeps track of the order in which the */
+/* records in the buffer were accessed. The three linked lists are */
+/* maintained in a doubly linked list pool structure. The logical */
+/* structure of each buffer is illustrated below. All of the array */
+/* elements in the same row are associated with the data record in */
+/* that row. */
+
+
+
+/* Linked Record Record Handles Unit Update */
+/* List buffer Numbers Numbers Flags */
+
+/* +---+ +------------+ +---+ +---+ +---+ +---+ */
+/* | | ---> | | | | | | | | | | */
+/* +---+ +------------+ +---+ +---+ +---+ +---+ */
+/* | | ---> | | | | | | | | | | */
+/* +---+ +------------+ +---+ +---+ +---+ +---+ */
+/* . . . . . . */
+/* . . . . . . */
+/* . . . . . . */
+/* +---+ +------------+ +---+ +---+ +---+ +---+ */
+/* | | ---> | | | | | | | | | | */
+/* +---+ +------------+ +---+ +---+ +---+ +---+ */
+
+
+
+/* Other local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+ /* Parameter adjustments */
+ if (recd) {
+ }
+ if (reci) {
+ }
+ if (datad) {
+ }
+ if (datai) {
+ }
+
+ /* Function Body */
+ switch(n__) {
+ case 1: goto L_dasrrd;
+ case 2: goto L_dasrri;
+ case 3: goto L_dasrrc;
+ case 4: goto L_daswrd;
+ case 5: goto L_daswri;
+ case 6: goto L_daswrc;
+ case 7: goto L_dasurd;
+ case 8: goto L_dasuri;
+ case 9: goto L_dasurc;
+ case 10: goto L_daswbr;
+ }
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASRWR", (ftnlen)6);
+ }
+
+/* Never come here. */
+
+ sigerr_("SPICE(BOGUSENTRY)", (ftnlen)17);
+ chkout_("DASRWR", (ftnlen)6);
+ return 0;
+/* $Procedure DASRRD ( DAS, read record, double precision ) */
+
+L_dasrrd:
+/* $ Abstract */
+
+/* Read DAS double precision physical records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* INTEGER FIRST */
+/* INTEGER LAST */
+/* DOUBLE PRECISION DATAD ( * ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAS file. */
+/* RECNO I Record number. */
+/* FIRST, */
+/* LAST I First and last indices of range within record. */
+/* DATAD O Double precision data read from record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of an open DAS file. */
+
+/* RECNO is the number of a record in a DAS file. */
+
+/* FIRST, */
+/* LAST are the first and last indices of a range of */
+/* double precision numbers to be read from the */
+/* indicated record. The record contains NWD */
+/* double precision numbers; these have indices */
+/* ranging from 1 to NWD. */
+
+/* $ Detailed_Output */
+
+/* DATAD is a double precision array containing the */
+/* elements FIRST through LAST of the specified */
+/* record. The record element FIRST is placed */
+/* in DATAD(1), the record element FIRST+1 is placed */
+/* in DATAD(2), and so on; the record element LAST is */
+/* placed in DATAD(LAST-FIRST+1). */
+
+/* $ Parameters */
+
+/* BUFSZD is the number of records in the double precision */
+/* record buffer. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. The */
+/* output argument DATAD will not be modified. */
+
+/* 2) If a read operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The output argument DATAD will not be modified. */
+
+/* 3) If a write operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The output argument DATAD will not be modified. This routine */
+/* may write out updated, buffered records in order to make */
+/* room in the double precision buffer for a newly read record. */
+/* Note that the file written to may be different than the file */
+/* designated by HANDLE if multiple DAS files are open for */
+/* writing. */
+
+/* 4) If FIRST or LAST is not in the range [1, NWD], the error */
+/* SPICE(INDEXOUTOFRANGE) will be signalled. The output argument */
+/* DATAD will not be modified. */
+
+/* 5) If FIRST > LAST, this routine will return without modifying */
+/* the output argument DATAD. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Routines outside of SPICELIB will normally have no need to call */
+/* this routine. */
+
+/* This routine can be used to read from a DAS file that is open for */
+/* reading or for writing. Any buffered double precision record */
+/* can be read with this routine. In particular, records that have */
+/* been written to the DAS double precision record buffer but have */
+/* not yet been written out to the DAS file they're intended to go */
+/* to ARE visible to this routine. */
+
+/* This routine should be used to read only records that contain */
+/* double precision data. */
+
+/* $ Examples */
+
+/* 1) Read the 10th through 100th d.p. numbers from record number 9 */
+/* in a DAS file designated by HANDLE. */
+
+/* CALL DASRRD ( HANDLE, 9, 10, 100, DATAD ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 03-NOV-1995 (NJB) */
+
+/* Made modifications to enhance efficiency. Removed references */
+/* to the function RETURN. */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read DAS double precision physical records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 03-NOV-1995 (NJB) */
+
+/* Made modifications to enhance efficiency. Removed references */
+/* to the function RETURN. For buffered reads, MOVED is not */
+/* called when a single word is to be read. */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* If it hasn't been done yet, initialize the pointer list pools. */
+
+ if (pass1) {
+ lnkini_(&c__10, poold);
+ lnkini_(&c__10, pooli);
+ lnkini_(&c__10, poolc);
+ pass1 = FALSE_;
+ }
+
+/* Check FIRST and LAST. Use discovery check-in. */
+
+ if (*first < 1 || *first > 128 || *last < 1 || *last > 128) {
+ chkin_("DASRRD", (ftnlen)6);
+ dashlu_(handle, &unit);
+ setmsg_("Array indices FIRST and LAST were #, #; allowed range for "
+ "both is [#, #]. File was #, record number was #.", (ftnlen)
+ 107);
+ errint_("#", first, (ftnlen)1);
+ errint_("#", last, (ftnlen)1);
+ errint_("#", &c__1, (ftnlen)1);
+ errint_("#", &c__128, (ftnlen)1);
+ errfnm_("#", &unit, (ftnlen)1);
+ errint_("#", recno, (ftnlen)1);
+ sigerr_("SPICE(INDEXOUTOFRANGE)", (ftnlen)22);
+ chkout_("DASRRD", (ftnlen)6);
+ return 0;
+ }
+
+/* There's nothing to do if LAST < FIRST. (We're not checked in at */
+/* this point.) */
+
+ if (*last < *first) {
+ return 0;
+ }
+
+/* See whether record number RECNO in file HANDLE is buffered. We'll */
+/* search through the list of buffered records starting at the head */
+/* of the list. If we find the desired record, transfer the */
+/* requested data to the array DATAD and return without further ado. */
+
+ node = headd;
+ while(node > 0) {
+ if (*handle == hnbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("hnbufd", i__1, "dasrwr_", (ftnlen)685)] && *recno ==
+ rnbufd[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
+ "rnbufd", i__2, "dasrwr_", (ftnlen)685)]) {
+
+/* Found it. Move this record to the head of the list. */
+/* Update our head pointer as required. */
+
+ if (node != headd) {
+ lnkxsl_(&node, &node, poold);
+ lnkilb_(&node, &headd, poold);
+ headd = node;
+ }
+
+/* Don't forget to return the requested data. */
+
+ if (*first == *last) {
+ datad[0] = rcbufd[(i__1 = *first + (node << 7) - 129) < 1280
+ && 0 <= i__1 ? i__1 : s_rnge("rcbufd", i__1, "dasrwr_"
+ , (ftnlen)705)];
+ } else {
+ i__2 = *last - *first + 1;
+ moved_(&rcbufd[(i__1 = *first + (node << 7) - 129) < 1280 &&
+ 0 <= i__1 ? i__1 : s_rnge("rcbufd", i__1, "dasrwr_", (
+ ftnlen)709)], &i__2, datad);
+ }
+
+/* We haven't checked in, so don't check out. */
+
+ return 0;
+ }
+ node = poold[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("poold", i__1, "dasrwr_", (ftnlen)720)];
+ }
+
+/* The record wasn't buffered. We need to allocate entries to */
+/* hold the record contents. If the buffer isn't full, just */
+/* select a free set of entries. If the buffer is full, use */
+/* the set of entries at the tail of the list. */
+
+/* Since we're now going to do a file read, it doesn't slow */
+/* us down much to check in, comparatively speaking. */
+
+ chkin_("DASRRD", (ftnlen)6);
+ if (usedd == 10) {
+
+/* Grab the buffer entry at the tail end of the list. */
+
+ node = lnktl_(&headd, poold);
+ lnkxsl_(&node, &node, poold);
+
+/* If the allocated buffer entry was updated, write it out. */
+
+ if (upbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fd", i__1, "dasrwr_", (ftnlen)746)]) {
+ dasiod_("WRITE", &lubufd[(i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("lubufd", i__1, "dasrwr_", (ftnlen)748)], &
+ rnbufd[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 :
+ s_rnge("rnbufd", i__2, "dasrwr_", (ftnlen)748)], &rcbufd[(
+ i__3 = (node << 7) - 128) < 1280 && 0 <= i__3 ? i__3 :
+ s_rnge("rcbufd", i__3, "dasrwr_", (ftnlen)748)], (ftnlen)
+ 5);
+ }
+ } else {
+
+/* Allocate a new set of buffer entries, but don't link */
+/* them into the list yet. */
+
+ lnkan_(poold, &node);
+ ++usedd;
+ }
+
+/* Try to read the record. */
+
+ dashlu_(handle, &unit);
+ dasiod_("READ", &unit, recno, &rcbufd[(i__1 = (node << 7) - 128) < 1280 &&
+ 0 <= i__1 ? i__1 : s_rnge("rcbufd", i__1, "dasrwr_", (ftnlen)770)
+ ], (ftnlen)4);
+ if (failed_()) {
+ chkout_("DASRRD", (ftnlen)6);
+ return 0;
+ }
+
+/* The read was successful. Link the node pointing to the buffer */
+/* entries for this record in before the current head of the */
+/* list, thus putting them at the head. */
+
+/* Set the file handle, record number, unit, and update flag for */
+/* this record. */
+
+ lnkilb_(&node, &headd, poold);
+ hnbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("hnbufd", i__1,
+ "dasrwr_", (ftnlen)787)] = *handle;
+ rnbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("rnbufd", i__1,
+ "dasrwr_", (ftnlen)788)] = *recno;
+ lubufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("lubufd", i__1,
+ "dasrwr_", (ftnlen)789)] = unit;
+ upbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbufd", i__1,
+ "dasrwr_", (ftnlen)790)] = FALSE_;
+ headd = node;
+
+/* Don't forget to return the requested data. */
+
+ i__2 = *last - *first + 1;
+ moved_(&rcbufd[(i__1 = *first + (node << 7) - 129) < 1280 && 0 <= i__1 ?
+ i__1 : s_rnge("rcbufd", i__1, "dasrwr_", (ftnlen)796)], &i__2,
+ datad);
+ chkout_("DASRRD", (ftnlen)6);
+ return 0;
+/* $Procedure DASRRI ( DAS, read record, integer ) */
+
+L_dasrri:
+/* $ Abstract */
+
+/* Read DAS integer physical records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* INTEGER FIRST */
+/* INTEGER LAST */
+/* INTEGER DATAI ( * ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Entry points */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAS file. */
+/* RECNO I Record number. */
+/* FIRST, */
+/* LAST I First and last indices of range within record. */
+/* DATAI O Integer data read from record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of an open DAS file. */
+
+/* RECNO is the number of a record in a DAS file. */
+
+/* FIRST, */
+/* LAST are the first and last indices of a range of */
+/* integers to be read from the indicated record. */
+/* The record contains NWI integers; these have */
+/* indices ranging from 1 to NWI. */
+
+/* $ Detailed_Output */
+
+/* DATAI is an integer array containing the elements FIRST */
+/* through LAST of the specified record. The record */
+/* element FIRST is placed in DATAI(1), the record */
+/* element FIRST+1 is placed in DATAI(2), and so on; */
+/* the record element LAST is placed in */
+/* DATAI(LAST-FIRST+1). */
+
+/* $ Parameters */
+
+/* BUFSZI is the number of records in the integer record */
+/* buffer. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. The */
+/* output argument DATAI will not be modified. */
+
+/* 2) If a read operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The output argument DATAI will not be modified. */
+
+/* 3) If a write operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The output argument DATAI will not be modified. This routine */
+/* may write out updated, buffered records in order to make room */
+/* in the integer buffer for a newly read record. Note that the */
+/* file written to may be different than the file designated by */
+/* HANDLE if multiple DAS files are open for writing. */
+
+/* 4) If FIRST or LAST is not in the range [1, NWI], the error */
+/* SPICE(INDEXOUTOFRANGE) will be signalled. The output argument */
+/* DATAI will not be modified. */
+
+/* 5) If FIRST > LAST, this routine will return without modifying */
+/* the output argument DATAI. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Routines outside of SPICELIB will normally have no need to call */
+/* this routine. */
+
+/* This routine can be used to read from a DAS file that is open for */
+/* reading or writing. Any buffered integer record can be read with */
+/* this routine. In particular, records that have been written to */
+/* the DAS integer record buffer but have not yet been written out */
+/* to the DAS file they're intended to go to ARE visible to this */
+/* routine. */
+
+/* This routine should be used to read only records that contain */
+/* integer data. */
+
+/* $ Examples */
+
+/* 1) Read the 10th through 100th integers from record number 9 */
+/* in a DAS file designated by HANDLE. */
+
+/* CALL DASRRI ( HANDLE, 9, 10, 100, DATAI ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 03-NOV-1995 (NJB) */
+
+/* Made modifications to enhance efficiency. Removed references */
+/* to the function RETURN. */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read DAS integer physical records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 03-NOV-1995 (NJB) */
+
+/* Made modifications to enhance efficiency. Removed references */
+/* to the function RETURN. For buffered reads, MOVEI is not */
+/* called when a single word is to be read. */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* Non-standard SPICE error handling. */
+
+/* If it hasn't been done yet, initialize the pointer list pools. */
+
+ if (pass1) {
+ lnkini_(&c__10, poold);
+ lnkini_(&c__10, pooli);
+ lnkini_(&c__10, poolc);
+ pass1 = FALSE_;
+ }
+
+/* Check FIRST and LAST. Use discovery check-in. */
+
+ if (*first < 1 || *first > 256 || *last < 1 || *last > 256) {
+ chkin_("DASRRI", (ftnlen)6);
+ dashlu_(handle, &unit);
+ setmsg_("Array indices FIRST and LAST were #, #; allowed range for "
+ "both is [#, #]. File was #, record number was #.", (ftnlen)
+ 107);
+ errint_("#", first, (ftnlen)1);
+ errint_("#", last, (ftnlen)1);
+ errint_("#", &c__1, (ftnlen)1);
+ errint_("#", &c__256, (ftnlen)1);
+ errfnm_("#", &unit, (ftnlen)1);
+ errint_("#", recno, (ftnlen)1);
+ sigerr_("SPICE(INDEXOUTOFRANGE)", (ftnlen)22);
+ chkout_("DASRRI", (ftnlen)6);
+ return 0;
+ }
+
+/* There's nothing to do if LAST < FIRST. (We're not checked in at */
+/* this point.) */
+
+ if (*last < *first) {
+ return 0;
+ }
+
+/* See whether record number RECNO in file HANDLE is buffered. We'll */
+/* search through the list of buffered records starting at the head */
+/* of the list. If we find the desired record, transfer the */
+/* requested data to the array DATAI and return without further ado. */
+
+ node = headi;
+ while(node > 0) {
+ if (*handle == hnbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("hnbufi", i__1, "dasrwr_", (ftnlen)1068)] && *recno ==
+ rnbufi[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
+ "rnbufi", i__2, "dasrwr_", (ftnlen)1068)]) {
+
+
+/* Found it. Move this record to the head of the list. */
+/* Update our head pointer as required. */
+
+ if (node != headi) {
+ lnkxsl_(&node, &node, pooli);
+ lnkilb_(&node, &headi, pooli);
+ headi = node;
+ }
+
+/* Don't forget to return the requested data. */
+
+ if (*first == *last) {
+ datai[0] = rcbufi[(i__1 = *first + (node << 8) - 257) < 2560
+ && 0 <= i__1 ? i__1 : s_rnge("rcbufi", i__1, "dasrwr_"
+ , (ftnlen)1089)];
+ } else {
+ i__2 = *last - *first + 1;
+ movei_(&rcbufi[(i__1 = *first + (node << 8) - 257) < 2560 &&
+ 0 <= i__1 ? i__1 : s_rnge("rcbufi", i__1, "dasrwr_", (
+ ftnlen)1093)], &i__2, datai);
+ }
+
+/* We haven't checked in, so don't check out. */
+
+ return 0;
+ }
+ node = pooli[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("pooli", i__1, "dasrwr_", (ftnlen)1104)];
+ }
+
+/* The record wasn't buffered. We need to allocate entries to */
+/* hold the record contents. If the buffer isn't full, just */
+/* select a free set of entries. If the buffer is full, use */
+/* the set of entries at the tail of the list. */
+
+/* Since we're now going to do a file read, it doesn't slow */
+/* us down much to check in, comparatively speaking. */
+
+ chkin_("DASRRI", (ftnlen)6);
+ if (usedi == 10) {
+
+/* Grab the buffer entry at the tail end of the list. */
+
+ node = lnktl_(&headi, pooli);
+ lnkxsl_(&node, &node, pooli);
+
+/* If the allocated buffer entry was updated, write it out. */
+
+ if (upbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fi", i__1, "dasrwr_", (ftnlen)1130)]) {
+ dasioi_("WRITE", &lubufi[(i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("lubufi", i__1, "dasrwr_", (ftnlen)1132)], &
+ rnbufi[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 :
+ s_rnge("rnbufi", i__2, "dasrwr_", (ftnlen)1132)], &rcbufi[
+ (i__3 = (node << 8) - 256) < 2560 && 0 <= i__3 ? i__3 :
+ s_rnge("rcbufi", i__3, "dasrwr_", (ftnlen)1132)], (ftnlen)
+ 5);
+ }
+ } else {
+
+/* Allocate a new set of buffer entries, but don't link */
+/* them into the list yet. */
+
+ lnkan_(pooli, &node);
+ ++usedi;
+ }
+
+/* Try to read the record. */
+
+ dashlu_(handle, &unit);
+ dasioi_("READ", &unit, recno, &rcbufi[(i__1 = (node << 8) - 256) < 2560 &&
+ 0 <= i__1 ? i__1 : s_rnge("rcbufi", i__1, "dasrwr_", (ftnlen)
+ 1153)], (ftnlen)4);
+ if (failed_()) {
+ chkout_("DASRRI", (ftnlen)6);
+ return 0;
+ }
+
+/* The read was successful. Link the node pointing to the buffer */
+/* entries for this record in before the current head of the */
+/* list, thus putting them at the head. */
+
+/* Set the file handle, record number, unit, and update flag for */
+/* this record. */
+
+ lnkilb_(&node, &headi, pooli);
+ hnbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("hnbufi", i__1,
+ "dasrwr_", (ftnlen)1170)] = *handle;
+ rnbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("rnbufi", i__1,
+ "dasrwr_", (ftnlen)1171)] = *recno;
+ lubufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("lubufi", i__1,
+ "dasrwr_", (ftnlen)1172)] = unit;
+ upbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbufi", i__1,
+ "dasrwr_", (ftnlen)1173)] = FALSE_;
+ headi = node;
+
+/* Don't forget to return the requested data. */
+
+ i__2 = *last - *first + 1;
+ movei_(&rcbufi[(i__1 = *first + (node << 8) - 257) < 2560 && 0 <= i__1 ?
+ i__1 : s_rnge("rcbufi", i__1, "dasrwr_", (ftnlen)1179)], &i__2,
+ datai);
+ chkout_("DASRRI", (ftnlen)6);
+ return 0;
+/* $Procedure DASRRC ( DAS, read record, character ) */
+
+L_dasrrc:
+/* $ Abstract */
+
+/* Read DAS character physical records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* INTEGER FIRST */
+/* INTEGER LAST */
+/* CHARACTER*(*) DATAC */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Entry points */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAS file. */
+/* RECNO I Record number. */
+/* FIRST, */
+/* LAST I First and last indices of range within record. */
+/* DATAC O Character data read from record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of an open DAS file. */
+
+/* RECNO is the number of a record in a DAS file. */
+
+/* FIRST, */
+/* LAST are the first and last indices of a range of */
+/* characters to be read from the indicated record. */
+/* The record contains NWC characters; these have */
+/* indices ranging from 1 to NWC. */
+
+/* $ Detailed_Output */
+
+/* DATAC is a character string containing the elements */
+/* FIRST through LAST of the specified record. The */
+/* record element FIRST is placed in DATAC(1:1), the */
+/* record element FIRST+1 is placed in DATAC(2:2), */
+/* and so on; the record element LAST is placed in */
+/* DATAC( LAST-FIRST+1 : LAST-FIRST+1 ). */
+
+/* $ Parameters */
+
+/* BUFSZC is the number of records in the character record */
+/* buffer. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. The */
+/* output argument DATAC will not be modified. */
+
+/* 2) If a read operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The output argument DATAC will not be modified. */
+
+/* 3) If a write operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The output argument DATAC will not be modified. This routine */
+/* may write out updated, buffered records in order to make room */
+/* in the character buffer for a newly read record. Note that */
+/* the file written to may be different than the file */
+/* designated by HANDLE if multiple DAS files are open for */
+/* writing. */
+
+/* 4) If FIRST or LAST is not in the range [1, NWC], the error */
+/* SPICE(INDEXOUTOFRANGE) will be signalled. The output argument */
+/* DATAC will not be modified. */
+
+/* 5) If FIRST > LAST, this routine will return without modifying */
+/* the output argument DATAC. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Routines outside of SPICELIB will normally have no need to call */
+/* this routine. */
+
+/* This routine can be used to read from a DAS file that is open for */
+/* reading or writing. Any buffered character record can be read */
+/* with this routine. In particular, records that have been */
+/* written to the DAS character record buffer but have not yet been */
+/* written out to the DAS file they're intended to go to ARE */
+/* visible to this routine. */
+
+/* This routine should be used to read only records that contain */
+/* character data. */
+
+/* $ Examples */
+
+/* 1) Read the 10th through 100th characters from record number 9 */
+/* in a DAS file designated by HANDLE. */
+
+/* CALL DASRRC ( HANDLE, 9, 10, 100, DATAC ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 09-NOV-1995 (NJB) */
+
+/* Made modifications to enhance efficiency. Removed references */
+/* to the function RETURN. */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* read DAS character physical records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 09-NOV-1995 (NJB) */
+
+/* Made modifications to enhance efficiency. Removed references */
+/* to the function RETURN. */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* If it hasn't been done yet, initialize the pointer list pools. */
+
+ if (pass1) {
+ lnkini_(&c__10, poold);
+ lnkini_(&c__10, pooli);
+ lnkini_(&c__10, poolc);
+ pass1 = FALSE_;
+ }
+
+/* Check FIRST and LAST. Use discovery check-in. */
+
+ if (*first < 1 || *first > 1024 || *last < 1 || *last > 1024) {
+ chkin_("DASRRC", (ftnlen)6);
+ dashlu_(handle, &unit);
+ setmsg_("Array indices FIRST and LAST were #, #; allowed range for "
+ "both is [#, #]. File was #, record number was #.", (ftnlen)
+ 107);
+ errint_("#", first, (ftnlen)1);
+ errint_("#", last, (ftnlen)1);
+ errint_("#", &c__1, (ftnlen)1);
+ errint_("#", &c__1024, (ftnlen)1);
+ errfnm_("#", &unit, (ftnlen)1);
+ errint_("#", recno, (ftnlen)1);
+ sigerr_("SPICE(INDEXOUTOFRANGE)", (ftnlen)22);
+ chkout_("DASRRC", (ftnlen)6);
+ return 0;
+ }
+
+/* There's nothing to do if LAST < FIRST. (We're not checked in at */
+/* this point.) */
+
+ if (*last < *first) {
+ return 0;
+ }
+
+/* See whether record number RECNO in file HANDLE is buffered. We'll */
+/* search through the list of buffered records starting at the head */
+/* of the list. If we find the desired record, transfer the */
+/* requested data to the array DATAC and return without further ado. */
+
+ node = headc;
+ while(node > 0) {
+ if (*handle == hnbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("hnbufc", i__1, "dasrwr_", (ftnlen)1450)] && *recno ==
+ rnbufc[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
+ "rnbufc", i__2, "dasrwr_", (ftnlen)1450)]) {
+
+
+/* Found it. Move this record to the head of the list. */
+/* Update our head pointer as required. */
+
+ if (node != headc) {
+ lnkxsl_(&node, &node, poolc);
+ lnkilb_(&node, &headc, poolc);
+ headc = node;
+ }
+
+/* Don't forget to return the requested data. */
+
+ s_copy(datac, rcbufc + ((((i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("rcbufc", i__1, "dasrwr_", (ftnlen)1469)) <<
+ 10) + (*first - 1)), datac_len, *last - (*first - 1));
+
+/* We haven't checked in, so don't check out. */
+
+ return 0;
+ }
+ node = poolc[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("poolc", i__1, "dasrwr_", (ftnlen)1478)];
+ }
+
+/* The record wasn't buffered. We need to allocate entries to */
+/* hold the record contents. If the buffer isn't full, just */
+/* select a free set of entries. If the buffer is full, use */
+/* the set of entries at the tail of the list. */
+
+/* Since we're now going to do a file read, it doesn't slow */
+/* us down much to check in, comparatively speaking. */
+
+ chkin_("DASRRC", (ftnlen)6);
+ if (usedc == 10) {
+
+/* Grab the buffer entry at the tail end of the list. */
+
+ node = lnktl_(&headc, poolc);
+ lnkxsl_(&node, &node, poolc);
+
+/* If the allocated buffer entry was updated, write it out. */
+
+ if (upbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fc", i__1, "dasrwr_", (ftnlen)1504)]) {
+ dasioc_("WRITE", &lubufc[(i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("lubufc", i__1, "dasrwr_", (ftnlen)1506)], &
+ rnbufc[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 :
+ s_rnge("rnbufc", i__2, "dasrwr_", (ftnlen)1506)], rcbufc
+ + (((i__3 = node - 1) < 10 && 0 <= i__3 ? i__3 : s_rnge(
+ "rcbufc", i__3, "dasrwr_", (ftnlen)1506)) << 10), (ftnlen)
+ 5, (ftnlen)1024);
+ }
+ } else {
+
+/* Allocate a new set of buffer entries, but don't link */
+/* them into the list yet. */
+
+ lnkan_(poolc, &node);
+ ++usedc;
+ }
+
+/* Try to read the record. */
+
+ dashlu_(handle, &unit);
+ dasioc_("READ", &unit, recno, rcbufc + (((i__1 = node - 1) < 10 && 0 <=
+ i__1 ? i__1 : s_rnge("rcbufc", i__1, "dasrwr_", (ftnlen)1528)) <<
+ 10), (ftnlen)4, (ftnlen)1024);
+ if (failed_()) {
+ chkout_("DASRRC", (ftnlen)6);
+ return 0;
+ }
+
+/* The read was successful. Link the node pointing to the buffer */
+/* entries for this record in before the current head of the */
+/* list, thus putting them at the head. */
+
+/* Set the file handle, record number, unit, and update flag for */
+/* this record. */
+
+ lnkilb_(&node, &headc, poolc);
+ hnbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("hnbufc", i__1,
+ "dasrwr_", (ftnlen)1545)] = *handle;
+ rnbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("rnbufc", i__1,
+ "dasrwr_", (ftnlen)1546)] = *recno;
+ lubufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("lubufc", i__1,
+ "dasrwr_", (ftnlen)1547)] = unit;
+ upbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbufc", i__1,
+ "dasrwr_", (ftnlen)1548)] = FALSE_;
+ headc = node;
+
+/* Don't forget to return the requested data. */
+
+ s_copy(datac, rcbufc + ((((i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("rcbufc", i__1, "dasrwr_", (ftnlen)1554)) << 10) + (*first
+ - 1)), datac_len, *last - (*first - 1));
+ chkout_("DASRRC", (ftnlen)6);
+ return 0;
+/* $Procedure DASWRD ( DAS, write record, double precision ) */
+
+L_daswrd:
+/* $ Abstract */
+
+/* Write DAS double precision physical records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* DOUBLE PRECISION RECD ( NWD ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAS file. */
+/* RECNO I Record number. */
+/* RECD I Double precision data to be written to record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAS file opened for writing. */
+
+/* RECNO is the number of a record in a DAS file. */
+
+/* RECD is an array of NWD double precision numbers. The */
+/* contents of this array are to be written to the */
+/* physical file record having number RECNO. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the action of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* BUFSZD is the number of records in the double precision */
+/* record buffer. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. The DAS file */
+/* designated by HANDLE will not be modified. */
+
+/* 2) If a write operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The status of the DAS file written to is uncertain in this */
+/* case. Note that the file written to may be different than */
+/* the file designated by HANDLE if multiple DAS files are open */
+/* for writing. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Routines outside of SPICELIB will normally have no need to call */
+/* this routine. */
+
+/* This routine can be used to write to only DAS files that are open */
+/* for writing. Records written via this routine will always be */
+/* buffered immediately, but may not be written to the file until */
+/* they are cleared from the double precision buffer to make room */
+/* for other records, or until they are explicitly forced to to be */
+/* written via a call to DASWBR. In any case, at the moment this */
+/* routine returns, the data supplied on input may be read back by */
+/* DASRRD or updated by DASURD. */
+
+/* Closing a DAS file via DASCLS forces any remaining updated data */
+/* records buffered by this routine to be written to the file. */
+
+/* $ Examples */
+
+/* 1) Write an array of NWD double precision numbers to the 9th */
+/* record in a DAS file designated by HANDLE. */
+
+/* DOUBLE PRECISION RECD */
+
+/* . */
+/* . */
+/* . */
+
+/* DO I = 1, NWD */
+/* RECD(I) = DBLE(I) */
+/* END DO */
+
+/* CALL DASWRD ( HANDLE, 9, RECD ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 03-NOV-1995 (NJB) */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write DAS double precision physical records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASWRD", (ftnlen)6);
+ }
+
+/* Check that the file is open for writing. Signal an error if not. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DASWRD", (ftnlen)6);
+ return 0;
+ }
+
+/* If it hasn't been done yet, initialize the pointer list pools. */
+
+ if (pass1) {
+ lnkini_(&c__10, poold);
+ lnkini_(&c__10, pooli);
+ lnkini_(&c__10, poolc);
+ pass1 = FALSE_;
+ }
+
+/* See whether double precision record number RECNO from file HANDLE */
+/* is buffered. We'll search through the list of buffered records */
+/* starting at the head of the list. If the record is already */
+/* buffered, we'll update the buffer entry, but we'll defer writing */
+/* the record out until we need to free a record, or until the */
+/* d.p. buffer is flushed, whichever comes first. */
+
+ node = headd;
+ while(node > 0) {
+ if (*handle == hnbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("hnbufd", i__1, "dasrwr_", (ftnlen)1787)] && *recno ==
+ rnbufd[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
+ "rnbufd", i__2, "dasrwr_", (ftnlen)1787)]) {
+
+/* Found it. Update the buffered record. */
+
+ moved_(recd, &c__128, &rcbufd[(i__1 = (node << 7) - 128) < 1280 &&
+ 0 <= i__1 ? i__1 : s_rnge("rcbufd", i__1, "dasrwr_", (
+ ftnlen)1792)]);
+
+/* Set the update flag, indicating that this buffer entry */
+/* has been modified. */
+
+ upbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fd", i__1, "dasrwr_", (ftnlen)1798)] = TRUE_;
+
+/* Put the information about this record at the head of the */
+/* active list, if it is not already there. */
+
+ if (node != headd) {
+ lnkxsl_(&node, &node, poold);
+ lnkilb_(&node, &headd, poold);
+ headd = node;
+ }
+ chkout_("DASWRD", (ftnlen)6);
+ return 0;
+ }
+ node = poold[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("poold", i__1, "dasrwr_", (ftnlen)1817)];
+ }
+
+/* The record we're writing to is not buffered. We'll allocate */
+/* a buffer entry. If the record buffer is full, we'll */
+/* commandeer the least recently accessed record. Before using */
+/* this record, we'll write its contents out to the corresponding */
+/* file, if the record has been updated. */
+
+ if (usedd < 10) {
+
+/* There's a free buffer entry available. Just allocate it. */
+
+ lnkan_(poold, &node);
+ ++usedd;
+ } else {
+
+/* Grab the buffer entry at the tail end of the list. */
+
+ node = lnktl_(&headd, poold);
+ lnkxsl_(&node, &node, poold);
+
+/* If the allocated record was updated, write it out. */
+
+ if (upbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fd", i__1, "dasrwr_", (ftnlen)1847)]) {
+ dasiod_("WRITE", &lubufd[(i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("lubufd", i__1, "dasrwr_", (ftnlen)1849)], &
+ rnbufd[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 :
+ s_rnge("rnbufd", i__2, "dasrwr_", (ftnlen)1849)], &rcbufd[
+ (i__3 = (node << 7) - 128) < 1280 && 0 <= i__3 ? i__3 :
+ s_rnge("rcbufd", i__3, "dasrwr_", (ftnlen)1849)], (ftnlen)
+ 5);
+ if (failed_()) {
+ chkout_("DASWRD", (ftnlen)6);
+ return 0;
+ }
+ }
+ }
+
+/* Now update the allocated buffer entry with the input data. */
+
+ moved_(recd, &c__128, &rcbufd[(i__1 = (node << 7) - 128) < 1280 && 0 <=
+ i__1 ? i__1 : s_rnge("rcbufd", i__1, "dasrwr_", (ftnlen)1866)]);
+
+/* Set the update flag, indicating that this buffer entry */
+/* has been modified. Also set the handle, unit, and record number */
+/* entries. */
+
+ dashlu_(handle, &unit);
+ upbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbufd", i__1,
+ "dasrwr_", (ftnlen)1875)] = TRUE_;
+ hnbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("hnbufd", i__1,
+ "dasrwr_", (ftnlen)1876)] = *handle;
+ lubufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("lubufd", i__1,
+ "dasrwr_", (ftnlen)1877)] = unit;
+ rnbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("rnbufd", i__1,
+ "dasrwr_", (ftnlen)1878)] = *recno;
+
+/* Link this buffer entry to the head of the list. */
+
+ lnkilb_(&node, &headd, poold);
+ headd = node;
+ chkout_("DASWRD", (ftnlen)6);
+ return 0;
+/* $Procedure DASWRI ( DAS, write record, integer ) */
+
+L_daswri:
+/* $ Abstract */
+
+/* Write DAS integer physical records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* INTEGER RECI ( NWI ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAS file. */
+/* RECNO I Record number. */
+/* RECI I Integer data to be written to record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAS file opened for writing. */
+
+/* RECNO is the number of a record in a DAS file. */
+
+/* RECI is an array of NWI integers. The contents of this */
+/* array are to be written to the physical file */
+/* record having number RECNO. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the action of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* BUFSZI is the number of records in the integer record */
+/* buffer. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. The DAS file */
+/* designated by HANDLE will not be modified. */
+
+/* 2) If a write operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The status of the DAS file written to is uncertain in this */
+/* case. Note that the file written to may be different than */
+/* the file designated by HANDLE if multiple DAS files are open */
+/* for writing. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Routines outside of SPICELIB will normally have no need to call */
+/* this routine. */
+
+/* This routine can be used to write to only DAS files that are open */
+/* for writing. Records written via this routine will always be */
+/* buffered immediately, but may not be written to the file until */
+/* they are cleared from the integer buffer to make room for other */
+/* records, or until they are explicitly forced to to be written via */
+/* a call to DASWBR. In any case, at the moment this routine */
+/* returns, the data supplied on input may be read back by DASRRI */
+/* or updated by DASURI. */
+
+/* Closing a DAS file via DASCLS forces any remaining updated data */
+/* records buffered by this routine to be written to the file. */
+
+/* $ Examples */
+
+/* 1) Write an array of NWI integers to the 9th record in a DAS */
+/* file designated by HANDLE. */
+
+/* INTEGER RECI ( NWI ) */
+/* . */
+/* . */
+/* . */
+
+/* DO I = 1, NWI */
+/* RECI(I) = I */
+/* END DO */
+
+/* CALL DASWRI ( HANDLE, 9, RECI ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 03-NOV-1995 (NJB) */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write DAS integer physical records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASWRI", (ftnlen)6);
+ }
+
+/* Check that the file is open for writing. Signal an error if not. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DASWRI", (ftnlen)6);
+ return 0;
+ }
+
+/* If it hasn't been done yet, initialize the pointer list pools. */
+
+ if (pass1) {
+ lnkini_(&c__10, poold);
+ lnkini_(&c__10, pooli);
+ lnkini_(&c__10, poolc);
+ pass1 = FALSE_;
+ }
+
+/* See whether integer record number RECNO from file HANDLE is */
+/* buffered. We'll search through the list of buffered records */
+/* starting at the head of the list. If the record is already */
+/* buffered, we'll update the buffer entry, but we'll defer writing */
+/* the record out until we need to free a record, or until the */
+/* integer buffer is flushed, whichever comes first. */
+
+ node = headi;
+ while(node > 0) {
+ if (*handle == hnbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("hnbufi", i__1, "dasrwr_", (ftnlen)2117)] && *recno ==
+ rnbufi[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
+ "rnbufi", i__2, "dasrwr_", (ftnlen)2117)]) {
+
+/* Found it. Update the buffered record. */
+
+ movei_(reci, &c__256, &rcbufi[(i__1 = (node << 8) - 256) < 2560 &&
+ 0 <= i__1 ? i__1 : s_rnge("rcbufi", i__1, "dasrwr_", (
+ ftnlen)2122)]);
+
+/* Set the update flag, indicating that this buffer entry */
+/* has been modified. */
+
+ upbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fi", i__1, "dasrwr_", (ftnlen)2128)] = TRUE_;
+
+/* Put the information about this record at the head of the */
+/* active list, if it is not already there. */
+
+ if (node != headi) {
+ lnkxsl_(&node, &node, pooli);
+ lnkilb_(&node, &headi, pooli);
+ headi = node;
+ }
+ chkout_("DASWRI", (ftnlen)6);
+ return 0;
+ }
+ node = pooli[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("pooli", i__1, "dasrwr_", (ftnlen)2147)];
+ }
+
+/* The record we're writing to is not buffered. We'll allocate */
+/* a buffer entry. If the record buffer is full, we'll */
+/* commandeer the least recently accessed record. Before using */
+/* this record, we'll write its contents out to the corresponding */
+/* file, if the record has been updated. */
+
+ if (usedi < 10) {
+
+/* There's a free buffer entry available. Just allocate it. */
+
+ lnkan_(pooli, &node);
+ ++usedi;
+ } else {
+
+/* Grab the buffer entry at the tail end of the list. */
+
+ node = lnktl_(&headi, pooli);
+ lnkxsl_(&node, &node, pooli);
+
+/* If the allocated record was updated, write it out. */
+
+ if (upbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fi", i__1, "dasrwr_", (ftnlen)2176)]) {
+ dasioi_("WRITE", &lubufi[(i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("lubufi", i__1, "dasrwr_", (ftnlen)2178)], &
+ rnbufi[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 :
+ s_rnge("rnbufi", i__2, "dasrwr_", (ftnlen)2178)], &rcbufi[
+ (i__3 = (node << 8) - 256) < 2560 && 0 <= i__3 ? i__3 :
+ s_rnge("rcbufi", i__3, "dasrwr_", (ftnlen)2178)], (ftnlen)
+ 5);
+ }
+ }
+
+/* Now update the allocated buffer entry with the input data. */
+
+ movei_(reci, &c__256, &rcbufi[(i__1 = (node << 8) - 256) < 2560 && 0 <=
+ i__1 ? i__1 : s_rnge("rcbufi", i__1, "dasrwr_", (ftnlen)2190)]);
+
+/* Set the update flag, indicating that this buffer entry */
+/* has been modified. Also set the handle, unit, and record number */
+/* entries. */
+
+ dashlu_(handle, &unit);
+ upbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbufi", i__1,
+ "dasrwr_", (ftnlen)2199)] = TRUE_;
+ hnbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("hnbufi", i__1,
+ "dasrwr_", (ftnlen)2200)] = *handle;
+ lubufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("lubufi", i__1,
+ "dasrwr_", (ftnlen)2201)] = unit;
+ rnbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("rnbufi", i__1,
+ "dasrwr_", (ftnlen)2202)] = *recno;
+
+/* Link this buffer entry to the head of the list. */
+
+ lnkilb_(&node, &headi, pooli);
+ headi = node;
+ chkout_("DASWRI", (ftnlen)6);
+ return 0;
+/* $Procedure DASWRC ( DAS, write record, character ) */
+
+L_daswrc:
+/* $ Abstract */
+
+/* Write DAS character physical records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* CHARACTER*(*) RECC */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAS file. */
+/* RECNO I Record number. */
+/* RECC I Character data to be written to record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAS file opened for writing. */
+
+/* RECNO is the number of a record in a DAS file. */
+
+/* RECC is a string of length NWC. The contents of this */
+/* string are to be written to the physical file */
+/* record having number RECNO. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the action of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* BUFSZC is the number of records in the character record */
+/* buffer. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. The DAS file */
+/* designated by HANDLE will not be modified. */
+
+/* 2) If a write operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The status of the DAS file written to is uncertain in this */
+/* case. Note that the file written to may be different than */
+/* the file designated by HANDLE if multiple DAS files are open */
+/* for writing. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Routines outside of SPICELIB will normally have no need to call */
+/* this routine. */
+
+/* This routine can be used to write to only DAS files that are open */
+/* for writing. Records written via this routine will always be */
+/* buffered immediately, but may not be written to the file until */
+/* they are cleared from the character buffer to make room for other */
+/* records, or until they are explicitly forced to to be written via */
+/* a call to DASWBR. In any case, at the moment this routine */
+/* returns, the data supplied on input may be read back by DASRRC */
+/* or updated by DASURC. */
+
+/* Closing a DAS file via DASCLS forces any remaining updated data */
+/* records buffered by this routine to be written to the file. */
+
+/* $ Examples */
+
+/* 1) Write a string of NWC characters to the 9th record in a DAS */
+/* file designated by HANDLE. */
+
+/* CHARACTER*(NWC) RECC */
+
+/* . */
+/* . */
+/* . */
+
+/* RECC = 'This example string is blank-padded on the ' // */
+/* . 'right. All of the trailing blanks will be ' // */
+/* . 'written to the DAS file by the following call.' */
+
+/* CALL DASWRC ( HANDLE, 9, RECC ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 03-NOV-1995 (NJB) */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write DAS character physical records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASWRC", (ftnlen)6);
+ }
+
+/* Check that the file is open for writing. Signal an error if not. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DASWRC", (ftnlen)6);
+ return 0;
+ }
+
+/* If it hasn't been done yet, initialize the pointer list pools. */
+
+ if (pass1) {
+ lnkini_(&c__10, poold);
+ lnkini_(&c__10, pooli);
+ lnkini_(&c__10, poolc);
+ pass1 = FALSE_;
+ }
+
+/* See whether character record number RECNO from file HANDLE is */
+/* buffered. We'll search through the list of buffered records */
+/* starting at the head of the list. If the record is already */
+/* buffered, we'll update the buffer entry, but we'll defer writing */
+/* the record out until we need to free a record, or until the */
+/* character buffer is flushed, whichever comes first. */
+
+ node = headc;
+ while(node > 0) {
+ if (*handle == hnbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("hnbufc", i__1, "dasrwr_", (ftnlen)2442)] && *recno ==
+ rnbufc[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
+ "rnbufc", i__2, "dasrwr_", (ftnlen)2442)]) {
+
+/* Found it. Update the buffered record. */
+
+ s_copy(rcbufc + (((i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("rcbufc", i__1, "dasrwr_", (ftnlen)2447)) << 10),
+ recc, (ftnlen)1024, recc_len);
+
+/* Set the update flag, indicating that this buffer entry */
+/* has been modified. */
+
+ upbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fc", i__1, "dasrwr_", (ftnlen)2453)] = TRUE_;
+
+/* Put the information about this record at the head of the */
+/* active list, if it is not already there. */
+
+ if (node != headc) {
+ lnkxsl_(&node, &node, poolc);
+ lnkilb_(&node, &headc, poolc);
+ headc = node;
+ }
+ chkout_("DASWRC", (ftnlen)6);
+ return 0;
+ }
+ node = poolc[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("poolc", i__1, "dasrwr_", (ftnlen)2472)];
+ }
+
+/* The record we're writing to is not buffered. We'll allocate */
+/* a buffer entry. If the record buffer is full, we'll */
+/* commandeer the least recently accessed record. Before using */
+/* this record, we'll write its contents out to the corresponding */
+/* file, if the record has been updated. */
+
+ if (usedc < 10) {
+
+/* There's a free buffer entry available. Just allocate it. */
+
+ lnkan_(poolc, &node);
+ ++usedc;
+ } else {
+
+/* Grab the buffer entry at the tail end of the list. */
+
+ node = lnktl_(&headc, poolc);
+ lnkxsl_(&node, &node, poolc);
+
+/* If the allocated record was updated, write it out. */
+
+ if (upbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fc", i__1, "dasrwr_", (ftnlen)2501)]) {
+ dasioc_("WRITE", &lubufc[(i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("lubufc", i__1, "dasrwr_", (ftnlen)2503)], &
+ rnbufc[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 :
+ s_rnge("rnbufc", i__2, "dasrwr_", (ftnlen)2503)], rcbufc
+ + (((i__3 = node - 1) < 10 && 0 <= i__3 ? i__3 : s_rnge(
+ "rcbufc", i__3, "dasrwr_", (ftnlen)2503)) << 10), (ftnlen)
+ 5, (ftnlen)1024);
+ if (failed_()) {
+ chkout_("DASWRC", (ftnlen)6);
+ return 0;
+ }
+ }
+ }
+
+/* Now update the allocated buffer entry with the input data. */
+
+ s_copy(rcbufc + (((i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge(
+ "rcbufc", i__1, "dasrwr_", (ftnlen)2520)) << 10), recc, (ftnlen)
+ 1024, recc_len);
+
+/* Set the update flag, indicating that this buffer entry */
+/* has been modified. Also set the handle, unit, and record number */
+/* entries. */
+
+ dashlu_(handle, &unit);
+ upbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbufc", i__1,
+ "dasrwr_", (ftnlen)2529)] = TRUE_;
+ hnbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("hnbufc", i__1,
+ "dasrwr_", (ftnlen)2530)] = *handle;
+ lubufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("lubufc", i__1,
+ "dasrwr_", (ftnlen)2531)] = unit;
+ rnbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("rnbufc", i__1,
+ "dasrwr_", (ftnlen)2532)] = *recno;
+
+/* Link this buffer entry to the head of the list. */
+
+ lnkilb_(&node, &headc, poolc);
+ headc = node;
+ chkout_("DASWRC", (ftnlen)6);
+ return 0;
+/* $Procedure DASURD ( DAS, update record, double precision ) */
+
+L_dasurd:
+/* $ Abstract */
+
+/* Update DAS double precision physical records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* INTEGER FIRST */
+/* INTEGER LAST */
+/* DOUBLE PRECISION DATAD ( * ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAS file. */
+/* RECNO I Record number. */
+/* FIRST, */
+/* LAST I First and last indices of range within record. */
+/* DATAD I Double precision data to write to record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAS file opened for writing. */
+
+/* RECNO is the number of a record in a DAS file. */
+
+/* FIRST, */
+/* LAST are the first and last indices of a range of */
+/* elements to be updated in the indicated record. */
+/* The record contains NWD double precision numbers; */
+/* these have indices ranging from 1 to NWD. */
+
+/* DATAD is a double precision array to be written to */
+/* elements FIRST through LAST of the specified */
+/* record. The array element DATAD(1) is placed in */
+/* record element FIRST, the array element DATAD(2) */
+/* is placed in record element FIRST+1, and so on; */
+/* the array element DATAD(LAST-FIRST+1) is placed in */
+/* the record element LAST. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the action of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* BUFSZD is the number of records in the double precision */
+/* record buffer. */
+
+/* $ Exceptions */
+
+/* 1) This routine may be used to update only records that have */
+/* already been written by DASWRD or that already exist in the */
+/* file designated by HANDLE. Attempting to update a record */
+/* that hasn't yet been written will cause the read operation */
+/* performed by this routine to fail. */
+
+/* If a read operation attempted by this routine fails for this */
+/* or any other reason, the error will be diagnosed by routines */
+/* called by this routine. The indicated record will not be */
+/* modified. */
+
+/* 2) If a write operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The status of the DAS file written to is uncertain in this */
+/* case. Note that the file written to may be different than */
+/* the file designated by HANDLE if multiple DAS files are open */
+/* for writing. */
+
+/* 3) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. The indicated */
+/* record will not be modified. */
+
+/* 4) If FIRST or LAST is not in the range [1, NWD], the error */
+/* SPICE(INDEXOUTOFRANGE) will be signalled. The indicated */
+/* record will not be modified. */
+
+/* 5) If FIRST > LAST, this routine will return without modifying */
+/* the indicated record. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Routines outside of SPICELIB will normally have no need to call */
+/* this routine. */
+
+/* This routine can be used to update any existing record in a DAS */
+/* file that is open for writing, or any record that has been */
+/* `written' by DASWRD, whether or not that record has yet been */
+/* physically written to the file it belongs to. Records that have */
+/* never been written cannot be updated. */
+
+/* Because the DAS system buffers records that are written, multiple */
+/* updates of parts of a record can be made without incurring a */
+/* large number of file reads and writes. */
+
+/* This routine should be used to update only records that contain */
+/* double precision data. */
+
+/* $ Examples */
+
+/* 1) Update the 10th through 100th d.p. numbers in record number 9 */
+/* in a DAS file designated by HANDLE. */
+
+/* DOUBLE PRECISION DATAD ( 100 ) */
+
+/* . */
+/* . */
+/* . */
+
+/* DO I = 1, 91 */
+/* DATAD = DBLE(I) */
+/* END DO */
+
+/* CALL DASURD ( HANDLE, 9, 10, 100, DATAD ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 03-NOV-1995 (NJB) */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* update DAS double precision physical records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASURD", (ftnlen)6);
+ }
+
+/* Check that the file is open for writing. Signal an error if not. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DASURD", (ftnlen)6);
+ return 0;
+ }
+
+/* If it hasn't been done yet, initialize the pointer list pools. */
+
+ if (pass1) {
+ lnkini_(&c__10, poold);
+ lnkini_(&c__10, pooli);
+ lnkini_(&c__10, poolc);
+ pass1 = FALSE_;
+ }
+
+/* If FIRST or LAST are out of range, no dice. */
+
+ if (*first < 1 || *first > 128 || *last < 1 || *last > 128) {
+ dashlu_(handle, &unit);
+ setmsg_("Array indices FIRST and LAST were #, #; allowed range for "
+ "both is [#, #]. File was #, record number was #.", (ftnlen)
+ 107);
+ errint_("#", first, (ftnlen)1);
+ errint_("#", last, (ftnlen)1);
+ errint_("#", &c__1, (ftnlen)1);
+ errint_("#", &c__128, (ftnlen)1);
+ errfnm_("#", &unit, (ftnlen)1);
+ errint_("#", recno, (ftnlen)1);
+ sigerr_("SPICE(INDEXOUTOFRANGE)", (ftnlen)22);
+ chkout_("DASURD", (ftnlen)6);
+ return 0;
+ }
+
+/* There's nothing to do if LAST < FIRST. */
+
+ if (*last < *first) {
+ chkout_("DASURD", (ftnlen)6);
+ return 0;
+ }
+
+/* See whether double precision record number RECNO from file HANDLE */
+/* is buffered. We'll search through the list of buffered records */
+/* starting at the head of the list. If the record is already */
+/* buffered, we'll update the buffer entry, but we'll defer writing */
+/* the record out until we need to free a record, or until the */
+/* d.p. buffer is flushed, whichever comes first. */
+
+ node = headd;
+ while(node > 0) {
+ if (*handle == hnbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("hnbufd", i__1, "dasrwr_", (ftnlen)2840)] && *recno ==
+ rnbufd[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
+ "rnbufd", i__2, "dasrwr_", (ftnlen)2840)]) {
+
+/* Found it. Update the buffered record. */
+
+ i__2 = *last - *first + 1;
+ moved_(datad, &i__2, &rcbufd[(i__1 = *first + (node << 7) - 129) <
+ 1280 && 0 <= i__1 ? i__1 : s_rnge("rcbufd", i__1, "dasr"
+ "wr_", (ftnlen)2845)]);
+
+/* Set the update flag, indicating that this buffer entry */
+/* has been modified. */
+
+ upbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fd", i__1, "dasrwr_", (ftnlen)2851)] = TRUE_;
+
+/* Put the information about this record at the head of the */
+/* active list, if it is not already there. */
+
+ if (node != headd) {
+ lnkxsl_(&node, &node, poold);
+ lnkilb_(&node, &headd, poold);
+ headd = node;
+ }
+ chkout_("DASURD", (ftnlen)6);
+ return 0;
+ }
+ node = poold[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("poold", i__1, "dasrwr_", (ftnlen)2870)];
+ }
+
+/* The record we're writing to is not buffered. In order to */
+/* update this record, we'll need to read it first. But before */
+/* we do that, we'll need to allocate a buffer entry. If the record */
+/* buffer is full, we'll commandeer the least recently accessed */
+/* record. Before using this record, we'll write its contents out */
+/* to the corresponding file, if the record has been updated. */
+
+ if (usedd < 10) {
+
+/* There's a free buffer entry available. Just allocate it. */
+
+ lnkan_(poold, &node);
+ ++usedd;
+ } else {
+
+/* Grab the buffer entry at the tail end of the list. */
+
+ node = lnktl_(&headd, poold);
+ lnkxsl_(&node, &node, poold);
+
+/* If the allocated record was updated, write it out. */
+
+ if (upbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fd", i__1, "dasrwr_", (ftnlen)2901)]) {
+ dasiod_("WRITE", &lubufd[(i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("lubufd", i__1, "dasrwr_", (ftnlen)2903)], &
+ rnbufd[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 :
+ s_rnge("rnbufd", i__2, "dasrwr_", (ftnlen)2903)], &rcbufd[
+ (i__3 = (node << 7) - 128) < 1280 && 0 <= i__3 ? i__3 :
+ s_rnge("rcbufd", i__3, "dasrwr_", (ftnlen)2903)], (ftnlen)
+ 5);
+ if (failed_()) {
+ chkout_("DASURD", (ftnlen)6);
+ return 0;
+ }
+ }
+ }
+
+/* Now try to read the record we're going to update. */
+
+ dashlu_(handle, &unit);
+ dasiod_("READ", &unit, recno, &rcbufd[(i__1 = (node << 7) - 128) < 1280 &&
+ 0 <= i__1 ? i__1 : s_rnge("rcbufd", i__1, "dasrwr_", (ftnlen)
+ 2922)], (ftnlen)4);
+ if (failed_()) {
+ chkout_("DASURD", (ftnlen)6);
+ return 0;
+ }
+
+/* The read was successful, so set the record number, handle, unit, */
+/* and update flag for this buffer entry, and link these buffer */
+/* entries in before the current head of the list, thus putting */
+/* them at the head. */
+
+/* Update the head pointer. */
+
+ lnkilb_(&node, &headd, poold);
+ hnbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("hnbufd", i__1,
+ "dasrwr_", (ftnlen)2939)] = *handle;
+ rnbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("rnbufd", i__1,
+ "dasrwr_", (ftnlen)2940)] = *recno;
+ lubufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("lubufd", i__1,
+ "dasrwr_", (ftnlen)2941)] = unit;
+ upbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbufd", i__1,
+ "dasrwr_", (ftnlen)2942)] = TRUE_;
+ headd = node;
+
+/* At long last, make the requested update. Note that we don't */
+/* have to write the record back to the file; that will get done */
+/* automatically before or at the time the file is closed. */
+
+ i__2 = *last - *first + 1;
+ moved_(datad, &i__2, &rcbufd[(i__1 = *first + (node << 7) - 129) < 1280 &&
+ 0 <= i__1 ? i__1 : s_rnge("rcbufd", i__1, "dasrwr_", (ftnlen)
+ 2950)]);
+ chkout_("DASURD", (ftnlen)6);
+ return 0;
+/* $Procedure DASURI ( DAS, update record, integer ) */
+
+L_dasuri:
+/* $ Abstract */
+
+/* Update DAS integer physical records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* INTEGER FIRST */
+/* INTEGER LAST */
+/* INTEGER DATAI ( * ) */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAS file. */
+/* RECNO I Record number. */
+/* FIRST, */
+/* LAST I First and last indices of range within record. */
+/* DATAI I Integer data to write to record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAS file opened for writing. */
+
+/* RECNO is the number of a record in a DAS file. */
+
+/* FIRST, */
+/* LAST are the first and last indices of a range of */
+/* elements to be updated in the indicated record. */
+/* The record contains NWI integers; these have */
+/* indices ranging from 1 to NWI. */
+
+/* DATAI is an integer array to be written to elements FIRST */
+/* through LAST of the specified record. The array */
+/* element DATAI(1) is placed in record element FIRST, */
+/* the array element DATAI(2) is placed in record */
+/* element FIRST+1, and so on; the array element */
+/* DATAI(LAST-FIRST+1) is placed in the record element */
+/* LAST. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the action of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* BUFSZI is the number of records in the integer record */
+/* buffer. */
+
+/* $ Exceptions */
+
+/* 1) This routine may be used to update only records that have */
+/* already been written by DASWRI or that already exist in the */
+/* file designated by HANDLE. Attempting to update a record */
+/* that hasn't yet been written will cause the read operation */
+/* performed by this routine to fail. */
+
+/* If a read operation attempted by this routine fails for this */
+/* or any other reason, the error will be diagnosed by routines */
+/* called by this routine. The indicated record will not be */
+/* modified. */
+
+/* 2) If a write operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The status of the DAS file written to is uncertain in this */
+/* case. Note that the file written to may be different than */
+/* the file designated by HANDLE if multiple DAS files are open */
+/* for writing. */
+
+/* 3) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. The indicated */
+/* record will not be modified. */
+
+/* 4) If FIRST or LAST is not in the range [1, NWI], the error */
+/* SPICE(INDEXOUTOFRANGE) will be signalled. The indicated */
+/* record will not be modified. */
+
+/* 5) If FIRST > LAST, this routine will return without modifying */
+/* the indicated record. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Routines outside of SPICELIB will normally have no need to call */
+/* this routine. */
+
+/* This routine can be used to update any existing record in a DAS */
+/* file that is open for writing, or any record that has been */
+/* `written' by DASWRI, whether or not that record has yet been */
+/* physically written to the file it belongs to. Records that have */
+/* never been written cannot be updated. */
+
+/* Because the DAS system buffers records that are written, multiple */
+/* updates of parts of a record can be made without incurring a */
+/* large number of file reads and writes. */
+
+/* This routine should be used to update only records that contain */
+/* integer data. */
+
+/* $ Examples */
+
+/* 1) Update the 10th through 100th integers in record number 9 */
+/* in a DAS file designated by HANDLE. */
+
+/* INTEGER DATAI ( 100 ) */
+
+/* . */
+/* . */
+/* . */
+
+/* DO I = 1, 91 */
+/* DATAI = I */
+/* END DO */
+
+/* CALL DASURI ( HANDLE, 9, 10, 100, DATAI ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 03-NOV-1995 (NJB) */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* update DAS integer physical records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASURI", (ftnlen)6);
+ }
+
+/* Check that the file is open for writing. Signal an error if not. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DASURI", (ftnlen)6);
+ return 0;
+ }
+
+/* If it hasn't been done yet, initialize the pointer list pools. */
+
+ if (pass1) {
+ lnkini_(&c__10, poold);
+ lnkini_(&c__10, pooli);
+ lnkini_(&c__10, poolc);
+ pass1 = FALSE_;
+ }
+
+/* If FIRST or LAST are out of range, no dice. */
+
+ if (*first < 1 || *first > 256 || *last < 1 || *last > 256) {
+ dashlu_(handle, &unit);
+ setmsg_("Array indices FIRST and LAST were #, #; allowed range for "
+ "both is [#, #]. File was #, record number was #.", (ftnlen)
+ 107);
+ errint_("#", first, (ftnlen)1);
+ errint_("#", last, (ftnlen)1);
+ errint_("#", &c__1, (ftnlen)1);
+ errint_("#", &c__256, (ftnlen)1);
+ errfnm_("#", &unit, (ftnlen)1);
+ errint_("#", recno, (ftnlen)1);
+ sigerr_("SPICE(INDEXOUTOFRANGE)", (ftnlen)22);
+ chkout_("DASURI", (ftnlen)6);
+ return 0;
+ }
+
+/* There's nothing to do if LAST < FIRST. */
+
+ if (*last < *first) {
+ chkout_("DASURI", (ftnlen)6);
+ return 0;
+ }
+
+/* See whether integer record number RECNO from file HANDLE is */
+/* buffered. We'll search through the list of buffered records */
+/* starting at the head of the list. If the record is already */
+/* buffered, we'll update the buffer entry, but we'll defer writing */
+/* the record out until we need to free a record, or until the */
+/* integer buffer is flushed, whichever comes first. */
+
+ node = headi;
+ while(node > 0) {
+ if (*handle == hnbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("hnbufi", i__1, "dasrwr_", (ftnlen)3251)] && *recno ==
+ rnbufi[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
+ "rnbufi", i__2, "dasrwr_", (ftnlen)3251)]) {
+
+/* Found it. Update the buffered record. */
+
+ i__2 = *last - *first + 1;
+ movei_(datai, &i__2, &rcbufi[(i__1 = *first + (node << 8) - 257) <
+ 2560 && 0 <= i__1 ? i__1 : s_rnge("rcbufi", i__1, "dasr"
+ "wr_", (ftnlen)3256)]);
+
+/* Set the update flag, indicating that this buffer entry */
+/* has been modified. */
+
+ upbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fi", i__1, "dasrwr_", (ftnlen)3262)] = TRUE_;
+
+/* Put the information about this record at the head of the */
+/* active list, if it is not already there. */
+
+ if (node != headi) {
+ lnkxsl_(&node, &node, pooli);
+ lnkilb_(&node, &headi, pooli);
+ headi = node;
+ }
+ chkout_("DASURI", (ftnlen)6);
+ return 0;
+ }
+ node = pooli[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("pooli", i__1, "dasrwr_", (ftnlen)3281)];
+ }
+
+/* The record we're writing to is not buffered. We'll allocate */
+/* a buffer entry. If the record buffer is full, we'll */
+/* commandeer the least recently accessed record. Before using */
+/* this record, we'll write its contents out to the corresponding */
+/* file, if the record has been updated. */
+
+ if (usedi < 10) {
+
+/* There's a free buffer entry available. Just allocate it. */
+
+ lnkan_(pooli, &node);
+ ++usedi;
+ } else {
+
+/* Grab the buffer entry at the tail end of the list. */
+
+ node = lnktl_(&headi, pooli);
+ lnkxsl_(&node, &node, pooli);
+
+/* If the allocated record was updated, write it out. */
+
+ if (upbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fi", i__1, "dasrwr_", (ftnlen)3310)]) {
+ dasioi_("WRITE", &lubufi[(i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("lubufi", i__1, "dasrwr_", (ftnlen)3312)], &
+ rnbufi[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 :
+ s_rnge("rnbufi", i__2, "dasrwr_", (ftnlen)3312)], &rcbufi[
+ (i__3 = (node << 8) - 256) < 2560 && 0 <= i__3 ? i__3 :
+ s_rnge("rcbufi", i__3, "dasrwr_", (ftnlen)3312)], (ftnlen)
+ 5);
+ if (failed_()) {
+ chkout_("DASURI", (ftnlen)6);
+ return 0;
+ }
+ }
+ }
+
+/* Now try to read the record we're going to update. */
+
+ dashlu_(handle, &unit);
+ dasioi_("READ", &unit, recno, &rcbufi[(i__1 = (node << 8) - 256) < 2560 &&
+ 0 <= i__1 ? i__1 : s_rnge("rcbufi", i__1, "dasrwr_", (ftnlen)
+ 3330)], (ftnlen)4);
+ if (failed_()) {
+ chkout_("DASURI", (ftnlen)6);
+ return 0;
+ }
+
+/* The read was successful, so set the record number, handle, unit, */
+/* and update flag for this buffer entry, and link these buffer */
+/* entries in before the current head of the list, thus putting */
+/* them at the head. */
+
+/* Update the head pointer. */
+
+ lnkilb_(&node, &headi, pooli);
+ hnbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("hnbufi", i__1,
+ "dasrwr_", (ftnlen)3347)] = *handle;
+ rnbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("rnbufi", i__1,
+ "dasrwr_", (ftnlen)3348)] = *recno;
+ lubufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("lubufi", i__1,
+ "dasrwr_", (ftnlen)3349)] = unit;
+ upbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbufi", i__1,
+ "dasrwr_", (ftnlen)3350)] = TRUE_;
+ headi = node;
+
+/* At long last, make the requested update. Note that we don't */
+/* have to write the record back to the file; that will get done */
+/* automatically before or at the time the file is closed. */
+
+ i__2 = *last - *first + 1;
+ movei_(datai, &i__2, &rcbufi[(i__1 = *first + (node << 8) - 257) < 2560 &&
+ 0 <= i__1 ? i__1 : s_rnge("rcbufi", i__1, "dasrwr_", (ftnlen)
+ 3358)]);
+ chkout_("DASURI", (ftnlen)6);
+ return 0;
+/* $Procedure DASURC ( DAS, update record, character ) */
+
+L_dasurc:
+/* $ Abstract */
+
+/* Update DAS character physical records. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+/* INTEGER RECNO */
+/* INTEGER FIRST */
+/* INTEGER LAST */
+/* CHARACTER*(*) DATAC */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAS file. */
+/* RECNO I Record number. */
+/* FIRST, */
+/* LAST I First and last indices of range within record. */
+/* DATAC I Character data to write to record. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAS file opened for writing. */
+
+/* RECNO is the number of a record in a DAS file. */
+
+/* FIRST, */
+/* LAST are the first and last indices of a range of */
+/* elements to be updated in the indicated record. */
+/* The record contains NWC characters; these have */
+/* indices ranging from 1 to NWC. */
+
+/* DATAC is a character string to be written to elements */
+/* FIRST through LAST of the specified record. The */
+/* character DATAC(1:1) is placed in record element */
+/* FIRST, the character DATAC(2) is placed in record */
+/* element FIRST+1, and so on; the character */
+/* DATAC(LAST-FIRST+1) is placed in the record element */
+/* LAST. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the action of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* BUFSZC is the number of records in the character record */
+/* buffer. */
+
+/* $ Exceptions */
+
+/* 1) This routine may be used to update only records that have */
+/* already been written by DASWRC or that already exist in the */
+/* file designated by HANDLE. Attempting to update a record */
+/* that hasn't yet been written will cause the read operation */
+/* performed by this routine to fail. */
+
+/* If a read operation attempted by this routine fails for this */
+/* or any other reason, the error will be diagnosed by routines */
+/* called by this routine. The indicated record will not be */
+/* modified. */
+
+/* 2) If a write operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The status of the DAS file written to is uncertain in this */
+/* case. Note that the file written to may be different than */
+/* the file designated by HANDLE if multiple DAS files are open */
+/* for writing. */
+
+/* 3) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. The indicated */
+/* record will not be modified. */
+
+/* 4) If FIRST or LAST is not in the range [1, NWC], the error */
+/* SPICE(INDEXOUTOFRANGE) will be signalled. The indicated */
+/* record will not be modified. */
+
+/* 5) If FIRST > LAST, this routine will return without modifying */
+/* the indicated record. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Routines outside of SPICELIB will normally have no need to call */
+/* this routine. */
+
+/* This routine can be used to update any existing record in a DAS */
+/* file that is open for writing, or any record that has been */
+/* `written' by DASWRC, whether or not that record has yet been */
+/* physically written to the file it belongs to. Records that have */
+/* never been written cannot be updated. */
+
+/* Because the DAS system buffers records that are written, multiple */
+/* updates of parts of a record can be made without incurring a */
+/* large number of file reads and writes. */
+
+/* Any buffered character record can be updated with this routine. */
+/* In particular, records that have been written to the DAS character */
+/* record buffer but have not yet been written out to the DAS file */
+/* they're intended to go to ARE visible to this routine. */
+
+/* This routine should be used to update only records that contain */
+/* character data. */
+
+/* $ Examples */
+
+/* 1) Update the 10th through 100th characters in record number 9 */
+/* in a DAS file designated by HANDLE. */
+
+/* CHARACTER*(100) DATAC */
+
+/* . */
+/* . */
+/* . */
+
+/* DATAC = 'The first 91 characters of this string, ' // */
+/* . 'including trailing blanks, will be written ' // */
+/* . 'to the indicated DAS file.' */
+
+/* CALL DASURC ( HANDLE, 9, 10, 100, DATAC ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 03-NOV-1995 (NJB) */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* update DAS character physical records */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASURC", (ftnlen)6);
+ }
+
+/* Check that the file is open for writing. Signal an error if not. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DASURC", (ftnlen)6);
+ return 0;
+ }
+
+/* If it hasn't been done yet, initialize the pointer list pools. */
+
+ if (pass1) {
+ lnkini_(&c__10, poold);
+ lnkini_(&c__10, pooli);
+ lnkini_(&c__10, poolc);
+ pass1 = FALSE_;
+ }
+
+/* If FIRST or LAST are out of range, no dice. */
+
+ if (*first < 1 || *first > 1024 || *last < 1 || *last > 1024) {
+ dashlu_(handle, &unit);
+ setmsg_("String indices FIRST and LAST were #, #; allowed range for"
+ " both is [#, #]. File was #, record number was #.", (ftnlen)
+ 108);
+ errint_("#", first, (ftnlen)1);
+ errint_("#", last, (ftnlen)1);
+ errint_("#", &c__1, (ftnlen)1);
+ errint_("#", &c__1024, (ftnlen)1);
+ errfnm_("#", &unit, (ftnlen)1);
+ errint_("#", recno, (ftnlen)1);
+ sigerr_("SPICE(INDEXOUTOFRANGE)", (ftnlen)22);
+ chkout_("DASURC", (ftnlen)6);
+ return 0;
+ }
+
+/* There's nothing to do if LAST < FIRST. */
+
+ if (*last < *first) {
+ chkout_("DASURC", (ftnlen)6);
+ return 0;
+ }
+
+/* See whether character record number RECNO from file HANDLE is */
+/* buffered. We'll search through the list of buffered records */
+/* starting at the head of the list. If the record is already */
+/* buffered, we'll update the buffer entry, but we'll defer writing */
+/* the record out until we need to free a record, or until the */
+/* character buffer is flushed, whichever comes first. */
+
+ node = headc;
+ while(node > 0) {
+ if (*handle == hnbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("hnbufc", i__1, "dasrwr_", (ftnlen)3665)] && *recno ==
+ rnbufc[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
+ "rnbufc", i__2, "dasrwr_", (ftnlen)3665)]) {
+
+/* Found it. Update the buffered record. */
+
+ s_copy(rcbufc + ((((i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("rcbufc", i__1, "dasrwr_", (ftnlen)3670)) << 10) +
+ (*first - 1)), datac, *last - (*first - 1), datac_len);
+
+/* Set the update flag, indicating that this buffer entry */
+/* has been modified. */
+
+ upbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fc", i__1, "dasrwr_", (ftnlen)3676)] = TRUE_;
+
+/* Put the information about this record at the head of the */
+/* active list, if it is not already there. */
+
+ if (node != headc) {
+ lnkxsl_(&node, &node, poolc);
+ lnkilb_(&node, &headc, poolc);
+ headc = node;
+ }
+ chkout_("DASURC", (ftnlen)6);
+ return 0;
+ }
+ node = poolc[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("poolc", i__1, "dasrwr_", (ftnlen)3695)];
+ }
+
+/* The record we're writing to is not buffered. We'll allocate */
+/* a buffer entry. If the record buffer is full, we'll */
+/* commandeer the least recently accessed record. Before using */
+/* this record, we'll write its contents out to the corresponding */
+/* file, if the record has been updated. */
+
+ if (usedc < 10) {
+
+/* There's a free buffer entry available. Just allocate it. */
+
+ lnkan_(poolc, &node);
+ ++usedc;
+ } else {
+
+/* Grab the buffer entry at the tail end of the list. */
+
+ node = lnktl_(&headc, poolc);
+ lnkxsl_(&node, &node, poolc);
+
+/* If the allocated record was updated, write it out. */
+
+ if (upbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbu"
+ "fc", i__1, "dasrwr_", (ftnlen)3724)]) {
+ dasioc_("WRITE", &lubufc[(i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("lubufc", i__1, "dasrwr_", (ftnlen)3726)], &
+ rnbufc[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 :
+ s_rnge("rnbufc", i__2, "dasrwr_", (ftnlen)3726)], rcbufc
+ + (((i__3 = node - 1) < 10 && 0 <= i__3 ? i__3 : s_rnge(
+ "rcbufc", i__3, "dasrwr_", (ftnlen)3726)) << 10), (ftnlen)
+ 5, (ftnlen)1024);
+ if (failed_()) {
+ chkout_("DASURC", (ftnlen)6);
+ return 0;
+ }
+ }
+ }
+
+/* Now try to read the record we're going to update. */
+
+ dashlu_(handle, &unit);
+ dasioc_("READ", &unit, recno, rcbufc + (((i__1 = node - 1) < 10 && 0 <=
+ i__1 ? i__1 : s_rnge("rcbufc", i__1, "dasrwr_", (ftnlen)3744)) <<
+ 10), (ftnlen)4, (ftnlen)1024);
+ if (failed_()) {
+ chkout_("DASURC", (ftnlen)6);
+ return 0;
+ }
+
+/* The read was successful, so set the record number, handle, unit, */
+/* and update flag for this buffer entry, and link these buffer */
+/* entries in before the current head of the list, thus putting */
+/* them at the head. */
+
+/* Update the head pointer. */
+
+ lnkilb_(&node, &headc, poolc);
+ hnbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("hnbufc", i__1,
+ "dasrwr_", (ftnlen)3761)] = *handle;
+ rnbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("rnbufc", i__1,
+ "dasrwr_", (ftnlen)3762)] = *recno;
+ lubufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("lubufc", i__1,
+ "dasrwr_", (ftnlen)3763)] = unit;
+ upbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("upbufc", i__1,
+ "dasrwr_", (ftnlen)3764)] = TRUE_;
+ headc = node;
+
+/* At long last, make the requested update. Note that we don't */
+/* have to write the record back to the file; that will get done */
+/* automatically before or at the time the file is closed. */
+
+ s_copy(rcbufc + ((((i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge(
+ "rcbufc", i__1, "dasrwr_", (ftnlen)3772)) << 10) + (*first - 1)),
+ datac, *last - (*first - 1), datac_len);
+ chkout_("DASURC", (ftnlen)6);
+ return 0;
+/* $Procedure DASWBR ( DAS, write buffered records ) */
+
+L_daswbr:
+/* $ Abstract */
+
+/* Write out all buffered records of a specified file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+
+/* INTEGER HANDLE */
+
+/* $ Brief_I/O */
+
+/* Variable I/O Entry points */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I Handle of DAS file. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is the handle of a DAS file opened for writing. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the action of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. The indicated */
+/* file will not be modified. */
+
+/* 2) If a write operation attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The status of the DAS file written to is uncertain in this */
+/* case. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine writes buffered records out to the DAS file to which */
+/* they correspond. After the records are written, the buffer */
+/* elements used to store them are deallocated. */
+
+/* Because the DAS system buffers records that are written as well */
+/* as those that are read, data supplied to the DASWRx and DASURx */
+/* routines on input has not necessarily been physically written to */
+/* the DAS file specified by the caller of those routines, at the */
+/* time those routines return. Before closing a DAS file that has */
+/* been opened for writing, the DAS system must write out to the */
+/* file any updated records present in the DAS buffers. The SPICELIB */
+/* routine DASCLS uses this routine to perform this function. The */
+/* SPICELIB routines DASACR and DASRCR, which respectively add */
+/* comment records to or delete comment records from a DAS file, use */
+/* this routine to ensure that the DASRWR record buffers don't */
+/* become out of synch with the file they operate upon. */
+
+/* In addition, this routine can be used by application programs */
+/* that create or update DAS files. The reason for calling this */
+/* routine directly would be to provide a measure of safety when */
+/* writing a very large file: if the file creation or update were */
+/* interrupted, the amount of work lost due to the loss of buffered, */
+/* unwritten records could be reduced. */
+
+/* However, routines outside of SPICELIB will generally not need to */
+/* call this routine directly. */
+
+/* $ Examples */
+
+/* 1) Supply a series of double precision records to DASWRD, */
+/* then force a physical write of those records to the file. */
+
+/* DO RECNO = 77, 100 */
+
+/* CALL FILLD ( DBLE(RECNO), NWD, RECD ) */
+/* CALL DASWRD ( HANDLE, RECNO, RECD ) */
+
+/* END DO */
+
+/* CALL DASWBR ( HANDLE ) */
+
+
+/* 2) This is the same as example (1), except we force a physical */
+/* write by closing the file. */
+
+/* DO RECNO = 77, 100 */
+
+/* CALL FILLD ( DBLE(RECNO), NWD, RECD ) */
+/* CALL DASWRD ( HANDLE, RECNO, RECD ) */
+
+/* END DO */
+
+/* CALL DASCLS ( HANDLE ) */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 03-NOV-1995 (NJB) */
+
+/* Removed weird spaces from ENTRY statement. */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write buffered records to a DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 28-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASWBR", (ftnlen)6);
+ }
+
+/* Check that the file is open for writing. Signal an error if not. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+ if (failed_()) {
+ chkout_("DASWBR", (ftnlen)6);
+ return 0;
+ }
+
+/* If it hasn't been done yet, initialize the pointer list pools. */
+
+ if (pass1) {
+ lnkini_(&c__10, poold);
+ lnkini_(&c__10, pooli);
+ lnkini_(&c__10, poolc);
+ pass1 = FALSE_;
+ }
+
+/* For each buffer, find the records belonging to this file, and */
+/* write them out to the file. */
+
+/* Double precision records first. */
+
+ node = headd;
+ while(node > 0) {
+ if (*handle == hnbufd[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("hnbufd", i__1, "dasrwr_", (ftnlen)4014)]) {
+
+/* This record belongs to the file of interest, so write the */
+/* the record out. */
+
+ dasiod_("WRITE", &lubufd[(i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("lubufd", i__1, "dasrwr_", (ftnlen)4019)], &
+ rnbufd[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 :
+ s_rnge("rnbufd", i__2, "dasrwr_", (ftnlen)4019)], &rcbufd[
+ (i__3 = (node << 7) - 128) < 1280 && 0 <= i__3 ? i__3 :
+ s_rnge("rcbufd", i__3, "dasrwr_", (ftnlen)4019)], (ftnlen)
+ 5);
+ if (failed_()) {
+ chkout_("DASWBR", (ftnlen)6);
+ return 0;
+ }
+
+/* The record is no longer in use; return it to the */
+/* free list. But grab the successor first. Update */
+/* the head of the list, if the node we're freeing is */
+/* the head node. Decrement the number of used d.p. */
+/* buffer elements. */
+
+ next = poold[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("poold", i__1, "dasrwr_", (ftnlen)4036)];
+ if (node == headd) {
+ headd = next;
+ }
+ lnkfsl_(&node, &node, poold);
+ node = next;
+ --usedd;
+ } else {
+
+/* Just get the next node. */
+
+ node = poold[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("poold", i__1, "dasrwr_", (ftnlen)4051)];
+ }
+ }
+
+/* Next, integer records. */
+
+ node = headi;
+ while(node > 0) {
+ if (*handle == hnbufi[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("hnbufi", i__1, "dasrwr_", (ftnlen)4066)]) {
+
+/* This record belongs to the file of interest, so write the */
+/* the record out. */
+
+ dasioi_("WRITE", &lubufi[(i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("lubufi", i__1, "dasrwr_", (ftnlen)4071)], &
+ rnbufi[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 :
+ s_rnge("rnbufi", i__2, "dasrwr_", (ftnlen)4071)], &rcbufi[
+ (i__3 = (node << 8) - 256) < 2560 && 0 <= i__3 ? i__3 :
+ s_rnge("rcbufi", i__3, "dasrwr_", (ftnlen)4071)], (ftnlen)
+ 5);
+ if (failed_()) {
+ chkout_("DASWBR", (ftnlen)6);
+ return 0;
+ }
+
+/* The record is no longer in use; return it to the */
+/* free list. But grab the successor first. Update */
+/* the head of the list, if the node we're freeing is */
+/* the head node. Decrement the number of used integer */
+/* buffer elements. */
+
+ next = pooli[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("pooli", i__1, "dasrwr_", (ftnlen)4088)];
+ if (node == headi) {
+ headi = next;
+ }
+ lnkfsl_(&node, &node, pooli);
+ node = next;
+ --usedi;
+ } else {
+
+/* Just get the next node. */
+
+ node = pooli[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("pooli", i__1, "dasrwr_", (ftnlen)4103)];
+ }
+ }
+
+/* And last, character records. */
+
+ node = headc;
+ while(node > 0) {
+ if (*handle == hnbufc[(i__1 = node - 1) < 10 && 0 <= i__1 ? i__1 :
+ s_rnge("hnbufc", i__1, "dasrwr_", (ftnlen)4118)]) {
+
+/* This record belongs to the file of interest, so write the */
+/* the record out. */
+
+ dasioc_("WRITE", &lubufc[(i__1 = node - 1) < 10 && 0 <= i__1 ?
+ i__1 : s_rnge("lubufc", i__1, "dasrwr_", (ftnlen)4123)], &
+ rnbufc[(i__2 = node - 1) < 10 && 0 <= i__2 ? i__2 :
+ s_rnge("rnbufc", i__2, "dasrwr_", (ftnlen)4123)], rcbufc
+ + (((i__3 = node - 1) < 10 && 0 <= i__3 ? i__3 : s_rnge(
+ "rcbufc", i__3, "dasrwr_", (ftnlen)4123)) << 10), (ftnlen)
+ 5, (ftnlen)1024);
+ if (failed_()) {
+ chkout_("DASWBR", (ftnlen)6);
+ return 0;
+ }
+
+/* The record is no longer in use; return it to the */
+/* free list. But grab the successor first. Update */
+/* the head of the list, if the node we're freeing is */
+/* the head node. Decrement the number of used character */
+/* buffer elements. */
+
+ next = poolc[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("poolc", i__1, "dasrwr_", (ftnlen)4140)];
+ if (node == headc) {
+ headc = next;
+ }
+ lnkfsl_(&node, &node, poolc);
+ node = next;
+ --usedc;
+ } else {
+
+/* Just get the next node. */
+
+ node = poolc[(i__1 = (node << 1) + 10) < 32 && 0 <= i__1 ? i__1 :
+ s_rnge("poolc", i__1, "dasrwr_", (ftnlen)4155)];
+ }
+ }
+ chkout_("DASWBR", (ftnlen)6);
+ return 0;
+} /* dasrwr_ */
+
+/* Subroutine */ int dasrwr_(integer *handle, integer *recno, char *recc,
+ doublereal *recd, integer *reci, integer *first, integer *last,
+ doublereal *datad, integer *datai, char *datac, ftnlen recc_len,
+ ftnlen datac_len)
+{
+ return dasrwr_0_(0, handle, recno, recc, recd, reci, first, last, datad,
+ datai, datac, recc_len, datac_len);
+ }
+
+/* Subroutine */ int dasrrd_(integer *handle, integer *recno, integer *first,
+ integer *last, doublereal *datad)
+{
+ return dasrwr_0_(1, handle, recno, (char *)0, (doublereal *)0, (integer *)
+ 0, first, last, datad, (integer *)0, (char *)0, (ftnint)0, (
+ ftnint)0);
+ }
+
+/* Subroutine */ int dasrri_(integer *handle, integer *recno, integer *first,
+ integer *last, integer *datai)
+{
+ return dasrwr_0_(2, handle, recno, (char *)0, (doublereal *)0, (integer *)
+ 0, first, last, (doublereal *)0, datai, (char *)0, (ftnint)0, (
+ ftnint)0);
+ }
+
+/* Subroutine */ int dasrrc_(integer *handle, integer *recno, integer *first,
+ integer *last, char *datac, ftnlen datac_len)
+{
+ return dasrwr_0_(3, handle, recno, (char *)0, (doublereal *)0, (integer *)
+ 0, first, last, (doublereal *)0, (integer *)0, datac, (ftnint)0,
+ datac_len);
+ }
+
+/* Subroutine */ int daswrd_(integer *handle, integer *recno, doublereal *
+ recd)
+{
+ return dasrwr_0_(4, handle, recno, (char *)0, recd, (integer *)0, (
+ integer *)0, (integer *)0, (doublereal *)0, (integer *)0, (char *)
+ 0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int daswri_(integer *handle, integer *recno, integer *reci)
+{
+ return dasrwr_0_(5, handle, recno, (char *)0, (doublereal *)0, reci, (
+ integer *)0, (integer *)0, (doublereal *)0, (integer *)0, (char *)
+ 0, (ftnint)0, (ftnint)0);
+ }
+
+/* Subroutine */ int daswrc_(integer *handle, integer *recno, char *recc,
+ ftnlen recc_len)
+{
+ return dasrwr_0_(6, handle, recno, recc, (doublereal *)0, (integer *)0, (
+ integer *)0, (integer *)0, (doublereal *)0, (integer *)0, (char *)
+ 0, recc_len, (ftnint)0);
+ }
+
+/* Subroutine */ int dasurd_(integer *handle, integer *recno, integer *first,
+ integer *last, doublereal *datad)
+{
+ return dasrwr_0_(7, handle, recno, (char *)0, (doublereal *)0, (integer *)
+ 0, first, last, datad, (integer *)0, (char *)0, (ftnint)0, (
+ ftnint)0);
+ }
+
+/* Subroutine */ int dasuri_(integer *handle, integer *recno, integer *first,
+ integer *last, integer *datai)
+{
+ return dasrwr_0_(8, handle, recno, (char *)0, (doublereal *)0, (integer *)
+ 0, first, last, (doublereal *)0, datai, (char *)0, (ftnint)0, (
+ ftnint)0);
+ }
+
+/* Subroutine */ int dasurc_(integer *handle, integer *recno, integer *first,
+ integer *last, char *datac, ftnlen datac_len)
+{
+ return dasrwr_0_(9, handle, recno, (char *)0, (doublereal *)0, (integer *)
+ 0, first, last, (doublereal *)0, (integer *)0, datac, (ftnint)0,
+ datac_len);
+ }
+
+/* Subroutine */ int daswbr_(integer *handle)
+{
+ return dasrwr_0_(10, handle, (integer *)0, (char *)0, (doublereal *)0, (
+ integer *)0, (integer *)0, (integer *)0, (doublereal *)0, (
+ integer *)0, (char *)0, (ftnint)0, (ftnint)0);
+ }
+
diff --git a/ext/spice/src/cspice/dassdr.c b/ext/spice/src/cspice/dassdr.c
new file mode 100644
index 0000000000..da0f576aeb
--- /dev/null
+++ b/ext/spice/src/cspice/dassdr.c
@@ -0,0 +1,948 @@
+/* dassdr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__4 = 4;
+static integer c__3 = 3;
+static integer c__1 = 1;
+static integer c__256 = 256;
+static integer c__0 = 0;
+
+/* $Procedure DASSDR ( DAS, segregate data records ) */
+/* Subroutine */ int dassdr_(integer *handle)
+{
+ /* Initialized data */
+
+ static integer next[3] = { 2,3,1 };
+ static integer prev[3] = { 3,1,2 };
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ integer base;
+ char crec[1024];
+ doublereal drec[128];
+ integer free, irec[256], lrec, dest;
+ logical more;
+ integer unit, type__, i__, j, n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc;
+ extern /* Subroutine */ int maxai_(integer *, integer *, integer *,
+ integer *);
+ char savec[1024];
+ doublereal saved[128];
+ integer recno, savei[256];
+ extern integer sumai_(integer *, integer *);
+ integer ncomr, total, lword, count[4], ltype, start;
+ extern logical failed_(void);
+ extern /* Subroutine */ int dasadi_(integer *, integer *, integer *),
+ cleari_(integer *, integer *);
+ integer drbase;
+ extern /* Subroutine */ int dasioc_(char *, integer *, integer *, char *,
+ ftnlen, ftnlen), dasiod_(char *, integer *, integer *, doublereal
+ *, ftnlen), dasllc_(integer *), dasrdi_(integer *, integer *,
+ integer *, integer *), dashfs_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *, integer *, integer *),
+ dasudi_(integer *, integer *, integer *, integer *);
+ integer minadr, maxadr, scrhan, lastla[3];
+ extern /* Subroutine */ int dassih_(integer *, char *, ftnlen), dashlu_(
+ integer *, integer *), daswbr_(integer *), dasrri_(integer *,
+ integer *, integer *, integer *, integer *);
+ integer offset;
+ extern /* Subroutine */ int dasioi_(char *, integer *, integer *, integer
+ *, ftnlen);
+ integer lastrc[3];
+ extern /* Subroutine */ int dasops_(integer *), dasufs_(integer *,
+ integer *, integer *, integer *, integer *, integer *, integer *,
+ integer *, integer *), chkout_(char *, ftnlen);
+ integer lastwd[3], nresvc;
+ extern logical return_(void);
+ integer nresvr, savtyp, prvtyp, loc, pos;
+
+/* $ Abstract */
+
+/* Segregate the data records in a DAS file into clusters, using */
+/* one cluster per data type present in the file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* ORDER */
+/* SORT */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a file handle of a DAS file opened for writing. */
+
+/* $ Detailed_Output */
+
+/* None. See $Particulars for a description of the effect of this */
+/* routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. */
+
+/* 2) If a Fortran read attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The state of the DAS file undergoing re-ordering will be */
+/* indeterminate. */
+
+/* 3) If a Fortran write attempted by this routine fails, the */
+/* error will be diagnosed by routines called by this routine. */
+/* The state of the DAS file undergoing re-ordering will be */
+/* indeterminate. */
+
+/* 4) If any other I/O error occurs during the re-arrangement of */
+/* the records in the indicated DAS file, the error will be */
+/* diagnosed by routines called by this routine. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* Normally, there should be no need for routines outside of */
+/* SPICELIB to call this routine. */
+
+/* The effect of this routine is to re-arrange the data records */
+/* in a DAS file so that the file contains a single cluster for */
+/* each data type present in the file: in the general case, there */
+/* will be a single cluster of each of the integer, double */
+/* precision, and character data types. */
+
+/* The relative order of data records of a given type is not */
+/* affected by this re-ordering. After the re-ordering, the DAS */
+/* file contains a single directory record that has one descriptor */
+/* for each cluster. After that point, the order in the file of the */
+/* sets of data records of the various data types will be: */
+
+/* +-------+ */
+/* | CHAR | */
+/* +-------+ */
+/* | DP | */
+/* +-------+ */
+/* | INT | */
+/* +-------+ */
+
+/* Files that contain multiple directory records will have all but */
+/* the first directory record moved to the end of the file when the */
+/* re-ordering is complete. These records are not visible to the */
+/* DAS system and will be overwritten if data is subsequently added */
+/* to the DAS file. */
+
+/* The purpose of segregating a DAS file's data records into three */
+/* clusters is to make read access more efficient: when a DAS file */
+/* contains a single directory with at most three cluster type */
+/* descriptors, mapping logical to physical addresses can be done */
+/* in constant time. */
+
+/* $ Examples */
+
+/* 1) Segregate data records in a DAS file designated by */
+/* HANDLE: */
+
+/* CALL DASSDR ( HANDLE ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 2.0.1 19-DEC-1995 (NJB) */
+
+/* Corrected title of permuted index entry section. */
+
+/* - EKLIB Version 2.0.0, 17-NOV-1993 (KRG) */
+
+/* Added test of FAILED after each DAS call, or sequence of calls, */
+/* which returns immediately if FAILED is true. This fixes a bug */
+/* where DASOPS signals an error and then DASSDR has a */
+/* segmentation fault. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - EKLIB Version 1.2.0, 07-OCT-1993 (NJB) (HAN) (MJS) */
+
+/* Bug fix: call to CLEARD replaced with call to */
+/* CLEARI. */
+
+/* - EKLIB Version 1.1.0, 08-JUL-1993 (NJB) (MJS) */
+
+/* Bug fix: extraneous commas removed from argument lists */
+/* in calls to DASADI. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* segregate the data records in a DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - EKLIB Version 2.0.0, 17-NOV-1993 (KRG) */
+
+/* Added test of failed after each DAS call, or sequence of calls, */
+/* which returns immediately if FAILED is true. This fixes a bug */
+/* where DASOPS signals an error and then DASSDR has a */
+/* segmentation fault. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* - EKLIB Version 1.2.0, 07-OCT-1993 (NJB) (HAN) (MJS) */
+
+/* Bug fix: call to CLEARD replaced with call to */
+/* CLEARI. */
+
+/* - EKLIB Version 1.1.0, 08-JUL-1993 (NJB) */
+
+/* Bug fix: extraneous commas removed from argument lists */
+/* in calls to DASADI. This bug had no visible effect on */
+/* VAX and Sun systems, but generated a compile error under */
+/* Lahey Fortran. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Data type parameters */
+
+
+/* Directory pointer locations (backward and forward): */
+
+
+/* Directory address range location base */
+
+
+/* Location of first type descriptor */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* NEXT and PREV map the DAS data type codes to their */
+/* successors and predecessors, respectively. */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASSDR", (ftnlen)6);
+ }
+
+/* Before starting, make sure that this DAS file is open for */
+/* writing. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+
+/* Get the logical unit for this file. */
+
+ dashlu_(handle, &unit);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+
+/* Write out any buffered records that belong to the file. */
+
+ daswbr_(handle);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+
+/* We're going to re-order the physical records in the DAS file, */
+/* starting with the first record after the first directory. */
+/* The other directory records are moved to the end of the file */
+/* as a result of the re-ordering. */
+
+/* The re-ordering algorithm is based on that used in the REORDx */
+/* routines. To use this algorithm, we'll build an order vector */
+/* for the records to be ordered; we'll construct this order vector */
+/* in a scratch DAS file. First, we'll traverse the directories */
+/* to build up a sort of inverse order vector that tells us the */
+/* final destination and data type of each data record; from this */
+/* inverse vector we can easily build a true order vector. The */
+/* cycles of the true order vector can be traversed without */
+/* repetitive searching, and with a minimum of assignment of the */
+/* contents of data records to temporary variables. */
+
+
+/* Allocate a scratch DAS file to keep our vectors in. */
+
+ dasops_(&scrhan);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+
+/* Now build up our `inverse order vector'. This array is an */
+/* inverse order vector only in loose sense: it actually consists */
+/* of an integer array that contains a sequence of pairs of integers, */
+/* the first of which indicates a data type, and the second of which */
+/* is an ordinal number. There is one pair for each data record in */
+/* the file. The ordinal number gives the ordinal position of the */
+/* record described by the number pair, relative to the other records */
+/* of the same type. Directory records are considered to have type */
+/* `directory', which is represented by the code DIR. */
+
+/* We also must maintain a count of records of each type. */
+
+ cleari_(&c__4, count);
+
+/* Get the file summary for the DAS file to be segregated. */
+
+ dashfs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla, lastrc,
+ lastwd);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+
+/* Find the record and word positions LREC and LWORD of the last */
+/* descriptor in the file, and also find the type of the descriptor */
+/* LTYPE. */
+
+ maxai_(lastrc, &c__3, &lrec, &loc);
+ lword = 0;
+ for (i__ = 1; i__ <= 3; ++i__) {
+ if (lastrc[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("lastrc",
+ i__1, "dassdr_", (ftnlen)451)] == lrec && lastwd[(i__2 = i__
+ - 1) < 3 && 0 <= i__2 ? i__2 : s_rnge("lastwd", i__2, "dassd"
+ "r_", (ftnlen)451)] > lword) {
+ lword = lastwd[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastwd", i__1, "dassdr_", (ftnlen)454)];
+ ltype = i__;
+ }
+ }
+
+/* The first directory starts after the last comment record. */
+
+ recno = nresvr + ncomr + 2;
+ while(recno <= lrec && recno > 0) {
+
+/* Read the directory record. */
+
+ dasrri_(handle, &recno, &c__1, &c__256, irec);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+
+/* Increment the directory count. */
+
+ ++count[3];
+
+/* Add the data type (`directory') and count (1) of the current */
+/* record to the inverse order vector. */
+
+ dasadi_(&scrhan, &c__1, &c__4);
+ dasadi_(&scrhan, &c__1, &count[3]);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+
+/* Set up our `finite state machine' that tells us the data */
+/* types of the records described by the last read directory. */
+
+ type__ = irec[8];
+ prvtyp = prev[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "prev", i__1, "dassdr_", (ftnlen)498)];
+
+/* Now traverse the directory and update the inverse order */
+/* vector based on the descriptors we find. */
+
+ more = TRUE_;
+ i__ = 10;
+ while(more) {
+
+/* Obtain the count for the current descriptor. */
+
+ n = (i__2 = irec[(i__1 = i__ - 1) < 256 && 0 <= i__1 ? i__1 :
+ s_rnge("irec", i__1, "dassdr_", (ftnlen)512)], abs(i__2));
+
+/* Update our inverse order vector to describe the positions */
+/* of the N records described by the current descriptor. */
+
+ i__1 = n;
+ for (j = 1; j <= i__1; ++j) {
+ dasadi_(&scrhan, &c__1, &type__);
+ i__3 = count[(i__2 = type__ - 1) < 4 && 0 <= i__2 ? i__2 :
+ s_rnge("count", i__2, "dassdr_", (ftnlen)521)] + j;
+ dasadi_(&scrhan, &c__1, &i__3);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* Adjust the count of records of data type TYPE. */
+
+ count[(i__1 = type__ - 1) < 4 && 0 <= i__1 ? i__1 : s_rnge("count"
+ , i__1, "dassdr_", (ftnlen)533)] = count[(i__2 = type__ -
+ 1) < 4 && 0 <= i__2 ? i__2 : s_rnge("count", i__2, "dass"
+ "dr_", (ftnlen)533)] + n;
+
+/* Find the next type. */
+
+ ++i__;
+ if (i__ > 256 || recno == lrec && i__ > lword) {
+ more = FALSE_;
+ } else {
+ if (irec[(i__1 = i__ - 1) < 256 && 0 <= i__1 ? i__1 : s_rnge(
+ "irec", i__1, "dassdr_", (ftnlen)547)] > 0) {
+ type__ = next[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1
+ : s_rnge("next", i__1, "dassdr_", (ftnlen)548)];
+ } else if (irec[(i__1 = i__ - 1) < 256 && 0 <= i__1 ? i__1 :
+ s_rnge("irec", i__1, "dassdr_", (ftnlen)550)] < 0) {
+ type__ = prev[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1
+ : s_rnge("prev", i__1, "dassdr_", (ftnlen)551)];
+ } else {
+ more = FALSE_;
+ }
+ }
+ }
+
+/* The forward pointer in this directory tells us where the */
+/* next directory record is. When there are no more directory */
+/* records, this pointer will be zero. */
+
+ recno = irec[1];
+ }
+
+/* At this point, the inverse order vector is set up. The array */
+/* COUNT contains counts of the number of records of each type we've */
+/* seen. Set TOTAL to the total number of records that we've going */
+/* to permute. */
+
+ total = sumai_(count, &c__4);
+
+/* The next step is to build a true order vector. Let BASE be */
+/* the base address for the order vector; this address is the */
+/* last logical address of the inverse order vector. */
+
+ base = total << 1;
+
+/* We'll store the actual order vector in locations BASE + 1 */
+/* through BASE + TOTAL. In addition, we'll build a parallel array */
+/* that contains, for each element of the order vector, the type of */
+/* data corresponding to that element. This type vector will */
+/* reside in locations BASE + TOTAL + 1 through BASE + 2*TOTAL. */
+
+/* Before setting the values of the order vector and its parallel */
+/* type vector, we'll allocate space in the scratch DAS file by */
+/* zeroing out the locations we plan to use. After this, locations */
+/* BASE+1 through BASE + 2*TOTAL can be written to in random access */
+/* fashion using DASUDI. */
+
+
+ i__1 = total << 1;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ dasadi_(&scrhan, &c__1, &c__0);
+ }
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+
+/* We note that the way to construct the inverse of a permutation */
+/* SIGMA in a single loop is suggested by the relation */
+
+/* -1 */
+/* SIGMA ( SIGMA(I) ) = I */
+
+/* We'll use this method. In our case, our order vector plays */
+/* the role of */
+
+/* -1 */
+/* SIGMA */
+
+/* and the `inverse order vector' plays the role of SIGMA. We'll */
+/* exclude the first directory from the order vector, since it's */
+/* an exception: we wish to reserve this record. Since the first */
+/* element of the order vector (logically) contains the index 1, we */
+/* can ignore it. */
+
+
+ i__1 = total;
+ for (i__ = 2; i__ <= i__1; ++i__) {
+ i__2 = (i__ << 1) - 1;
+ i__3 = (i__ << 1) - 1;
+ dasrdi_(&scrhan, &i__2, &i__3, &type__);
+ i__2 = i__ << 1;
+ i__3 = i__ << 1;
+ dasrdi_(&scrhan, &i__2, &i__3, &dest);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+
+/* Set DEST to the destination location, measured as an offset */
+/* from the last comment record, of the Ith record by adding */
+/* on the count of the predecessors of the block of records of */
+/* TYPE. */
+
+ for (j = 1; j <= 3; ++j) {
+ if (type__ > j) {
+ dest += count[(i__2 = j - 1) < 4 && 0 <= i__2 ? i__2 : s_rnge(
+ "count", i__2, "dassdr_", (ftnlen)648)];
+ }
+ }
+
+/* The destination offset of each record should be incremented to */
+/* allow room for the first directory record. However, we don't */
+/* need to do this for directory records; they'll already have */
+/* this offset accounted for. */
+
+ if (type__ != 4) {
+ ++dest;
+ }
+
+/* The value of element DEST of the order vector is I. */
+/* Write this value to location BASE + DEST. */
+
+ i__2 = base + dest;
+ i__3 = base + dest;
+ dasudi_(&scrhan, &i__2, &i__3, &i__);
+
+/* We want the ith element of the order vector to give us the */
+/* number of the record to move to position i (offset from the */
+/* last comment record), but we want the corresponding element */
+/* of the type array to give us the type of the record currently */
+/* occupying position i. */
+
+ i__2 = base + i__ + total;
+ i__3 = base + i__ + total;
+ dasudi_(&scrhan, &i__2, &i__3, &type__);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* Ok, here's what we've got in the scratch file that's still of */
+/* interest: */
+
+/* -- In integer logical addresses BASE + 1 : BASE + TOTAL, */
+/* we have an order vector. The Ith element of this */
+/* vector indicates the record that should be moved to */
+/* location DRBASE + I in the DAS file we're re-ordering, */
+/* where DRBASE is the base address of the data records */
+/* (the first directory record follows the record having this */
+/* index). */
+
+
+/* -- In integer logical addresses BASE + TOTAL + 1 : BASE + */
+/* 2*TOTAL, we have data type indicators for the records to */
+/* be re-ordered. The type for the Ith record in the file, */
+/* counted from the last comment record, is located in logical */
+/* address BASE + TOTAL + I. */
+
+
+ drbase = nresvr + ncomr + 1;
+
+/* As we traverse the order vector, we flip the sign of elements */
+/* we've accessed, so that we can tell when we encounter an element */
+/* of a cycle that we've already traversed. */
+
+/* Traverse the order vector. The variable START indicates the */
+/* first element to look at. Ignore the first element; it's a */
+/* singleton cycle. */
+
+
+ start = 2;
+ while(start < total) {
+
+/* Traverse the current cycle of the order vector. */
+
+/* We `make a hole' in the file by saving the record in position */
+/* START, then we traverse the cycle in reverse order, filling in */
+/* the hole at the ith position with the record whose number is */
+/* the ith element of the order vector. At the end, we deposit */
+/* the saved record into the `hole' left behind by the last */
+/* record we moved. */
+
+/* We're going to read and write records to and from the DAS file */
+/* directly, rather than going through the buffering system. */
+/* This will allow us to avoid any untoward interactions between */
+/* the buffers for different data types. */
+
+ i__1 = base + total + start;
+ i__2 = base + total + start;
+ dasrdi_(&scrhan, &i__1, &i__2, &savtyp);
+ i__1 = base + start;
+ i__2 = base + start;
+ dasrdi_(&scrhan, &i__1, &i__2, &offset);
+
+/* Save the record at the location DRBASE + START. */
+
+ if (savtyp == 1) {
+ i__1 = drbase + start;
+ dasioc_("READ", &unit, &i__1, savec, (ftnlen)4, (ftnlen)1024);
+ } else if (savtyp == 2) {
+ i__1 = drbase + start;
+ dasiod_("READ", &unit, &i__1, saved, (ftnlen)4);
+ } else {
+ i__1 = drbase + start;
+ dasioi_("READ", &unit, &i__1, savei, (ftnlen)4);
+ }
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+
+/* Let I be the index of the record that we are going to move */
+/* data into next. I is an offset from the last comment record. */
+
+ i__ = start;
+ while(offset != start) {
+
+/* Mark the order vector element by writing its negative */
+/* back to the location it came from. */
+
+ i__1 = base + i__;
+ i__2 = base + i__;
+ i__3 = -offset;
+ dasudi_(&scrhan, &i__1, &i__2, &i__3);
+
+/* Move the record at location */
+
+/* DRBASE + OFFSET */
+
+/* to location */
+
+/* DRBASE + I */
+
+/* There is no need to do anything about the corresponding */
+/* elements of the type vector; we won't need them again. */
+
+/* The read and write operations, as well as the temporary */
+/* record required to perform the move, are dependent on the */
+/* data type of the record to be moved. */
+
+ i__1 = base + total + offset;
+ i__2 = base + total + offset;
+ dasrdi_(&scrhan, &i__1, &i__2, &type__);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+
+/* Only pick records up if we're going to put them down in */
+/* a location other than their original one. */
+
+ if (i__ != offset) {
+ if (type__ == 1) {
+ i__1 = drbase + offset;
+ dasioc_("READ", &unit, &i__1, crec, (ftnlen)4, (ftnlen)
+ 1024);
+ i__1 = drbase + i__;
+ dasioc_("WRITE", &unit, &i__1, crec, (ftnlen)5, (ftnlen)
+ 1024);
+ } else if (type__ == 2) {
+ i__1 = drbase + offset;
+ dasiod_("READ", &unit, &i__1, drec, (ftnlen)4);
+ i__1 = drbase + i__;
+ dasiod_("WRITE", &unit, &i__1, drec, (ftnlen)5);
+ } else {
+ i__1 = drbase + offset;
+ dasioi_("READ", &unit, &i__1, irec, (ftnlen)4);
+ i__1 = drbase + i__;
+ dasioi_("WRITE", &unit, &i__1, irec, (ftnlen)5);
+ }
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* OFFSET is the index of the next order vector element to */
+/* look at. */
+
+ i__ = offset;
+ i__1 = base + i__;
+ i__2 = base + i__;
+ dasrdi_(&scrhan, &i__1, &i__2, &offset);
+ i__1 = base + i__ + total;
+ i__2 = base + i__ + total;
+ dasrdi_(&scrhan, &i__1, &i__2, &type__);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* The last value of I is the location in the cycle that element */
+/* START followed. Therefore, the saved record corresponding */
+/* to index START should be written to this location. */
+
+ if (savtyp == 1) {
+ i__1 = drbase + i__;
+ dasioc_("WRITE", &unit, &i__1, savec, (ftnlen)5, (ftnlen)1024);
+ } else if (savtyp == 2) {
+ i__1 = drbase + i__;
+ dasiod_("WRITE", &unit, &i__1, saved, (ftnlen)5);
+ } else {
+ i__1 = drbase + i__;
+ dasioi_("WRITE", &unit, &i__1, savei, (ftnlen)5);
+ }
+
+/* Mark the order vector element by writing its negative */
+/* back to the location it came from. */
+
+ i__1 = base + i__;
+ i__2 = base + i__;
+ i__3 = -start;
+ dasudi_(&scrhan, &i__1, &i__2, &i__3);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+
+/* Update START so that it points to the first element of a cycle */
+/* of the order vector that has not yet been traversed. This will */
+/* be the first positive element of the order vector in a location */
+/* indexed higher than the current value of START. Note that */
+/* this way of updating START guarantees that we don't have to */
+/* backtrack to find an element in the next cycle. */
+
+ offset = -1;
+ while(offset < 0 && start < total) {
+ ++start;
+ i__1 = base + start;
+ i__2 = base + start;
+ dasrdi_(&scrhan, &i__1, &i__2, &offset);
+ if (failed_()) {
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+ }
+ }
+
+/* At this point, START is the index of an element in the order */
+/* vector that belongs to a cycle where no routine has gone */
+/* before, or else START is the last index in the order vector, */
+/* in which case we're done. */
+
+ }
+
+/* At this point, the records in the DAS are organized as follows: */
+
+/* +----------------------------------+ */
+/* | File record | ( 1 ) */
+/* +----------------------------------+ */
+/* | Reserved records | ( 0 or more ) */
+/* | | */
+/* +----------------------------------+ */
+/* | Comment records | ( 0 or more ) */
+/* | | */
+/* | | */
+/* +----------------------------------+ */
+/* | First directory record | ( 1 ) */
+/* +----------------------------------+ */
+/* | Character data records | ( 0 or more ) */
+/* | | */
+/* +----------------------------------+ */
+/* | Double precision data records | ( 0 or more ) */
+/* | | */
+/* +----------------------------------+ */
+/* | Integer data records | ( 0 or more ) */
+/* | | */
+/* +----------------------------------+ */
+/* | Additional directory records | ( 0 or more ) */
+/* | | */
+/* +----------------------------------+ */
+
+
+/* Not all of the indicated components must be present; only the */
+/* file record and first directory record will exist in all cases. */
+/* The `additional directory records' at the end of the file serve */
+/* no purpose; if more data is appended to the file, they will be */
+/* overwritten. */
+
+/* The last step in preparing the file is to fill in the first */
+/* directory record with the correct information, and to update */
+/* the file summary. */
+
+
+ recno = drbase + 1;
+ cleari_(&c__256, irec);
+
+/* Set the logical address ranges in the directory record, for each */
+/* data type. */
+
+ for (type__ = 1; type__ <= 3; ++type__) {
+ maxadr = lastla[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastla", i__1, "dassdr_", (ftnlen)957)];
+ if (maxadr > 0) {
+ minadr = 1;
+ } else {
+ minadr = 0;
+ }
+ irec[(i__1 = type__ << 1) < 256 && 0 <= i__1 ? i__1 : s_rnge("irec",
+ i__1, "dassdr_", (ftnlen)965)] = minadr;
+ irec[(i__1 = (type__ << 1) + 1) < 256 && 0 <= i__1 ? i__1 : s_rnge(
+ "irec", i__1, "dassdr_", (ftnlen)966)] = maxadr;
+ }
+
+/* Set the descriptors in the directory. Determine which type */
+/* comes first: the order of priority is character, double */
+/* precision, integer. */
+
+ pos = 9;
+ for (type__ = 1; type__ <= 3; ++type__) {
+ if (lastla[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("las"
+ "tla", i__1, "dassdr_", (ftnlen)979)] > 0) {
+ if (pos == 9) {
+
+/* This is the first type for which any data is present. */
+/* We must enter a type code at position BEGDSC in the */
+/* directory, and we must enter a count at position */
+/* BEGDSC+1. */
+
+ irec[8] = type__;
+ irec[9] = count[(i__1 = type__ - 1) < 4 && 0 <= i__1 ? i__1 :
+ s_rnge("count", i__1, "dassdr_", (ftnlen)989)];
+ lastrc[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastrc", i__1, "dassdr_", (ftnlen)990)] = recno;
+ lastwd[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastwd", i__1, "dassdr_", (ftnlen)991)] = 10;
+ pos += 2;
+ prvtyp = type__;
+ } else {
+
+/* Place an appropriately signed count at location POS in */
+/* the directory. */
+
+ if (type__ == next[(i__1 = prvtyp - 1) < 3 && 0 <= i__1 ?
+ i__1 : s_rnge("next", i__1, "dassdr_", (ftnlen)1000)])
+ {
+ irec[(i__1 = pos - 1) < 256 && 0 <= i__1 ? i__1 : s_rnge(
+ "irec", i__1, "dassdr_", (ftnlen)1001)] = count[(
+ i__2 = type__ - 1) < 4 && 0 <= i__2 ? i__2 :
+ s_rnge("count", i__2, "dassdr_", (ftnlen)1001)];
+ } else {
+ irec[(i__1 = pos - 1) < 256 && 0 <= i__1 ? i__1 : s_rnge(
+ "irec", i__1, "dassdr_", (ftnlen)1003)] = -count[(
+ i__2 = type__ - 1) < 4 && 0 <= i__2 ? i__2 :
+ s_rnge("count", i__2, "dassdr_", (ftnlen)1003)];
+ }
+ lastrc[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastrc", i__1, "dassdr_", (ftnlen)1006)] = recno;
+ lastwd[(i__1 = type__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge(
+ "lastwd", i__1, "dassdr_", (ftnlen)1007)] = pos;
+ ++pos;
+ prvtyp = type__;
+ }
+ }
+ }
+
+/* Since we've done away with all but the first directory, the first */
+/* free record is decremented by 1 less than the directory count. */
+
+ free = free - count[3] + 1;
+
+/* Write out the new directory record. Don't use the DAS buffered */
+/* write mechanism; this could trash the file by dumping buffered */
+/* records in the wrong places. */
+
+ dasioi_("WRITE", &unit, &recno, irec, (ftnlen)5);
+
+/* Write out the updated file summary. */
+
+ dasufs_(handle, &nresvr, &nresvc, &ncomr, &ncomc, &free, lastla, lastrc,
+ lastwd);
+
+/* Clean up the DAS data buffers: we don't want buffered scratch */
+/* file records hanging around there. Then get rid of the scratch */
+/* file. */
+
+ daswbr_(&scrhan);
+ dasllc_(&scrhan);
+ chkout_("DASSDR", (ftnlen)6);
+ return 0;
+} /* dassdr_ */
+
diff --git a/ext/spice/src/cspice/dastb.c b/ext/spice/src/cspice/dastb.c
new file mode 100644
index 0000000000..067669a31f
--- /dev/null
+++ b/ext/spice/src/cspice/dastb.c
@@ -0,0 +1,2249 @@
+/* dastb.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__9 = 9;
+static integer c__1 = 1;
+static integer c__0 = 0;
+static integer c__4 = 4;
+
+/* $Procedure DASTB ( DAS, convert transfer file to binary file ) */
+/* Subroutine */ int dastb_(integer *xfrlun, char *binfil, ftnlen binfil_len)
+{
+ /* System generated locals */
+ cilist ci__1;
+
+ /* Builtin functions */
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen),
+ e_rsle(void), s_cmp(char *, char *, ftnlen, ftnlen), s_rsfe(
+ cilist *), do_fio(integer *, char *, ftnlen), e_rsfe(void);
+
+ /* Local variables */
+ char line[255];
+ logical more;
+ char word[255], rest[255];
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer ncomc;
+ logical inblk;
+ char tarch[8];
+ extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
+ integer recno, ncomr;
+ char ttype[8];
+ extern /* Subroutine */ int idw2at_(char *, char *, char *, ftnlen,
+ ftnlen, ftnlen), dasadc_(integer *, integer *, integer *, integer
+ *, char *, ftnlen), dasadd_(integer *, integer *, doublereal *);
+ extern logical failed_(void);
+ extern /* Subroutine */ int dasadi_(integer *, integer *, integer *);
+ integer ncdata, handle, nddata;
+ extern /* Subroutine */ int dasacr_(integer *, integer *);
+ char ifname[60];
+ integer nidata;
+ extern /* Subroutine */ int rdencc_(integer *, integer *, char *, ftnlen);
+ char crecrd[1024];
+ extern /* Subroutine */ int rdenci_(integer *, integer *, integer *),
+ dasioc_(char *, integer *, integer *, char *, ftnlen, ftnlen);
+ char cbuffr[4*1024];
+ doublereal dbuffr[1024];
+ integer bindex, blkcnt, dtacnt, eindex, ibuffr[1024], daslun;
+ char idword[8];
+ integer bcount, numblk, numdta, ecount;
+ extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen);
+ char errmsg[320];
+ integer nresvc;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int setmsg_(char *, ftnlen);
+ integer numlft;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen), chkout_(
+ char *, ftnlen), dasonw_(char *, char *, char *, integer *,
+ integer *, ftnlen, ftnlen, ftnlen), daswfr_(integer *, char *,
+ char *, integer *, integer *, integer *, integer *, ftnlen,
+ ftnlen), dascls_(integer *), dashlu_(integer *, integer *);
+ integer tcount;
+ extern /* Subroutine */ int nextwd_(char *, char *, char *, ftnlen,
+ ftnlen, ftnlen);
+ extern logical return_(void);
+ integer errptr, nresvr;
+ extern /* Subroutine */ int nparsi_(char *, integer *, char *, integer *,
+ ftnlen, ftnlen), rdencd_(integer *, integer *, doublereal *);
+
+ /* Fortran I/O blocks */
+ static cilist io___3 = { 1, 0, 1, 0, 0 };
+ static cilist io___7 = { 1, 0, 1, 0, 0 };
+
+
+/* $ Abstract */
+
+/* Convert the contents of a DAS transfer file into an equivalent */
+/* binary DAS file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* CONVERSION */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* XFRLUN I Logical unit of an open DAS transfer file. */
+/* BINFIL I Name of the binary DAS file to be created. */
+
+/* $ Detailed_Input */
+
+/* XFRLUN The Fortran logical unit number of a previously opened */
+/* DAS transfer file. */
+
+/* The file pointer should be positioned ready to read */
+/* the DAS file ID word. */
+
+/* BINFIL The name of the binary DAS file to be created. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* See arguments XFRLUN, BINFIL. */
+
+/* $ Exceptions */
+
+/* 1) If the DAS transfer file cannot be read, the error */
+/* SPICE(FILEREADFAILED) will be signalled. */
+
+/* 2) If the specified file is not a DAS file, as indicated by the */
+/* file's ID word, the error SPICE(NOTADASFILE) is signalled. */
+
+/* 3) If an error occurs while attempting to decode data in the */
+/* DAS transfer file, the error SPICE(BADDASTRANSFERFILE) will */
+/* be signalled. */
+
+/* 4) If the DAS file cannot be written, a DAS file access routine */
+/* will signal an error with an appropriate error message. */
+
+/* 5) The binary DAS file opened by this routine, BINFIL, is only */
+/* GUARANTEED to be closed upon successful completion of the */
+/* text to binary conversion process. In the event of an error, */
+/* the caller of this routine is required to close the binary */
+/* DAS file BINFIL. */
+
+/* $ Particulars */
+
+/* Any binary DAS file may be transferred between heterogeneous */
+/* Fortran environments by converting it to an equivalent file */
+/* containing only ASCII characters called a DAS transfer file. */
+/* Such a file can be transferred almost universally using any number */
+/* of established protocols. Once transferred, the DAS transfer file */
+/* can be converted to a binary file using the representations native */
+/* to the new host environment. */
+
+/* This routine provides a mechanism for converting a DAS */
+/* transfer file created by DASBT, or an equivalent procedure, */
+/* into an equivalent binary DAS file which may be used with the */
+/* SPICE system. It is one of a pair of routines for performing */
+/* conversions between the binary format of a DAS file and the DAS */
+/* transfer file. The inverse of this routine is the routine DASTB. */
+
+/* Upon successful completion, the binary DAS file specified by */
+/* BINFIL will have been created. The binary DAS file that was */
+/* created will be closed when this routine exits. The DAS transfer */
+/* file will remain open, as it was on entry, and it will be */
+/* positioned to read the first line after the encoded DAS file data. */
+
+/* $ Examples */
+
+/* Let */
+
+/* XFRLUN be the Fortran logical unit attached to a DAS transfer */
+/* file which is to be converted into its binary DAS */
+/* equivalent. */
+
+/* BINFIL be the name of the binary DAS file which will be */
+/* created. */
+
+/* Then, the following subroutine call would read the DAS transfer */
+/* file attached to the Fortran logical unit XFRLUN, convert its data */
+/* into binary format, and write that data to the binary DAS file */
+/* which is being created: */
+
+/* CALL DASTB( XFRLUN, BINFIL ) */
+
+/* $ Restrictions */
+
+/* 1) This routine assumes that it is positioned ready to read the */
+/* DAS file ID word from the encoded text DAS file. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.1.0, 06-DEC-1995 (KRG) */
+
+/* Updated the call to DASONW; a new argument was added to the */
+/* call for reserving comment records. */
+
+/* - SPICELIB Version 3.0.0, 13-AUG-1994 (KRG) */
+
+/* Updated the header and in line comments to reflect the change */
+/* from calling files text files to calling them transfer files. */
+
+/* Changed the variable name XFRLUN to XFRLUN to make it */
+/* compatible with the change in terminology. */
+
+/* Changed the short error message "BADDASTEXTFILE" to the */
+/* message "BADDASTRANSFERFILE". */
+
+/* - SPICELIB Version 2.0.0, 27-OCT-1993 (KRG) */
+
+/* Updated the routine to use the new format ID words which */
+/* contain type as well as architecture information. */
+/* C */
+/* Fixed a typo in the description of the DAS encoded text file: */
+/* ncomc appeared where nresvc should have been. */
+
+/* - SPICELIB Version 1.0.0, 02-NOV-1992 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* convert das transfer file to binary das */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 3.1.0, 06-DEC-1995 (KRG) */
+
+/* Updated the call to DASONW; a new argument was added to the */
+/* call for reserving comment records. The value used here is */
+/* zero (0). */
+
+/* - SPICELIB Version 3.0.0, 13-AUG-1994 (KRG) */
+
+/* Updated the header and in line comments to reflect the change */
+/* from calling files text files to calling them transfer files. */
+
+/* Changed the variable name XFRLUN to XFRLUN to make it */
+/* compatible with the change in terminology. */
+
+/* Changed the short error message "BADDASTEXTFILE" to the */
+/* message "BADDASTRANSFERFILE". */
+
+/* - SPICELIB Version 2.0.0, 27-OCT-1993 (KRG) */
+
+/* Updated the routine to use the new format ID words which */
+/* contain type as well as architecture information. */
+
+/* Changed the wording of exception '2)' so that it would make */
+/* sense with the ID word format change that was made. */
+
+/* Changed the error */
+
+/* SPICE(DASIDWORDNOTKNOWN) */
+
+/* to */
+
+/* SPICE(NOTADASFILE) */
+
+/* Added variables to support the file architecture and type */
+/* stored in the ID word. These are used in order to verify that */
+/* the text file that is to be converted is indeed a DAS file. */
+/* This test is performed instead of testing whether the ID word */
+/* is equal to 'NAIF/DAS'. */
+
+/* Modified the long error message that was set to conform to the */
+/* ID word change. */
+
+/* Changed the DASOPN call to DASONW to support the addition of */
+/* type information to the ID word. */
+
+/* Fixed a typo in the description of the DAS encoded text file: */
+/* ncomc appeared where nresvc should have been. */
+
+/* - SPICELIB Version 1.0.0, 02-NOV-1992 (KRG) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local Parameters */
+
+/* CHARACTER*(*) BEGRES */
+/* PARAMETER ( BEGRES = 'BEGIN_RESERVED_BLOCK' ) */
+
+/* CHARACTER*(*) ENDRES */
+/* PARAMETER ( ENDRES = 'END_RESERVED_BLOCK' ) */
+
+/* CHARACTER*(*) TRRBLK */
+/* PARAMETER ( TRRBLK = 'TOTAL_RESERVED_BLOCKS' ) */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASTB", (ftnlen)5);
+ }
+
+/* A DAS transfer file contains in an encoded form all of the data */
+/* from the original binary DAS file. This includes the reserved */
+/* record area, the comment area, and the character, double */
+/* precision, and integer data arrays as well. */
+
+/* Currently, the reserved record area has not been implemented, as */
+/* there is no need for it at this time. If, or when, the reserved */
+/* record area is implemented, this routine will need to be modified */
+/* in order to support it. See the code for details. */
+
+/* The data in the DAS transfer file are available as sequences of */
+/* small blocks of data. This is to provide a means for performing */
+/* some error detection when converting a DAS transfer file into its */
+/* binary equivalent. Each block of data is enclosed within begin and */
+/* end block markers which hold the count of data items in a data */
+/* block. When all of the data blocks for a data area have been */
+/* written, a total blocks line is read to verify that all of the */
+/* data has been converted. */
+
+/* The data in the DAS transfer file MUST appear in the following */
+/* order for this routine to work properly. */
+
+/* 1) Reserved records (when/if implemented) */
+/* 2) Comment area */
+/* 3) Character data array */
+/* 4) Double precision data array */
+/* 5) Integer data array */
+
+/* If the data count for any of these DAS data areas is zero, */
+/* conversion proceeds with the next DAS data area in the list. */
+
+/* For example, suppose that we have a binary DAS file where there */
+/* are 0 reserved characters in the reserved record area, 5000 */
+/* comment characters in the comment area, and that the character, */
+/* double precision, and integer array counts are 0, 2300, and */
+/* 6900, respectively. Then, the DAS encoded text file will contain */
+/* no reserved record data blocks, 2 comment data blocks, no */
+/* character data blocks, 3 double precision data blocks, and 7 */
+/* integer data blocks, in that order. */
+
+/* DAS encoded text file description. */
+/* ---------------------------------- */
+
+
+/* A brief description of the DAS encoded file format and its */
+/* intended use follows. This description is intended to provide a */
+/* simple ``picture'' of the DAS transfer file format to aid in the */
+/* understanding of this routine. This description is NOT intended to */
+/* be a detailed specification of the file format. */
+
+/* A DAS transfer file contains all of the data from a binary */
+/* DAS file in an encoded ASCII format. It also contains some */
+/* bookkeeping information for maintaining the integrity of the */
+/* data. The DAS transfer file format allows the full precision of */
+/* character, integer, and floating point numeric data to be */
+/* maintained in a portable fashion. The DAS transfer file format is */
+/* intended to provide a reliable and accurate means for porting data */
+/* among multiple computer systems and for the archival storage of */
+/* data. */
+
+/* A DAS transfer file is not intended to be used directly to provide */
+/* data to a program. The equivalent binary DAS file is to be used */
+/* for this purpose. In no way should any program, other than a DAS */
+/* binary <-> transfer conversion program, rely on the DAS transfer */
+/* file format. */
+
+/* To correctly understand the DAS transfer file description the */
+/* reader should be familiar with the DAS file architecture. Items */
+/* enclosed in angle brackets, '<' and '>', are used to represent the */
+/* data which are to be placed at that position in the file. The */
+/* bookkeeping information which appears is represented exactly as it */
+/* would appear in a DAS transfer file. */
+
+/* Let */
+
+/* denote the beginning of the file */
+/* denote the end of the file */
+
+/* and */
+
+/* nresvb denote the number of encoded reserved record data */
+/* blocks generated */
+/* nresvc denote the total number of reserved record characters */
+/* in the reserved record area of a DAS file */
+/* ncomb denote the number of encoded comment data blocks */
+/* generated */
+/* ncomc denote the total number of comment characters in the */
+/* comment area of a DAS file */
+/* nchrb denote the number of encoded character data blocks */
+/* generated */
+/* nchrs denote the count of characters in the DAS character */
+/* data array */
+/* ndpb denote the number of encoded double precision data */
+/* blocks generated */
+/* ndps denote the count of double precision numbers in the DAS */
+/* double precision data array */
+/* nintb denote the number of encoded integer data blocks */
+/* generated */
+/* nints denote the count of integers in the DAS integer data */
+/* array */
+
+/* A DAS encoded transfer file has the following format: */
+
+/* */
+/* < Information line > */
+/* < DAS file ID word > */
+/* < Internal filename > */
+/* < Encoded count of reserved records > */
+/* < Encoded count of reserved characters > */
+/* < Encoded count of comment records > */
+/* < Encoded count of comment characters > */
+/* < Blocks of encoded reserved record data, if nresvc > 0 > */
+/* TOTAL_RESERVED_BLOCKS nresvb nresvc */
+/* < Blocks of encoded comment data, if ncomc > 0 > */
+/* TOTAL_COMMENT_BLOCKS ncomb ncomc */
+/* < Encoded count of character data > */
+/* < Encoded count of double precision data > */
+/* < Encoded count of integer data > */
+/* < Blocks of encoded character data, if nchrs > 0 > */
+/* TOTAL_CHARACTER_BLOCKS nchrb nchrs */
+/* < Blocks of encoded double precision data, if ndps > 0 > */
+/* TOTAL_DP_BLOCKS ndpb ndps */
+/* < Blocks of encoded integer data, if nints > 0 > */
+/* TOTAL_INTEGER_BLOCKS nintb nints */
+/* */
+
+/* This routine will check the SPICELIB function FAILED() after */
+/* each call, or consecutive sequence of calls, to data encoding */
+/* routines, and if an error was signalled it will simply check out */
+/* and return to the caller. */
+
+/* This routine will check the SPICELIB function FAILED() after */
+/* each DAS file access call, and if an error was signalled it will */
+/* simply check out and return to the caller. */
+
+/* We begin by reading the DAS file ID word from the DAS transfer */
+/* file. We should have been positioned ready to read this. If an */
+/* error occurs, set an appropriate error message and signal the */
+/* error. */
+
+ s_copy(idword, " ", (ftnlen)8, (ftnlen)1);
+ io___3.ciunit = *xfrlun;
+ iostat = s_rsle(&io___3);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_lio(&c__9, &c__1, idword, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rsle();
+L100001:
+ if (iostat != 0) {
+ setmsg_("Error reading the file ID word from the DAS transfer file: "
+ "#. IOSTAT = #.", (ftnlen)73);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check the DAS ID word. When checking the ID word all we care about */
+/* is that we are attempting to convert a DAS file. So, split the */
+/* ID word into its architecture and type and check the architecture. */
+
+ idw2at_(idword, tarch, ttype, (ftnlen)8, (ftnlen)8, (ftnlen)8);
+ if (s_cmp(tarch, "DAS", (ftnlen)8, (ftnlen)3) != 0) {
+ setmsg_("File architecture was not 'DAS' for file #.", (ftnlen)43);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(NOTADASFILE)", (ftnlen)18);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Read the internal filename for the DAS file. */
+
+ s_copy(ifname, " ", (ftnlen)60, (ftnlen)1);
+ io___7.ciunit = *xfrlun;
+ iostat = s_rsle(&io___7);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_lio(&c__9, &c__1, ifname, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_rsle();
+L100002:
+ if (iostat != 0) {
+ setmsg_("Error reading the internal filename from the DAS transfer f"
+ "ile: #. IOSTAT = #.", (ftnlen)78);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Open a new binary DAS file and write its file record. */
+
+ dasonw_(binfil, ttype, ifname, &c__0, &handle, binfil_len, (ftnlen)8, (
+ ftnlen)60);
+ if (failed_()) {
+
+/* If an error occurred while opening the new DAS file, */
+/* then check out and return. */
+
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Write the initial file record to the newly opened DAS file. This */
+/* call will overwrite the ID word set when we opened the file with */
+/* the ID word from the DAS transfer file. We got to this point, so */
+/* we know that the ID word was a good one. */
+
+ ncomr = 0;
+ ncomc = 0;
+ nresvr = 0;
+ nresvc = 0;
+ daswfr_(&handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (
+ ftnlen)8, (ftnlen)60);
+ if (failed_()) {
+
+/* If an error occurred while writing the DAS file record, */
+/* attempt to close the binary file, then check out and return. */
+
+ dascls_(&handle);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Read and decode the number of reserved records and reserved */
+/* characters. */
+
+ rdenci_(xfrlun, &c__1, &nresvr);
+ rdenci_(xfrlun, &c__1, &nresvc);
+ if (failed_()) {
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to be sure that the number of reserved records and the */
+/* number of reserved characters are not being used. The DAS */
+/* reserved record area is not currently implemented, so nobody */
+/* should be using it. */
+
+ if (nresvc != 0) {
+
+/* Close the file, signal the error, and exit. */
+
+ dascls_(&handle);
+ setmsg_("The number of reserved characters was nonzero (#) in file: "
+ "#, but the DAS reserved record area has NOT been implemented"
+ " yet!", (ftnlen)124);
+ errint_("#", &nresvc, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASFILE)", (ftnlen)17);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+ if (nresvr != 0) {
+
+/* Close the file, signal the error, and exit. */
+
+ dascls_(&handle);
+ setmsg_("The number of reserved records was nonzero (#) in file: #, "
+ "but the DAS reserved record area has NOT been implemented ye"
+ "t!", (ftnlen)121);
+ errint_("#", &nresvr, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASFILE)", (ftnlen)17);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Read and decode the number of comment records and comment */
+/* characters. */
+
+ rdenci_(xfrlun, &c__1, &ncomr);
+ rdenci_(xfrlun, &c__1, &ncomc);
+ if (failed_()) {
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Begin converting the DAS transfer file into an equivalent */
+/* binary DAS file here. */
+
+/* The reserved records, if there are any. */
+
+/* ************************************************************** */
+/* When/if the reserved record area is implemented, the code to */
+/* read it from the DAS transfer file and convert it to binary */
+/* should go here. It should be possible to simply copy the code */
+/* for the comment area, making all of the necessary variable */
+/* name changes, etc., since the reserved record area is going */
+/* to contain ONLY character data. */
+/* ************************************************************** */
+
+
+/* The comments, if there are any. */
+
+ if (ncomc > 0) {
+
+/* We assume that the condition NCOMC > 0 and NCOMR <= 0 */
+/* cannot occur. */
+
+/* The binary DAS file that we are creating is already open, */
+/* so just add the comments. But first, convert the DAS file */
+/* handle into its equivalent logical unit. */
+
+ dashlu_(&handle, &daslun);
+ if (failed_()) {
+
+/* If an error occurred, attempt to close the binary file, */
+/* then check out and return. */
+
+ dascls_(&handle);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Allocate the necessary comment records. */
+
+ dasacr_(&handle, &ncomr);
+ if (failed_()) {
+
+/* If an error occurred, attempt to close the binary file, */
+/* then checkout and return. */
+
+ dascls_(&handle);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Initialize a few things: the block counter, the data */
+/* counter, and the starting record position. The starting */
+/* record position is one short of the actual first comment */
+/* record. We will increment the record number before we */
+/* write anything. */
+
+ blkcnt = 0;
+ dtacnt = 0;
+ recno = nresvr + 1;
+
+/* We currently have more to process. */
+
+ more = TRUE_;
+
+/* We are currently not processing a comment block. */
+
+ inblk = FALSE_;
+ while(more) {
+ s_copy(crecrd, " ", (ftnlen)1024, (ftnlen)1);
+ ci__1.cierr = 1;
+ ci__1.ciend = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_rsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = do_fio(&c__1, line, (ftnlen)255);
+ if (iostat != 0) {
+ goto L100003;
+ }
+ iostat = e_rsfe();
+L100003:
+ if (iostat != 0) {
+
+/* If an error occurred while reading from the DAS transfer */
+/* file close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Error reading from the DAS transfer file #. IOSTAT "
+ "= #.", (ftnlen)55);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* At this point, we should be beginning a comment block, */
+/* ending a comment block, or scanning for the total number */
+/* of comment blocks. So look for the appropriate keyword. */
+
+ nextwd_(line, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)255);
+ if (s_cmp(word, "BEGIN_COMMENT_BLOCK", (ftnlen)255, (ftnlen)19) ==
+ 0) {
+
+/* Get the comment block index. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &bindex, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the begin block */
+/* index, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Begin comment block error, could not parse bloc"
+ "k number. Error: # File: #", (ftnlen)73);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the count of characters in the block. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &bcount, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the beginning */
+/* data count, close the binary file, set an */
+/* appropriate error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Begin comment block error, could not parse the "
+ "data count for block: #. Error: # File: #", (
+ ftnlen)88);
+ errint_("#", &bindex, (ftnlen)1);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we are inside a comment block, so set */
+/* the in block flag, INBLK, to .TRUE. and increment the */
+/* block counter. */
+
+ inblk = TRUE_;
+ ++blkcnt;
+ } else if (s_cmp(word, "END_COMMENT_BLOCK", (ftnlen)255, (ftnlen)
+ 17) == 0) {
+
+/* Get the data block index. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &eindex, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the end comment */
+/* block index, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("End comment block error, could not parse block "
+ "number. Error: # File: #", (ftnlen)71);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the count of characters in the DAS array. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &ecount, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the ending data */
+/* count, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("End comment block error, could not parse the da"
+ "ta count for block: #. Error: # File: #", (
+ ftnlen)87);
+ errint_("#", &eindex, (ftnlen)1);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the beginning and ending array indices */
+/* match. */
+
+ if (eindex != bindex) {
+
+/* If the begin and end data block indices do not match, */
+/* close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Comment block index mismatch: Beginning index: "
+ "#; Ending index: #. File: #", (ftnlen)74);
+ errint_("#", &bindex, (ftnlen)1);
+ errint_("#", &eindex, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the beginning and ending comment data */
+/* counts match. */
+
+ if (ecount != bcount) {
+
+/* If the begin and end data block counts do not match, */
+/* close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Comment block count mismatch: Beginning count: "
+ "#; Ending count: #. File: #", (ftnlen)74);
+ errint_("#", &bcount, (ftnlen)1);
+ errint_("#", &ecount, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we have successfully ended the */
+/* processing of a comment block, so set the in block */
+/* flag INBLK, to .FALSE.. */
+
+ inblk = FALSE_;
+ } else if (s_cmp(word, "TOTAL_COMMENT_BLOCKS", (ftnlen)255, (
+ ftnlen)20) == 0) {
+
+/* We have the total comment blocks keyword to parse, so */
+/* get the total number of comment blocks processed. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &numblk, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the total number of */
+/* data blocks, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Comment block count error, could not parse the "
+ "total number of character blocks: #. File: #", (
+ ftnlen)91);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the total count of comment characters. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &tcount, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the comment */
+/* data count, close the binary file, set an */
+/* appropriate error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Comment count error, could not parse the total "
+ "count. Error: # File: #", (ftnlen)70);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Compare the computed block count with the block count */
+/* from the file. */
+
+ if (blkcnt != numblk) {
+
+/* If the computed number of comment blocks and the */
+/* number of comment blocks from the text file do */
+/* not match, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("The number of comment data blocks processed (#)"
+ " was not equal to the number of comment data blo"
+ "cks placed in the DAS text file (#). File: #", (
+ ftnlen)139);
+ errint_("#", &blkcnt, (ftnlen)1);
+ errint_("#", &numblk, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the total count and the computed count */
+/* match. */
+
+ if (tcount != dtacnt) {
+
+/* If the total count and computed count do not match, */
+/* close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Comment count mismatch: computed count: #; expe"
+ "cted count: #. File: #", (ftnlen)69);
+ errint_("#", &dtacnt, (ftnlen)1);
+ errint_("#", &tcount, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we have successfully processed the */
+/* entire DAS comment area in the text file, so there is */
+/* no more comment data. */
+
+ more = FALSE_;
+ } else {
+
+/* We got an unknown keyword of some sort, so set an */
+/* appropriate error message, close the DAS file, and */
+/* return. */
+
+ dascls_(&handle);
+ setmsg_("Unknown keyword '#' encountered while processing th"
+ "e DAS transfer file #.", (ftnlen)73);
+ errch_("#", word, (ftnlen)1, (ftnlen)255);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we have begun a block, then process it. Otherwise, we */
+/* have ended a block. */
+
+ if (inblk) {
+
+/* Increment the record number by one for each comment */
+/* data block we process, because each block contains a */
+/* comment record. */
+
+ ++recno;
+
+/* Set the count of comment characters yet to be decoded and */
+/* placed in the binary DAS file. */
+
+ numlft = bcount;
+ while(numlft > 0) {
+
+/* Now read and decode the data in the current */
+/* comment data block, placing the data in the */
+/* comment area of the binary DAS file. */
+
+ if (numlft >= 1024) {
+ numdta = 1024;
+ } else {
+ numdta = numlft;
+ }
+
+/* Read and decode a record of encoded comment data */
+/* from the text file. */
+
+ rdencc_(xfrlun, &numdta, crecrd, (ftnlen)1024);
+
+/* Write the comment data to the comment area in the */
+/* binary DAS file. */
+
+ dasioc_("WRITE", &daslun, &recno, crecrd, (ftnlen)5, (
+ ftnlen)1024);
+ if (failed_()) {
+
+/* If an error occurred, attempt to close the */
+/* binary file, then checkout and return. */
+
+ dascls_(&handle);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Decrement the counter for the amount of data */
+/* remaining to be moved from the current comment */
+/* block, NUMLFT. */
+
+ numlft -= numdta;
+
+/* Increment the counter for the amount of data that */
+/* has been successfully moved into the comment area */
+/* of the binary DAS file. */
+
+ dtacnt += numdta;
+ }
+
+/* At this point, we have finished reading in an entire */
+/* comment block. */
+
+ }
+
+/* If we got to here, we have successfully written a comment */
+/* block to the binary file. */
+
+ }
+
+/* At this point, we will have successfully written the entire */
+/* comment area to the binary DAS file, if there was a comment */
+/* area. */
+
+/* Write the file record to the DAS file, to update the number */
+/* of comment characters. */
+
+ daswfr_(&handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (
+ ftnlen)8, (ftnlen)60);
+ }
+
+/* Read the data counts from the DAS transfer file. These will be */
+/* useful in determining which data types to expect in the text file */
+/* when converting back to binary. */
+
+ rdenci_(xfrlun, &c__1, &ncdata);
+ rdenci_(xfrlun, &c__1, &nddata);
+ rdenci_(xfrlun, &c__1, &nidata);
+
+/* Process the character data array, if there is some character data. */
+
+ if (ncdata > 0) {
+
+/* Initialize a few things: the block counter, and the data */
+/* counter. */
+
+ blkcnt = 0;
+ dtacnt = 0;
+
+/* We currently have more to process. */
+
+ more = TRUE_;
+
+/* We are currently not processing a data block. */
+
+ inblk = FALSE_;
+ while(more) {
+ ci__1.cierr = 1;
+ ci__1.ciend = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_rsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = do_fio(&c__1, line, (ftnlen)255);
+ if (iostat != 0) {
+ goto L100004;
+ }
+ iostat = e_rsfe();
+L100004:
+ if (iostat != 0) {
+
+/* If an error occurred while reading from the encoded text */
+/* DAS file close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Error reading from the DAS transferfile #. IOSTAT ="
+ " #.", (ftnlen)54);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* At this point, we should be beginning a data block, ending a */
+/* data block, or scanning for the total number of data blocks. */
+/* So look for the appropriate keyword. */
+
+ nextwd_(line, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)255);
+ if (s_cmp(word, "BEGIN_CHARACTER_BLOCK", (ftnlen)255, (ftnlen)21)
+ == 0) {
+
+/* Get the block number. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &bindex, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the begin block */
+/* index, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Begin character block error, could not parse bl"
+ "ock number. Error: # File: #", (ftnlen)75);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the count of characters in the block. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &bcount, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the beginning */
+/* data count, close the binary file, set an */
+/* appropriate error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Begin character block error, could not parse th"
+ "e data count for block: #. Error: # File: #", (
+ ftnlen)90);
+ errint_("#", &bindex, (ftnlen)1);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we are inside a data block, so set */
+/* the in block flag, INBLK, to .TRUE. and increment the */
+/* data block counter. */
+
+ inblk = TRUE_;
+ ++blkcnt;
+ } else if (s_cmp(word, "END_CHARACTER_BLOCK", (ftnlen)255, (
+ ftnlen)19) == 0) {
+
+/* Get the data block index. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &eindex, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the end block */
+/* index, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("End character block error, could not parse bloc"
+ "k number. Error: # File: #", (ftnlen)73);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the count of characters in the DAS array. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &ecount, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the ending data */
+/* count, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("End character block error, could not parse the "
+ "data count for block: #. Error: # File: #", (
+ ftnlen)88);
+ errint_("#", &eindex, (ftnlen)1);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the beginning and ending array indices */
+/* match. */
+
+ if (eindex != bindex) {
+
+/* If the begin and end data block indices do not match, */
+/* close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Character block index mismatch: Beginning index"
+ ": #; Ending index: #. File: #", (ftnlen)76);
+ errint_("#", &bindex, (ftnlen)1);
+ errint_("#", &eindex, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the beginning and ending array data */
+/* counts match. */
+
+ if (ecount != bcount) {
+
+/* If the begin and end data block counts do not match, */
+/* close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Character block count mismatch: Beginning count"
+ ": #; Ending count: #. File: #", (ftnlen)76);
+ errint_("#", &bcount, (ftnlen)1);
+ errint_("#", &ecount, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we have successfully ended the */
+/* processing of a data block, so set the in block flag, */
+/* INBLK, to .FALSE.. */
+
+ inblk = FALSE_;
+ } else if (s_cmp(word, "TOTAL_CHARACTER_BLOCKS", (ftnlen)255, (
+ ftnlen)22) == 0) {
+
+/* We have the total data blocks keyword to parse, so get */
+/* the total number of character data blocks processed. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &numblk, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the total number of */
+/* data blocks, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Block count error, could not parse the total nu"
+ "mber of character blocks: #. File: #", (ftnlen)83)
+ ;
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the total count of characters. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &tcount, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the character */
+/* data count, close the binary file, set an */
+/* appropriate error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Character count error, could not parse the tota"
+ "l count. Error: # File: #", (ftnlen)72);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Compare the computed block count with the block count */
+/* from the file. */
+
+ if (blkcnt != numblk) {
+
+/* If the calculated data block count and the data */
+/* block count from the text file do not match, close */
+/* the binary file, set an appropriate error message, */
+/* then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("The number of character data blocks processed ("
+ "#) was not equal to the number of character data"
+ " blocks placed in the DAS transfer file (#). Fil"
+ "e: #", (ftnlen)147);
+ errint_("#", &blkcnt, (ftnlen)1);
+ errint_("#", &numblk, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the total count and the computed count */
+/* match. */
+
+ if (tcount != dtacnt) {
+
+/* If the total count and computed count do not match, */
+/* close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Character count mismatch: computed count: #; ex"
+ "pected count: #. File: #", (ftnlen)71);
+ errint_("#", &dtacnt, (ftnlen)1);
+ errint_("#", &tcount, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we have successfully processed the */
+/* entire character data portion of the DAS transfer file, */
+/* so there is no more character data. */
+
+ more = FALSE_;
+ } else {
+
+/* We got an unknown keyword of some sort, so set an */
+/* appropriate error message, close the DAS file, and */
+/* return. */
+
+ dascls_(&handle);
+ setmsg_("Unknown keyword '#' encountered while processing th"
+ "e DAS trtansfer file #.", (ftnlen)74);
+ errch_("#", word, (ftnlen)1, (ftnlen)255);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we have begun a block, then process it. Otherwise, we */
+/* have ended a block. */
+
+ if (inblk) {
+
+/* Read and decode the data in the current DAS character */
+/* array data block. */
+
+/* Set the count of characters yet to be decoded and placed */
+/* in the binary DAS file. */
+
+ numlft = bcount;
+ while(numlft > 0) {
+
+/* Now read and decode the data in the current */
+/* character data block, placing the data in the */
+/* character array in the binary DAS file. */
+
+ if (numlft >= 4096) {
+ numdta = 4096;
+ } else {
+ numdta = numlft;
+ }
+
+/* Read and decode a buffer of encoded character data */
+/* from the text file. */
+
+ rdencc_(xfrlun, &numdta, cbuffr, (ftnlen)4);
+
+/* Write the character data to the DAS character */
+/* array in the binary DAS file. */
+
+ dasadc_(&handle, &numdta, &c__1, &c__4, cbuffr, (ftnlen)4)
+ ;
+ if (failed_()) {
+
+/* If an error occurred, attempt to close the */
+/* binary file, then checkout and return. */
+
+ dascls_(&handle);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Decrement the counter for the amount of data */
+/* remaining to be moved from the current data block, */
+/* NUMLFT. */
+
+ numlft -= numdta;
+
+/* Increment the counter for the amount of data that */
+/* has been successfully moved into the current array */
+/* in the binary DAS file. */
+
+ dtacnt += numdta;
+
+/* At this point, we have either finished reading in an */
+/* entire data block, or we have more data to read in */
+/* the current data block. */
+
+ }
+ }
+
+/* If we got to here, we have successfully written a data */
+/* block to the binary file. */
+
+ }
+
+/* At this point, we will have successfully written the entire */
+/* character data array to the binary DAS file, if there was */
+/* any character data to be written. */
+ }
+
+/* Process the double precision data array, if there is some */
+/* double precision data. */
+
+ if (nddata > 0) {
+
+/* Initialize a few things: the block counter, and the data */
+/* counter. */
+
+ blkcnt = 0;
+ dtacnt = 0;
+
+/* We currently have more to process. */
+
+ more = TRUE_;
+
+/* We are currently not processing a data block. */
+
+ inblk = FALSE_;
+ while(more) {
+ ci__1.cierr = 1;
+ ci__1.ciend = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_rsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = do_fio(&c__1, line, (ftnlen)255);
+ if (iostat != 0) {
+ goto L100005;
+ }
+ iostat = e_rsfe();
+L100005:
+ if (iostat != 0) {
+
+/* If an error occurred while reading from the encoded text */
+/* DAS file close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Error reading from the DAS transfer file #. IOSTAT "
+ "= #.", (ftnlen)55);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* At this point, we should be beginning a data block, ending a */
+/* data block, or scanning for the total number of data blocks. */
+/* So look for the appropriate keyword. */
+
+ nextwd_(line, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)255);
+ if (s_cmp(word, "BEGIN_DP_BLOCK", (ftnlen)255, (ftnlen)14) == 0) {
+
+/* Get the block number. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &bindex, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the begin block */
+/* index, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Begin double precision block error, could not p"
+ "arse block number. Error: # File: #", (ftnlen)82);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the count of double precision numbers in the block. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &bcount, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the beginning */
+/* data count, close the binary file, set an */
+/* appropriate error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Begin double precision block error, could not p"
+ "arse the data count for block: #. Error: # File:"
+ " #", (ftnlen)97);
+ errint_("#", &bindex, (ftnlen)1);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we are inside a data block, so set */
+/* the in block flag, INBLK, to .TRUE. and increment the */
+/* data block counter. */
+
+ inblk = TRUE_;
+ ++blkcnt;
+ } else if (s_cmp(word, "END_DP_BLOCK", (ftnlen)255, (ftnlen)12) ==
+ 0) {
+
+/* Get the data block index. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &eindex, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the end block */
+/* index, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("End double precision block error, could not par"
+ "se block number. Error: # File: #", (ftnlen)80);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the count of double precision numbers in the block. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &ecount, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the ending data */
+/* count, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("End double precision block error, could not par"
+ "se the data count for block: #. Error: # File: #",
+ (ftnlen)95);
+ errint_("#", &eindex, (ftnlen)1);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the beginning and ending array indices */
+/* match. */
+
+ if (eindex != bindex) {
+
+/* If the begin and end data block indices do not match, */
+/* close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Double precision block index mismatch: Beginnin"
+ "g index: #; Ending index: #. File: #", (ftnlen)83)
+ ;
+ errint_("#", &bindex, (ftnlen)1);
+ errint_("#", &eindex, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the beginning and ending array data */
+/* counts match. */
+
+ if (ecount != bcount) {
+
+/* If the begin and end data block counts do not match, */
+/* close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Double precision block count mismatch: Beginnin"
+ "g count: #; Ending count: #. File: #", (ftnlen)83)
+ ;
+ errint_("#", &bcount, (ftnlen)1);
+ errint_("#", &ecount, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we have successfully ended the */
+/* processing of a data block, so set the in block flag, */
+/* INBLK, to .FALSE.. */
+
+ inblk = FALSE_;
+ } else if (s_cmp(word, "TOTAL_DP_BLOCKS", (ftnlen)255, (ftnlen)15)
+ == 0) {
+
+/* We have the total data blocks keyword to parse, so get */
+/* the total number of character data blocks processed. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &numblk, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the total number of */
+/* data blocks, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Block count error, could not parse the total nu"
+ "mber of double precision data blocks: #. File: #",
+ (ftnlen)95);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the total count of double precision numbers. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &tcount, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the double */
+/* precision data count, close the binary file, set an */
+/* appropriate error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Double precision count error, could not parse t"
+ "he total count. Error: # File: #", (ftnlen)79);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Compare the computed block count with the block count */
+/* from the file. */
+
+ if (blkcnt != numblk) {
+
+/* If the calculated data block count and the data */
+/* block count from the text file do not match, close */
+/* the binary file, set an appropriate error message, */
+/* then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("The number of double precision data blocks proc"
+ "essed (#) was not equal to the number of double "
+ "precision data blocks placed in the DAS transfer"
+ " file (#). File: #", (ftnlen)161);
+ errint_("#", &blkcnt, (ftnlen)1);
+ errint_("#", &numblk, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the total count and the computed count */
+/* match. */
+
+ if (tcount != dtacnt) {
+
+/* If the total count and computed count do not match, */
+/* close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Double precision count mismatch: computed count"
+ ": #; expected count: #. File: #", (ftnlen)78);
+ errint_("#", &dtacnt, (ftnlen)1);
+ errint_("#", &tcount, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we have successfully processed the */
+/* entire DAS double precision data portion of the text */
+/* file, so there is no more double precision data. */
+
+ more = FALSE_;
+ } else {
+
+/* We got an unknown keyword of some sort, so set an */
+/* appropriate error message, close the DAS file, and */
+/* return. */
+
+ dascls_(&handle);
+ setmsg_("Unknown keyword '#' encountered while processing th"
+ "e DAS transfer file #.", (ftnlen)74);
+ errch_("#", word, (ftnlen)1, (ftnlen)255);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we have begun a block, then process it. Otherwise, we */
+/* have ended a block. */
+ if (inblk) {
+
+/* Read and decode the data in the current DAS double */
+/* precision array data block. */
+
+/* Set the count of double precision numbers yet to be */
+/* decoded and placed in the binary DAS file. */
+
+ numlft = bcount;
+ while(numlft > 0) {
+
+/* Now read and decode the data in the current double */
+/* precision data block, placing the data in the double */
+/* precision array in the binary DAS file. */
+
+ if (numlft >= 1024) {
+ numdta = 1024;
+ } else {
+ numdta = numlft;
+ }
+
+/* Read and decode a buffer of encoded double precision */
+/* data from the text file. */
+
+ rdencd_(xfrlun, &numdta, dbuffr);
+
+/* Write the double precision data to the DAS double */
+/* precision array in the binary DAS file. */
+
+ dasadd_(&handle, &numdta, dbuffr);
+ if (failed_()) {
+
+/* If an error occurred, attempt to close the */
+/* binary file, then checkout and return. */
+
+ dascls_(&handle);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Decrement the counter for the amount of data */
+/* remaining to be moved from the current data block, */
+/* NUMLFT. */
+
+ numlft -= numdta;
+
+/* Increment the counter for the amount of data that */
+/* has been successfully moved into the current array */
+/* in the binary DAS file. */
+
+ dtacnt += numdta;
+
+/* At this point, we have either finished reading in an */
+/* entire data block, or there is still some data */
+/* remaining to be read. */
+
+ }
+ }
+
+/* If we got to here, we have successfully written a data */
+/* block to the binary file. */
+
+ }
+
+/* At this point, we will have successfully written the entire */
+/* double precision data array to the binary DAS file, if there */
+/* was any double precision data to be written. */
+ }
+
+/* Process the integer data array, if there is some integer data. */
+
+ if (nidata > 0) {
+
+/* Initialize a few things: the block counter, and the data */
+/* counter. */
+
+ blkcnt = 0;
+ dtacnt = 0;
+
+/* We currently have more to process. */
+
+ more = TRUE_;
+
+/* We are currently not processing a data block. */
+
+ inblk = FALSE_;
+ while(more) {
+ ci__1.cierr = 1;
+ ci__1.ciend = 1;
+ ci__1.ciunit = *xfrlun;
+ ci__1.cifmt = "(A)";
+ iostat = s_rsfe(&ci__1);
+ if (iostat != 0) {
+ goto L100006;
+ }
+ iostat = do_fio(&c__1, line, (ftnlen)255);
+ if (iostat != 0) {
+ goto L100006;
+ }
+ iostat = e_rsfe();
+L100006:
+ if (iostat != 0) {
+
+/* If an error occurred while reading from the encoded text */
+/* DAS file close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Error reading from the DAS transfer file #. IOSTAT "
+ "= #.", (ftnlen)55);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* At this point, we should be beginning a data block, ending a */
+/* data block, or scanning for the total number of data blocks. */
+/* So look for the appropriate keyword. */
+
+ nextwd_(line, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)255);
+ if (s_cmp(word, "BEGIN_INTEGER_BLOCK", (ftnlen)255, (ftnlen)19) ==
+ 0) {
+
+/* Get the block number. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &bindex, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the begin block */
+/* index, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Begin integer block error, could not parse bloc"
+ "k number. Error: # File: #", (ftnlen)73);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the count of integers in the block. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &bcount, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the beginning */
+/* data count, close the binary file, set an */
+/* appropriate error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Begin integer block error, could not parse the "
+ "data count for block: #. Error: # File: #", (
+ ftnlen)89);
+ errint_("#", &bindex, (ftnlen)1);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we are inside a data block, so set */
+/* the in block flag, INBLK, to .TRUE. and increment the */
+/* data block counter. */
+
+ inblk = TRUE_;
+ ++blkcnt;
+ } else if (s_cmp(word, "END_INTEGER_BLOCK", (ftnlen)255, (ftnlen)
+ 17) == 0) {
+
+/* Get the data block index. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &eindex, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the end block */
+/* index, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("End integer block error, could not parse block "
+ "number. Error: # File: #", (ftnlen)71);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the count of integers in the block. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &ecount, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the ending data */
+/* count, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("End integer block error, could not parse the da"
+ "ta count for block: #.Error: # File: #", (ftnlen)
+ 85);
+ errint_("#", &eindex, (ftnlen)1);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the beginning and ending array indices */
+/* match. */
+
+ if (eindex != bindex) {
+
+/* If the begin and end data block indices do not match, */
+/* close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Integer block index mismatch: Beginning index: "
+ "#; Ending index: #. File: #", (ftnlen)74);
+ errint_("#", &bindex, (ftnlen)1);
+ errint_("#", &eindex, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the beginning and ending array data */
+/* counts match. */
+
+ if (ecount != bcount) {
+
+/* If the begin and end data block counts do not match, */
+/* close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Integer block count mismatch: Beginning count: "
+ "#; Ending count: #. File: #", (ftnlen)74);
+ errint_("#", &bcount, (ftnlen)1);
+ errint_("#", &ecount, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we have successfully ended the */
+/* processing of a data block, so set the in block flag, */
+/* INBLK, to .FALSE.. */
+
+ inblk = FALSE_;
+ } else if (s_cmp(word, "TOTAL_INTEGER_BLOCKS", (ftnlen)255, (
+ ftnlen)20) == 0) {
+
+/* We have the total data blocks keyword to parse, so get */
+/* the total number of character data blocks processed. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &numblk, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the total number of */
+/* data blocks, close the binary file, set an appropriate */
+/* error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Block count error, could not parse the total nu"
+ "mber of integer data blocks: #. File: #", (ftnlen)
+ 86);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Parse the total count of integers. */
+
+ nextwd_(rest, word, rest, (ftnlen)255, (ftnlen)255, (ftnlen)
+ 255);
+ nparsi_(word, &tcount, errmsg, &errptr, (ftnlen)255, (ftnlen)
+ 320);
+ if (s_cmp(errmsg, " ", (ftnlen)320, (ftnlen)1) != 0) {
+
+/* If an error occurred while parsing the integer */
+/* data count, close the binary file, set an */
+/* appropriate error message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Integer count error, could not parse the total "
+ "count. Error: # File: #", (ftnlen)70);
+ errch_("#", errmsg, (ftnlen)1, (ftnlen)320);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Compare the computed block count with the block count */
+/* from the file. */
+
+ if (blkcnt != numblk) {
+
+/* If the calculated data block count and the data */
+/* block count from the text file do not match, close */
+/* the binary file, set an appropriate error message, */
+/* then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("The number of integer data blocks processed (#)"
+ " was not equal to the number of integer data blo"
+ "cks placed in the DAS transfer file (#). File: #",
+ (ftnlen)143);
+ errint_("#", &blkcnt, (ftnlen)1);
+ errint_("#", &numblk, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Check to see if the total count and the computed count */
+/* match. */
+
+ if (tcount != dtacnt) {
+
+/* If the total count and computed count do not match, */
+/* close the binary file, set an appropriate error */
+/* message, then check out and return. */
+
+ dascls_(&handle);
+ setmsg_("Integer count mismatch: computed count: #; expe"
+ "cted count: #. File: #", (ftnlen)69);
+ errint_("#", &dtacnt, (ftnlen)1);
+ errint_("#", &tcount, (ftnlen)1);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we got to here, we have successfully processed the */
+/* entire DAS integer data portion of the text file, so */
+/* there is no more integer data. */
+
+ more = FALSE_;
+ } else {
+
+/* We got an unknown keyword of some sort, so set an */
+/* appropriate error message, close the DAS file, and */
+/* return. */
+
+ dascls_(&handle);
+ setmsg_("Unknown keyword '#' encountered while processing th"
+ "e DAS transfer file #.", (ftnlen)74);
+ errch_("#", word, (ftnlen)1, (ftnlen)255);
+ errfnm_("#", xfrlun, (ftnlen)1);
+ sigerr_("SPICE(BADDASTRANSFERFILE)", (ftnlen)25);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* If we have begun a block, then process it. Otherwise, we */
+/* have ended a block. */
+ if (inblk) {
+
+/* Read and decode the data in the current DAS integer */
+/* array data block. */
+
+/* Set the count of integers yet to be decoded and placed */
+/* in the binary DAS file. */
+
+ numlft = bcount;
+ while(numlft > 0) {
+
+/* Now read and decode the data in the current */
+/* integer data block, placing the data in the */
+/* integer precision array in the binary DAS file. */
+
+ if (numlft >= 1024) {
+ numdta = 1024;
+ } else {
+ numdta = numlft;
+ }
+
+/* Read and decode a buffer of encoded integer data */
+/* from the text file. */
+
+ rdenci_(xfrlun, &numdta, ibuffr);
+
+/* Write the integer data to the DAS integer array in */
+/* the binary DAS file. */
+
+ dasadi_(&handle, &numdta, ibuffr);
+ if (failed_()) {
+
+/* If an error occurred, attempt to close the */
+/* binary file, then checkout and return. */
+
+ dascls_(&handle);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+ }
+
+/* Decrement the counter for the amount of data */
+/* remaining to be moved from the current data block, */
+/* NUMLFT. */
+
+ numlft -= numdta;
+
+/* Increment the counter for the amount of data that */
+/* has been successfully moved into the current array */
+/* in the binary DAS file. */
+
+ dtacnt += numdta;
+
+/* At this point, we have either finished reading in an */
+/* entire data block, or there is still data remaining */
+/* to be read. */
+
+ }
+ }
+
+/* If we got to here, we have successfully written a data */
+/* block to the binary file. */
+
+ }
+
+/* At this point, we will have successfully written the entire */
+/* integer data array to the binary DAS file, if there was any */
+/* integer data to be written. */
+ }
+
+/* Close only the binary file. */
+
+ dascls_(&handle);
+ chkout_("DASTB", (ftnlen)5);
+ return 0;
+} /* dastb_ */
+
diff --git a/ext/spice/src/cspice/dasudc.c b/ext/spice/src/cspice/dasudc.c
new file mode 100644
index 0000000000..34ac5232e5
--- /dev/null
+++ b/ext/spice/src/cspice/dasudc.c
@@ -0,0 +1,477 @@
+/* dasudc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+
+/* $Procedure DASUDC ( DAS, update data, character ) */
+/* Subroutine */ int dasudc_(integer *handle, integer *first, integer *last,
+ integer *bpos, integer *epos, char *data, ftnlen data_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer l, n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer lastc, lastd, recno, lasti, nmove, rcpos;
+ extern /* Subroutine */ int dasa2l_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *);
+ extern logical failed_(void);
+ integer clbase;
+ extern /* Subroutine */ int daslla_(integer *, integer *, integer *,
+ integer *), dasurc_(integer *, integer *, integer *, integer *,
+ char *, ftnlen);
+ integer nmoved, clsize;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ integer numchr;
+ extern /* Subroutine */ int chkout_(char *, ftnlen), setmsg_(char *,
+ ftnlen), errint_(char *, integer *, ftnlen);
+ integer wordno;
+ extern logical return_(void);
+ integer nwritn, chr, elt;
+
+/* $ Abstract */
+
+/* Update character data in a specified range of DAS logical */
+/* addresses with substrings of a character array. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* FIRST, */
+/* LAST I Range of DAS character logical addresses. */
+/* BPOS, */
+/* EPOS I Begin and end positions of substrings. */
+/* DATA I Data having addresses FIRST through LAST. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a file handle of a DAS file opened for writing. */
+
+/* FIRST, */
+/* LAST are the first and last of a range of DAS logical */
+/* addresses of characters. These addresses satisfy */
+/* the inequality */
+
+/* 1 < FIRST < LAST < LASTC */
+/* _ - - */
+
+/* where LASTC is the last character logical address */
+/* in use in the DAS file designated by HANDLE. */
+
+/* BPOS, */
+/* EPOS are begin and end character positions that define */
+/* the substrings of the input array that are to be */
+/* added to the DAS file. */
+
+/* DATA is an array of character strings. The contents of */
+/* the specified substrings of the elements of the */
+/* array DATA will be written to the indicated DAS */
+/* file in order: DATA(1)(BPOS:BPOS) will be written */
+/* to character logical address FIRST; */
+/* DATA(1)(BPOS+1:BPOS+1) will be written to */
+/* the character logical address FIRST+1, and so on; */
+/* in this ordering scheme, character (BPOS:BPOS) of */
+/* DATA(I+1) is the successor of character (EPOS:EPOS) */
+/* of DATA(I). */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. */
+
+/* 2) Only logical addresses that already contain data may be */
+/* updated: if either FIRST or LAST are outside the range */
+
+/* [ 1, LASTC ] */
+
+/* where LASTC is the last character logical address that */
+/* currently contains data in the indicated DAS file, the error */
+/* SPICE(INVALIDADDRESS) is signalled. The DAS file will not be */
+/* modified. */
+
+/* 3) If FIRST > LAST but both addresses are valid, this routine */
+/* will not modify the indicated DAS file. No error will be */
+/* signalled. */
+
+/* 4) If an I/O error occurs during the data update attempted */
+/* by this routine, the error will be diagnosed by routines */
+/* called by this routine. FIRST and LAST will not be modified. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine replaces the character data in the specified range */
+/* of logical addresses within a DAS file with the contents of the */
+/* specified substrings of the input array DATA. */
+
+/* The actual physical write operations that update the indicated */
+/* DAS file with the contents of the input array DATA may not take */
+/* place before this routine returns, since the DAS system buffers */
+/* data that is written as well as data that is read. In any case, */
+/* the data will be flushed to the file at the time the file is */
+/* closed, if not earlier. A physical write of all buffered */
+/* records can be forced by calling the SPICELIB routine DASWUR */
+/* ( DAS, write updated records ). */
+
+/* In order to append character data to a DAS file, filling in a */
+/* range of character logical addresses that starts immediately */
+/* after the last character logical address currently in use, the */
+/* SPICELIB routines DASADS ( DAS add data, substring ) or DASADC */
+/* ( DAS add data, character ) should be used. */
+
+/* $ Examples */
+
+/* 1) Write to addresses 1 through 320 in a DAS file in */
+/* random-access fashion by updating the file. Recall */
+/* that data must be present in the file before it can */
+/* be updated. */
+
+
+/* PROGRAM UP */
+
+/* CHARACTER*(80) BUFFER ( 10 ) */
+/* CHARACTER*(80) LINE */
+/* CHARACTER*(4) TYPE */
+
+/* INTEGER FIRST */
+/* INTEGER HANDLE */
+/* INTEGER I */
+/* INTEGER LAST */
+
+/* C */
+/* C Open the new DAS file RAND.DAS. Use the file name */
+/* C as the internal file name. */
+/* C */
+/* TYPE = 'TEST' */
+/* CALL DASONW ( 'TEST.DAS', TYPE, 'TEST.DAS', HANDLE ) */
+
+/* C */
+/* C Append 320 characters to the file, thereby reserving */
+/* C enough room for 10 strings of 32 characters. After */
+/* C the data is present, we're free to update it in any */
+/* C order we please. */
+/* C */
+/* LINE = ' ' */
+
+/* DO I = 1, 10 */
+/* CALL DASADC ( HANDLE, 32, 1, 32, LINE ) */
+/* END DO */
+
+/* C */
+/* C Now the character logical addresses 1:320 can be */
+/* C written to in random-access fashion. We'll fill */
+/* C them in by writing 32 characters at a time, starting */
+/* C with addresses 289:320 and working backwards. */
+/* C */
+/* FIRST = 321 */
+
+/* DO I = 10, 1, -1 */
+
+/* LAST = FIRST - 1 */
+/* FIRST = LAST - 32 */
+
+/* LINE = 'This is the # line.' */
+/* CALL REPMOT ( LINE, '#', I, 'L', LINE ) */
+/* CALL DASUDC ( HANDLE, FIRST, LAST, 1, 32, LINE ) */
+
+/* END DO */
+
+/* C */
+/* C Close the file. */
+/* C */
+/* CALL DASCLS ( HANDLE ) */
+
+/* C */
+/* C Now make sure that we updated the file properly. */
+/* C Open the file for reading and dump the contents */
+/* C of the character logical addresses 1:320. */
+/* C */
+/* CALL DASOPR ( 'RAND.DAS', HANDLE ) */
+
+/* CALL DASRDC ( HANDLE, 1, 320, 1, 32, BUFFER ) */
+
+/* WRITE (*,*) 'Contents of RAND.DAS:' */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) BUFFER(1:32) */
+
+/* END */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.2.1 19-DEC-1995 (NJB) */
+
+/* Corrected title of permuted index entry section. */
+
+/* - SPICELIB Version 1.2.0, 12-MAY-1995 (NJB) */
+
+/* Bug fix: routine handled values of BPOS incorrectly when */
+/* BPOS > 1. */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination conditions. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* - SPICELIB Version 1.0.0, 12-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* update a range of DAS logical addresses using substrings */
+/* write substrings to a range of DAS logical addresses */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.2.0, 12-MAY-1995 (NJB) */
+
+/* Bug fix: routine handled values of BPOS incorrectly when */
+/* BPOS > 1. This was due to the incorrect initialization */
+/* of the internal variables CHR and ELT. The initialization */
+/* was corrected. */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Tests of FAILED() added to loop termination conditions. */
+/* Without these tests, infinite loops could result if DASA2L or */
+/* DASURC signaled an error inside the loops. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* - SPICELIB Version 1.0.0, 12-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASUDC", (ftnlen)6);
+ }
+
+/* Get the last logical addresses in use in this DAS file. */
+
+ daslla_(handle, &lastc, &lastd, &lasti);
+
+/* Validate the input addresses. */
+
+ if (*first < 1 || *first > lastc || *last < 1 || *last > lastc) {
+ setmsg_("FIRST was #. LAST was #. Valid range is [1,#].", (ftnlen)46);
+ errint_("#", first, (ftnlen)1);
+ errint_("#", last, (ftnlen)1);
+ errint_("#", &lastc, (ftnlen)1);
+ sigerr_("SPICE(INVALIDADDRESS)", (ftnlen)21);
+ chkout_("DASUDC", (ftnlen)6);
+ return 0;
+ }
+
+/* Get the length of the substrings of DATA. Count the total number */
+/* of characters to write. */
+
+ l = *epos - *bpos + 1;
+ n = *last - *first + 1;
+ nwritn = 0;
+
+/* Find out the physical location of the first character to update. */
+
+ dasa2l_(handle, &c__1, first, &clbase, &clsize, &recno, &wordno);
+
+/* Write as much data into record RECNO as is necessary and possible. */
+
+/* NUMCHR is the number of characters to write to the current record. */
+
+/* ELT is the index of the element of the input array that we're */
+/* taking data from. CHR is the position in that array element of */
+/* the next character to move to the file. */
+
+/* NMOVED is the number of characters we've moved into the current */
+/* record so far. */
+
+/* RCPOS is the character position we'll write to next in the current */
+/* record. */
+
+/* Computing MIN */
+ i__1 = n, i__2 = 1024 - wordno + 1;
+ numchr = min(i__1,i__2);
+ elt = 1;
+ chr = *bpos;
+ nmoved = 0;
+ rcpos = wordno;
+ while(nmoved < numchr && ! failed_()) {
+ if (chr > *epos) {
+ ++elt;
+ chr = *bpos;
+ }
+
+/* Find out how many characters to move from the current array */
+/* element to the current record. */
+
+/* Computing MIN */
+ i__1 = numchr - nmoved, i__2 = *epos - chr + 1;
+ nmove = min(i__1,i__2);
+
+/* Update the current record. */
+
+ i__1 = rcpos + nmove - 1;
+ dasurc_(handle, &recno, &rcpos, &i__1, data + ((elt - 1) * data_len +
+ (chr - 1)), chr + nmove - 1 - (chr - 1));
+ nmoved += nmove;
+ rcpos += nmove;
+ chr += nmove;
+ }
+ nwritn = numchr;
+ ++recno;
+
+/* Update as many additional records as necessary. */
+
+ while(nwritn < n && ! failed_()) {
+
+/* At this point, RECNO is the correct number of the record to */
+/* write to next. CLBASE is the number of the first record of */
+/* the cluster we're about to write to. */
+
+ if (recno < clbase + clsize) {
+
+/* We can continue writing the current cluster. Find */
+/* out how many elements to write to the current record, */
+/* and write them. */
+
+/* Computing MIN */
+ i__1 = n - nwritn;
+ numchr = min(i__1,1024);
+ nmoved = 0;
+ rcpos = 1;
+ while(nmoved < numchr && ! failed_()) {
+ if (chr > l) {
+ ++elt;
+ chr = *bpos;
+ }
+
+/* Find out how many characters to move from the array */
+/* element to the current record. */
+
+/* Computing MIN */
+ i__1 = numchr - nmoved, i__2 = *epos - chr + 1;
+ nmove = min(i__1,i__2);
+ i__1 = rcpos + nmove - 1;
+ dasurc_(handle, &recno, &rcpos, &i__1, data + ((elt - 1) *
+ data_len + (chr - 1)), chr + nmove - 1 - (chr - 1));
+ nmoved += nmove;
+ rcpos += nmove;
+ chr += nmove;
+ }
+ nwritn += numchr;
+ ++recno;
+ } else {
+
+/* We must find the next character cluster to write to. */
+/* The first character in this cluster has address FIRST + */
+/* NWRITN. */
+
+ i__1 = *first + nwritn;
+ dasa2l_(handle, &c__1, &i__1, &clbase, &clsize, &recno, &wordno);
+ }
+ }
+ chkout_("DASUDC", (ftnlen)6);
+ return 0;
+} /* dasudc_ */
+
diff --git a/ext/spice/src/cspice/dasudd.c b/ext/spice/src/cspice/dasudd.c
new file mode 100644
index 0000000000..aa1e67465d
--- /dev/null
+++ b/ext/spice/src/cspice/dasudd.c
@@ -0,0 +1,393 @@
+/* dasudd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+
+/* $Procedure DASUDD ( DAS, update data, double precision ) */
+/* Subroutine */ int dasudd_(integer *handle, integer *first, integer *last,
+ doublereal *data)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer lastc, lastd, recno, lasti, numdp;
+ extern /* Subroutine */ int dasa2l_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *);
+ extern logical failed_(void);
+ integer clbase;
+ extern /* Subroutine */ int daslla_(integer *, integer *, integer *,
+ integer *), dasurd_(integer *, integer *, integer *, integer *,
+ doublereal *);
+ integer clsize;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ integer wordno;
+ extern logical return_(void);
+ integer nwritn;
+
+/* $ Abstract */
+
+/* Update data in a specified range of double precision addresses */
+/* in a DAS file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ARRAY */
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* FIRST, */
+/* LAST I Range of d.p. addresses to write to. */
+/* DATA I An array of d.p. numbers. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a file handle of a DAS file opened for writing. */
+
+/* FIRST, */
+/* LAST are the first and last of a range of DAS logical */
+/* addresses of double precision numbers. These */
+/* addresses satisfy the inequality */
+
+/* 1 < FIRST < LAST < LASTD */
+/* _ - - */
+
+/* where LASTD is the last double precision logical */
+/* address in use in the DAS file designated by */
+/* HANDLE. */
+
+/* DATA is an array of double precision numbers. The */
+/* array elements DATA(1) through DATA(N) will be */
+/* written to the indicated DAS file, where N is */
+/* LAST - FIRST + 1. */
+
+/* $ Detailed_Output */
+
+/* See $Particulars for a description of the effect of this routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. */
+
+/* 2) Only logical addresses that already contain data may be */
+/* updated: if either FIRST or LAST are outside the range */
+
+/* [ 1, LASTD ] */
+
+/* where LASTD is the last double precision logical address */
+/* that currently contains data in the indicated DAS file, the */
+/* error SPICE(INVALIDADDRESS) is signalled. */
+/* The DAS file will not be modified. */
+
+/* 3) If FIRST > LAST but both addresses are valid, this routine */
+/* will not modify the indicated DAS file. No error will be */
+/* signalled. */
+
+/* 4) If an I/O error occurs during the data update attempted */
+/* by this routine, the error will be diagnosed by routines */
+/* called by this routine. FIRST and LAST will not be modified. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine replaces the double precision data in the specified */
+/* range of logical addresses within a DAS file with the contents of */
+/* the input array DATA. */
+
+/* The actual physical write operations that update the indicated */
+/* DAS file with the contents of the input array DATA may not take */
+/* place before this routine returns, since the DAS system buffers */
+/* data that is written as well as data that is read. In any case, */
+/* the data will be flushed to the file at the time the file is */
+/* closed, if not earlier. A physical write of all buffered */
+/* records can be forced by calling the SPICELIB routine DASWUR */
+/* ( DAS, write updated records ). */
+
+/* In order to append double precision data to a DAS file, filling */
+/* in a range of double precision logical addresses that starts */
+/* immediately after the last double precision logical address */
+/* currently in use, the SPICELIB routine DASADD ( DAS add data, */
+/* double precision ) should be used. */
+
+/* $ Examples */
+
+/* 1) Write to addresses 1 through 500 in a DAS file in */
+/* random-access fashion by updating the file. Recall */
+/* that data must be present in the file before it can */
+/* be updated. */
+
+
+/* PROGRAM UP */
+
+/* CHARACTER*(4) TYPE */
+
+/* DOUBLE PRECISION DATA ( 500 ) */
+
+/* INTEGER HANDLE */
+/* INTEGER I */
+
+/* C */
+/* C Open the new DAS file RAND.DAS. Use the file name */
+/* C as the internal file name. */
+/* C */
+/* TYPE = 'TEST' */
+/* CALL DASONW ( 'TEST.DAS', TYPE, 'TEST.DAS', HANDLE ) */
+
+/* C */
+/* C Append 500 double precision numbers to the file; */
+/* C after the data is present, we're free to update it */
+/* C in any order we please. (CLEARD zeros out a double */
+/* C precision array.) */
+/* C */
+/* CALL CLEARD ( 500, DATA ) */
+/* CALL DASADD ( HANDLE, 500, DATA ) */
+
+/* C */
+/* C Now the double precision logical addresses 1:500 */
+/* C can be written to in random-access fashion. We'll */
+/* C fill them in in reverse order. */
+/* C */
+/* DO I = 500, 1, -1 */
+/* CALL DASUDD ( HANDLE, I, I, DBLE(I) ) */
+/* END DO */
+
+/* C */
+/* C Close the file. */
+/* C */
+/* CALL DASCLS ( HANDLE ) */
+
+/* C */
+/* C Now make sure that we updated the file properly. */
+/* C Open the file for reading and dump the contents */
+/* C of the double precision logical addresses 1:500. */
+/* C */
+/* CALL DASOPR ( 'RAND.DAS', HANDLE ) */
+
+/* CALL CLEARD ( 500, DATA ) */
+/* CALL DASRDD ( HANDLE, 1, 500, DATA ) */
+
+/* WRITE (*,*) 'Contents of RAND.DAS:' */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) DATA */
+
+/* END */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1 19-DEC-1995 (NJB) */
+
+/* Corrected title of permuted index entry section. */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination conditions. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* update double precision data in a DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination condition. Without */
+/* this test, an infinite loop could result if DASA2L or DASURD */
+/* signaled an error inside the loop. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASUDD", (ftnlen)6);
+ }
+
+/* Get the last logical addresses in use in this DAS file. */
+
+ daslla_(handle, &lastc, &lastd, &lasti);
+
+/* Validate the input addresses. */
+
+ if (*first < 1 || *first > lastd || *last < 1 || *last > lastd) {
+ setmsg_("FIRST was #. LAST was #. Valid range is [1,#].", (ftnlen)46);
+ errint_("#", first, (ftnlen)1);
+ errint_("#", last, (ftnlen)1);
+ errint_("#", &lastd, (ftnlen)1);
+ sigerr_("SPICE(INVALIDADDRESS)", (ftnlen)21);
+ chkout_("DASUDD", (ftnlen)6);
+ return 0;
+ }
+
+/* Let N be the number of addresses to update. */
+
+ n = *last - *first + 1;
+
+/* We will use the variables RECNO and OFFSET to determine where to */
+/* write data in the DAS file. RECNO will be the record containing */
+/* the physical location to write to; WORDNO will be the word */
+/* location that we will write to next. */
+
+/* Find the first location to write to. CLBASE and CLSIZE are the */
+/* base record number and size of the cluster of d.p. records that */
+/* the address FIRST lies within. */
+
+ dasa2l_(handle, &c__2, first, &clbase, &clsize, &recno, &wordno);
+
+/* Set the number of double precision words already written. Keep */
+/* writing to the file until this number equals the number of */
+/* elements in DATA. */
+
+/* Note that if N is non-positive, the loop doesn't get exercised. */
+
+
+ nwritn = 0;
+ while(nwritn < n && ! failed_()) {
+
+/* Write as much data as we can (or need to) into the current */
+/* record. We assume that CLBASE, RECNO, WORDNO, and NWRITN have */
+/* been set correctly at this point. */
+
+/* Find out how many words to write into the current record. */
+/* There may be no space left in the current record. */
+
+/* Computing MIN */
+ i__1 = n - nwritn, i__2 = 128 - wordno + 1;
+ numdp = min(i__1,i__2);
+ if (numdp > 0) {
+
+/* Write NUMDP words into the current record. */
+
+ i__1 = wordno + numdp - 1;
+ dasurd_(handle, &recno, &wordno, &i__1, &data[nwritn]);
+ nwritn += numdp;
+ wordno += numdp;
+ } else {
+
+/* It's time to start on a new record. If the record we */
+/* just finished writing to (or just attempted writing to, */
+/* if it was full) was not the last of the cluster, the next */
+/* record to write to is the immediate successor of the last */
+/* one. Otherwise, we'll have to look up the location of the */
+/* next d.p. logical address. */
+
+ if (recno < clbase + clsize - 1) {
+ ++recno;
+ wordno = 1;
+ } else {
+ i__1 = *first + nwritn;
+ dasa2l_(handle, &c__2, &i__1, &clbase, &clsize, &recno, &
+ wordno);
+ }
+ }
+ }
+ chkout_("DASUDD", (ftnlen)6);
+ return 0;
+} /* dasudd_ */
+
diff --git a/ext/spice/src/cspice/dasudi.c b/ext/spice/src/cspice/dasudi.c
new file mode 100644
index 0000000000..eba4d6cca3
--- /dev/null
+++ b/ext/spice/src/cspice/dasudi.c
@@ -0,0 +1,389 @@
+/* dasudi.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__3 = 3;
+
+/* $Procedure DASUDI ( DAS, update data, integer ) */
+/* Subroutine */ int dasudi_(integer *handle, integer *first, integer *last,
+ integer *data)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Local variables */
+ integer n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer lastc, lastd, recno, lasti;
+ extern /* Subroutine */ int dasa2l_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *);
+ extern logical failed_(void);
+ integer clbase;
+ extern /* Subroutine */ int daslla_(integer *, integer *, integer *,
+ integer *), dasuri_(integer *, integer *, integer *, integer *,
+ integer *);
+ integer clsize;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ integer wordno, numint;
+ extern logical return_(void);
+ integer nwritn;
+
+/* $ Abstract */
+
+/* Update data in a specified range of integer addresses in a DAS */
+/* file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* ARRAY */
+/* ASSIGNMENT */
+/* DAS */
+/* FILES */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* FIRST, */
+/* LAST I Range of integer addresses to write to. */
+/* DATA I An array of integers. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a file handle of a DAS file opened for writing. */
+
+/* FIRST, */
+/* LAST are the first and last of a range of DAS logical */
+/* addresses of integers. These addresses satisfy the */
+/* inequality */
+
+/* 1 < FIRST < LAST < LASTI */
+/* _ - - */
+
+/* where LASTI is the last integer logical address in */
+/* use in the DAS file designated by HANDLE. */
+
+/* DATA is an array of integers. The array elements */
+/* DATA(1) through DATA(N) will be written to the */
+/* indicated DAS file, where N is LAST - FIRST + 1. */
+
+/* $ Detailed_Output */
+
+/* See $Particulars for a description of the effect of this routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input file handle is invalid, the error will be */
+/* diagnosed by routines called by this routine. */
+
+/* 2) Only logical addresses that already contain data may be */
+/* updated: if either FIRST or LAST are outside the range */
+
+/* [ 1, LASTI ] */
+
+/* where LASTI is the last integer logical address that */
+/* currently contains data in the indicated DAS file, the error */
+/* SPICE(INVALIDADDRESS) is signalled. The DAS file will not be */
+/* modified. */
+
+/* 3) If FIRST > LAST but both addresses are valid, this routine */
+/* will not modify the indicated DAS file. No error will be */
+/* signalled. */
+
+/* 4) If an I/O error occurs during the data update attempted */
+/* by this routine, the error will be diagnosed by routines */
+/* called by this routine. FIRST and LAST will not be modified. */
+
+/* $ Files */
+
+/* See the description of the argument HANDLE in $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine replaces the integer data in the specified range of */
+/* logical addresses within a DAS file with the contents of the */
+/* input array DATA. */
+
+/* The actual physical write operations that update the indicated */
+/* DAS file with the contents of the input array DATA may not take */
+/* place before this routine returns, since the DAS system buffers */
+/* data that is written as well as data that is read. In any case, */
+/* the data will be flushed to the file at the time the file is */
+/* closed, if not earlier. A physical write of all buffered */
+/* records can be forced by calling the SPICELIB routine DASWUR */
+/* ( DAS, write updated records ). */
+
+/* In order to append integer data to a DAS file, filling in a range */
+/* of integer logical addresses that starts immediately after the */
+/* last integer logical address currently in use, the SPICELIB */
+/* routine DASADI ( DAS add data, integer ) should be used. */
+
+/* $ Examples */
+
+/* 1) Write to addresses 1 through 500 in a DAS file in */
+/* random-access fashion by updating the file. Recall */
+/* that data must be present in the file before it can */
+/* be updated. */
+
+
+/* PROGRAM UP */
+
+/* CHARACTER*(4) TYPE */
+
+/* INTEGER DATA ( 500 ) */
+
+/* INTEGER HANDLE */
+/* INTEGER I */
+
+/* C */
+/* C Open the new DAS file RAND.DAS. Use the file name */
+/* C as the internal file name. */
+/* C */
+/* TYPE = 'TEST' */
+/* CALL DASONW ( 'TEST.DAS', TYPE, 'TEST.DAS', HANDLE ) */
+
+/* C */
+/* C Append 500 integers to the file; after the data is */
+/* C present, we're free to update it in any order we */
+/* C please. (CLEARI zeros out an integer array.) */
+/* C */
+/* CALL CLEARI ( 500, DATA ) */
+/* CALL DASADI ( HANDLE, 500, DATA ) */
+
+/* C */
+/* C Now the integer logical addresses 1:500 can be */
+/* C written to in random-access fashion. We'll fill them */
+/* C in in reverse order. */
+/* C */
+/* DO I = 500, 1, -1 */
+/* CALL DASUDI ( HANDLE, I, I, I ) */
+/* END DO */
+
+/* C */
+/* C Close the file. */
+/* C */
+/* CALL DASCLS ( HANDLE ) */
+
+/* C */
+/* C Now make sure that we updated the file properly. */
+/* C Open the file for reading and dump the contents */
+/* C of the integer logical addresses 1:500. */
+/* C */
+/* CALL DASOPR ( 'RAND.DAS', HANDLE ) */
+
+/* CALL CLEARI ( 500, DATA ) */
+/* CALL DASRDI ( HANDLE, 1, 500, DATA ) */
+
+/* WRITE (*,*) 'Contents of RAND.DAS:' */
+/* WRITE (*,*) ' ' */
+/* WRITE (*,*) DATA */
+
+/* END */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.1 19-DEC-1995 (NJB) */
+
+/* Corrected title of permuted index entry section. */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination conditions. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* update integer data in a DAS file */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.1.0, 12-MAY-1994 (KRG) (NJB) */
+
+/* Test of FAILED() added to loop termination condition. Without */
+/* this test, an infinite loop could result if DASA2L or DASURI */
+/* signaled an error inside the loop. */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if the DAS open routines ever */
+/* change. */
+
+/* Modified the $ Examples section to demonstrate the new ID word */
+/* format which includes a file type and to include a call to the */
+/* new routine DASONW, open new for write, which makes use of the */
+/* file type. Also, a variable for the type of the file to be */
+/* created was added. */
+
+/* - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASUDI", (ftnlen)6);
+ }
+
+/* Get the last logical addresses in use in this DAS file. */
+
+ daslla_(handle, &lastc, &lastd, &lasti);
+
+/* Validate the input addresses. */
+
+ if (*first < 1 || *first > lasti || *last < 1 || *last > lasti) {
+ setmsg_("FIRST was #. LAST was #. Valid range is [1,#].", (ftnlen)46);
+ errint_("#", first, (ftnlen)1);
+ errint_("#", last, (ftnlen)1);
+ errint_("#", &lasti, (ftnlen)1);
+ sigerr_("SPICE(INVALIDADDRESS)", (ftnlen)21);
+ chkout_("DASUDI", (ftnlen)6);
+ return 0;
+ }
+
+/* Let N be the number of addresses to update. */
+
+ n = *last - *first + 1;
+
+/* We will use the variables RECNO and OFFSET to determine where to */
+/* write data in the DAS file. RECNO will be the record containing */
+/* the physical location to write to; WORDNO will be the word */
+/* location that we will write to next. */
+
+/* Find the first location to write to. CLBASE and CLSIZE are the */
+/* base record number and size of the cluster of integer records that */
+/* the address FIRST lies within. */
+
+ dasa2l_(handle, &c__3, first, &clbase, &clsize, &recno, &wordno);
+
+/* Set the number of integer words already written. Keep */
+/* writing to the file until this number equals the number of */
+/* elements in DATA. */
+
+/* Note that if N is non-positive, the loop doesn't get exercised. */
+
+
+ nwritn = 0;
+ while(nwritn < n && ! failed_()) {
+
+/* Write as much data as we can (or need to) into the current */
+/* record. We assume that CLBASE, RECNO, WORDNO, and NWRITN have */
+/* been set correctly at this point. */
+
+/* Find out how many words to write into the current record. */
+/* There may be no space left in the current record. */
+
+/* Computing MIN */
+ i__1 = n - nwritn, i__2 = 256 - wordno + 1;
+ numint = min(i__1,i__2);
+ if (numint > 0) {
+
+/* Write NUMINT words into the current record. */
+
+ i__1 = wordno + numint - 1;
+ dasuri_(handle, &recno, &wordno, &i__1, &data[nwritn]);
+ nwritn += numint;
+ wordno += numint;
+ } else {
+
+/* It's time to start on a new record. If the record we */
+/* just finished writing to (or just attempted writing to, */
+/* if it was full) was not the last of the cluster, the next */
+/* record to write to is the immediate successor of the last */
+/* one. Otherwise, we'll have to look up the location of the */
+/* next integer logical address. */
+
+ if (recno < clbase + clsize - 1) {
+ ++recno;
+ wordno = 1;
+ } else {
+ i__1 = *first + nwritn;
+ dasa2l_(handle, &c__3, &i__1, &clbase, &clsize, &recno, &
+ wordno);
+ }
+ }
+ }
+ chkout_("DASUDI", (ftnlen)6);
+ return 0;
+} /* dasudi_ */
+
diff --git a/ext/spice/src/cspice/daswfr.c b/ext/spice/src/cspice/daswfr.c
new file mode 100644
index 0000000000..219165b1a4
--- /dev/null
+++ b/ext/spice/src/cspice/daswfr.c
@@ -0,0 +1,474 @@
+/* daswfr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+
+/* $Procedure DASWFR ( DAS write file record ) */
+/* Subroutine */ int daswfr_(integer *handle, char *idword, char *ifname,
+ integer *nresvr, integer *nresvc, integer *ncomr, integer *ncomc,
+ ftnlen idword_len, ftnlen ifname_len)
+{
+ /* Builtin functions */
+ integer s_rdue(cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_wdue(cilist *), e_wdue(void);
+
+ /* Local variables */
+ integer free;
+ char tail[932];
+ integer unit;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ extern logical failed_(void);
+ integer oldcch, locncc, oldcrc;
+ extern /* Subroutine */ int dashfs_(integer *, integer *, integer *,
+ integer *, integer *, integer *, integer *, integer *, integer *);
+ char locifn[60];
+ integer oldrch;
+ extern /* Subroutine */ int dassih_(integer *, char *, ftnlen);
+ integer lastla[3];
+ char locidw[8];
+ integer locncr, locnvc, oldrrc;
+ char format[8];
+ integer lastrc[3];
+ extern /* Subroutine */ int dashlu_(integer *, integer *), errfnm_(char *,
+ integer *, ftnlen), chkout_(char *, ftnlen);
+ integer lastwd[3];
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), dasufs_(integer *,
+ integer *, integer *, integer *, integer *, integer *, integer *,
+ integer *, integer *), setmsg_(char *, ftnlen);
+ integer iostat, locnvr;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+ char ifn[60];
+
+ /* Fortran I/O blocks */
+ static cilist io___3 = { 1, 0, 1, 0, 1 };
+ static cilist io___13 = { 1, 0, 0, 0, 1 };
+
+
+/* $ Abstract */
+
+/* Update the contents of the file record of a specified DAS file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* DAS */
+
+/* $ Keywords */
+
+/* DAS */
+/* FILES */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* HANDLE I DAS file handle. */
+/* IDWORD I ID word. */
+/* IFNAME I DAS internal file name. */
+/* NRESVR I Number of reserved records in file. */
+/* NRESVC I Number of characters in use in reserved rec. area. */
+/* NCOMR I Number of comment records in file. */
+/* NCOMC I Number of characters in use in comment area. */
+
+/* $ Detailed_Input */
+
+/* HANDLE is a file handle for a DAS file open for writing. */
+
+/* IDWORD is the `ID word' contained in the first eight */
+/* characters of the file record. */
+
+/* IFNAME is the internal file name of the DAS file. The */
+/* maximum length of the internal file name is 60 */
+/* characters. */
+
+/* NRESVR is the number of reserved records in the DAS file */
+/* specified by HANDLE. */
+
+/* NRESVC is the number of characters in use in the reserved */
+/* record area of the DAS file specified by HANDLE. */
+
+/* NCOMR is the number of comment records in the DAS file */
+/* specified by HANDLE. */
+
+/* NCOMC is the number of characters in use in the comment area */
+/* of the DAS file specified by HANDLE. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the handle passed to this routine is not the handle of an */
+/* open DAS file, the error will be signaled by a routine called */
+/* by this routine. */
+
+/* 2) If the specified DAS file is not open for write access, the */
+/* error will be diagnosed by a routine called by this routine. */
+
+/* 3) If the attempt to read the file record fails, the error */
+/* SPICE(DASREADFAIL) is signaled. */
+
+/* 4) If the file write attempted by this routine fails, the error */
+/* SPICE(DASFILEWRITEFAILED) is signaled. */
+
+/* $ Files */
+
+/* See the description of HANDLE under $Detailed_Input. */
+
+/* $ Particulars */
+
+/* This routine provides a convenient way of updating the internal */
+/* file name of a DAS file. */
+
+/* The `ID word' contained in the file record is a string of eight */
+/* characters that identifies the file as a DAS file and optionally */
+/* indicates a specific file format, for example, `EK'. */
+
+/* $ Examples */
+
+/* 1) Update the internal file name of an existing DAS file. */
+
+/* C */
+/* C Open the file for writing. */
+/* C */
+/* CALL DASOPW ( FNAME, HANDLE ) */
+
+/* C */
+/* C Retrieve the ID word and current reserved record */
+/* C and comment area record and character counts. */
+/* C */
+/* CALL DASRFR ( HANDLE, */
+/* . IDWORD, */
+/* . IFNAME, */
+/* . NRESVR, */
+/* . NRESVC, */
+/* . NCOMR, */
+/* . NCOMC ) */
+
+/* C */
+/* C Set the internal file name and update the file */
+/* C with it. */
+/* C */
+/* IFNAME = 'New internal file name' */
+
+/* CALL DASWFR ( HANDLE, */
+/* . IDWORD, */
+/* . IFNAME, */
+/* . NRESVR, */
+/* . NRESVC, */
+/* . NCOMR, */
+/* . NCOMC ) */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+/* F.S. Turner (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 3.0.0, 11-DEC-2001 (FST) */
+
+/* This routine was modified to accomodate the preservation */
+/* of the FTP validation and binary file format strings that */
+/* are not part of the DAS file record. */
+
+/* - SPICELIB Version 2.0.0, 27-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* Added a check of FAILED after the call to DASHLU which will */
+/* check out and return if DASHLU fails. This is so that when in */
+/* return mode of the error handling the READ following the call */
+/* to DASHLU will not be executed. */
+
+/* Reworded some of the descriptions contained in the */
+/* $ Detailed_Output section of the header so that they were more */
+/* clear. */
+
+/* - SPICELIB Version 1.0.0, 24-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* write DAS file record */
+/* write DAS internal file name */
+/* update DAS internal file name */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 3.0.0, 11-DEC-2001 (FST) */
+
+/* In order to preserve the additional information that */
+/* now resides in the file record, this routine reads */
+/* the entire record into local buffers, including the */
+/* TAILEN characters that follow the actual data content. */
+/* The contents of the local buffers that correspond to */
+/* information brought in from the call sequence of the */
+/* routine are ignored when the record is rewritten. */
+/* However, the ID word, the file format string, and the */
+/* trailing TAILEN characters that contain the FTP validation */
+/* string are rewritten along with the input values. */
+
+/* This routine does not simply replace the FTP validation */
+/* string with the components from ZZFTPSTR, since that */
+/* would possibly validate a corrupt file created using a newer */
+/* Toolkit. */
+
+/* The string arguments passed into this routine are now */
+/* copied to local buffers of the appropriate length. */
+
+/* - SPICELIB Version 2.0.0, 27-OCT-1993 (KRG) */
+
+/* Removed references to specific DAS file open routines in the */
+/* $ Detailed_Input section of the header. This was done in order */
+/* to minimize documentation changes if these open routines ever */
+/* change. */
+
+/* Added a check of FAILED after the call to DASHLU which will */
+/* check out and return if DASHLU fails. This is so that when in */
+/* return mode of the error handling the READ following the call */
+/* to DASHLU will not be executed. */
+
+/* Reworded some of the descriptions contained in the */
+/* $ Detailed_Output section of the header so that they were more */
+/* clear. */
+
+/* - SPICELIB Version 1.0.0, 24-NOV-1992 (NJB) (WLT) */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local Parameters */
+
+
+/* The parameter TAILEN determines the tail length of a DAS file */
+/* record. This is the number of bytes (characters) that */
+/* occupy the portion of the file record that follows the */
+/* integer holding the first free address. For environments */
+/* with a 32 bit word length, 1 byte characters, and DAS */
+/* record sizes of 1024 bytes, we have: */
+
+/* 8 bytes - IDWORD */
+/* 60 bytes - IFNAME */
+/* 4 bytes - NRESVR (32 bit integer) */
+/* 4 bytes - NRESVC (32 bit integer) */
+/* 4 bytes - NCOMR (32 bit integer) */
+/* + 4 bytes - NCOMC (32 bit integer) */
+/* --------- */
+/* 84 bytes - (All file records utilize this space.) */
+
+/* So the size of the remaining portion (or tail) of the DAS */
+/* file record for computing enviroments as described above */
+/* would be: */
+
+/* 1024 bytes - DAS record size */
+/* - 8 bytes - DAS Binary File Format Word */
+/* - 84 bytes - (from above) */
+/* ------------ */
+/* 932 bytes - DAS file record tail length */
+
+/* Note: environments that do not have a 32 bit word length, */
+/* 1 byte characters, and a DAS record size of 1024 bytes, will */
+/* require the adjustment of this parameter. */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DASWFR", (ftnlen)6);
+ }
+
+/* Check to be sure that HANDLE is attached to a file that is open */
+/* with write access. If the call fails, check out and return. */
+
+ dassih_(handle, "WRITE", (ftnlen)5);
+
+/* Get the logical unit for this DAS file. */
+
+ dashlu_(handle, &unit);
+ if (failed_()) {
+ chkout_("DASWFR", (ftnlen)6);
+ return 0;
+ }
+
+/* In order to maintain the integrity of the file ID word, the */
+/* file FORMAT, and the FTP string if present, we need to */
+/* read the entire file record into the appropriate sized local */
+/* buffers. The values of the LOCxxx variables are simply */
+/* ignored, since the caller passes new values in for updates. */
+
+ io___3.ciunit = unit;
+ iostat = s_rdue(&io___3);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, locidw, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, locifn, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&locnvr, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&locnvc, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&locncr, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, (char *)&locncc, (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, format, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = do_uio(&c__1, tail, (ftnlen)932);
+ if (iostat != 0) {
+ goto L100001;
+ }
+ iostat = e_rdue();
+L100001:
+ if (iostat != 0) {
+ setmsg_("Attempt to read the file record failed for file '#'. IOSTAT"
+ " = #", (ftnlen)63);
+ errfnm_("#", &unit, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASREADFAIL)", (ftnlen)18);
+ chkout_("DASWFR", (ftnlen)6);
+ return 0;
+ }
+
+/* Set the value of the internal file name and IDWORD before */
+/* writing. This is to guarantee that their lengths are ok. */
+
+ s_copy(ifn, ifname, (ftnlen)60, ifname_len);
+ s_copy(locidw, idword, (ftnlen)8, idword_len);
+ io___13.ciunit = unit;
+ iostat = s_wdue(&io___13);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, locidw, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, ifn, (ftnlen)60);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&(*nresvr), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&(*nresvc), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&(*ncomr), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, (char *)&(*ncomc), (ftnlen)sizeof(integer));
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, format, (ftnlen)8);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = do_uio(&c__1, tail, (ftnlen)932);
+ if (iostat != 0) {
+ goto L100002;
+ }
+ iostat = e_wdue();
+L100002:
+ if (iostat != 0) {
+ setmsg_("Could not write file record. File was #. IOSTAT was #.", (
+ ftnlen)56);
+ errfnm_("#", &unit, (ftnlen)1);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(DASFILEWRITEFAILED)", (ftnlen)25);
+ chkout_("DASWFR", (ftnlen)6);
+ return 0;
+ }
+
+/* Update the file summary, in case the values of the reserved */
+/* record or comment area counts have changed. */
+
+ dashfs_(handle, &oldrrc, &oldrch, &oldcrc, &oldcch, &free, lastla, lastrc,
+ lastwd);
+ dasufs_(handle, nresvr, nresvc, ncomr, ncomc, &free, lastla, lastrc,
+ lastwd);
+ chkout_("DASWFR", (ftnlen)6);
+ return 0;
+} /* daswfr_ */
+
diff --git a/ext/spice/src/cspice/datanh.c b/ext/spice/src/cspice/datanh.c
new file mode 100644
index 0000000000..3182626610
--- /dev/null
+++ b/ext/spice/src/cspice/datanh.c
@@ -0,0 +1,176 @@
+/* datanh.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DATANH ( Double precision arc hyperbolic tangent ) */
+doublereal datanh_(doublereal *x)
+{
+ /* System generated locals */
+ doublereal ret_val;
+
+ /* Builtin functions */
+ double log(doublereal);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), sigerr_(char *,
+ ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Return the inverse hyperbolic tangent of a double */
+/* precision argument. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* HYPERBOLIC, MATH */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* X I Number whose inverse hyperbolic tangent is */
+/* desired. X must lie in the range -1 < X < +1. */
+
+/* $ Detailed_Input */
+
+/* X is any double precision number greater than or equal to 1. */
+
+/* $ Detailed_Output */
+
+/* DATANH is the inverse hyperbolic tangent of X. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This function simply implements the definition of the inverse */
+/* hyperbolic tangent as follows: */
+
+/* DATANH = 0.5D0 * DLOG ( (1+X) / (1-X) ) */
+
+/* If the input value is not valid, an error is signalled. */
+
+/* $ Examples */
+
+/* The following table gives a few values for X and the resulting */
+/* value of DATANH. */
+
+/* X DATANH(X) */
+/* ---------------------------------------------- */
+/* -0.2000000000000000 -0.2027325540540822 */
+/* -0.1000000000000000 -0.1003353477310756 */
+/* 0.0000000000000000E+00 0.0000000000000000E+00 */
+/* 0.1000000000000000 0.1003353477310756 */
+/* 0.2000000000000000 0.2027325540540822 */
+/* 0.4000000000000000 0.4236489301936018 */
+/* 0.8000000000000000 1.098612288668110 */
+
+/* $ Restrictions */
+
+/* The value of the input variable X must be between -1.0 and 1.0, */
+/* otherwise an error is signalled. */
+
+/* $ Exceptions */
+
+/* 1) If X is not between -1.0 and 1.0, the error */
+/* SPICE(INVALIDARGUMENT) is signalled. */
+
+
+/* $ Files */
+
+/* None */
+
+/* $ Author_and_Institution */
+
+/* H.A. Neilan (JPL) */
+/* W.M. Owen (JPL) */
+
+/* $ Literature_References */
+
+/* Any good book of mathematical tables and formulae, for example */
+/* the "Standard Mathematical Tables" published by the Chemical */
+/* Rubber Company. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.0, 17-MAY-1994 (HAN) */
+
+/* Set the default function value to either 0, 0.0D0, .FALSE., */
+/* or blank depending on the type of the function. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WMO) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* d.p. arc hyperbolic_tangent */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Set up the error processing. */
+
+ if (return_()) {
+ ret_val = 0.;
+ return ret_val;
+ } else {
+ chkin_("DATANH", (ftnlen)6);
+ ret_val = 0.;
+ }
+
+/* Check that -1 < X < +1. */
+
+ if (abs(*x) >= 1.) {
+ setmsg_("DATANH: Argument out of range.", (ftnlen)30);
+ sigerr_("SPICE(INVALIDARGUMENT)", (ftnlen)22);
+ chkout_("DATANH", (ftnlen)6);
+ return ret_val;
+ }
+ ret_val = log((*x + 1.) / (1. - *x)) * .5;
+ chkout_("DATANH", (ftnlen)6);
+ return ret_val;
+} /* datanh_ */
+
diff --git a/ext/spice/src/cspice/dcbrt.c b/ext/spice/src/cspice/dcbrt.c
new file mode 100644
index 0000000000..0d0a7d8690
--- /dev/null
+++ b/ext/spice/src/cspice/dcbrt.c
@@ -0,0 +1,142 @@
+/* dcbrt.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static doublereal c_b2 = .33333333333333331;
+
+/* $Procedure DCBRT ( Double precision cube root ) */
+doublereal dcbrt_(doublereal *x)
+{
+ /* System generated locals */
+ doublereal ret_val, d__1, d__2;
+
+ /* Builtin functions */
+ double pow_dd(doublereal *, doublereal *), d_sign(doublereal *,
+ doublereal *);
+
+/* $ Abstract */
+
+/* Return the cube root of a double precision number. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* MATH, ROOT */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* X I Number whose cube root is desired. */
+
+/* $ Detailed_Input */
+
+/* X may be any double precision value. */
+
+/* $ Detailed_Output */
+
+/* DCBRT is the cube root of the input value. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* DCBRT calculates the cube root of the input value by using the */
+/* exponentiation operator to raise the input value to the 1/3 */
+/* power. This operation, however, is performed on the absolute */
+/* value of the input variable, and then the sign of the input */
+/* is transferred to the output value. */
+
+/* All values of the input variable X should be acceptible to the */
+/* DCBRT. */
+
+/* $ Examples */
+
+/* The following table gives sample values of the variable X and */
+/* DCBRT(X) */
+
+/* X DCBRT(X) */
+/* -------------------------------------------------------------- */
+/* 0.0D0 0.0D0 */
+/* 8.0D0 2.0D0 */
+/* -1.0D3 -1.0D1 */
+
+/* $ Restrictions */
+
+/* None */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None */
+
+/* $ Author_and_Institution */
+
+/* W.M. Owen (JPL) */
+
+/* $ Literature_References */
+
+/* None */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WMO) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* d.p. cube root */
+
+/* -& */
+
+ d__2 = abs(*x);
+ d__1 = pow_dd(&d__2, &c_b2);
+ ret_val = d_sign(&d__1, x);
+
+ return ret_val;
+} /* dcbrt_ */
+
diff --git a/ext/spice/src/cspice/dcyldr.c b/ext/spice/src/cspice/dcyldr.c
new file mode 100644
index 0000000000..39831c9b37
--- /dev/null
+++ b/ext/spice/src/cspice/dcyldr.c
@@ -0,0 +1,251 @@
+/* dcyldr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DCYLDR (Derivative of cylindrical w.r.t. rectangular ) */
+/* Subroutine */ int dcyldr_(doublereal *x, doublereal *y, doublereal *z__,
+ doublereal *jacobi)
+{
+ doublereal long__, r__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), vpack_(doublereal *,
+ doublereal *, doublereal *, doublereal *);
+ doublereal injacb[9] /* was [3][3] */, rectan[3];
+ extern /* Subroutine */ int reccyl_(doublereal *, doublereal *,
+ doublereal *, doublereal *), drdcyl_(doublereal *, doublereal *,
+ doublereal *, doublereal *);
+ doublereal zz;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int invort_(doublereal *, doublereal *);
+
+/* $ Abstract */
+
+/* This routine computes the Jacobian of the transformation from */
+/* rectangular to cylindrical coordinates. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* COORDINATES */
+/* DERIVATIVES */
+/* MATRIX */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* X I X-coordinate of point. */
+/* Y I Y-coordinate of point. */
+/* Z I Z-coordinate of point. */
+/* JACOBI O Matrix of partial derivatives. */
+
+/* $ Detailed_Input */
+
+/* X, */
+/* Y, */
+/* Z are the rectangular coordinates of the point at */
+/* which the Jacobian of the map from rectangular */
+/* to cylindrical coordinates is desired. */
+
+/* $ Detailed_Output */
+
+/* JACOBI is the matrix of partial derivatives of the conversion */
+/* between rectangular and cylindrical coordinates. It */
+/* has the form */
+
+/* .- -. */
+/* | dr /dx dr /dy dr /dz | */
+/* | dlong/dx dlong/dy dlong/dz | */
+/* | dz /dx dz /dy dz /dz | */
+/* `- -' */
+
+/* evaluated at the input values of X, Y, and Z. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input point is on the Z-axis (X and Y = 0), the */
+/* Jacobian is undefined. The error SPICE(POINTONZAXIS) */
+/* will be signaled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* When performing vector calculations with velocities it is */
+/* usually most convenient to work in rectangular coordinates. */
+/* However, once the vector manipulations have been performed, */
+/* it is often desirable to convert the rectangular representations */
+/* into cylindrical coordinates to gain insights about phenomena */
+/* in this coordinate frame. */
+
+/* To transform rectangular velocities to derivatives of coordinates */
+/* in a cylindrical system, one uses the Jacobian of the */
+/* transformation between the two systems. */
+
+/* Given a state in rectangular coordinates */
+
+/* ( x, y, z, dx, dy, dz ) */
+
+/* the velocity in cylindrical coordinates is given by the matrix */
+/* equation: */
+
+/* t | t */
+/* (dr, dlong, dz) = JACOBI| * (dx, dy, dz) */
+/* |(x,y,z) */
+
+/* This routine computes the matrix */
+
+/* | */
+/* JACOBI| */
+/* |(x,y,z) */
+
+/* $ Examples */
+
+/* Suppose one is given the bodyfixed rectangular state of an object */
+/* (x(t), y(t), z(t), dx(t), dy(t), dz(t)) as a function of time t. */
+
+/* To find the derivatives of the coordinates of the object in */
+/* bodyfixed cylindrical coordinates, one simply multiplies the */
+/* Jacobian of the transformation from rectangular to cylindrical */
+/* coordinates (evaluated at x(t), y(t), z(t)) by the rectangular */
+/* velocity vector of the object at time t. */
+
+/* In code this looks like: */
+
+/* C */
+/* C Load the rectangular velocity vector vector RECV. */
+/* C */
+/* RECV(1) = DX_DT ( T ) */
+/* RECV(2) = DY_DT ( T ) */
+/* RECV(3) = DZ_DT ( T ) */
+
+/* C */
+/* C Determine the Jacobian of the transformation from */
+/* C rectangular to cylindrical coordinates at the */
+/* C given rectangular coordinates at time T. */
+/* C */
+/* CALL DCYLDR ( X(T), Y(T), Z(T), JACOBI ) */
+
+/* C */
+/* C Multiply the Jacobian on the right by the rectangular */
+/* C velocity to obtain the cylindrical coordinate derivatives */
+/* C CYLV. */
+/* C */
+/* CALL MXV ( JACOBI, RECV, CYLV ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 19-JUL-2001 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* Jacobian of cylindrical w.r.t. rectangular coordinates */
+
+/* -& */
+/* $ Revisions */
+
+/* None. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DCYLDR", (ftnlen)6);
+ }
+
+/* There is a singularity of the Jacobian for points on the z-axis. */
+
+ if (*x == 0. && *y == 0.) {
+ setmsg_("The Jacobian of the transformation from rectangular to cyli"
+ "ndrical coordinates is not defined for points on the z-axis.",
+ (ftnlen)119);
+ sigerr_("SPICE(POINTONZAXIS)", (ftnlen)19);
+ chkout_("DCYLDR", (ftnlen)6);
+ return 0;
+ }
+
+/* We will get the Jacobian of rectangular to cylindrical by */
+/* implicit differentiation. */
+
+/* First move the X,Y and Z coordinates into a vector. */
+
+ vpack_(x, y, z__, rectan);
+
+/* Convert from rectangular to cylindrical coordinates. */
+
+ reccyl_(rectan, &r__, &long__, &zz);
+
+/* Get the Jacobian from cylindrical to rectangular coordinates at */
+/* R, LONG, Z. */
+
+ drdcyl_(&r__, &long__, &zz, injacb);
+
+/* Now invert INJACB to get the Jacobian from rectangular to */
+/* cylindrical coordinates. */
+
+ invort_(injacb, jacobi);
+ chkout_("DCYLDR", (ftnlen)6);
+ return 0;
+} /* dcyldr_ */
+
diff --git a/ext/spice/src/cspice/dcyldr_c.c b/ext/spice/src/cspice/dcyldr_c.c
new file mode 100644
index 0000000000..80909b5182
--- /dev/null
+++ b/ext/spice/src/cspice/dcyldr_c.c
@@ -0,0 +1,213 @@
+/*
+
+-Procedure dcyldr_c (Derivative of cylindrical w.r.t. rectangular )
+
+-Abstract
+
+ This routine computes the Jacobian of the transformation from
+ rectangular to cylindrical coordinates.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ COORDINATES
+ DERIVATIVES
+ MATRIX
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+ void dcyldr_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble jacobi[3][3] )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ x I X-coordinate of point.
+ y I Y-coordinate of point.
+ z I Z-coordinate of point.
+ jacobi O Matrix of partial derivatives.
+
+-Detailed_Input
+
+ x,
+ y,
+ z are the rectangular coordinates of the point at
+ which the Jacobian of the map from rectangular
+ to cylindrical coordinates is desired.
+
+-Detailed_Output
+
+ jacobi is the matrix of partial derivatives of the conversion
+ between rectangular and cylindrical coordinates. It
+ has the form
+
+ .- -.
+ | dr /dx dr /dy dr /dz |
+ | dlon/dx dlon/dy dlon/dz |
+ | dz /dx dz /dy dz /dz |
+ `- -'
+
+ evaluated at the input values of x, y, and z.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the input point is on the z-axis (x and y = 0), the
+ Jacobian is undefined. The error SPICE(POINTONZAXIS)
+ will be signaled.
+
+-Files
+
+ None.
+
+-Particulars
+
+ When performing vector calculations with velocities it is
+ usually most convenient to work in rectangular coordinates.
+ However, once the vector manipulations have been performed,
+ it is often desirable to convert the rectangular representations
+ into cylindrical coordinates to gain insights about phenomena
+ in this coordinate frame.
+
+ To transform rectangular velocities to derivatives of
+ coordinates in a cylindrical system, one uses the Jacobian
+ of the transformation between the two systems.
+
+ Given a state in rectangular coordinates
+
+ ( x, y, z, dx, dy, dz )
+
+ the velocity in cylindrical coordinates is given by the matrix
+ equation:
+
+ t | t
+ (dr, dlon, dz) = jacobi| * (dx, dy, dz)
+ |(x,y,z)
+
+ This routine computes the matrix
+
+ |
+ jacobi|
+ |(x,y,z)
+
+-Examples
+
+ Suppose one is given the bodyfixed rectangular state of an object
+ (x(t), y(t), z(t), dx(t), dy(t), dz(t)) as a function of time t.
+
+ To find the derivatives of the coordinates of the object in
+ bodyfixed cylindrical coordinates, one simply multiplies the
+ Jacobian of the transformation from rectangular to cylindrical
+ coordinates (evaluated at x(t), y(t), z(t)) by the rectangular
+ velocity vector of the object at time t.
+
+ In code this looks like:
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Load the rectangular velocity vector vector recv.
+ ./
+ recv[0] = dx ( t );
+ recv[1] = dy ( t );
+ recv[2] = dz ( t );
+
+ /.
+ Determine the Jacobian of the transformation from
+ rectangular to cylindrical coordinates at the
+ given rectangular coordinates at time T.
+ ./
+ dcyldr_c ( x(t), y(t), z(t), jacobi );
+
+ /.
+ Multiply the Jacobian on the right by the rectangular
+ velocity to obtain the cylindrical coordinate derivatives
+ cylv.
+ ./
+ mxv_c ( jacobi, recv, cylv );
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ W.L. Taber (JPL)
+ N.J. Bachman (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 19-JUL-2001 (WLT) (NJB)
+
+-Index_Entries
+
+ Jacobian of cylindrical w.r.t. rectangular coordinates
+
+-&
+*/
+
+{ /* Begin dcyldr_c */
+
+ chkin_c ( "dcyldr_c" );
+
+
+ dcyldr_ ( (doublereal *) &x,
+ (doublereal *) &y,
+ (doublereal *) &z,
+ (doublereal *) jacobi );
+
+ /*
+ Transpose the Jacobian to create a C-style matrix.
+ */
+ xpose_c ( jacobi, jacobi );
+
+
+ chkout_c ( "dcyldr_c" );
+
+} /* End dcyldr_c */
diff --git a/ext/spice/src/cspice/delfil.c b/ext/spice/src/cspice/delfil.c
new file mode 100644
index 0000000000..6bd7bf4524
--- /dev/null
+++ b/ext/spice/src/cspice/delfil.c
@@ -0,0 +1,286 @@
+/* delfil.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DELFIL ( Delete a file ) */
+/* Subroutine */ int delfil_(char *filnam, ftnlen filnam_len)
+{
+ /* System generated locals */
+ olist o__1;
+ cllist cl__1;
+ inlist ioin__1;
+
+ /* Builtin functions */
+ integer s_cmp(char *, char *, ftnlen, ftnlen), f_inqu(inlist *), f_open(
+ olist *), f_clos(cllist *);
+
+ /* Local variables */
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen);
+ integer lunit;
+ logical opened;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), getlun_(integer *), setmsg_(char *, ftnlen);
+ integer iostat;
+ extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+ logical exists;
+
+/* $ Abstract */
+
+/* Delete a file. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* UTILITY */
+
+/* $ Declarations */
+
+
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* FILNAM I The name of a file to be deleted. */
+
+/* $ Detailed_Input */
+
+/* FILNAM is the name of a file that is to be deleted. Upon */
+/* successful completion of this routine this file will */
+/* no longer exist. The file to be deleted must be closed */
+/* when this routine is called. */
+
+/* $ Detailed_Output */
+
+/* None. */
+
+/* $ Parameters */
+
+/* None */
+
+/* $ Exceptions */
+
+/* 1) If the file name is blank, the error SPICE(BLANKFILENAME) */
+/* is signalled. */
+
+/* 2) If the inquire on the filename specified by FILNAM fails for */
+/* some reason, the error SPICE(INQUIREERROR) will be signalled. */
+
+/* 3) If the file specified by FILNAM is already open, the error */
+/* SPICE(FILECURRENTLYOPEN) will be signalled. */
+
+/* 4) If the file specified by FILNAM does not exist, the error */
+/* SPICE(NOSUCHFILE) will be signalled. */
+
+/* 5) If the attempt to open the file specified by FILNAM fails, */
+/* the error SPICE(FILEOPENFAILED) will be signalled. */
+
+/* 6) If the attempt to close the file with STATUS='DELETE' fails */
+/* the error SPICE(FILEDELETEFAILED) will be signalled. */
+
+/* $ Files */
+
+/* The file specified by FILNAM is opened and then closed by this */
+/* routine with STATUS = 'DELETE' to delete it. The file must be */
+/* closed for this routine to delete it. */
+
+/* $ Particulars */
+
+/* This subroutine is a support utility that deletes a file. */
+
+/* $ Examples */
+
+/* Suppose you wish to delete a file named 'delete.me' in the */
+/* current directory. The code fragment below would accomplish this. */
+
+/* FILE = 'delete.me' */
+/* CALL DELFIL ( FILE ) */
+
+/* $ Restrictions */
+
+/* The file to be deleted must be closed when this routine is */
+/* invoked. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 20-DEC-1995 (KRG) */
+
+/* -& */
+
+/* $ Index_Entries */
+
+/* delete a file */
+
+/* -& */
+
+/* Spicelib Routines */
+
+
+/* Local Variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DELFIL", (ftnlen)6);
+ }
+
+/* Check to see if the filename we got is blank. If it is, signal an */
+/* error and return. */
+
+ if (s_cmp(filnam, " ", filnam_len, (ftnlen)1) == 0) {
+ setmsg_("The file name is blank.", (ftnlen)23);
+ sigerr_("SPICE(BLANKFILENAME)", (ftnlen)20);
+ chkout_("DELFIL", (ftnlen)6);
+ return 0;
+ }
+
+/* We inquire before we try opening anything to see if the file */
+/* exists or is currently open. */
+
+ ioin__1.inerr = 1;
+ ioin__1.infilen = filnam_len;
+ ioin__1.infile = filnam;
+ ioin__1.inex = &exists;
+ ioin__1.inopen = &opened;
+ ioin__1.innum = 0;
+ ioin__1.innamed = 0;
+ ioin__1.inname = 0;
+ ioin__1.inacc = 0;
+ ioin__1.inseq = 0;
+ ioin__1.indir = 0;
+ ioin__1.infmt = 0;
+ ioin__1.inform = 0;
+ ioin__1.inunf = 0;
+ ioin__1.inrecl = 0;
+ ioin__1.innrec = 0;
+ ioin__1.inblank = 0;
+ iostat = f_inqu(&ioin__1);
+
+/* Not too likely, but if the INQUIRE statement fails signal an error */
+/* and return. */
+
+ if (iostat != 0) {
+ setmsg_("INQUIRE statement failed for file '#'. IOSTAT = #.", (ftnlen)
+ 50);
+ errch_("#", filnam, (ftnlen)1, filnam_len);
+ errint_("#", &iostat, (ftnlen)1);
+ sigerr_("SPICE(INQUIREFAILED)", (ftnlen)20);
+ chkout_("DELFIL", (ftnlen)6);
+ return 0;
+ }
+
+/* The file ought to exist if you're trying to delete it. If not, */
+/* signal an error and return. */
+
+ if (! exists) {
+ setmsg_("The file '#' does not exist.", (ftnlen)28);
+ errch_("#", filnam, (ftnlen)1, filnam_len);
+ sigerr_("SPICE(NOSUCHFILE)", (ftnlen)17);
+ chkout_("DELFIL", (ftnlen)6);
+ return 0;
+ }
+
+/* The file that is to be deleted should not be in use, indicated by */
+/* it being open, by anything when we try to delete it. If it is */
+/* open, signal an error and return. */
+
+ if (opened) {
+ setmsg_("The file '#' is currently open and cannot be deleted.", (
+ ftnlen)53);
+ errch_("#", filnam, (ftnlen)1, filnam_len);
+ sigerr_("SPICE(FILECURRENTLYOPEN)", (ftnlen)24);
+ chkout_("DELFIL", (ftnlen)6);
+ return 0;
+ }
+
+/* Get an available logical unit and attempt to open the file. */
+
+ getlun_(&lunit);
+ o__1.oerr = 1;
+ o__1.ounit = lunit;
+ o__1.ofnmlen = filnam_len;
+ o__1.ofnm = filnam;
+ o__1.orl = 0;
+ o__1.osta = "OLD";
+ o__1.oacc = 0;
+ o__1.ofm = 0;
+ o__1.oblnk = 0;
+ iostat = f_open(&o__1);
+
+/* If we had trouble opening the file, signal an appropriate error */
+/* and return. */
+
+ if (iostat != 0) {
+ setmsg_("Attempt to open the file '#' failed.", (ftnlen)36);
+ errch_("#", filnam, (ftnlen)1, filnam_len);
+ sigerr_("SPICE(FILEOPENFAILED)", (ftnlen)21);
+ chkout_("DELFIL", (ftnlen)6);
+ return 0;
+ }
+
+/* We opened the file successfully, so let's try to close it with */
+/* STATUS = 'DELETE'. If this fails, attempt to just close the file, */
+/* signal an error and return. */
+
+ cl__1.cerr = 1;
+ cl__1.cunit = lunit;
+ cl__1.csta = "DELETE";
+ iostat = f_clos(&cl__1);
+ if (iostat != 0) {
+ cl__1.cerr = 0;
+ cl__1.cunit = lunit;
+ cl__1.csta = 0;
+ f_clos(&cl__1);
+ setmsg_("Attempt to delete the file '#' failed.", (ftnlen)38);
+ errch_("#", filnam, (ftnlen)1, filnam_len);
+ sigerr_("SPICE(FILEDELETEFAILED)", (ftnlen)23);
+ chkout_("DELFIL", (ftnlen)6);
+ return 0;
+ }
+ chkout_("DELFIL", (ftnlen)6);
+ return 0;
+} /* delfil_ */
+
diff --git a/ext/spice/src/cspice/deltet.c b/ext/spice/src/cspice/deltet.c
new file mode 100644
index 0000000000..ebe40b9a1d
--- /dev/null
+++ b/ext/spice/src/cspice/deltet.c
@@ -0,0 +1,424 @@
+/* deltet.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static integer c__2 = 2;
+static integer c__200 = 200;
+static integer c__400 = 400;
+
+/* $Procedure DELTET ( Delta ET, ET - UTC ) */
+/* Subroutine */ int deltet_(doublereal *epoch, char *eptype, doublereal *
+ delta, ftnlen eptype_len)
+{
+ /* Initialized data */
+
+ static char missed[20*5] = "DELTET/DELTA_T_A, # " "DELTET/K, # "
+ "DELTET/EB, # " "DELTET/M, # " "DELTET/DELTA_AT, "
+ "# ";
+
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+ doublereal d__1;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer), s_cmp(char *, char *,
+ ftnlen, ftnlen);
+ double d_nint(doublereal *), sin(doublereal);
+
+ /* Local variables */
+ char type__[4];
+ integer i__;
+ doublereal k, m[2];
+ integer n;
+ doublereal dleap[400] /* was [2][200] */;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer nleap;
+ extern /* Subroutine */ int ucase_(char *, char *, ftnlen, ftnlen),
+ errch_(char *, char *, ftnlen, ftnlen);
+ doublereal leaps, ettai;
+ logical found[5];
+ char dtype[1];
+ doublereal ea, eb, ma, et;
+ extern /* Subroutine */ int gdpool_(char *, integer *, integer *, integer
+ *, doublereal *, logical *, ftnlen), sigerr_(char *, ftnlen),
+ chkout_(char *, ftnlen), dtpool_(char *, logical *, integer *,
+ char *, ftnlen, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
+ integer *, ftnlen);
+ extern logical return_(void);
+ doublereal dta, aet;
+
+/* $ Abstract */
+
+/* Return the value of Delta ET (ET-UTC) for an input epoch. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* TIME */
+/* KERNEL */
+
+/* $ Keywords */
+
+/* TIME */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* EPOCH I Input epoch (seconds past J2000). */
+/* EPTYPE I Type of input epoch ('UTC' or 'ET'). */
+/* DELTA O Delta ET (ET-UTC) at input epoch. */
+
+/* $ Detailed_Input */
+
+/* EPOCH is the epoch at which Delta ET is to be computed. */
+/* This may be either UTC or ephemeris seconds past */
+/* J2000, as specified by EPTYPE. */
+
+/* EPTYPE indicates the type of input epoch. It may be either */
+/* of the following: */
+
+/* 'UTC' input is UTC seconds past J2000. */
+/* 'ET' input is ephemeris seconds past J2000. */
+
+
+/* $ Detailed_Output */
+
+/* DELTA is the value of */
+
+/* Delta ET = ET - UTC */
+
+/* at the input epoch. This is added to UTC to give */
+/* ET, or subtracted from ET to give UTC. The routine */
+/* is reversible: that is, given the following calls, */
+
+/* CALL DELTET ( UTC, 'UTC', DEL1 ) */
+/* CALL DELTET ( UTC+DEL1, 'ET', DEL2 ) */
+
+/* the expression */
+
+/* ( DEL1 .EQ. DEL2 ) */
+
+/* is always true. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input epoch is not recognized, the error */
+/* SPICE(INVALIDEPOCH) is signaled. */
+
+/* 2) If the variables necessary for the computation of DELTA */
+/* have not been loaded into the kernel pool, the error */
+/* SPICE(KERNELVARNOTFOUND) is signaled. */
+
+/* 3) If the number of leapseconds in the pool is greater than */
+/* the local leapseconds buffer size, the error */
+/* SPICE(BUFFEROVERFLOW) is signaled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* The constants necessary for computing the offset are taken */
+/* from the kernel pool, where they are assumed to have been */
+/* loaded from a kernel file. */
+
+/* The tables are consulted to determine the number of leap seconds */
+/* preceding the input epoch. Also, an approximation to the periodic */
+/* yearly variation (which has an amplitude of just under two */
+/* milliseconds) in the difference between ET and TAI (Atomic Time) */
+/* is computed. The final value of Delta ET is given by */
+
+/* Delta ET = ( ET - TAI ) + leap seconds */
+
+/* $ Examples */
+
+/* The following example shows how DELTET may be used to convert */
+/* from UTC seconds past J2000 to ephemeris seconds past J2000. */
+
+/* CALL DELTET ( UTCSEC, 'UTC', DELTA ) */
+/* ET = UTCSEC + DELTA */
+
+/* The following example shows how DELTET may be used to convert */
+/* from ephemeris seconds past J2000 to UTC seconds past J2000. */
+
+/* CALL DELTET ( ET, 'ET', DELTA ) */
+/* UTCSEC = ET - DELTA */
+
+/* See the TIME required reading for further examples. */
+
+/* $ Restrictions */
+
+/* The routines UTC2ET and ET2UTC are preferred for conversions */
+/* between UTC and ET. This routine is provided mainly as a utility */
+/* for UTC2ET and ET2UTC. */
+
+/* The kernel pool containing leapseconds and relativistic terms */
+/* MUST be loaded prior to calling this subroutine. Examples */
+/* demonstrating how to load a kernel pool are included in the */
+/* Required Reading file TIME.REQ and in the "Examples" */
+/* section of this header. For more general information about */
+/* kernel pools, please consult the Required Reading file */
+/* KERNEL.REQ. */
+
+/* $ Literature_References */
+
+/* Astronomical Almanac. */
+
+/* $ Author_and_Institution */
+
+/* W.M. Owen (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.2.1, 18-MAY-2010 (BVS) */
+
+/* Removed "C$" marker from text in the header. */
+
+/* - SPICELIB Version 1.2.0, 24-AUG-1998 (WLT) */
+
+/* The previous upgrade introduced an error in the fetch */
+/* of the variable DELTET/M from the kernel pool. This */
+/* error was corrected. */
+
+/* - SPICELIB Version 1.1.0, 20-APR-1998 (NJB) */
+
+/* Calls to RTPOOL were replaced with calls to GDPOOL, which */
+/* does more robust error checking. Check for buffer overflow */
+/* was added. Local declarations were re-organized. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WMO) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* difference between ephemeris time and utc */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.2.0, 24-AUG-1998 (WLT) */
+
+/* The previous upgrade introduced an error in the fetch */
+/* of the variable DELTET/M from the kernel pool. This */
+/* error was corrected. */
+
+/* - SPICELIB Version 1.1.0, 20-APR-1998 (NJB) */
+
+/* Calls to RTPOOL were replaced with calls to GDPOOL, which */
+/* does more robust error checking. */
+
+/* - Beta Version 1.1.0, 06-OCT-1988 (IMU) */
+
+/* Tim Colvin of Rand noticed that times returned by UTC2ET */
+/* and TPARSE differed by one second. Upon closer inspection, */
+/* crack NAIF staff members deduced that in fact Mr. Colvin */
+/* had not loaded the kernel pool, and were surprised to learn */
+/* that no error had occurred. */
+
+/* Multiple FOUND flags and a bevy of new error messages were */
+/* implemented to cope with this unfortunate oversight. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DELTET", (ftnlen)6);
+ }
+
+/* Convert the epoch type to uppercase, to simplify comparisons. */
+
+ ucase_(eptype, type__, eptype_len, (ftnlen)4);
+
+/* Extract the necessary constants from the kernel pool. */
+/* Leap seconds and their epochs are interleaved in DELTA_AT. */
+
+/* DLEAP(1,i) is the number of leap seconds at DLEAP(2,i) UTC */
+/* seconds past J2000. */
+
+ gdpool_("DELTET/DELTA_T_A", &c__1, &c__1, &n, &dta, found, (ftnlen)16);
+ gdpool_("DELTET/K", &c__1, &c__1, &n, &k, &found[1], (ftnlen)8);
+ gdpool_("DELTET/EB", &c__1, &c__1, &n, &eb, &found[2], (ftnlen)9);
+ gdpool_("DELTET/M", &c__1, &c__2, &n, m, &found[3], (ftnlen)8);
+
+/* Check that the number of leapseconds is not too great for our */
+/* buffer size (not likely). */
+
+ dtpool_("DELTET/DELTA_AT", &found[4], &nleap, dtype, (ftnlen)15, (ftnlen)
+ 1);
+ if (nleap > 400) {
+ setmsg_("Number of leapseconds, #, is greater than the number that c"
+ "an be buffered, #.", (ftnlen)77);
+ i__1 = nleap / 2;
+ errint_("#", &i__1, (ftnlen)1);
+ errint_("#", &c__200, (ftnlen)1);
+ sigerr_("SPICE(BUFFERTOOSMALL)", (ftnlen)21);
+ chkout_("DELTET", (ftnlen)6);
+ return 0;
+ }
+ gdpool_("DELTET/DELTA_AT", &c__1, &c__400, &nleap, dleap, &found[4], (
+ ftnlen)15);
+ nleap /= 2;
+ if (! (found[0] && found[1] && found[2] && found[3] && found[4])) {
+ setmsg_("The following, needed to compute Delta ET (ET - UTC), could"
+ " not be found in the kernel pool: #", (ftnlen)94);
+ for (i__ = 1; i__ <= 5; ++i__) {
+ if (! found[(i__1 = i__ - 1) < 5 && 0 <= i__1 ? i__1 : s_rnge(
+ "found", i__1, "deltet_", (ftnlen)337)]) {
+ errch_("#", missed + ((i__1 = i__ - 1) < 5 && 0 <= i__1 ?
+ i__1 : s_rnge("missed", i__1, "deltet_", (ftnlen)338))
+ * 20, (ftnlen)1, (ftnlen)20);
+ }
+ }
+ errch_(", #", ".", (ftnlen)3, (ftnlen)1);
+ sigerr_("SPICE(KERNELVARNOTFOUND)", (ftnlen)24);
+ chkout_("DELTET", (ftnlen)6);
+ return 0;
+ }
+
+/* There are two separate quantities to be determined. First, */
+/* the appropriate number of leap seconds. Second, the size of */
+/* the periodic term ET-TAI. */
+
+
+/* For epochs before the first leap second, return Delta ET at */
+/* the epoch of the leap second minus one second. */
+
+ leaps = dleap[0] - 1;
+
+/* When counting leap seconds for UTC epochs, we can compare */
+/* directly against the values in DLEAP. */
+
+ if (s_cmp(type__, "UTC", (ftnlen)4, (ftnlen)3) == 0) {
+ i__1 = nleap;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ if (*epoch >= dleap[(i__2 = (i__ << 1) - 1) < 400 && 0 <= i__2 ?
+ i__2 : s_rnge("dleap", i__2, "deltet_", (ftnlen)371)]) {
+ leaps = dleap[(i__2 = (i__ << 1) - 2) < 400 && 0 <= i__2 ?
+ i__2 : s_rnge("dleap", i__2, "deltet_", (ftnlen)372)];
+ }
+ }
+
+/* For ET epochs, things are a little tougher. In order to compare */
+/* the input epoch against the epochs of the leap seconds, we need */
+/* to compute ET-TAI at each of the leap epochs. To make sure that */
+/* the computation is reversible, it is always done at the nearest */
+/* ET second (the "approximate ET", or AET). */
+
+/* There must be a hundred ways to do this more efficiently. */
+/* For now, we'll settle for one that works. */
+
+ } else if (s_cmp(type__, "ET", (ftnlen)4, (ftnlen)2) == 0) {
+ i__1 = nleap;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ if (*epoch > dleap[(i__2 = (i__ << 1) - 1) < 400 && 0 <= i__2 ?
+ i__2 : s_rnge("dleap", i__2, "deltet_", (ftnlen)389)]) {
+ d__1 = dleap[(i__2 = (i__ << 1) - 1) < 400 && 0 <= i__2 ?
+ i__2 : s_rnge("dleap", i__2, "deltet_", (ftnlen)391)]
+ + dta + dleap[(i__3 = (i__ << 1) - 2) < 400 && 0 <=
+ i__3 ? i__3 : s_rnge("dleap", i__3, "deltet_", (
+ ftnlen)391)];
+ aet = d_nint(&d__1);
+ ma = m[0] + m[1] * aet;
+ ea = ma + eb * sin(ma);
+ ettai = k * sin(ea);
+ et = dleap[(i__2 = (i__ << 1) - 1) < 400 && 0 <= i__2 ? i__2 :
+ s_rnge("dleap", i__2, "deltet_", (ftnlen)397)] + dta
+ + dleap[(i__3 = (i__ << 1) - 2) < 400 && 0 <= i__3 ?
+ i__3 : s_rnge("dleap", i__3, "deltet_", (ftnlen)397)]
+ + ettai;
+ if (*epoch >= et) {
+ leaps = dleap[(i__2 = (i__ << 1) - 2) < 400 && 0 <= i__2 ?
+ i__2 : s_rnge("dleap", i__2, "deltet_", (ftnlen)
+ 400)];
+ }
+ }
+ }
+
+/* Uh, those are the only choices. */
+
+ } else {
+ setmsg_("Epoch type was #", (ftnlen)16);
+ errch_("#", type__, (ftnlen)1, (ftnlen)4);
+ sigerr_("SPICE(INVALIDEPOCH)", (ftnlen)19);
+ chkout_("DELTET", (ftnlen)6);
+ return 0;
+ }
+
+/* Add the constant offset, leap seconds, and the relativistic term */
+/* (as before, computed at the nearest ET second). */
+
+ if (s_cmp(type__, "ET", (ftnlen)4, (ftnlen)2) == 0) {
+ aet = d_nint(epoch);
+ } else if (s_cmp(type__, "UTC", (ftnlen)4, (ftnlen)3) == 0) {
+ d__1 = *epoch + dta + leaps;
+ aet = d_nint(&d__1);
+ }
+ ma = m[0] + m[1] * aet;
+ ea = ma + eb * sin(ma);
+ ettai = k * sin(ea);
+ *delta = dta + leaps + ettai;
+ chkout_("DELTET", (ftnlen)6);
+ return 0;
+} /* deltet_ */
+
diff --git a/ext/spice/src/cspice/deltet_c.c b/ext/spice/src/cspice/deltet_c.c
new file mode 100644
index 0000000000..8a1a0cb040
--- /dev/null
+++ b/ext/spice/src/cspice/deltet_c.c
@@ -0,0 +1,211 @@
+/*
+
+-Procedure deltet_c ( Delta ET, ET - UTC )
+
+-Abstract
+
+ Return the value of Delta ET (ET-UTC) for an input epoch.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ TIME
+ KERNEL
+
+-Keywords
+
+ TIME
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ void deltet_c ( SpiceDouble epoch,
+ ConstSpiceChar * eptype,
+ SpiceDouble * delta )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ epoch I Input epoch (seconds past J2000).
+ eptype I Type of input epoch ("UTC" or "ET").
+ delta O Delta ET (ET-UTC) at input epoch.
+
+-Detailed_Input
+
+ epoch is the epoch at which "delta ET" is to be computed.
+ `epoch' may be either UTC or ephemeris seconds past
+ J2000, as specified by EPTYPE.
+
+ eptype indicates the type of input epoch. It may be either
+ of the following:
+
+ "UTC" UTC seconds past J2000 UTC.
+
+ "ET" Ephemeris seconds past J2000 TDB,
+ also known as barycentric dynamical
+ time (TDB).
+
+-Detailed_Output
+
+ delta is the value of
+
+ "delta ET" = ET - UTC
+
+ at the input epoch. This is added to UTC to give
+ ET, or subtracted from ET to give UTC. The routine
+ is reversible: that is, given the following calls,
+
+ deltet_c ( utc, "UTC", &del1 );
+ deltet_c ( utc+del1, "ET", &del2 );
+
+ the expression
+
+ ( del1 == del2 )
+
+ is true.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the input epoch is not recognized, the error
+ SPICE(INVALIDEPOCH) is signaled.
+
+ 2) If the variables necessary for the computation of delta
+ have not been loaded into the kernel pool, the error
+ SPICE(KERNELVARNOTFOUND) is signaled.
+
+ 3) If the number of leapseconds in the pool is greater than
+ the local leapseconds buffer size, the error
+ SPICE(BUFFEROVERFLOW) is signaled.
+
+ 4) The error SPICE(EMPTYSTRING) is signaled if the input
+ string `eptype' does not contain at least one character, since
+ the input string cannot be converted to a Fortran-style string in
+ this case.
+
+ 5) The error SPICE(NULLPOINTER) is signaled if the input string
+ pointer is null.
+
+-Files
+
+ None.
+
+-Particulars
+
+ The value of Delta ET is given by
+
+ delta = ( ET - TAI ) + leap seconds
+
+ where TAI is the atomic time corresponding to the input epoch.
+
+-Examples
+
+ The following example shows how deltet_c may be used to convert
+ from UTC seconds past J2000 to TDB seconds past J2000.
+
+ deltet_c ( utcsec, "UTC", &delta );
+ et = utcsec + delta
+
+ The following example shows how deltet_c may be used to convert
+ from ephemeris seconds past J2000 to UTC seconds past J2000.
+
+ deltet_c ( et, "et", &delta );
+ utcsec = et - delta;
+
+ See the TIME Required Reading for further examples.
+
+-Restrictions
+
+ The routines str2et_c and timout_c are preferred for conversions
+ between UTC string and ET represented as seconds past J2000 TDB.
+
+ This routine is provided mainly to provide a method of representing
+ an epoch as UTC seconds past J2000.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.M. Owen (JPL)
+ I.M. Underwood (JPL)
+
+-Literature_References
+
+ [1] Astronomical Almanac.
+
+-Version
+
+ -CSPICE Version 1.0.0, 01-AUG-2003 (NJB) (WMO) (IMU)
+
+-Index_Entries
+
+ difference between ephemeris time and utc
+
+-&
+*/
+
+{ /* Begin deltet_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+ chkin_c ( "deltet_c" );
+
+
+ /*
+ Check the input string `eptype' to make sure the pointer is non-null
+ and the string length is non-zero.
+ */
+ CHKFSTR ( CHK_STANDARD, "deltet_c", eptype );
+
+
+ /*
+ Call the f2c'd Fortran routine.
+ */
+ deltet_ ( ( doublereal * ) &epoch,
+ ( char * ) eptype,
+ ( doublereal * ) delta,
+ ( ftnlen ) strlen(eptype) );
+
+
+ chkout_c ( "deltet_c" );
+
+} /* End deltet_c */
diff --git a/ext/spice/src/cspice/derf_.c b/ext/spice/src/cspice/derf_.c
new file mode 100644
index 0000000000..6afaccdaa3
--- /dev/null
+++ b/ext/spice/src/cspice/derf_.c
@@ -0,0 +1,12 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double erf();
+double derf_(x) doublereal *x;
+#else
+extern double erf(double);
+double derf_(doublereal *x)
+#endif
+{
+return( erf(*x) );
+}
diff --git a/ext/spice/src/cspice/derfc_.c b/ext/spice/src/cspice/derfc_.c
new file mode 100644
index 0000000000..e199f91605
--- /dev/null
+++ b/ext/spice/src/cspice/derfc_.c
@@ -0,0 +1,14 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+extern double erfc();
+
+double derfc_(x) doublereal *x;
+#else
+extern double erfc(double);
+
+double derfc_(doublereal *x)
+#endif
+{
+return( erfc(*x) );
+}
diff --git a/ext/spice/src/cspice/det.c b/ext/spice/src/cspice/det.c
new file mode 100644
index 0000000000..1f6d8d00a5
--- /dev/null
+++ b/ext/spice/src/cspice/det.c
@@ -0,0 +1,134 @@
+/* det.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DET ( Determinant of a double precision 3x3 matrix ) */
+doublereal det_(doublereal *m1)
+{
+ /* System generated locals */
+ doublereal ret_val;
+
+/* $ Abstract */
+
+/* Compute the determinant of a double precision 3x3 matrix. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* MATRIX, MATH */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* M1 I Matrix whose determinant is to be found. */
+
+/* $ Detailed_Input */
+
+/* M1 This variable may be any double precision, 3x3 matrix. */
+
+/* $ Detailed_Output */
+
+/* DET This is the value of the determinant found by direct */
+/* application of the definition of the determinant. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* DET calculates the determinant of M1 in a single arithmetic */
+/* expression which is, effectively, the expansion of M1 about its */
+/* first row. Since the calculation of the determinant involves */
+/* the multiplication of numbers whose magnitudes are unrestricted, */
+/* there is the possibility of floating point overflow or underflow. */
+/* NO error checking or recovery is implemented in this routine. */
+
+/* $ Examples */
+
+/* | 1 2 3 | */
+/* M1 = | 4 5 6 | ----> DET(M1) = 0 */
+/* | 7 8 9 | */
+
+/* | 1 2 3 | */
+/* M1 = | 0 5 6 | ----> DET(M1) = 45 */
+/* | 0 0 9 | */
+
+/* $ Restrictions */
+
+/* No checking is implemented to determine whether M1 will cause */
+/* overflow or underflow in the process of calculating the */
+/* determinant. In most cases, this will not pose a problem. */
+/* The user is required to determine if M1 is suitable matrix */
+/* for DET to operate on. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* $ Files */
+
+/* None */
+
+/* $ Author_and_Institution */
+
+/* W.M. Owen (JPL) */
+
+/* $ Literature_References */
+
+/* None */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WMO) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* determinant of a d.p. 3x3_matrix */
+
+/* -& */
+ ret_val = m1[0] * (m1[4] * m1[8] - m1[7] * m1[5]) - m1[3] * (m1[1] * m1[8]
+ - m1[7] * m1[2]) + m1[6] * (m1[1] * m1[5] - m1[4] * m1[2]);
+
+ return ret_val;
+} /* det_ */
+
diff --git a/ext/spice/src/cspice/det_c.c b/ext/spice/src/cspice/det_c.c
new file mode 100644
index 0000000000..58ead2e371
--- /dev/null
+++ b/ext/spice/src/cspice/det_c.c
@@ -0,0 +1,134 @@
+/*
+
+-Procedure det_c ( Determinant of a double precision 3x3 matrix )
+
+-Abstract
+
+ Compute the determinant of a double precision 3x3 matrix.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ MATRIX, MATH
+
+*/
+
+ #include "SpiceUsr.h"
+ #undef det_c
+
+
+ SpiceDouble det_c ( ConstSpiceDouble m1[3][3] )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ m1 I Matrix whose determinant is to be found.
+
+-Detailed_Input
+
+ m1 This variable may be any double precision, 3x3 matrix.
+
+-Detailed_Output
+
+ det_c This is the value of the determinant found by direct
+ application of the definition of the determinant.
+
+-Parameters
+
+ None.
+
+-Particulars
+
+ det_c calculates the determinant of m1 in a single arithmetic
+ expression which is, effectively, the expansion of m1 about its
+ first row. Since the calculation of the determinant involves
+ the multiplication of numbers whose magnitudes are unrestricted,
+ there is the possibility of floating point overflow or underflow.
+ NO error checking or recovery is implemented in this routine.
+
+-Examples
+
+ | 1 2 3 |
+ M1 = | 4 5 6 | ----> det_c(m1) = 0
+ | 7 8 9 |
+
+ | 1 2 3 |
+ M1 = | 0 5 6 | ----> det_c(m1) = 45
+ | 0 0 9 |
+
+-Restrictions
+
+ No checking is implemented to determine whether M1 will cause
+ overflow or underflow in the process of calculating the
+ determinant. In most cases, this will not pose a problem.
+ The user is required to determine if M1 is suitable matrix
+ for det_c to operate on.
+
+-Exceptions
+
+ Error free.
+
+-Files
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ W.M. Owen (JPL)
+
+-Literature_References
+
+ None
+
+-Version
+
+ -CSPICE Version 1.0.0, 21-OCT-1998 (NJB)
+
+-Index_Entries
+
+ determinant of a d.p. 3x3_matrix
+
+-&
+*/
+
+{ /* Begin det_c */
+
+
+ return ( ( m1[0][0] * ( m1[1][1]*m1[2][2] - m1[2][1]*m1[1][2] ) )
+ - ( m1[0][1] * ( m1[1][0]*m1[2][2] - m1[2][0]*m1[1][2] ) )
+ + ( m1[0][2] * ( m1[1][0]*m1[2][1] - m1[2][0]*m1[1][1] ) ) );
+
+
+} /* End det_c */
diff --git a/ext/spice/src/cspice/dfe.c b/ext/spice/src/cspice/dfe.c
new file mode 100644
index 0000000000..6963d5a011
--- /dev/null
+++ b/ext/spice/src/cspice/dfe.c
@@ -0,0 +1,141 @@
+#include "f2c.h"
+#include "fio.h"
+#include "fmt.h"
+
+y_rsk(Void)
+{
+ if(f__curunit->uend || f__curunit->url <= f__recpos
+ || f__curunit->url == 1) return 0;
+ do {
+ getc(f__cf);
+ } while(++f__recpos < f__curunit->url);
+ return 0;
+}
+y_getc(Void)
+{
+ int ch;
+ if(f__curunit->uend) return(-1);
+ if((ch=getc(f__cf))!=EOF)
+ {
+ f__recpos++;
+ if(f__curunit->url>=f__recpos ||
+ f__curunit->url==1)
+ return(ch);
+ else return(' ');
+ }
+ if(feof(f__cf))
+ {
+ f__curunit->uend=1;
+ errno=0;
+ return(-1);
+ }
+ err(f__elist->cierr,errno,"readingd");
+}
+
+ static int
+y_rev(Void)
+{
+ if (f__recpos < f__hiwater)
+ f__recpos = f__hiwater;
+ if (f__curunit->url > 1)
+ while(f__recpos < f__curunit->url)
+ (*f__putn)(' ');
+ if (f__recpos)
+ f__putbuf(0);
+ f__recpos = 0;
+ return(0);
+}
+
+ static int
+y_err(Void)
+{
+ err(f__elist->cierr, 110, "dfe");
+}
+
+ static int
+y_newrec(Void)
+{
+ y_rev();
+ f__hiwater = f__cursor = 0;
+ return(1);
+}
+
+#ifdef KR_headers
+c_dfe(a) cilist *a;
+#else
+c_dfe(cilist *a)
+#endif
+{
+ f__sequential=0;
+ f__formatted=f__external=1;
+ f__elist=a;
+ f__cursor=f__scale=f__recpos=0;
+ f__curunit = &f__units[a->ciunit];
+ if(a->ciunit>MXUNIT || a->ciunit<0)
+ err(a->cierr,101,"startchk");
+ if(f__curunit->ufd==NULL && fk_open(DIR,FMT,a->ciunit))
+ err(a->cierr,104,"dfe");
+ f__cf=f__curunit->ufd;
+ if(!f__curunit->ufmt) err(a->cierr,102,"dfe")
+ if(!f__curunit->useek) err(a->cierr,104,"dfe")
+ f__fmtbuf=a->cifmt;
+ if(a->cirec <= 0)
+ err(a->cierr,130,"dfe")
+ fseek(f__cf,(long)f__curunit->url * (a->cirec-1),SEEK_SET);
+ f__curunit->uend = 0;
+ return(0);
+}
+#ifdef KR_headers
+integer s_rdfe(a) cilist *a;
+#else
+integer s_rdfe(cilist *a)
+#endif
+{
+ int n;
+ if(!f__init) f_init();
+ f__reading=1;
+ if(n=c_dfe(a))return(n);
+ if(f__curunit->uwrt && f__nowreading(f__curunit))
+ err(a->cierr,errno,"read start");
+ f__getn = y_getc;
+ f__doed = rd_ed;
+ f__doned = rd_ned;
+ f__dorevert = f__donewrec = y_err;
+ f__doend = y_rsk;
+ if(pars_f(f__fmtbuf)<0)
+ err(a->cierr,100,"read start");
+ fmt_bg();
+ return(0);
+}
+#ifdef KR_headers
+integer s_wdfe(a) cilist *a;
+#else
+integer s_wdfe(cilist *a)
+#endif
+{
+ int n;
+ if(!f__init) f_init();
+ f__reading=0;
+ if(n=c_dfe(a)) return(n);
+ if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
+ err(a->cierr,errno,"startwrt");
+ f__putn = x_putc;
+ f__doed = w_ed;
+ f__doned= w_ned;
+ f__dorevert = y_err;
+ f__donewrec = y_newrec;
+ f__doend = y_rev;
+ if(pars_f(f__fmtbuf)<0)
+ err(a->cierr,100,"startwrt");
+ fmt_bg();
+ return(0);
+}
+integer e_rdfe(Void)
+{
+ en_fio();
+ return 0;
+}
+integer e_wdfe(Void)
+{
+ return en_fio();
+}
diff --git a/ext/spice/src/cspice/dgeodr.c b/ext/spice/src/cspice/dgeodr.c
new file mode 100644
index 0000000000..43c8ba9868
--- /dev/null
+++ b/ext/spice/src/cspice/dgeodr.c
@@ -0,0 +1,288 @@
+/* dgeodr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DGEODR ( Derivative of geodetic w.r.t. rectangular ) */
+/* Subroutine */ int dgeodr_(doublereal *x, doublereal *y, doublereal *z__,
+ doublereal *re, doublereal *f, doublereal *jacobi)
+{
+ doublereal long__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), vpack_(doublereal *,
+ doublereal *, doublereal *, doublereal *), errdp_(char *,
+ doublereal *, ftnlen);
+ doublereal injacb[9] /* was [3][3] */;
+ extern /* Subroutine */ int recgeo_(doublereal *, doublereal *,
+ doublereal *, doublereal *, doublereal *, doublereal *), drdgeo_(
+ doublereal *, doublereal *, doublereal *, doublereal *,
+ doublereal *, doublereal *);
+ doublereal rectan[3];
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int invort_(doublereal *, doublereal *);
+ doublereal lat, alt;
+
+/* $ Abstract */
+
+/* This routine computes the Jacobian of the transformation from */
+/* rectangular to geodetic coordinates. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* COORDINATES */
+/* DERIVATIVES */
+/* MATRIX */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* X I X-coordinate of point. */
+/* Y I Y-coordinate of point. */
+/* Z I Z-coordinate of point. */
+/* RE I Equatorial radius of the reference spheroid. */
+/* F I Flattening coefficient. */
+/* JACOBI O Matrix of partial derivatives. */
+
+/* $ Detailed_Input */
+
+/* X, */
+/* Y, */
+/* Z are the rectangular coordinates of the point at */
+/* which the Jacobian of the map from rectangular */
+/* to geodetic coordinates is desired. */
+
+/* RE Equatorial radius of the reference spheroid. */
+
+/* F Flattening coefficient = (RE-RP) / RE, where RP is */
+/* the polar radius of the spheroid. (More importantly */
+/* RP = RE*(1-F).) */
+
+/* $ Detailed_Output */
+
+/* JACOBI is the matrix of partial derivatives of the conversion */
+/* between rectangular and geodetic coordinates. It */
+/* has the form */
+
+/* .- -. */
+/* | DLONG/DX DLONG/DY DLONG/DZ | */
+/* | DLAT/DX DLAT/DY DLAT/DZ | */
+/* | DALT/DX DALT/DY DALT/DZ | */
+/* `- -' */
+
+/* evaluated at the input values of X, Y, and Z. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input point is on the z-axis (X and Y = 0), the */
+/* Jacobian is undefined. The error SPICE(POINTONZAXIS) */
+/* will be signaled. */
+
+/* 2) If the flattening coefficient is greater than or equal to */
+/* one, the error SPICE(VALUEOUTOFRANGE) is signaled. */
+
+/* 3) If the equatorial radius is not positive, the error */
+/* SPICE(BADRADIUS) is signaled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* When performing vector calculations with velocities it is */
+/* usually most convenient to work in rectangular coordinates. */
+/* However, once the vector manipulations have been performed, */
+/* it is often desirable to convert the rectangular representations */
+/* into geodetic coordinates to gain insights about phenomena */
+/* in this coordinate frame. */
+
+/* To transform rectangular velocities to derivatives of coordinates */
+/* in a geodetic system, one uses the Jacobian of the transformation */
+/* between the two systems. */
+
+/* Given a state in rectangular coordinates */
+
+/* ( x, y, z, dx, dy, dz ) */
+
+/* the velocity in geodetic coordinates is given by the matrix */
+/* equation: */
+/* t | t */
+/* (dlon, dlat, dalt) = JACOBI| * (dx, dy, dz) */
+/* |(x,y,z) */
+
+/* This routine computes the matrix */
+
+/* | */
+/* JACOBI| */
+/* |(x, y, z) */
+
+/* $ Examples */
+
+/* Suppose one is given the bodyfixed rectangular state of an object */
+/* (x(t), y(t), z(t), dx(t), dy(t), dz(t)) as a function of time t. */
+
+/* To find the derivatives of the coordinates of the object in */
+/* bodyfixed geodetic coordinates, one simply multiplies the */
+/* Jacobian of the transformation from rectangular to geodetic */
+/* coordinates (evaluated at x(t), y(t), z(t)) by the rectangular */
+/* velocity vector of the object at time t. */
+
+/* In code this looks like: */
+
+/* C */
+/* C Load the rectangular velocity vector vector RECV. */
+/* C */
+/* RECV(1) = DX_DT ( T ) */
+/* RECV(2) = DY_DT ( T ) */
+/* RECV(3) = DZ_DT ( T ) */
+
+/* C */
+/* C Determine the Jacobian of the transformation from */
+/* C rectangular to geodetic coordinates at the rectangular */
+/* C coordinates at time T. */
+/* C */
+/* CALL DGEODR ( X(T), Y(T), Z(T), RE, F, JACOBI ) */
+
+/* C */
+/* C Multiply the Jacobian on the right by the rectangular */
+/* C velocity to obtain the geodetic coordinate derivatives */
+/* C GEOV. */
+/* C */
+/* CALL MXV ( JACOBI, RECV, GEOV ) */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 20-JUL-2001 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* Jacobian of geodetic w.r.t. rectangular coordinates */
+
+/* -& */
+/* $ Revisions */
+
+/* None. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DGEODR", (ftnlen)6);
+ }
+
+/* If the flattening coefficient is greater than one, the polar */
+/* radius computed below is negative. If it's equal to one, the */
+/* polar radius is zero. Either case is a problem, so signal an */
+/* error and check out. */
+
+ if (*f >= 1.) {
+ setmsg_("Flattening coefficient was *.", (ftnlen)29);
+ errdp_("*", f, (ftnlen)1);
+ sigerr_("SPICE(VALUEOUTOFRANGE)", (ftnlen)22);
+ chkout_("DGEODR", (ftnlen)6);
+ return 0;
+ }
+ if (*re <= 0.) {
+ setmsg_("Equatorial Radius <= 0.0D0. RE = *", (ftnlen)34);
+ errdp_("*", re, (ftnlen)1);
+ sigerr_("SPICE(BADRADIUS)", (ftnlen)16);
+ chkout_("DGEODR", (ftnlen)6);
+ return 0;
+ }
+
+/* There is a singularity of the Jacobian for points on the z-axis. */
+
+ if (*x == 0. && *y == 0.) {
+ setmsg_("The Jacobian of the transformation from rectangular to geod"
+ "etic coordinates is not defined for points on the z-axis.", (
+ ftnlen)116);
+ sigerr_("SPICE(POINTONZAXIS)", (ftnlen)19);
+ chkout_("DGEODR", (ftnlen)6);
+ return 0;
+ }
+
+/* We will get the Jacobian of rectangular to geodetic by */
+/* implicit differentiation. */
+
+/* First move the X,Y and Z coordinates into a vector. */
+
+ vpack_(x, y, z__, rectan);
+
+/* Convert from rectangular to geodetic coordinates. */
+
+ recgeo_(rectan, re, f, &long__, &lat, &alt);
+
+/* Get the Jacobian of the transformation from geodetic to */
+/* rectangular coordinates at LONG, LAT, ALT. */
+
+ drdgeo_(&long__, &lat, &alt, re, f, injacb);
+
+/* Now invert INJACB to get the Jacobian of the transformation */
+/* from rectangular to geodetic coordinates. */
+
+ invort_(injacb, jacobi);
+ chkout_("DGEODR", (ftnlen)6);
+ return 0;
+} /* dgeodr_ */
+
diff --git a/ext/spice/src/cspice/dgeodr_c.c b/ext/spice/src/cspice/dgeodr_c.c
new file mode 100644
index 0000000000..166d691ecc
--- /dev/null
+++ b/ext/spice/src/cspice/dgeodr_c.c
@@ -0,0 +1,237 @@
+/*
+
+-Procedure dgeodr_c ( Derivative of geodetic w.r.t. rectangular )
+
+-Abstract
+
+ This routine computes the Jacobian of the transformation from
+ rectangular to geodetic coordinates.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ COORDINATES
+ DERIVATIVES
+ MATRIX
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+
+ void dgeodr_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble jacobi[3][3] )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ X I X-coordinate of point.
+ Y I Y-coordinate of point.
+ Z I Z-coordinate of point.
+ RE I Equatorial radius of the reference spheroid.
+ F I Flattening coefficient.
+ JACOBI O Matrix of partial derivatives.
+
+-Detailed_Input
+
+ x,
+ y,
+ z are the rectangular coordinates of the point at
+ which the Jacobian of the map from rectangular
+ to geodetic coordinates is desired.
+
+ re Equatorial radius of the reference spheroid.
+
+ f Flattening coefficient = (re-rp) / re, where rp is
+ the polar radius of the spheroid. (More importantly
+ rp = re*(1-f).)
+
+-Detailed_Output
+
+ jacobi is the matrix of partial derivatives of the conversion
+ between rectangular and geodetic coordinates. It
+ has the form
+
+ .- -.
+ | dlon/dx dlon/dy dlon/dz |
+ | dlat/dx dlat/dy dlat/dz |
+ | dalt/dx dalt/dy dalt/dz |
+ `- -'
+
+ evaluated at the input values of x, y, and z.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the input point is on the z-axis (x and y = 0), the
+ Jacobian is undefined. The error SPICE(POINTONZAXIS)
+ will be signaled.
+
+ 2) If the flattening coefficient is greater than or equal to
+ one, the error SPICE(VALUEOUTOFRANGE) is signaled.
+
+ 3) If the equatorial radius is not positive, the error
+ SPICE(BADRADIUS) is signaled.
+
+-Files
+
+ None.
+
+-Particulars
+
+ When performing vector calculations with velocities it is
+ usually most convenient to work in rectangular coordinates.
+ However, once the vector manipulations have been performed,
+ it is often desirable to convert the rectangular representations
+ into geodetic coordinates to gain insights about phenomena
+ in this coordinate frame.
+
+ To transform rectangular velocities to derivatives of coordinates
+ in a geodetic system, one uses the Jacobian of the transformation
+ between the two systems.
+
+ Given a state in rectangular coordinates
+
+ ( x, y, z, dx, dy, dz )
+
+ the velocity in geodetic coordinates is given by the matrix
+ equation:
+ t | t
+ (dlon, dlat, dalt) = jacobi| * (dx, dy, dz)
+ |(x,y,z)
+
+ This routine computes the matrix
+
+ |
+ jacobi|
+ |(x, y, z)
+
+
+-Examples
+
+ Suppose one is given the bodyfixed rectangular state of an object
+ (x(t), y(t), z(t), dx(t), dy(t), dz(t)) as a function of time t.
+
+ To find the derivatives of the coordinates of the object in
+ bodyfixed geodetic coordinates, one simply multiplies the
+ Jacobian of the transformation from rectangular to geodetic
+ coordinates (evaluated at x(t), y(t), z(t)) by the rectangular
+ velocity vector of the object at time t.
+
+ In code this looks like:
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+
+ /.
+ Load the rectangular velocity vector vector recv.
+ ./
+ recv[0] = dx_dt ( t );
+ recv[1] = dy_dt ( t );
+ recv[2] = dz_dt ( t );
+
+ /.
+ Determine the Jacobian of the transformation from
+ rectangular to geodetic coordinates at the rectangular
+ coordinates at time t.
+ ./
+ dgeodr_c ( x(t), y(t), z(t), re, f, jacobi );
+
+ /.
+ Multiply the Jacobian on the right by the rectangular
+ velocity to obtain the geodetic coordinate derivatives
+ geov.
+ ./
+ mxv_c ( jacobi, recv, geov );
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ W.L. Taber (JPL)
+ N.J. Bachman (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 18-JUL-2001 (WLT) (NJB)
+
+-Index_Entries
+
+ Jacobian of geodetic w.r.t. rectangular coordinates
+
+-&
+*/
+
+{ /* Begin dgeodr_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dgeodr_c" );
+
+
+ dgeodr_ ( (doublereal *) &x,
+ (doublereal *) &y,
+ (doublereal *) &z,
+ (doublereal *) &re,
+ (doublereal *) &f,
+ (doublereal *) jacobi );
+
+ /*
+ Transpose the Jacobian to create a C-style matrix.
+ */
+ xpose_c ( jacobi, jacobi );
+
+
+ chkout_c ( "dgeodr_c" );
+
+} /* End dgeodr_c */
diff --git a/ext/spice/src/cspice/dhfa.c b/ext/spice/src/cspice/dhfa.c
new file mode 100644
index 0000000000..f1f018d21e
--- /dev/null
+++ b/ext/spice/src/cspice/dhfa.c
@@ -0,0 +1,346 @@
+/* dhfa.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DHFA ( Time derivative of half angle ) */
+doublereal dhfa_(doublereal *state, doublereal *bodyr)
+{
+ /* System generated locals */
+ doublereal ret_val, d__1, d__2;
+
+ /* Builtin functions */
+ double sqrt(doublereal);
+
+ /* Local variables */
+ doublereal base;
+ extern doublereal vdot_(doublereal *, doublereal *);
+ doublereal p[3], r__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errdp_(char *,
+ doublereal *, ftnlen), unorm_(doublereal *, doublereal *,
+ doublereal *);
+ extern logical vzero_(doublereal *);
+ extern /* Subroutine */ int sigerr_(char *, ftnlen);
+ doublereal rngrat;
+ extern /* Subroutine */ int chkout_(char *, ftnlen), setmsg_(char *,
+ ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Calculate the value of the time derivative of the */
+/* half angle of a spherical body given a state vector */
+/* STATE and body radius BODYR. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* None. */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* STATE I SPICE state vector */
+/* BODYR I Radius of body */
+
+/* $ Detailed_Input */
+
+/* STATE the state vector of a target body as seen from an */
+/* observer. */
+
+/* BODYR the radius of the target body observed from the */
+/* position in STATE; the target body assumed as a sphere. */
+
+/* $ Detailed_Output */
+
+/* The function returns the double precision value of the time */
+/* derivative of the half angle of a spherical body in radians */
+/* per second. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) A negative value for BODYR causes SPICE(BADRADIUS) to signal. */
+
+/* 2) A position component of STATE equaling the zero vector */
+/* causes SPICE(DEGENERATECASE) to signal. */
+
+/* 3) A condition where the body radius exceeds the distance from */
+/* the body to the observer causes SPICE(BADGEOMETRY) to signal. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* In this discussion, the notation */
+
+/* < V1, V2 > */
+
+/* indicates the dot product of vectors V1 and V2. */
+
+/* The expression */
+
+/* body_radius */
+/* sin(ALPHA) = ----------- (1) */
+/* range */
+
+/* describes the half angle (ALPHA) of a spherical body, i.e. the */
+/* angular radius of the spherical body as viewed by an observer at */
+/* distance 'range'. */
+
+/* Solve for ALPHA */
+
+/* -1 body_radius */
+/* ALPHA = sin ( ----------- ) (2) */
+/* range */
+
+/* Take the derivative of ALPHA with respect to time */
+
+/* d 1 d body_radius */
+/* --(ALPHA) = --------------------- * __ (----------- ) (3) */
+/* dt 1 - body_radius 2 1/2 dt range */
+/* ( [ ----------- ] ) */
+/* range */
+
+/* d - body_radius 1 d */
+/* --(ALPHA) = --------------------- * ------ * __(range) (4) */
+/* dt 1 - body_radius 2 1/2 2 dt */
+/* ( [ ----------- ] ) range */
+/* range */
+
+/* With */
+/* _ _ */
+/* d < R, V > - */
+/* -- ( range ) = -------- , range = ||R|| (5) */
+/* dt - */
+/* ||R|| */
+
+/* Apply (5) to equation (4) */
+/* _ _ */
+/* d - body_radius 1 < R, V > */
+/* --(ALPHA) = --------------------- * ------ * -------- (6) */
+/* dt 1 - body_radius 2 1/2 2 range */
+/* ( [ ----------- ] ) range */
+/* range */
+
+/* Carry range through the denominator gives */
+
+/* _ _ */
+/* d - body_radius < R, V > */
+/* --(ALPHA) = --------------------- * -------- (7) */
+/* dt 2 2 1/2 2 */
+/* (range - body_radius ) range */
+
+/* So since */
+/* - - _ _ */
+/* ^ - < R, V > < R, V > */
+/* < R, V > = --- = -------- */
+/* - range */
+/* ||R|| */
+
+/* ^ _ */
+/* d - body_radius < R, V > */
+/* --(ALPHA) = --------------------- * -------- (8) */
+/* dt 2 2 1/2 */
+/* (range - body_radius ) range */
+
+
+/* $ Examples */
+
+/* PROGRAM DHFA_EX */
+/* IMPLICIT NONE */
+
+/* INTEGER DIM */
+
+/* DOUBLE PRECISION ET */
+/* DOUBLE PRECISION LT */
+/* DOUBLE PRECISION DHADT */
+/* DOUBLE PRECISION RAD (3) */
+/* DOUBLE PRECISION STATE (6) */
+
+/* INTEGER STRLEN */
+/* PARAMETER ( STRLEN = 64 ) */
+
+/* CHARACTER*(STRLEN) BEGSTR */
+
+
+/* DOUBLE PRECISION SPD */
+/* DOUBLE PRECISION DHFA */
+/* C */
+/* C Load kernels. */
+/* C */
+/* CALL FURNSH ('standard.tm') */
+
+/* C */
+/* C An approximate time corresponding to a maximal angular */
+/* C separation between the earth and Moon as seen from the sun. */
+/* C */
+/* BEGSTR = '2007-DEC-17 04:04:46.935443 (TDB)' */
+/* CALL STR2ET( BEGSTR, ET ) */
+
+/* CALL BODVRD ('SUN', 'RADII', 3, DIM, RAD ) */
+
+/* CALL SPKEZR ('MOON', ET, 'J2000', 'NONE', 'SUN', STATE, LT ) */
+
+/* C */
+/* C The derivative of the half angle at ET should have a near-to */
+/* C maximal value as the Moon velocity vector points either */
+/* C towards the sun or away. */
+/* C */
+/* DHADT = DHFA( STATE, RAD(1) ) */
+/* WRITE(*,*) 'Half angle derivative at begin time : ', DHADT */
+
+/* C */
+/* C Two weeks later the derivate should have a similar */
+/* C magnitude but the opposite sign. */
+/* C */
+/* ET = SPD() * 14.D0 + ET */
+
+/* CALL SPKEZR ('MOON', ET, 'J2000', 'NONE', 'SUN', STATE, LT ) */
+
+/* DHADT = DHFA( STATE, RAD(1) ) */
+/* WRITE(*,*) 'Half angle derivative two weeks later: ', DHADT */
+
+/* END */
+
+/* The program compiled on OS X with g77 outputs (radians/sec): */
+
+/* Half angle derivative at begin time : -2.53879935E-11 */
+/* Half angle derivative two weeks later: 2.94362059E-11 */
+
+/* As expected, the derivate values have similar magnitudes but */
+/* opposite signs. */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* E.D. Wright (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 06-JUL-2009 (EDW) */
+
+/* Rename of the ZZDHA call to DHFA. */
+
+/* - SPICELIB Version 1.0.0, 10-FEB-2009 (EDW) (NJB) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* time derivative of half angle */
+
+/* -& */
+
+/* SPICELIB functions */
+
+ if (return_()) {
+ ret_val = 0.;
+ return ret_val;
+ } else {
+ chkin_("DHFA", (ftnlen)4);
+ }
+
+/* A zero body radius (point object) returns a zero for the */
+/* derivative. A negative value indicates an error */
+/* the caller should diagnose. */
+
+ if (*bodyr == 0.) {
+ ret_val = 0.;
+ chkout_("DHFA", (ftnlen)4);
+ return ret_val;
+ } else if (*bodyr < 0.) {
+ ret_val = 0.;
+ setmsg_("Non physical case. The input body radius has a negative val"
+ "ue.", (ftnlen)62);
+ sigerr_("SPICE(BADRADIUS)", (ftnlen)16);
+ chkout_("DHFA", (ftnlen)4);
+ return ret_val;
+ }
+
+/* Normalize the position component of STATE. Store the unit vector */
+/* in P. */
+
+ unorm_(state, p, &r__);
+ if (vzero_(p)) {
+ ret_val = 0.;
+ setmsg_("The position component of the input state vector equals the"
+ " zero vector.", (ftnlen)72);
+ sigerr_("SPICE(DEGENERATECASE)", (ftnlen)21);
+ chkout_("DHFA", (ftnlen)4);
+ return ret_val;
+ }
+
+/* Calculate the range rate. */
+
+ rngrat = vdot_(p, &state[3]);
+
+/* Confirm R > BODYR. */
+
+/* Computing 2nd power */
+ d__1 = r__;
+/* Computing 2nd power */
+ d__2 = *bodyr;
+ base = d__1 * d__1 - d__2 * d__2;
+ if (base <= 0.) {
+ ret_val = 0.;
+ setmsg_("Invalid case. The body radius, #1, equals or exceeds the ra"
+ "nge to the target, #2.", (ftnlen)81);
+ errdp_("#1", bodyr, (ftnlen)2);
+ errdp_("#2", &r__, (ftnlen)2);
+ sigerr_("SPICE(BADGEOMETRY)", (ftnlen)18);
+ chkout_("DHFA", (ftnlen)4);
+ return ret_val;
+ }
+
+/* Now we safely take the square root of BASE. */
+
+ base = sqrt(base);
+ ret_val = -(rngrat * *bodyr) / (base * r__);
+ chkout_("DHFA", (ftnlen)4);
+ return ret_val;
+} /* dhfa_ */
+
diff --git a/ext/spice/src/cspice/diags2.c b/ext/spice/src/cspice/diags2.c
new file mode 100644
index 0000000000..787c534219
--- /dev/null
+++ b/ext/spice/src/cspice/diags2.c
@@ -0,0 +1,574 @@
+/* diags2.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__4 = 4;
+static doublereal c_b6 = 1.;
+static integer c__2 = 2;
+
+/* $Procedure DIAGS2 ( Diagonalize symmetric 2x2 matrix ) */
+/* Subroutine */ int diags2_(doublereal *symmat, doublereal *diag, doublereal
+ *rotate)
+{
+ /* Initialized data */
+
+ static doublereal ident[4] /* was [2][2] */ = { 1.,0.,0.,1. };
+
+ /* System generated locals */
+ doublereal d__1, d__2, d__3;
+
+ /* Local variables */
+ doublereal tmpd, tmpv[2], a, b, c__, root1[2], root2[2], scale;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), vhatg_(doublereal *,
+ integer *, doublereal *), moved_(doublereal *, integer *,
+ doublereal *), rquad_(doublereal *, doublereal *, doublereal *,
+ doublereal *, doublereal *);
+ doublereal eigvec[2];
+ extern /* Subroutine */ int chkout_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Diagonalize a symmetric 2x2 matrix. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* ROTATION */
+
+/* $ Keywords */
+
+/* ELLIPSE */
+/* MATRIX */
+/* ROTATION */
+/* TRANSFORMATION */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+
+/* SYMMAT I A symmetric 2x2 matrix. */
+/* DIAG O A diagonal matrix similar to SYMMAT. */
+/* ROTATE O A rotation used as the similarity transformation. */
+
+/* $ Detailed_Input */
+
+/* SYMMAT A symmetric 2x2 matrix. That is, SYMMAT has the */
+/* form */
+
+/* +- -+ */
+/* | A B | */
+/* | |. */
+/* | B C | */
+/* +- -+ */
+
+/* This routine uses only the upper-triangular */
+/* elements of SYMMAT, that is, the elements */
+
+/* SYMMAT(1,1) */
+/* SYMMAT(1,2) */
+/* SYMMAT(2,2) */
+
+/* to determine the outputs DIAG and ROTATE. */
+
+/* $ Detailed_Output */
+
+/* DIAG, */
+/* ROTATE are, respectively, a diagonal matrix and a 2x2 */
+/* rotation matrix that satisfy the equation */
+
+/* T */
+/* DIAG = ROTATE * SYMMAT * ROTATE. */
+
+/* In other words, DIAG is similar to SYMMAT, and */
+/* ROTATE is a change-of-basis matrix that */
+/* diagonalizes SYMMAT. DIAGS2 chooses ROTATE so */
+/* that its angle of rotation has the smallest */
+/* possible magnitude. If there are two rotations */
+/* that meet these criteria (they will be inverses of */
+/* one another), either rotation may be chosen. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) The matrix element SYMMAT(2,1) is not used in this routine's */
+/* computations, so the condition */
+
+/* SYMMAT(1,2) .NE. SYMMAT(2,1) */
+
+/* has no effect on this routine's outputs. */
+
+/* $ Particulars */
+
+/* The capability of diagonalizing a 2x2 symmetric matrix is */
+/* especially useful in a number of geometric applications */
+/* involving quadratic curves such as ellipses. Such curves are */
+/* described by expressions of the form */
+
+/* 2 2 */
+/* A x + B xy + C y + D x + E y + F = 0. */
+
+/* Diagonalization of the matrix */
+
+/* +- -+ */
+/* | A B/2 | */
+/* | | */
+/* | B/2 C | */
+/* +- -+ */
+
+/* allows us to perform a coordinate transformation (a rotation, */
+/* specifically) such that the equation of the curve becomes */
+
+/* 2 2 */
+/* P u + Q v + R u + S v + T = 0 */
+
+/* in the transformed coordinates. This form is much easier to */
+/* handle. If the quadratic curve in question is an ellipse, */
+/* we can easily find its center, semi-major axis, and semi-minor */
+/* axis from the second equation. */
+
+/* Ellipses turn up frequently in navigation geometry problems; */
+/* for example, the limb and terminator (if we treat the Sun as a */
+/* point source) of a body modelled as a tri-axial ellipsoid are */
+/* ellipses. */
+
+/* A mathematical note: because SYMMAT is symmetric, we can ALWAYS */
+/* find an orthogonal similarity transformation that diagonalizes */
+/* SYMMAT, and we can choose the similarity transformation to be a */
+/* rotation matrix. By `orthogonal' we mean that if the ROTATE is */
+/* the matrix in question, then */
+
+/* T T */
+/* ROTATE ROTATE = ROTATE ROTATE = I. */
+
+/* The reasons this routine handles only the 2x2 case are: first, */
+/* the 2x2 case is much simpler than the general case, in which */
+/* iterative diagonalization methods must be used, and second, the */
+/* 2x2 case is adequate for solving problems involving ellipses in */
+/* 3 dimensional space. Finally, this routine can be used to */
+/* support a routine that solves the general-dimension */
+/* diagonalization problem for symmetric matrices. */
+
+/* Another feature of the routine that might provoke curiosity is */
+/* its insistence on choosing the diagonalization matrix that */
+/* rotates the original basis vectors by the smallest amount. The */
+/* rotation angle of ROTATE is of no concern for most applications, */
+/* but can be important if this routine is used as part of an */
+/* iterative diagonalization method for higher-dimensional matrices. */
+/* In that case, it is most undesirable to interchange diagonal */
+/* matrix elements willy-nilly; the matrix to be diagonalized could */
+/* get ever closer to being diagonal without converging. Choosing */
+/* the smallest rotation angle precludes this possibility. */
+
+/* $ Examples */
+
+/* 1) A case that can be verified by hand computation: */
+/* Suppose SYMMAT is */
+
+/* +- -+ */
+/* | 1.0D0 4.0D0 | */
+/* | | */
+/* | 4.0D0 -5.0D0 | */
+/* +- -+ */
+
+/* Then SYMMAT is similar to the diagonal matrix */
+
+/* +- -+ */
+/* | 3.0D0 0.0D0 | */
+/* | | */
+/* | 0.0D0 -7.0D0 | */
+/* +- -+ */
+
+/* so */
+
+/* DIAG(1,1) = 3.D0 */
+/* DIAG(2,1) = 0.D0 */
+/* DIAG(1,2) = 0.D0 */
+/* DIAG(2,2) = -7.D0 */
+
+/* and ROTATE is */
+
+/* +- -+ */
+/* | 0.894427191 -0.447213595 | */
+/* | | */
+/* | 0.447213595 0.894427191 | */
+/* +- -+ */
+
+/* which is an approximation to */
+
+/* +- -+ */
+/* | 0.4 * 5**(1/2) -0.2 * 5**(1/2) | */
+/* | | */
+/* | 0.2 * 5**(1/2) 0.4 * 5**(1/2) | */
+/* +- -+ */
+
+
+/* 2) Suppose we want to find the semi-axes of the ellipse defined */
+/* by */
+/* 2 2 */
+/* 27 x + 10 xy + 3 y = 1. */
+
+/* We can write the above equation as the matrix equation */
+
+/* +- -+ +- -+ +- -+ */
+/* | x y | | 27 5 | | x | = 1; */
+/* +- -+ | | | | */
+/* | 5 3 | | y | */
+/* +- -+ +- -+ */
+
+/* let SYMMAT be the symmetric matrix on the left. The code */
+/* fragment */
+
+/* SYMMAT(1,1) = 27.D0 */
+/* SYMMAT(2,1) = 5.D0 */
+/* SYMMAT(1,2) = 5.D0 */
+/* SYMMAT(2,2) = 3.D0 */
+
+/* CALL DIAGS2 ( SYMMAT, DIAG, ROTATE ) */
+
+/* will return DIAG, an array containing the eigenvalues of */
+/* SYMMAT, and ROTATE, the coordinate transformation required */
+/* to diagonalize SYMMAT. In this case, */
+
+/* DIAG(1,1) = 28.D0 */
+/* DIAG(2,1) = 0.D0 */
+/* DIAG(1,2) = 0.D0 */
+/* DIAG(2,2) = 2.D0 */
+
+/* and */
+
+/* ROTATE(1,1) = 0.980580676D0 */
+/* ROTATE(2,1) = 0.196116135D0 */
+/* ROTATE(1,2) = -0.196116135D0 */
+/* ROTATE(2,2) = 0.980580676D0 */
+
+/* The columns of ROTATE give the ellipse's axes, after scaling */
+/* them by */
+
+/* 1 1 */
+/* ---------------- and --------------- */
+/* ____________ ____________ */
+/* \/ DIAG(1,1) \/ DIAG(2,2) */
+
+/* respectively. */
+
+/* If SMAJOR and SMINOR are semi-major and semi-minor axes, */
+/* we can find them as shown below. For brevity, we omit the */
+/* check for zero or negative eigenvalues. Negative or zero */
+/* eigenvalues will occur only as a result of round-off error; */
+/* mathematically, the eigenvalues of the matrix SYMMAT are */
+/* guaranteed to be positive, since they are the reciprocals of */
+/* the squares of the lengths of the ellipse's semi-axes. */
+
+/* DO I = 1, 2 */
+/* SMAJOR(I) = ROTATE(I,1) / DSQRT( DIAG(1,1) ) */
+/* SMINOR(I) = ROTATE(I,2) / DSQRT( DIAG(2,2) ) */
+/* END DO */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* [1] Calculus, Vol. II. Tom Apostol. John Wiley & Sons, 1969. */
+/* See Chapter 5, `Eigenvalues of Operators Acting on Euclidean */
+/* Spaces'. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.2.0, 06-SEP-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in VHATG and SWAPD calls. */
+
+/* - SPICELIB Version 1.1.0, 24-JAN-2002 (EDW) */
+
+/* Edited incorrect examples in the header. The example */
+/* outputs did not correspond to the actual function */
+/* of the routine. */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 04-NOV-1990 (NJB) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* diagonalize symmetric 2x2_matrix */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.2.0, 06-SEP-2005 (NJB) */
+
+/* Updated to remove non-standard use of duplicate arguments */
+/* in VHATG and SWAPD calls. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DIAGS2", (ftnlen)6);
+ }
+
+/* We check for the case of a diagonal input matrix, since */
+/* eigenvector determination is simplified by ruling out this */
+/* case. */
+ if (symmat[2] == 0.) {
+ moved_(ident, &c__4, rotate);
+ moved_(symmat, &c__4, diag);
+
+/* Explicity zero out the (2,1) entry of DIAG, since DIAG is */
+/* guaranteed to be diagonal. */
+
+ diag[1] = 0.;
+ chkout_("DIAGS2", (ftnlen)6);
+ return 0;
+ }
+
+/* Getting here means there's some actual work to do. We start out */
+/* by scaling our matrix, in order to reduce the chance of overflow. */
+/* We divide everything by the largest magnitude of any element of */
+/* SYMMAT. We're guaranteed that SCALE is non-zero, since the 0 */
+/* matrix is diagonal. */
+
+/* Computing MAX */
+ d__1 = abs(symmat[0]), d__2 = abs(symmat[2]), d__1 = max(d__1,d__2), d__2
+ = abs(symmat[3]);
+ scale = max(d__1,d__2);
+ a = symmat[0] / scale;
+ b = symmat[2] / scale;
+ c__ = symmat[3] / scale;
+
+/* Compute the eigenvalues of the scaled version of SYMMAT. The */
+/* eigenvalues are roots of the equation */
+
+/* DET ( (1 / SCALE) * SYMMAT - x * IDENTITY ) = 0, */
+
+/* or equivalently, */
+
+/* 2 2 */
+/* x - ( A + C ) x + ( AC - B ) = 0. */
+
+
+ d__1 = -(a + c__);
+/* Computing 2nd power */
+ d__3 = b;
+ d__2 = a * c__ - d__3 * d__3;
+ rquad_(&c_b6, &d__1, &d__2, root1, root2);
+
+/* ROOT1 is the root corresponding to the positive discriminant term; */
+/* this is guaranteed by RQUAD. */
+
+ diag[0] = root1[0];
+ diag[1] = 0.;
+ diag[2] = 0.;
+ diag[3] = root2[0];
+
+/* Our next job is to find an eigenvector corresponding to the */
+/* eigenvalue of smaller magnitude. We can unitize it and choose */
+/* an orthogonal unit vector so as to create the desired rotation */
+/* matrix. */
+
+/* If our original matrix is */
+
+/* +- -+ */
+/* | A B | */
+/* | |, */
+/* | B C | */
+/* +- -+ */
+
+/* then the matrix */
+
+/* +- -+ */
+/* | A - DIAG(x,x) B | */
+/* | | */
+/* | B C - DIAG(x,x) | */
+/* +- -+ */
+
+/* maps to zero all elements of the eigenspace corresponding to */
+/* DIAG(x,x), where x is either 1 or 2. */
+
+/* So */
+
+/* +- -+ +- -+ */
+/* | B | | DIAG(x,x) - C | */
+/* | | and | | */
+/* | DIAG(x,x) - A | | B | */
+/* +- -+ +- -+ */
+
+/* are candidates for eigenvectors for DIAG(x,x). To minimize */
+/* loss of accuracy in our eigenvector due to subtraction of */
+/* nearly equal quantities, we choose the vector in which the */
+/* term involving the eigenvalue has the larger magnitude. The */
+/* rigorous justification of this choice would literally take */
+/* pages of explanation, and we are not going to go through it */
+/* here. In most cases, either choice is satisfactory, and in */
+/* the case where cancellation is a problem, our choice is */
+/* preferable. */
+
+/* Note that there is nothing to be gained as far as accuracy is */
+/* concerned by working with one eigenvalue as opposed to the */
+/* other: the magnitudes of the quantities DIAG(x,x) - A and */
+/* DIAG(x,x) - C would be interchanged by taking x = '2' instead */
+/* of x = '1'. */
+
+ if ((d__1 = diag[0] - a, abs(d__1)) >= (d__2 = diag[0] - c__, abs(d__2)))
+ {
+
+/* In this case, the second eigenvector component EIGVEC(2) */
+/* should be larger than |B|; we explain why in detail below. */
+/* We use the MAX function below to guard against reversal of the */
+/* inequality due to round-off error. */
+
+ eigvec[0] = b;
+/* Computing MAX */
+ d__1 = diag[0] - a, d__2 = abs(b);
+ eigvec[1] = max(d__1,d__2);
+
+/* Recall that DIAG(1,1) is an eigenvalue of the scaled version */
+/* of SYMMAT */
+
+/* +- -+ */
+/* | A B | */
+/* | |. */
+/* | B C | */
+/* +- -+ */
+
+/* DIAG(1,1) is the positive-discriminant root of this matrix's */
+/* characteristic equation. EIGVEC's y-component */
+
+/* DIAG(1,1) - A */
+
+/* is positive and of magnitude at least as large as that of B, */
+/* since it is the larger of */
+/* ______________________ */
+/* / 2 */
+/* C - A / ( A - C ) 2 */
+/* DIAG(1,1) - A = ----- + \ / ---------- + B */
+/* 2 \/ 4 */
+
+/* and */
+/* ______________________ */
+/* / 2 */
+/* A - C / ( A - C ) 2 */
+/* DIAG(1,1) - C = ----- + \ / ---------- + B */
+/* 2 \/ 4 */
+
+/* Equality between these expressions can occur only when A is */
+/* equal to C, in which case both expressions are equal (except */
+/* for round-off error) to |B|. */
+
+
+/* So the argument of EIGVEC is in the interval [pi/4, 3*pi/4]. */
+/* The second eigenvector is EIGVEC, and the first */
+/* eigenvector is found by rotating EIGVEC by -pi/2. Since */
+/* DIAG(1,1) is the eigenvalue for the SECOND eigenvector, we */
+/* must swap the eigenvalues. */
+
+
+/* Unitize the eigenvector. */
+
+ vhatg_(eigvec, &c__2, tmpv);
+ moved_(tmpv, &c__2, eigvec);
+ rotate[0] = eigvec[1];
+ rotate[1] = -eigvec[0];
+ rotate[2] = eigvec[0];
+ rotate[3] = eigvec[1];
+
+/* Swap DIAG(1,1) and DIAG(2,2). */
+
+ tmpd = diag[3];
+ diag[3] = diag[0];
+ diag[0] = tmpd;
+ } else {
+/* Computing MAX */
+ d__1 = diag[0] - c__, d__2 = abs(b);
+ eigvec[0] = max(d__1,d__2);
+ eigvec[1] = b;
+
+/* The x-component of EIGVEC is positive and has magnitude */
+/* greater than or equal to that of the y-component of EIGVEC. */
+/* The argument of EIGVEC is in [-pi/4, pi/4], and the second */
+/* eigenvector is found by rotating EIGVEC by pi/2. */
+
+
+/* Unitize the eigenvector. */
+
+ vhatg_(eigvec, &c__2, tmpv);
+ moved_(tmpv, &c__2, eigvec);
+ rotate[0] = eigvec[0];
+ rotate[1] = eigvec[1];
+ rotate[2] = -eigvec[1];
+ rotate[3] = eigvec[0];
+ }
+
+/* We must scale the eigenvalues. */
+
+ diag[0] *= scale;
+ diag[3] *= scale;
+ chkout_("DIAGS2", (ftnlen)6);
+ return 0;
+} /* diags2_ */
+
diff --git a/ext/spice/src/cspice/diags2_c.c b/ext/spice/src/cspice/diags2_c.c
new file mode 100644
index 0000000000..7eff8e4734
--- /dev/null
+++ b/ext/spice/src/cspice/diags2_c.c
@@ -0,0 +1,551 @@
+/*
+
+-Procedure diags2_c ( Diagonalize symmetric 2x2 matrix )
+
+-Abstract
+
+ Diagonalize a symmetric 2x2 matrix.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ ROTATION
+
+-Keywords
+
+ ELLIPSE
+ MATRIX
+ ROTATION
+ TRANSFORMATION
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+ #undef diags2_c
+
+
+ void diags2_c ( ConstSpiceDouble symmat [2][2],
+ SpiceDouble diag [2][2],
+ SpiceDouble rotate [2][2] )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+
+ symmat I A symmetric 2x2 matrix.
+ diag O A diagonal matrix similar to symmat.
+ rotate O A rotation used as the similarity transformation.
+
+-Detailed_Input
+
+ symmat A symmetric 2x2 matrix. That is, symmat has the
+ form
+
+ +- -+
+ | A B |
+ | |.
+ | B C |
+ +- -+
+
+ This routine uses only the upper-triangular
+ elements of symmat, that is, the elements
+
+ symmat[0][0]
+ symmat[0][1]
+ symmat[1][1]
+
+ to determine the outputs diag and rotate.
+
+-Detailed_Output
+
+ diag,
+ rotate are, respectively, a diagonal matrix and a 2x2
+ rotation matrix that satisfy the equation
+
+ T
+ diag = rotate * symmat * rotate.
+
+ In other words, diag is similar to symmat, and
+ rotate is a change-of-basis matrix that
+ diagonalizes symmat. diags2_c chooses rotate so
+ that its angle of rotation has the smallest
+ possible magnitude. If there are two rotations
+ that meet these criteria (they will be inverses of
+ one another), either rotation may be chosen.
+
+-Parameters
+
+ None.
+
+-Files
+
+ None.
+
+-Exceptions
+
+ Error free.
+
+
+ 1) The matrix element symmat[1][0] is not used in this routine's
+ computations, so the condition
+
+ symmat[0][1] != symmat[1][0]
+
+ has no effect on this routine's outputs.
+
+-Particulars
+
+ The capability of diagonalizing a 2x2 symmetric matrix is
+ especially useful in a number of geometric applications
+ involving quadratic curves such as ellipses. Such curves are
+ described by expressions of the form
+
+ 2 2
+ A x + B xy + C y + D x + E y + F = 0.
+
+ Diagonalization of the matrix
+
+ +- -+
+ | A B/2 |
+ | |
+ | B/2 C |
+ +- -+
+
+ allows us to perform a coordinate transformation (a rotation,
+ specifically) such that the equation of the curve becomes
+
+ 2 2
+ P u + Q v + R u + S v + T = 0
+
+ in the transformed coordinates. This form is much easier to
+ handle. If the quadratic curve in question is an ellipse,
+ we can easily find its center, semi-major axis, and semi-minor
+ axis from the second equation.
+
+ Ellipses turn up frequently in navigation geometry problems;
+ for example, the limb and terminator (if we treat the Sun as a
+ point source) of a body modelled as a tri-axial ellipsoid are
+ ellipses.
+
+ A mathematical note: because symmat is symmetric, we can ALWAYS
+ find an orthogonal similarity transformation that diagonalizes
+ symmat, and we can choose the similarity transformation to be a
+ rotation matrix. By `orthogonal' we mean that if the rotate is
+ the matrix in question, then
+
+ T T
+ rotate rotate = rotate rotate = I.
+
+ The reasons this routine handles only the 2x2 case are: first,
+ the 2x2 case is much simpler than the general case, in which
+ iterative diagonalization methods must be used, and second, the
+ 2x2 case is adequate for solving problems involving ellipses in
+ 3 dimensional space. Finally, this routine can be used to
+ support a routine that solves the general-dimension diagonalization
+ problem for symmetric matrices.
+
+ Another feature of the routine that might provoke curiosity is
+ its insistence on choosing the diagonalization matrix that
+ rotates the original basis vectors by the smallest amount. The
+ rotation angle of rotate is of no concern for most applications,
+ but can be important if this routine is used as part of an
+ iterative diagonalization method for higher-dimensional matrices.
+ In that case, it is most undesirable to interchange diagonal
+ matrix elements willy-nilly; the matrix to be diagonalized could
+ get ever closer to being diagonal without converging. Choosing
+ the smallest rotation angle precludes this possibility.
+
+-Examples
+
+ 1) A case that can be verified by hand computation:
+ Suppose symmat is
+
+ +- -+
+ | 1.0 4.0 |
+ | |
+ | 4.0 -5.0 |
+ +- -+
+
+ Then symmat is similar to the diagonal matrix
+
+ +- -+
+ | 3.0 0.0 |
+ | |
+ | 0.0 -7.0 |
+ +- -+
+
+ so
+
+ diag[0][0] = 3.
+ diag[1][0] = 0.
+ diag[0][1] = 0.
+ diag[1][1] = -7.
+
+ and rotate is
+
+ +- -+
+ | 0.89442719099991588 -0.44721359549995794 |
+ | |
+ | 0.44721359549995794 0.89442719099991588 |
+ +- -+
+
+ which is an approximation to
+
+ +- -+
+ | .4 * 5**(1/2) -.2 * 5**(1/2) |
+ | |
+ | .2 * 5**(1/2) .4 * 5**(1/2) |
+ +- -+
+
+
+ 2) Suppose we want to find the semi-axes of the ellipse defined
+ by
+ 2 2
+ 27 x + 10 xy + 3 y = 1
+
+ We can write the above equation as the matrix equation
+
+ +- -+ +- -+ +- -+
+ | x y | | 27 5 | | x | = 1
+ +- -+ | | | |
+ | 5 3 | | y |
+ +- -+ +- -+
+
+ Let symmat be the symmetric matrix on the left. The code
+ fragment
+
+ symmat[0][0] = 27.0;
+ symmat[1][0] = 5.0;
+ symmat[0][1] = 5.0;
+ symmat[1][1] = 3.0;
+
+ diags2_c ( symmat, diag, rotate );
+
+ will return diag, an array containing the eigenvalues of
+ symmat, and rotate, the coordinate transformation required
+ to diagonalize symmat. In this case,
+
+ diag[0][0] = 28.
+ diag[1][0] = 0.
+ diag[0][1] = 0.
+ diag[1][1] = 2.
+
+ and
+
+ rotate[0][0] = 0.980580675690920
+ rotate[1][0] = 0.196116135138184
+ rotate[0][1] = -0.196116135138184
+ rotate[1][1] = 0.980580675690920
+
+ The columns of rotate give the ellipse's axes, after scaling
+ them by
+
+ 1 1
+ ---------------- and ---------------
+ ____________ ____________
+ \/ diag[0][0] \/ diag[1][1]
+
+ respectively.
+
+ If smajor and sminor are semi-major and semi-minor axes,
+ we can find them as shown below. For brevity, we omit the
+ check for zero or negative eigenvalues.
+
+ for ( i = 0; i < 2; i++ )
+ {
+ smajor[i] = rotate[i][0] / sqrt( diag[0][0] );
+ sminor[i] = rotate[i][1] / sqrt( diag[1][1] );
+ }
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ [1] Calculus, Vol. II. Tom Apostol. John Wiley & Sons, 1969.
+ See Chapter 5, `Eigenvalues of Operators Acting on Euclidean
+ Spaces'.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 13-JUL-1999 (NJB)
+
+-Index_Entries
+
+ diagonalize symmetric 2x2_matrix
+
+-&
+*/
+
+{ /* Begin diags2_c */
+
+ /*
+ Local constants
+ */
+
+
+ /*
+ Static variables
+ */
+ static SpiceDouble ident [2][2] = { {1., 0.}, {0., 1.} };
+
+
+ /*
+ Local variables
+ */
+ SpiceDouble a;
+ SpiceDouble b;
+ SpiceDouble c;
+ SpiceDouble eigvec [2];
+ SpiceDouble root1 [2];
+ SpiceDouble root2 [2];
+ SpiceDouble scale;
+
+
+ /*
+ Error free.
+ */
+
+ /*
+ We check for the case of a diagonal input matrix, since
+ eigenvector determination is simplified by ruling out this
+ case.
+ */
+
+ if ( symmat [0][1] == 0. )
+ {
+ MOVED ( ident, 4, rotate );
+ MOVED ( symmat, 4, diag );
+
+ /*
+ Explicitly zero out the [1][0] entry of diag, since diag is
+ guaranteed to be diagonal.
+ */
+ diag[1][0] = 0.0;
+
+ return;
+ }
+
+
+ /*
+ Getting here means there's some actual work to do. We start out
+ by scaling our matrix, in order to reduce the chance of overflow.
+ We divide everything by the largest magnitude of any element of
+ symmat. We're guaranteed that scale is non-zero, since the 0
+ matrix is diagonal.
+ */
+
+ scale = MaxAbs ( symmat[0][0], symmat[0][1] );
+ scale = MaxAbs ( scale, symmat[1][1] );
+
+ a = symmat[0][0] / scale;
+ b = symmat[0][1] / scale;
+ c = symmat[1][1] / scale;
+
+
+ /*
+ Compute the eigenvalues of the scaled version of symmat. The
+ eigenvalues are roots of the equation
+
+ det ( (1 / scale) * symmat - x * identity ) = 0,
+
+ or equivalently,
+
+ 2 2
+ x - ( a + c ) x + ( ac - b ) = 0.
+
+ */
+
+ rquad_c ( 1.0, -(a + c), a*c - b*b, root1, root2 );
+
+
+ /*
+ root1 is the root corresponding to the positive discriminant term;
+ this is guaranteed by rquad_c.
+ */
+ diag[0][0] = root1[0];
+ diag[1][0] = 0.;
+ diag[0][1] = 0.;
+ diag[1][1] = root2[0];
+
+
+ /*
+ Our next job is to find an eigenvector corresponding to the
+ eigenvalue of smaller magnitude. We can unitize it and choose
+ an orthogonal unit vector so as to create the desired rotation
+ matrix.
+
+ If our original matrix is
+
+ +- -+
+ | a b |
+ | |,
+ | b c |
+ +- -+
+
+ then the matrix
+
+ +- -+
+ | a - diag[x][x] b |
+ | |
+ | b c - diag[x][x] |
+ +- -+
+
+ maps to zero all elements of the eigenspace corresponding to
+ diag[x][x], where x is either 0 or 1.
+
+ So
+
+ +- -+ +- -+
+ | b | | diag[x][x] - c |
+ | | and | |
+ | diag[x][x] - a | | b |
+ +- -+ +- -+
+
+ are candidates for eigenvectors for diag[x][x]. To minimize
+ loss of accuracy in our eigenvector due to subtraction of
+ nearly equal quantities, we choose the vector in which the
+ term involving the eigenvalue has the larger magnitude.
+
+ Note that there is nothing to be gained as far as accuracy is
+ concerned by working with one eigenvalue as opposed to the
+ other: the magnitudes of the quantities diag[x][x] - a and
+ diag[x][x] - c would be interchanged by taking x = 1 instead
+ of x = 0.
+ */
+
+ if ( fabs( diag[0][0] - a ) >= fabs( diag[0][0] - c ) )
+ {
+
+ /*
+ In this case, the second eigenvector component eigvec[1]
+ should be larger than |b|; we explain why in detail below.
+ We use the MaxVal macro below to guard against reversal of the
+ inequality due to round-off error.
+ */
+
+ eigvec[0] = b;
+ eigvec[1] = MaxVal ( diag[0][0] - a, fabs(b) );
+
+ /*
+ Recall that diag[0][0] is an eigenvalue of the scaled version
+ of symmat
+
+ +- -+
+ | a b |
+ | |.
+ | b c |
+ +- -+
+
+ diag[0][0] is the positive-discriminant root of this matrix's
+ characteristic equation. eigvec's y-component
+
+ diag[0][0] - a
+
+ is positive and of magnitude at least as large as that of B,
+ since it is the larger of
+ ______________________
+ / 2
+ c - a / ( a - c ) 2
+ diag[0][0] - a = ----- + \ / ---------- + b
+ 2 \/ 4
+
+ and
+ ______________________
+ / 2
+ a - c / ( a - c ) 2
+ diag[0][0] - c = ----- + \ / ---------- + b
+ 2 \/ 4
+
+ Equality between these expressions can occur only when a is
+ equal to c, in which case both expressions are equal (except
+ for round-off error) to |b|.
+
+ So the argument of eigvec is in the interval [pi/4, 3*pi/4].
+ The second eigenvector is eigvec, and the first
+ eigenvector is found by rotating eigvec by -pi/2. Since
+ diag[0][0] is the eigenvalue for the SECOND eigenvector, we
+ must swap the eigenvalues.
+ */
+
+ /*
+ Unitize the eigenvector.
+ */
+ vhatg_c ( eigvec, 2, eigvec );
+
+ rotate[0][0] = eigvec[1];
+ rotate[1][0] = -eigvec[0];
+ rotate[0][1] = eigvec[0];
+ rotate[1][1] = eigvec[1];
+
+ swapd_ ( &(diag[0][0]), &(diag[1][1]) );
+
+ }
+
+ else
+ {
+
+ eigvec[0] = MaxVal ( diag[0][0] - c, fabs(b) );
+ eigvec[1] = b;
+
+ /*
+ The x-component of eigvec is positive and has magnitude
+ greater than or equal to that of the y-component of eigvec.
+ The argument of eigvec is in [-pi/4, pi/4], and the second
+ eigenvector is found by rotating eigvec by pi/2.
+ */
+
+ /*
+ Unitize the eigenvector.
+ */
+ vhatg_c ( eigvec, 2, eigvec );
+
+ rotate[0][0] = eigvec[0];
+ rotate[1][0] = eigvec[1];
+ rotate[0][1] = -eigvec[1];
+ rotate[1][1] = eigvec[0];
+ }
+
+ /*
+ We must scale the eigenvalues.
+ */
+ diag[0][0] *= scale;
+ diag[1][1] *= scale;
+
+
+} /* End diags2_c */
+
diff --git a/ext/spice/src/cspice/diff_c.c b/ext/spice/src/cspice/diff_c.c
new file mode 100644
index 0000000000..7187bf8a9d
--- /dev/null
+++ b/ext/spice/src/cspice/diff_c.c
@@ -0,0 +1,358 @@
+/*
+
+-Procedure diff_c ( Difference of two sets )
+
+-Abstract
+
+ Take the difference of two sets of any data type to form a third
+ set.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ SETS
+
+-Keywords
+
+ CELLS, SETS
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+
+ void diff_c ( SpiceCell * a,
+ SpiceCell * b,
+ SpiceCell * c )
+
+/*
+
+-Brief_I/O
+
+ VARIABLE I/O DESCRIPTION
+ -------- --- --------------------------------------------------
+ a I First input set.
+ b I Second input set.
+ c O Difference of a and b.
+
+-Detailed_Input
+
+ a is a CSPICE set. a must be declared as a SpiceCell
+ of data type character, double precision, or integer.
+
+ b is a CSPICE set, distinct from a. b must have the
+ same data type as a.
+
+-Detailed_Output
+
+ c is a CSPICE set, distinct from sets a and b, which
+ contains the difference of a and b (that is, all of
+ the elements which are in a but NOT in b). c must
+ have the same data type as a and b.
+
+ When comparing elements of character sets, this routine
+ ignores trailing blanks. Trailing blanks will be
+ trimmed from the members of the output set c.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the input set arguments don't have identical data types,
+ the error SPICE(TYPEMISMATCH) is signaled.
+
+ 2) If the difference of the two sets contains more elements than can
+ be contained in the output set, the error SPICE(SETEXCESS) is
+ signaled.
+
+ 3) If the set arguments have character type and the length of the
+ elements of the output set is less than the maximum of the
+ lengths of the elements of the input sets, the error
+ SPICE(ELEMENTSTOOSHORT) is signaled.
+
+ 4) If either of the input arguments may be unordered or contain
+ duplicates, the error SPICE(NOTASET) is signaled.
+
+-Files
+
+ None.
+
+-Particulars
+
+ This is a generic CSPICE set routine; it operates on sets of any
+ supported data type.
+
+ The difference of two sets contains every element which is
+ in the first set, but NOT in the second.
+
+ {a,b} difference {c,d} = {a,b}
+ {a,b,c} {b,c,d} {a}
+ {a,b,c,d} {} {a,b,c,d}
+ {} {a,b,c,d} {}
+ {} {} {}
+
+
+-Examples
+
+ 1) The following code fragment places the difference of the
+ character sets planets and asteroids into the character set
+ result.
+
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Declare the sets with string length NAMLEN and with maximum
+ number of elements MAXSIZ.
+ ./
+ SPICECHAR_CELL ( planets, MAXSIZ, NAMLEN );
+ SPICECHAR_CELL ( asteroids, MAXSIZ, NAMLEN );
+ SPICECHAR_CELL ( result, MAXSIZ, NAMLEN );
+ .
+ .
+ .
+ /.
+ Compute the difference.
+ ./
+ diff_c ( &planets, &asteroids, &result );
+
+
+ 2) Repeat example #1, this time using integer sets containing
+ ID codes of the bodies of interest.
+
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+ /.
+ Declare the sets with maximum number of elements MAXSIZ.
+ ./
+ SPICEINT_CELL ( planets, MAXSIZ );
+ SPICEINT_CELL ( asteroids, MAXSIZ );
+ SPICEINT_CELL ( result, MAXSIZ );
+ .
+ .
+ .
+ /.
+ Compute the difference.
+ ./
+ diff_c ( &planets, &asteroids, &result );
+
+-Restrictions
+
+ 1) The output set must be distinct from both of the input sets.
+ For example, the following calls are invalid.
+
+ diff_c ( ¤t, &new, ¤t );
+ diff_c ( &new, ¤t, ¤t );
+
+ In each of the examples above, whether or not the subroutine
+ signals an error, the results will almost certainly be wrong.
+ Nearly the same effect can be achieved, however, by placing the
+ result into a temporary set, which is immediately copied back
+ into one of the input sets, as shown below.
+
+ diff_c ( ¤t, &new, &temp );
+ copy_c ( &temp, &new );
+
+
+ 2) String comparisons performed by this routine are Fortran-style:
+ trailing blanks in the input sets are ignored. This gives
+ consistent behavior with CSPICE code generated by the f2c
+ translator, as well as with the Fortran SPICE Toolkit.
+
+ Note that this behavior is not identical to that of the ANSI
+ C library functions strcmp and strncmp.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ N.J. Bachman (JPL)
+ C.A. Curzon (JPL)
+ W.L. Taber (JPL)
+ I.M. Underwood (JPL)
+
+-Version
+
+ -CSPICE Version 1.1.0, 15-FEB-2005 (NJB)
+
+ Bug fix: loop bound changed from 2 to 3 in loop used
+ to free dynamically allocated arrays.
+
+ -CSPICE Version 1.0.0, 08-AUG-2002 (NJB) (CAC) (WLT) (IMU)
+
+-Index_Entries
+
+ difference of two sets
+
+-&
+*/
+
+
+{ /* Begin diff_c */
+
+
+ /*
+ Local variables
+ */
+ SpiceChar * fCell[3];
+
+ SpiceInt fLen [3];
+ SpiceInt i;
+
+
+ /*
+ Standard SPICE error handling.
+ */
+ if ( return_c() )
+ {
+ return;
+ }
+
+ chkin_c ( "diff_c" );
+
+ /*
+ Make sure data types match.
+ */
+ CELLMATCH3 ( CHK_STANDARD, "diff_c", a, b, c );
+
+ /*
+ Make sure the input cells are sets.
+ */
+ CELLISSETCHK2 ( CHK_STANDARD, "diff_c", a, b );
+
+ /*
+ Initialize the cells if necessary.
+ */
+ CELLINIT3 ( a, b, c );
+
+ /*
+ Call the difference routine appropriate for the data type of the
+ cells.
+ */
+ if ( a->dtype == SPICE_CHR )
+ {
+
+ /*
+ Construct Fortran-style sets suitable for passing to diffc_.
+ */
+ C2F_MAP_CELL3 ( "",
+ a, fCell, fLen,
+ b, fCell+1, fLen+1,
+ c, fCell+2, fLen+2 );
+
+
+ if ( failed_c() )
+ {
+ chkout_c ( "diff_c" );
+ return;
+ }
+
+
+ diffc_ ( (char * ) fCell[0],
+ (char * ) fCell[1],
+ (char * ) fCell[2],
+ (ftnlen ) fLen[0],
+ (ftnlen ) fLen[1],
+ (ftnlen ) fLen[2] );
+
+
+ /*
+ Map the diff back to a C style cell.
+ */
+ F2C_MAP_CELL ( fCell[2], fLen[2], c );
+
+
+ /*
+ We're done with the dynamically allocated Fortran-style arrays.
+ */
+ for ( i = 0; i < 3; i++ )
+ {
+ free ( fCell[i] );
+ }
+
+ }
+
+ else if ( a->dtype == SPICE_DP )
+ {
+ diffd_ ( (doublereal * ) (a->base),
+ (doublereal * ) (b->base),
+ (doublereal * ) (c->base) );
+ /*
+ Sync the output cell.
+ */
+ if ( !failed_c() )
+ {
+ zzsynccl_c ( F2C, c );
+ }
+
+ }
+
+ else if ( a->dtype == SPICE_INT )
+ {
+ diffi_ ( (integer * ) (a->base),
+ (integer * ) (b->base),
+ (integer * ) (c->base) );
+
+ /*
+ Sync the output cell.
+ */
+ if ( !failed_c() )
+ {
+ zzsynccl_c ( F2C, c );
+ }
+ }
+
+ else
+ {
+ setmsg_c ( "Cell a contains unrecognized data type code #." );
+ errint_c ( "#", (SpiceInt) (a->dtype) );
+ sigerr_c ( "SPICE(NOTSUPPORTED)" );
+ chkout_c ( "diff_c" );
+ return;
+ }
+
+
+ /*
+ Indicate the result is a set.
+ */
+ c->isSet = SPICETRUE;
+
+
+ chkout_c ( "diff_c" );
+
+} /* End diff_c */
diff --git a/ext/spice/src/cspice/diffc.c b/ext/spice/src/cspice/diffc.c
new file mode 100644
index 0000000000..b009abb04c
--- /dev/null
+++ b/ext/spice/src/cspice/diffc.c
@@ -0,0 +1,310 @@
+/* diffc.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DIFFC ( Difference of two character sets ) */
+/* Subroutine */ int diffc_(char *a, char *b, char *c__, ftnlen a_len, ftnlen
+ b_len, ftnlen c_len)
+{
+ /* System generated locals */
+ integer i__1, i__2, i__3;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ integer s_cmp(char *, char *, ftnlen, ftnlen);
+ logical l_lt(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ integer over, acard;
+ extern integer cardc_(char *, ftnlen);
+ integer bcard, ccard;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ extern integer sizec_(char *, ftnlen);
+ integer csize;
+ extern /* Subroutine */ int scardc_(integer *, char *, ftnlen);
+ integer apoint, bpoint;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), excess_(integer *, char *, ftnlen), setmsg_(char *,
+ ftnlen), errint_(char *, integer *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Take the difference of two character sets to form a third set. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* SETS */
+
+/* $ Keywords */
+
+/* CELLS, SETS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* A I First input set. */
+/* B I Second input set. */
+/* C O Difference of A and B. */
+
+/* $ Detailed_Input */
+
+
+/* A is a set. */
+
+
+/* B is a set, distinct from A. */
+
+/* $ Detailed_Output */
+
+/* C is a set, distinct from sets A and B, which */
+/* contains the difference of A and B (that is, */
+/* all of the elements which are in A, but NOT */
+/* in B). */
+
+/* If the size (maximum cardinality) of C is smaller */
+/* than the cardinality of the difference of A and B, */
+/* then only as many items as will fit in C are */
+/* included, and an error is returned. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* The DIFFERENCE of two sets contains every element which is */
+/* in the first set, but NOT in the second. */
+
+/* {a,b} difference {c,d} = {a,b} */
+/* {a,b,c} {b,c,d} {a} */
+/* {a,b,c,d} {} {a,b,c,d} */
+/* {} {a,b,c,d} {} */
+/* {} {} {} */
+
+/* The following call */
+
+/* CALL DIFFC ( PLANETS, ASTEROIDS, RESULT ) */
+
+/* places the difference of the character sets PLANETS and */
+/* ASTEROIDS into the character set RESULT. */
+
+/* The output set must be distinct from both of the input sets. */
+/* For example, the following calls are invalid. */
+
+/* CALL DIFFI ( CURRENT, NEW, CURRENT ) */
+/* CALL DIFFI ( NEW, CURRENT, CURRENT ) */
+
+/* In each of the examples above, whether or not the subroutine */
+/* signals an error, the results will almost certainly be wrong. */
+/* Nearly the same effect can be achieved, however, by placing the */
+/* result into a temporary set, which is immediately copied back */
+/* into one of the input sets, as shown below. */
+
+/* CALL DIFFI ( CURRENT, NEW, TEMP ) */
+/* CALL COPYI ( TEMP, NEW ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the difference of the two sets causes an excess of */
+/* elements, the error SPICE(SETEXCESS) is signalled. */
+
+/* 2) If length of the elements of the output set is less than */
+/* the length of the elements of the FIRST input set, the */
+/* error SPICE(ELEMENTSTOOSHORT) is signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* C.A. Curzon (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (CAC) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* difference of two character sets */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 2.0.0, 21-DEC-1988 (NJB) */
+
+/* Error signalled if output set elements are not long enough. */
+/* Length must be at least max of lengths of input elements. */
+/* Also, calling protocol for EXCESS has been changed. Call to */
+/* SETMSG removed. */
+
+/* Also, in the overflow case, the number of excess elements was */
+/* computed incorrectly; this has been fixed. The problem was */
+/* that OVER was incremented in all cases of the overflow IF */
+/* block, rather than only in the cases where the cardinality of */
+/* the output cell would have been incremented if there were */
+/* enough room. */
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Set up the error processing. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("DIFFC", (ftnlen)5);
+
+/* Make sure output set elements are long enough. */
+
+ if (i_len(c__, c_len) < i_len(a, a_len)) {
+ setmsg_("Length of output cell is #. Length required to contain res"
+ "ult is #.", (ftnlen)68);
+ i__1 = i_len(c__, c_len);
+ errint_("#", &i__1, (ftnlen)1);
+/* Computing MAX */
+ i__2 = i_len(a, a_len), i__3 = i_len(b, b_len);
+ i__1 = max(i__2,i__3);
+ errint_("#", &i__1, (ftnlen)1);
+ sigerr_("SPICE(ELEMENTSTOOSHORT)", (ftnlen)23);
+ chkout_("DIFFC", (ftnlen)5);
+ return 0;
+ }
+
+/* Find the cardinality of the input sets, and the allowed size */
+/* of the output set. */
+
+ acard = cardc_(a, a_len);
+ bcard = cardc_(b, b_len);
+ csize = sizec_(c__, c_len);
+
+/* Begin with the input pointers at the first elements of the */
+/* input sets. The cardinality of the output set is zero. */
+/* And there is no overflow so far. */
+
+ apoint = 1;
+ bpoint = 1;
+ ccard = 0;
+ over = 0;
+
+/* When the end of the first input set is reached, we're done. */
+
+ while(apoint <= acard) {
+
+/* If there is still space in the output set, fill it */
+/* as necessary. */
+
+ if (ccard < csize) {
+ if (bpoint > bcard) {
+ ++ccard;
+ s_copy(c__ + (ccard + 5) * c_len, a + (apoint + 5) * a_len,
+ c_len, a_len);
+ ++apoint;
+ } else if (s_cmp(a + (apoint + 5) * a_len, b + (bpoint + 5) *
+ b_len, a_len, b_len) == 0) {
+ ++apoint;
+ ++bpoint;
+ } else if (l_lt(a + (apoint + 5) * a_len, b + (bpoint + 5) *
+ b_len, a_len, b_len)) {
+ ++ccard;
+ s_copy(c__ + (ccard + 5) * c_len, a + (apoint + 5) * a_len,
+ c_len, a_len);
+ ++apoint;
+ } else if (l_lt(b + (bpoint + 5) * b_len, a + (apoint + 5) *
+ a_len, b_len, a_len)) {
+ ++bpoint;
+ }
+
+/* Otherwise, stop filling the array, but continue to count the */
+/* number of elements in excess of the size of the output set. */
+
+ } else {
+ if (bpoint > bcard) {
+ ++over;
+ ++apoint;
+ } else if (s_cmp(a + (apoint + 5) * a_len, b + (bpoint + 5) *
+ b_len, a_len, b_len) == 0) {
+ ++apoint;
+ ++bpoint;
+ } else if (l_lt(a + (apoint + 5) * a_len, b + (bpoint + 5) *
+ b_len, a_len, b_len)) {
+ ++over;
+ ++apoint;
+ } else if (l_lt(b + (bpoint + 5) * b_len, a + (apoint + 5) *
+ a_len, b_len, a_len)) {
+ ++bpoint;
+ }
+ }
+ }
+
+/* Set the cardinality of the output set. */
+
+ scardc_(&ccard, c__, c_len);
+
+/* Report any excess. */
+
+ if (over > 0) {
+ excess_(&over, "set", (ftnlen)3);
+ sigerr_("SPICE(SETEXCESS)", (ftnlen)16);
+ }
+ chkout_("DIFFC", (ftnlen)5);
+ return 0;
+} /* diffc_ */
+
diff --git a/ext/spice/src/cspice/diffd.c b/ext/spice/src/cspice/diffd.c
new file mode 100644
index 0000000000..5533391f9d
--- /dev/null
+++ b/ext/spice/src/cspice/diffd.c
@@ -0,0 +1,268 @@
+/* diffd.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DIFFD ( Difference of two double precision sets ) */
+/* Subroutine */ int diffd_(doublereal *a, doublereal *b, doublereal *c__)
+{
+ integer over, acard, bcard;
+ extern integer cardd_(doublereal *);
+ integer ccard;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer csize;
+ extern integer sized_(doublereal *);
+ extern /* Subroutine */ int scardd_(integer *, doublereal *);
+ integer apoint, bpoint;
+ extern /* Subroutine */ int excess_(integer *, char *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Take the difference of two double precision sets to form */
+/* a third set. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CELLS, SETS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* A I First input set. */
+/* B I Second input set. */
+/* C O Difference of A and B. */
+
+/* $ Detailed_Input */
+
+
+/* A is a set. */
+
+
+/* B is a set, distinct from A. */
+
+/* $ Detailed_Output */
+
+/* C is a set, distinct from sets A and B, which */
+/* contains the difference of A and B (that is, */
+/* all of the elements which are in A, but NOT */
+/* in B). */
+
+/* If the size (maximum cardinality) of C is smaller */
+/* than the cardinality of the difference of A and B, */
+/* then only as many items as will fit in C are */
+/* included, and an error is returned. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* The DIFFERENCE of two sets contains every element which is */
+/* in the first set, but NOT in the second. */
+
+/* {a,b} difference {c,d} = {a,b} */
+/* {a,b,c} {b,c,d} {a} */
+/* {a,b,c,d} {} {a,b,c,d} */
+/* {} {a,b,c,d} {} */
+/* {} {} {} */
+
+/* The following call */
+
+/* CALL DIFFC ( PLANETS, ASTEROIDS, RESULT ) */
+
+/* places the difference of the character sets PLANETS and */
+/* ASTEROIDS into the character set RESULT. */
+
+/* The output set must be distinct from both of the input sets. */
+/* For example, the following calls are invalid. */
+
+/* CALL DIFFI ( CURRENT, NEW, CURRENT ) */
+/* CALL DIFFI ( NEW, CURRENT, CURRENT ) */
+
+/* In each of the examples above, whether or not the subroutine */
+/* signals an error, the results will almost certainly be wrong. */
+/* Nearly the same effect can be achieved, however, by placing the */
+/* result into a temporary set, which is immediately copied back */
+/* into one of the input sets, as shown below. */
+
+/* CALL DIFFI ( CURRENT, NEW, TEMP ) */
+/* CALL COPYI ( TEMP, NEW ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the difference of the two sets causes an excess of */
+/* elements, the error SPICE(SETEXCESS) is signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* C.A. Curzon (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (CAC) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* difference of two d.p. sets */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.1.0, 06-JAN-1989 (NJB) */
+
+/* Calling protocol of EXCESS changed. Call to SETMSG removed. */
+
+/* Also, in the overflow case, the number of excess elements was */
+/* computed incorrectly; this has been fixed. The problem was */
+/* that OVER was incremented in all cases of the overflow IF */
+/* block, rather than only in the cases where the cardinality of */
+/* the output cell would have been incremented if there were */
+/* enough room. */
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Set up the error processing. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("DIFFD", (ftnlen)5);
+
+/* Find the cardinality of the input sets, and the allowed size */
+/* of the output set. */
+
+ acard = cardd_(a);
+ bcard = cardd_(b);
+ csize = sized_(c__);
+
+/* Begin with the input pointers at the first elements of the */
+/* input sets. The cardinality of the output set is zero. */
+/* And there is no overflow so far. */
+
+ apoint = 1;
+ bpoint = 1;
+ ccard = 0;
+ over = 0;
+
+/* When the end of the first input set is reached, we're done. */
+
+ while(apoint <= acard) {
+
+/* If there is still space in the output set, fill it */
+/* as necessary. */
+
+ if (ccard < csize) {
+ if (bpoint > bcard) {
+ ++ccard;
+ c__[ccard + 5] = a[apoint + 5];
+ ++apoint;
+ } else if (a[apoint + 5] == b[bpoint + 5]) {
+ ++apoint;
+ ++bpoint;
+ } else if (a[apoint + 5] < b[bpoint + 5]) {
+ ++ccard;
+ c__[ccard + 5] = a[apoint + 5];
+ ++apoint;
+ } else if (b[bpoint + 5] < a[apoint + 5]) {
+ ++bpoint;
+ }
+
+/* Otherwise, stop filling the array, but continue to count the */
+/* number of elements in excess of the size of the output set. */
+
+ } else {
+ if (bpoint > bcard) {
+ ++over;
+ ++apoint;
+ } else if (a[apoint + 5] == b[bpoint + 5]) {
+ ++apoint;
+ ++bpoint;
+ } else if (a[apoint + 5] < b[bpoint + 5]) {
+ ++over;
+ ++apoint;
+ } else if (b[bpoint + 5] < a[apoint + 5]) {
+ ++bpoint;
+ }
+ }
+ }
+
+/* Set the cardinality of the output set. */
+
+ scardd_(&ccard, c__);
+
+/* Report any excess. */
+
+ if (over > 0) {
+ excess_(&over, "set", (ftnlen)3);
+ sigerr_("SPICE(SETEXCESS)", (ftnlen)16);
+ }
+ chkout_("DIFFD", (ftnlen)5);
+ return 0;
+} /* diffd_ */
+
diff --git a/ext/spice/src/cspice/diffi.c b/ext/spice/src/cspice/diffi.c
new file mode 100644
index 0000000000..1373c69af7
--- /dev/null
+++ b/ext/spice/src/cspice/diffi.c
@@ -0,0 +1,267 @@
+/* diffi.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DIFFI ( Difference of two integer sets ) */
+/* Subroutine */ int diffi_(integer *a, integer *b, integer *c__)
+{
+ integer over, acard, bcard, ccard;
+ extern integer cardi_(integer *);
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ integer csize;
+ extern integer sizei_(integer *);
+ extern /* Subroutine */ int scardi_(integer *, integer *);
+ integer apoint, bpoint;
+ extern /* Subroutine */ int excess_(integer *, char *, ftnlen), sigerr_(
+ char *, ftnlen), chkout_(char *, ftnlen);
+ extern logical return_(void);
+
+/* $ Abstract */
+
+/* Take the difference of two integer sets to form a third set. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* CELLS, SETS */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* A I First input set. */
+/* B I Second input set. */
+/* C O Difference of A and B. */
+
+/* $ Detailed_Input */
+
+
+/* A is a set. */
+
+
+/* B is a set, distinct from A. */
+
+/* $ Detailed_Output */
+
+/* C is a set, distinct from sets A and B, which */
+/* contains the difference of A and B (that is, */
+/* all of the elements which are in A, but NOT */
+/* in B). */
+
+/* If the size (maximum cardinality) of C is smaller */
+/* than the cardinality of the difference of A and B, */
+/* then only as many items as will fit in C are */
+/* included, and an error is returned. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Particulars */
+
+/* None. */
+
+/* $ Examples */
+
+/* The DIFFERENCE of two sets contains every element which is */
+/* in the first set, but NOT in the second. */
+
+/* {a,b} difference {c,d} = {a,b} */
+/* {a,b,c} {b,c,d} {a} */
+/* {a,b,c,d} {} {a,b,c,d} */
+/* {} {a,b,c,d} {} */
+/* {} {} {} */
+
+/* The following call */
+
+/* CALL DIFFC ( PLANETS, ASTEROIDS, RESULT ) */
+
+/* places the difference of the character sets PLANETS and */
+/* ASTEROIDS into the character set RESULT. */
+
+/* The output set must be distinct from both of the input sets. */
+/* For example, the following calls are invalid. */
+
+/* CALL DIFFI ( CURRENT, NEW, CURRENT ) */
+/* CALL DIFFI ( NEW, CURRENT, CURRENT ) */
+
+/* In each of the examples above, whether or not the subroutine */
+/* signals an error, the results will almost certainly be wrong. */
+/* Nearly the same effect can be achieved, however, by placing the */
+/* result into a temporary set, which is immediately copied back */
+/* into one of the input sets, as shown below. */
+
+/* CALL DIFFI ( CURRENT, NEW, TEMP ) */
+/* CALL COPYI ( TEMP, NEW ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the difference of the two sets causes an excess of */
+/* elements, the error SPICE(SETEXCESS) is signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* C.A. Curzon (JPL) */
+/* W.L. Taber (JPL) */
+/* I.M. Underwood (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
+
+/* Comment section for permuted index source lines was added */
+/* following the header. */
+
+/* - SPICELIB Version 1.0.0, 31-JAN-1990 (CAC) (WLT) (IMU) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* difference of two integer sets */
+
+/* -& */
+/* $ Revisions */
+
+/* - Beta Version 1.1.0, 06-JAN-1989 (NJB) */
+
+/* Calling protocol of EXCESS changed. Call to SETMSG removed. */
+
+/* Also, in the overflow case, the number of excess elements was */
+/* computed incorrectly; this has been fixed. The problem was */
+/* that OVER was incremented in all cases of the overflow IF */
+/* block, rather than only in the cases where the cardinality of */
+/* the output cell would have been incremented if there were */
+/* enough room. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Set up the error processing. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("DIFFI", (ftnlen)5);
+
+/* Find the cardinality of the input sets, and the allowed size */
+/* of the output set. */
+
+ acard = cardi_(a);
+ bcard = cardi_(b);
+ csize = sizei_(c__);
+
+/* Begin with the input pointers at the first elements of the */
+/* input sets. The cardinality of the output set is zero. */
+/* And there is no overflow so far. */
+
+ apoint = 1;
+ bpoint = 1;
+ ccard = 0;
+ over = 0;
+
+/* When the end of the first input set is reached, we're done. */
+
+ while(apoint <= acard) {
+
+/* If there is still space in the output set, fill it */
+/* as necessary. */
+
+ if (ccard < csize) {
+ if (bpoint > bcard) {
+ ++ccard;
+ c__[ccard + 5] = a[apoint + 5];
+ ++apoint;
+ } else if (a[apoint + 5] == b[bpoint + 5]) {
+ ++apoint;
+ ++bpoint;
+ } else if (a[apoint + 5] < b[bpoint + 5]) {
+ ++ccard;
+ c__[ccard + 5] = a[apoint + 5];
+ ++apoint;
+ } else if (b[bpoint + 5] < a[apoint + 5]) {
+ ++bpoint;
+ }
+
+/* Otherwise, stop folling the array, but continue to count the */
+/* number of elements in excess of the size of the output set. */
+
+ } else {
+ if (bpoint > bcard) {
+ ++over;
+ ++apoint;
+ } else if (a[apoint + 5] == b[bpoint + 5]) {
+ ++apoint;
+ ++bpoint;
+ } else if (a[apoint + 5] < b[bpoint + 5]) {
+ ++over;
+ ++apoint;
+ } else if (b[bpoint + 5] < a[apoint + 5]) {
+ ++bpoint;
+ }
+ }
+ }
+
+/* Set the cardinality of the output set. */
+
+ scardi_(&ccard, c__);
+
+/* Report any excess. */
+
+ if (over > 0) {
+ excess_(&over, "set", (ftnlen)3);
+ sigerr_("SPICE(SETEXCESS)", (ftnlen)16);
+ }
+ chkout_("DIFFI", (ftnlen)5);
+ return 0;
+} /* diffi_ */
+
diff --git a/ext/spice/src/cspice/dlatdr.c b/ext/spice/src/cspice/dlatdr.c
new file mode 100644
index 0000000000..44a8111a18
--- /dev/null
+++ b/ext/spice/src/cspice/dlatdr.c
@@ -0,0 +1,253 @@
+/* dlatdr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* $Procedure DLATDR ( Derivative of latitudinal w.r.t. rectangular ) */
+/* Subroutine */ int dlatdr_(doublereal *x, doublereal *y, doublereal *z__,
+ doublereal *jacobi)
+{
+ doublereal long__, r__;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), vpack_(doublereal *,
+ doublereal *, doublereal *, doublereal *);
+ doublereal injacb[9] /* was [3][3] */;
+ extern /* Subroutine */ int reclat_(doublereal *, doublereal *,
+ doublereal *, doublereal *);
+ doublereal rectan[3];
+ extern /* Subroutine */ int drdlat_(doublereal *, doublereal *,
+ doublereal *, doublereal *), sigerr_(char *, ftnlen), chkout_(
+ char *, ftnlen), setmsg_(char *, ftnlen);
+ extern logical return_(void);
+ extern /* Subroutine */ int invort_(doublereal *, doublereal *);
+ doublereal lat;
+
+/* $ Abstract */
+
+/* This routine computes the Jacobian of the transformation from */
+/* rectangular to latitudinal coordinates. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* COORDINATES */
+/* DERIVATIVES */
+/* MATRIX */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* X I X-coordinate of point. */
+/* Y I Y-coordinate of point. */
+/* Z I Z-coordinate of point. */
+/* JACOBI O Matrix of partial derivatives. */
+
+/* $ Detailed_Input */
+
+/* X, */
+/* Y, */
+/* Z are the rectangular coordinates of the point at */
+/* which the Jacobian of the map from rectangular */
+/* to latitudinal coordinates is desired. */
+
+/* $ Detailed_Output */
+
+/* JACOBI is the matrix of partial derivatives of the conversion */
+/* between rectangular and latitudinal coordinates. It */
+/* has the form */
+
+/* .- -. */
+/* | dr/dx dr/dy dr/dz | */
+/* | dlong/dx dlong/dy dlong/dz | */
+/* | dlat/dx dlat/dy dlat/dz | */
+/* `- -' */
+
+/* evaluated at the input values of X, Y, and Z. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the input point is on the z-axis ( X and Y = 0 ), the */
+/* Jacobian is undefined. The error SPICE(POINTONZAXIS) */
+/* will be signaled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* When performing vector calculations with velocities it is */
+/* usually most convenient to work in rectangular coordinates. */
+/* However, once the vector manipulations have been performed */
+/* it is often desirable to convert the rectangular representations */
+/* into latitudinal coordinates to gain insights about phenomena */
+/* in this coordinate frame. */
+
+/* To transform rectangular velocities to derivatives of coordinates */
+/* in a latitudinal system, one uses the Jacobian of the */
+/* transformation between the two systems. */
+
+/* Given a state in rectangular coordinates */
+
+/* ( x, y, z, dx, dy, dz ) */
+
+/* the corresponding latitudinal coordinate derivatives are given by */
+/* the matrix equation: */
+
+/* t | t */
+/* (dr, dlong, dlat) = JACOBI| * (dx, dy, dz) */
+/* |(x,y,z) */
+
+/* This routine computes the matrix */
+
+/* | */
+/* JACOBI| */
+/* |(x, y, z) */
+
+/* $ Examples */
+
+/* Suppose one is given the bodyfixed rectangular state of an object */
+/* ( x(t), y(t), z(t), dx(t), dy(t), dz(t) ) as a function of time t. */
+
+/* To find the derivatives of the coordinates of the object in */
+/* bodyfixed latitudinal coordinates, one simply multiplies the */
+/* Jacobian of the transformation from rectangular to latitudinal */
+/* (evaluated at x(t), y(t), z(t) ) by the rectangular velocity */
+/* vector of the object at time t. */
+
+/* In code this looks like: */
+
+/* C */
+/* C Load the rectangular velocity vector vector RECV. */
+/* C */
+/* RECV(1) = DX_DT ( T ) */
+/* RECV(3) = DY_DT ( T ) */
+/* RECV(2) = DZ_DT ( T ) */
+
+/* C */
+/* C Determine the Jacobian of the transformation from */
+/* C rectangular to latitudinal at the rectangular */
+/* C coordinates at time T. */
+/* C */
+/* CALL DLATDR ( X(T), Y(T), Z(T), JACOBI ) */
+
+/* C */
+/* C Multiply the Jacobian on the right by the rectangular */
+/* C velocity to obtain the latitudinal coordinate */
+/* C derivatives LATV. */
+/* C */
+/* CALL MXV ( JACOBI, RECV, LATV ) */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 16-JUL-2001 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* Jacobian of latitudinal w.r.t. rectangular coordinates */
+
+/* -& */
+/* $ Revisions */
+
+/* None. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DLATDR", (ftnlen)6);
+ }
+
+/* There is a singularity of the Jacobian for points on the z-axis. */
+
+ if (*x == 0. && *y == 0.) {
+ setmsg_("The Jacobian of the transformation from rectangular to lati"
+ "tudinal coordinates is not defined for points on the z-axis.",
+ (ftnlen)119);
+ sigerr_("SPICE(POINTONZAXIS)", (ftnlen)19);
+ chkout_("DLATDR", (ftnlen)6);
+ return 0;
+ }
+
+/* We will get the Jacobian of the transformation from rectangular */
+/* to latitudinal coordinates by implicit differentiation. */
+
+/* First move the X,Y and Z coordinates into a vector. */
+
+ vpack_(x, y, z__, rectan);
+
+/* Convert from rectangular to latitudinal coordinates. */
+
+ reclat_(rectan, &r__, &long__, &lat);
+
+/* Get the Jacobian of the transformation from latitudinal to */
+/* rectangular coordinates at R, LONG, LAT. */
+
+ drdlat_(&r__, &long__, &lat, injacb);
+
+/* Now invert INJACB to get the Jacobian of the transformation from */
+/* rectangular to latitudinal coordinates. */
+
+ invort_(injacb, jacobi);
+ chkout_("DLATDR", (ftnlen)6);
+ return 0;
+} /* dlatdr_ */
+
diff --git a/ext/spice/src/cspice/dlatdr_c.c b/ext/spice/src/cspice/dlatdr_c.c
new file mode 100644
index 0000000000..556397b407
--- /dev/null
+++ b/ext/spice/src/cspice/dlatdr_c.c
@@ -0,0 +1,218 @@
+/*
+
+-Procedure dlatdr_c ( Derivative of latitudinal w.r.t. rectangular )
+
+-Abstract
+
+ This routine computes the Jacobian of the transformation from
+ rectangular to latitudinal coordinates.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ COORDINATES
+ DERIVATIVES
+ MATRIX
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+
+
+ void dlatdr_c ( SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble jacobi[3][3] )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ x I X-coordinate of point.
+ y I Y-coordinate of point.
+ z I Z-coordinate of point.
+ jacobi O Matrix of partial derivatives.
+
+-Detailed_Input
+
+ x,
+ y,
+ z are the rectangular coordinates of the point at
+ which the Jacobian of the map from rectangular
+ to latitudinal coordinates is desired.
+
+-Detailed_Output
+
+ jacobi is the matrix of partial derivatives of the conversion
+ between rectangular and latitudinal coordinates. It
+ has the form
+
+ .- -.
+ | dr/dx dr/dy dr/dz |
+ | dlon/dx dlon/dy dlon/dz |
+ | dlat/dx dlat/dy dlat/dz |
+ `- -'
+
+ evaluated at the input values of x, y, and z.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the input point is on the z-axis (x and y = 0), the
+ Jacobian is undefined. The error SPICE(POINTONZAXIS)
+ will be signaled.
+
+-Files
+
+ None.
+
+-Particulars
+
+ When performing vector calculations with velocities it is
+ usually most convenient to work in rectangular coordinates.
+ However, once the vector manipulations have been performed
+ it is often desirable to convert the rectangular representations
+ into latitudinal coordinates to gain insights about phenomena
+ in this coordinate frame.
+
+ To transform rectangular velocities to derivatives of coordinates
+ in a latitudinal system, one uses the Jacobian of the
+ transformation between the two systems.
+
+ Given a state in rectangular coordinates
+
+ ( x, y, z, dx, dy, dz )
+
+ the corresponding latitudinal coordinate derivatives are given by
+ the matrix equation:
+
+ t | t
+ (dr, dlon, dlat) = jacobi | * (dx, dy, dz)
+ |(x,y,z)
+
+ This routine computes the matrix
+
+ |
+ jacobi|
+ |(x, y, z)
+
+-Examples
+
+ Suppose one is given the bodyfixed rectangular state of an object
+ ( x(t), y(t), z(t), dx(t), dy(t), dz(t) ) as a function of time t.
+
+ To find the derivatives of the coordinates of the object in
+ bodyfixed latitudinal coordinates, one simply multiplies the
+ Jacobian of the transformation from rectangular to latitudinal
+ coordinates (evaluated at x(t), y(t), z(t) ) by the rectangular
+ velocity vector of the object at time t.
+
+ In code this looks like:
+
+ #include "SpiceUsr.h"
+ .
+ .
+ .
+
+ /.
+ Load the rectangular velocity vector vector recv.
+ ./
+ recv[0] = dx ( t );
+ recv[1] = dy ( t );
+ recv[2] = dz ( t );
+
+ /.
+ Determine the Jacobian of the transformation from rectangular to
+ latitudinal coordinates at the rectangular coordinates at time t.
+ ./
+ dlatdr_c ( x(t), y(t), z(t), jacobi );
+
+ /.
+ Multiply the Jacobian on the right by the rectangular
+ velocity to obtain the latitudinal coordinate derivatives
+ latv.
+ ./
+ mxv_c ( jacobi, recv, latv );
+
+
+-Restrictions
+
+ None.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ W.L. Taber (JPL)
+ N.J. Bachman (JPL)
+
+-Version
+
+ -CSPICE Version 1.0.0, 13-JUL-2001 (WLT) (NJB)
+
+-Index_Entries
+
+ Jacobian of rectangular w.r.t. latitudinal coordinates
+
+-&
+*/
+
+{ /* Begin dlatdr_c */
+
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dlatdr_c" );
+
+
+ dlatdr_ ( (doublereal *) &x,
+ (doublereal *) &y,
+ (doublereal *) &z,
+ (doublereal *) jacobi );
+
+ /*
+ Transpose the Jacobian to create a C-style matrix.
+ */
+ xpose_c ( jacobi, jacobi );
+
+
+ chkout_c ( "dlatdr_c" );
+
+} /* End dlatdr_c */
diff --git a/ext/spice/src/cspice/dnearp.c b/ext/spice/src/cspice/dnearp.c
new file mode 100644
index 0000000000..1b86fe4c6b
--- /dev/null
+++ b/ext/spice/src/cspice/dnearp.c
@@ -0,0 +1,528 @@
+/* dnearp.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static doublereal c_b16 = 1.;
+
+/* $Procedure DNEARP ( Derivative of near point ) */
+/* Subroutine */ int dnearp_(doublereal *state, doublereal *a, doublereal *b,
+ doublereal *c__, doublereal *dnear, doublereal *dalt, logical *found)
+{
+ /* Initialized data */
+
+ static doublereal gradm[9] /* was [3][3] */ = { 1.,0.,0.,0.,1.,0.,0.,0.,
+ 1. };
+ static doublereal m[9] /* was [3][3] */ = { 1.,0.,0.,0.,1.,0.,0.,0.,
+ 1. };
+
+ /* System generated locals */
+ integer i__1, i__2;
+ doublereal d__1;
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+
+ /* Local variables */
+ doublereal grad[3], temp[3];
+ extern doublereal vdot_(doublereal *, doublereal *);
+ extern /* Subroutine */ int vsub_(doublereal *, doublereal *, doublereal *
+ );
+ extern doublereal vtmv_(doublereal *, doublereal *, doublereal *);
+ integer i__;
+ doublereal l;
+ extern /* Subroutine */ int chkin_(char *, ftnlen);
+ doublereal denom, dterm[3];
+ extern /* Subroutine */ int vlcom_(doublereal *, doublereal *, doublereal
+ *, doublereal *, doublereal *);
+ doublereal norml[3];
+ extern /* Subroutine */ int unorm_(doublereal *, doublereal *, doublereal
+ *);
+ extern logical failed_(void);
+ doublereal length, lprime;
+ extern /* Subroutine */ int nearpt_(doublereal *, doublereal *,
+ doublereal *, doublereal *, doublereal *, doublereal *), chkout_(
+ char *, ftnlen);
+ doublereal zenith[3];
+ extern logical return_(void);
+ extern /* Subroutine */ int mxv_(doublereal *, doublereal *, doublereal *)
+ ;
+
+/* $ Abstract */
+
+/* Compute the ellipsoid surface point nearest to a specified */
+/* position; also compute the velocity of this point. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ELLIPSOID, GEOMETRY, DERIVATIVE */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* STATE I State of an object in body-fixed coordinates. */
+/* A I Length of semi-axis parallel to x-axis. */
+/* B I Length of semi-axis parallel to y-axis. */
+/* C I Length on semi-axis parallel to z-axis. */
+/* DNEAR O State of the nearest point on the ellipsoid. */
+/* DALT O Altitude and derivative of altitude. */
+/* FOUND O Tells whether DNEAR is degenerate. */
+
+/* $ Detailed_Input */
+
+/* STATE is a 6-vector giving the position and velocity of */
+/* some object in the body-fixed coordinates of the */
+/* ellipsoid. */
+
+/* In body-fixed coordinates, the semi-axes of the */
+/* ellipsoid are aligned with the x, y, and z-axes of the */
+/* coordinate system. */
+
+/* A is the length of the semi-axis of the ellipsoid */
+/* that is parallel to the x-axis of the body-fixed */
+/* coordinate system. */
+
+/* B is the length of the semi-axis of the ellipsoid */
+/* that is parallel to the y-axis of the body-fixed */
+/* coordinate system. */
+
+/* C is the length of the semi-axis of the ellipsoid */
+/* that is parallel to the z-axis of the body-fixed */
+/* coordinate system. */
+
+/* $ Detailed_Output */
+
+
+/* DNEAR is the 6-vector giving the position and velocity */
+/* in body-fixed coordinates of the point on the */
+/* ellipsoid, closest to the object whose position */
+/* and velocity are represented by STATE. */
+
+/* While the position component of DNEAR is always */
+/* meaningful, the velocity component of DNEAR will be */
+/* meaningless if FOUND if .FALSE. (See the discussion */
+/* of the meaning of FOUND below.) */
+
+
+/* DALT is an array of two double precision numbers. The */
+/* first gives the altitude of STATE with respect to */
+/* the ellipsoid. The second gives the rate of */
+/* change of the altitude. */
+
+/* Note that the rate of change of altitude is meaningful */
+/* if and only if FOUND is .TRUE. (See the discussion of */
+/* the meaning of FOUND below.) */
+
+/* FOUND is a logical flag indicating whether or not the */
+/* velocity portion of DNEAR is meaningful. */
+/* If the velocity portion of DNEAR is meaningful */
+/* FOUND will be returned with a value of .TRUE. */
+/* Under very rare circumstance the velocity of the */
+/* near point is undefined. Under these circumstances */
+/* FOUND will be returned with the value .FALSE. */
+
+/* FOUND can be .FALSE. only for states whose position */
+/* components are inside the ellipsoid and then only at */
+/* points on a special surface contained inside the */
+/* ellipsoid called the focal set of the ellipsoid. */
+
+/* A point in the interior is on this special surface */
+/* only if there are two or more points on the ellipsoid */
+/* that are closest to it. The origin is such a point */
+/* and the only such point if the ellipsoid is a */
+/* sphere. For non-spheroidal ellipsoids the focal */
+/* set contains small portions of the planes of */
+/* symmetry of the ellipsoid. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+
+/* 1) If the axes are non-positive, a routine in the call tree */
+/* of this routine will diagnose the error. */
+
+/* 2) If an object is passing through the interior of an ellipsoid */
+/* there are points at which there is more than 1 point on */
+/* the ellipsoid that is closest to the object. At these */
+/* points the velocity of the near point is undefined. (See */
+/* the description of the output variable FOUND). */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* If an object is moving relative to some triaxial body along */
+/* a trajectory C(t) then there is a companion trajectory N(t) */
+/* that gives the point on the ellipsoid that is closest to */
+/* C(t) as a function of t. The instantaneous position and */
+/* velocity of C(t) (STATE) are sufficient to compute the */
+/* instantaneous position and velocity of N(t) (DNEAR). */
+
+/* This routine computes DNEAR from STATE. In addition it returns */
+/* the altitude and rate of change of altitude. */
+
+/* Note that this routine can compute DNEAR for STATES outside, */
+/* on, or inside the ellipsoid. However, the velocity of DNEAR */
+/* and derivative of altitude do not exist for a "small" set */
+/* of STATES in the interior of the ellipsoid. See the */
+/* discussion of FOUND above for a description of this set of */
+/* points. */
+
+/* $ Examples */
+
+/* Example 1. Speed of a ground track. */
+/* ======================================= */
+
+/* Suppose you wish to compute the velocity of the ground track */
+/* of a satellite as it passes over a location on the earth */
+/* and that the moment of passage (ET) has been previously */
+/* determined. (We assume that the spacecraft is close enough */
+/* to the surface that light time corrections do not matter.) */
+
+/* We let */
+
+/* BODY be the idcode for the body */
+/* FRAME be the string representing the body's body-fixed frame */
+/* SCID be the idcode of the spacecraft */
+
+/* First get the axes of the body. */
+
+/* CALL BODVCD ( BODY, 'RADII', 3, DIM, ABC ) */
+
+/* A = ABC(1) */
+/* B = ABC(2) */
+/* C = ABC(3) */
+
+/* CALL SPKEZ ( SCID, ET, FRAME, 'NONE', BODY, STATE, LT ) */
+/* CALL DNEARP ( STATE, A, B, C, DNEAR, DALT ) */
+
+/* DNEAR contains the state of the subspacecraft point. */
+
+
+/* Example 2. Doppler shift of an altimeter. */
+/* ========================================= */
+
+/* Suppose you wish to compute the one-way doppler shift of a radar */
+/* altimeter mounted on board a spacecraft as it passes */
+/* over some region. Moreover, assume that for your */
+/* purposes it is sufficient to neglect effects of atmosphere, */
+/* topography and antenna pattern for the sake of this */
+/* computation. We use the same notation as in the previous example. */
+
+/* First get the axes of the body. */
+
+/* CALL BODVCD ( BODY, 'RADII', 3, DIM, ABC ) */
+
+/* A = ABC(1) */
+/* B = ABC(2) */
+/* C = ABC(3) */
+
+/* CALL SPKEZ ( SCID, ET, FRAME, 'NONE', BODY, STATE, LT ) */
+/* CALL DNEARP ( STATE, A, B, C, DNEAR, DALT ) */
+
+
+/* The change in frequency is given by multiplying SHIFT times the */
+/* carrier frequency */
+
+/* SHIFT = ( DALT(2) / CLIGHT() ) */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.1.2, 26-JUN-2008 (NJB) */
+
+/* Corrected spelling error in abstract; re-wrote */
+/* abstract text. */
+
+/* - SPICELIB Version 1.1.1, 24-OCT-2005 (NJB) */
+
+/* Header update: changed references to BODVAR to references */
+/* to BODVCD. */
+
+/* - SPICELIB Version 1.1.0, 05-MAR-1998 (WLT) */
+
+/* In the previous version of the routine FOUND could be */
+/* returned without being set to TRUE when the velocity */
+/* of the near point and rate of change of altitude */
+/* could be determined. This error has been corrected. */
+
+/* - SPICELIB Version 1.0.0, 15-JUN-1995 (WLT) */
+
+
+/* -& */
+/* $ Index_Entries */
+
+/* Velocity of the nearest point on an ellipsoid */
+/* Rate of change of the altitude over an ellipsoid */
+/* Derivative of altitude over an ellipoid */
+/* Velocity of a ground track */
+
+/* -& */
+
+/* Spicelib functions */
+
+
+/* Local Variables */
+
+
+/* Saved Variables */
+
+
+/* Initial Values */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ }
+ chkin_("DNEARP", (ftnlen)6);
+
+/* Until we have reason to believe otherwise, we set FOUND to TRUE. */
+
+ *found = TRUE_;
+
+/* First we need to compute the near point. */
+
+ nearpt_(state, a, b, c__, dnear, dalt);
+
+/* Make sure nothing went bump in the dark innards of NEARPT. */
+
+ if (failed_()) {
+ *found = FALSE_;
+ chkout_("DNEARP", (ftnlen)6);
+ return 0;
+ }
+
+/* Now for the work of this routine. We need to compute the */
+/* velocity component of DNEAR. */
+
+/* In all of the discussions below we let <,> stand for the */
+/* dot product. */
+
+/* Let P be the position (first three components) of STATE */
+/* and let N be the position (first three components) of DNEAR. */
+
+/* The surface of the ellipsoid is described as the level set */
+/* f(x,y,z) = 1 for the function f defined by */
+
+/* f(x,y,z) = x**2/a**2 + y**2/b**2 + z**2/c**2 */
+
+/* Let GRAD be the "half" gradiant of f. Then for some L */
+
+
+/* N + L * GRAD = P ( 1 ) */
+
+
+/* So that */
+/* < P - N, GRAD > */
+/* L = -------------- */
+/* < GRAD , GRAD > */
+
+/* GRAD */
+/* = < P - N, ------ > / | GRAD | */
+/* |GRAD| */
+
+/* Since GRAD is computed at a point on the level set f(x,y,z) = 1 */
+/* we don't have to worry about the magnitude of |GRAD| being */
+/* so small that underflow can occur. */
+
+/* Note that the half gradiant of f can be computed by simple */
+/* vector multiplication */
+
+/* [ 1/A**2 0 0 ] [ x ] */
+/* GRAD(x,y,z) = | 0 1/B**2 0 | | y | */
+/* [ 0 0 1/C**2 ] [ z ] */
+
+/* We call the matrix above GRADM. The correct off */
+/* diagonal values have been established in the data statement */
+/* following the declaration section of this routine. */
+
+ gradm[0] = 1. / (*a * *a);
+ gradm[4] = 1. / (*b * *b);
+ gradm[8] = 1. / (*c__ * *c__);
+ vsub_(state, dnear, zenith);
+ mxv_(gradm, dnear, grad);
+ unorm_(grad, norml, &length);
+ l = vdot_(zenith, norml) / length;
+
+/* We can rewrite equation (1) as */
+
+/* P = N + L * GRADM * N */
+
+/* from this it follows that */
+
+/* P' = N' + L' * GRADM * N */
+/* + L * GRADM * N' */
+
+/* = ( IDENT + L*GRADM ) * N' + L' * GRADM * N */
+
+/* = ( IDENT + L*GRADM ) * N' + L' * GRAD */
+
+/* where IDENT is the 3x3 identity matrix. */
+
+/* Let M be the inverse of the matrix IDENT + L*GRADM. (Provided */
+/* of course that all of the diagonal entries are non-zero). */
+
+/* If we multiply both sides of the equation above by M */
+/* we have */
+
+
+/* M*P' = N' + L'* M * GRAD ( 2 ) */
+
+
+/* Recall now that N' is orthogonal to GRAD (N' lies in the */
+/* tangent plane to the ellipsoid at N and GRAD is normal */
+/* to this tangent plane). Thus */
+
+/* < GRAD, M*P' > = L' < GRAD, M * GRAD > */
+
+/* and */
+
+/* < GRAD, M*P' > */
+/* L' = ----------------- */
+/* < GRAD, M*GRAD > */
+
+
+/* = VTMV ( GRAD, M, P' ) / VTMV ( GRAD, M, GRAD ) */
+
+/* Let's pause now to compute M and L'. */
+
+/* This is where things could go bad. M might not exist (which */
+/* indicates STATE is on the focal set of the ellipsoid). In */
+/* addition it is conceivable that VTMV ( GRAD, M, GRAD ) is */
+/* zero. This turns out not to be possible. However, the */
+/* demonstration of this fact requires delving into the details */
+/* of how N was computed by NEARPT. Rather than spending a */
+/* lot of time explaining the details we will make an */
+/* unnecessary but inexpensive check that we don't divide by */
+/* zero when computing L'. */
+
+ for (i__ = 1; i__ <= 3; ++i__) {
+ dterm[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("dterm", i__1,
+ "dnearp_", (ftnlen)458)] = l * gradm[(i__2 = i__ + i__ * 3 -
+ 4) < 9 && 0 <= i__2 ? i__2 : s_rnge("gradm", i__2, "dnearp_",
+ (ftnlen)458)] + 1.;
+ }
+ for (i__ = 1; i__ <= 3; ++i__) {
+ if (dterm[(i__1 = i__ - 1) < 3 && 0 <= i__1 ? i__1 : s_rnge("dterm",
+ i__1, "dnearp_", (ftnlen)463)] != 0.) {
+ m[(i__1 = i__ + i__ * 3 - 4) < 9 && 0 <= i__1 ? i__1 : s_rnge(
+ "m", i__1, "dnearp_", (ftnlen)464)] = 1. / dterm[(i__2 =
+ i__ - 1) < 3 && 0 <= i__2 ? i__2 : s_rnge("dterm", i__2,
+ "dnearp_", (ftnlen)464)];
+ } else {
+ *found = FALSE_;
+ chkout_("DNEARP", (ftnlen)6);
+ return 0;
+ }
+ }
+ denom = vtmv_(grad, m, grad);
+ if (denom == 0.) {
+ *found = FALSE_;
+ chkout_("DNEARP", (ftnlen)6);
+ return 0;
+ }
+ lprime = vtmv_(grad, m, &state[3]) / denom;
+
+/* Now that we have L' we can easily compute N'. Rewriting */
+/* equation (2) from above we have. */
+
+/* N' = M * ( P' - L'*GRAD ) */
+
+ d__1 = -lprime;
+ vlcom_(&c_b16, &state[3], &d__1, grad, temp);
+ mxv_(m, temp, &dnear[3]);
+
+/* Only one thing left to do. Compute the derivative */
+/* of the altitude ALT. Recall that */
+
+/* GRAD */
+/* ALT = < P - N, ------ > */
+/* |GRAD| */
+
+/* GRAD */
+/* dALT/dt = < P' - N', ------ > */
+/* |GRAD| */
+
+/* GRAD */
+/* + < P - N, Deriv of{------} > */
+/* |GRAD| */
+
+/* The second term is zero. To see this note that P - N is parallel */
+/* to GRAD. Moreover, since GRAD/|GRAD| is a unit vector its */
+/* derivative is necessarily orthogonal to it. Hence it is */
+/* orthogonal to GRAD and P-N. */
+
+/* Thus */
+/* GRAD */
+/* dALT/dt = < P' - N', ------ > */
+/* |GRAD| */
+
+/* But as we discussed earlier N' is orthogonal to GRAD. Thus */
+
+/* GRAD */
+/* dALT/dt = < P' , ------ > */
+/* |GRAD| */
+
+/* We've already computed GRAD/|GRAD| (NORML). Hence */
+
+/* dALT/dt = < P', NORML > */
+
+ dalt[1] = vdot_(&state[3], norml);
+ chkout_("DNEARP", (ftnlen)6);
+ return 0;
+} /* dnearp_ */
+
diff --git a/ext/spice/src/cspice/dolio.c b/ext/spice/src/cspice/dolio.c
new file mode 100644
index 0000000000..4b5a2ca658
--- /dev/null
+++ b/ext/spice/src/cspice/dolio.c
@@ -0,0 +1,20 @@
+#include "f2c.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifdef KR_headers
+extern int (*f__lioproc)();
+
+integer do_lio(type,number,ptr,len) ftnint *number,*type; char *ptr; ftnlen len;
+#else
+extern int (*f__lioproc)(ftnint*, char*, ftnlen, ftnint);
+
+integer do_lio(ftnint *type, ftnint *number, char *ptr, ftnlen len)
+#endif
+{
+ return((*f__lioproc)(number,ptr,len,*type));
+}
+#ifdef __cplusplus
+ }
+#endif
diff --git a/ext/spice/src/cspice/dp2hx.c b/ext/spice/src/cspice/dp2hx.c
new file mode 100644
index 0000000000..19ba07d17a
--- /dev/null
+++ b/ext/spice/src/cspice/dp2hx.c
@@ -0,0 +1,568 @@
+/* dp2hx.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__2 = 2;
+
+/* $Procedure DP2HX ( D.p. number to hexadecimal string ) */
+/* Subroutine */ int dp2hx_(doublereal *number, char *string, integer *length,
+ ftnlen string_len)
+{
+ /* Initialized data */
+
+ static char digits[1*16] = "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A"
+ "B" "C" "D" "E" "F";
+
+ /* System generated locals */
+ address a__1[2];
+ integer i__1, i__2[2];
+
+ /* Builtin functions */
+ integer s_rnge(char *, integer, char *, integer);
+ /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen),
+ s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ extern /* Subroutine */ int int2hx_(integer *, char *, integer *, ftnlen);
+ doublereal remndr;
+ integer explen;
+ logical negtiv;
+ integer intexp, positn, result;
+ doublereal tmpnum;
+ logical postiv;
+ char expstr[255], tmpstr[255];
+
+/* $ Abstract */
+
+/* Convert a double precision number to an equivalent character */
+/* string using a base 16 ``scientific notation.'' */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ALPHANUMERIC */
+/* CONVERSION */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* VARIABLE I/O DESCRIPTION */
+/* -------- --- -------------------------------------------------- */
+/* NUMBER I D.p. number to be converted. */
+/* STRING O Equivalent character string, left justified. */
+/* LENGTH O Length of the character string produced. */
+
+/* $ Detailed_Input */
+
+/* NUMBER The double precision number to be converted to a */
+/* character string representation. */
+
+/* $ Detailed_Output */
+
+/* STRING The character string produced by this routine which */
+/* represents NUMBER in a base 16 ``scientific notation,'' */
+/* e.g.: */
+
+/* 672.0 = '2A^3' = ( 2/16 + 10/( 16**2 ) ) * 16**3 */
+
+/* and */
+
+/* -11.0 = '-B^1' = - ( 11/16 ) * 16**1. */
+
+/* The following table describes the character set used to */
+/* represent the hexadecimal digits and their corresponding */
+/* values. */
+
+/* Character Value Character Value */
+/* --------- ------ --------- ------ */
+/* '0' 0.0D0 '8' 8.0D0 */
+/* '1' 1.0D0 '9' 9.0D0 */
+/* '2' 2.0D0 'A' 10.0D0 */
+/* '3' 3.0D0 'B' 11.0D0 */
+/* '4' 4.0D0 'C' 12.0D0 */
+/* '5' 5.0D0 'D' 13.0D0 */
+/* '6' 6.0D0 'E' 14.0D0 */
+/* '7' 7.0D0 'F' 15.0D0 */
+
+/* The carat, or hat, character, '^', is used to */
+/* distinguish the exponent. */
+
+/* The plus sign, '+', and the minus sign, '-', are used, */
+/* and they have their usual meanings. */
+
+/* In order to obtain the entire character string produced */
+/* by this routine, the output character string should be */
+/* at least N characters long, where */
+
+
+/* # of bits per double precision mantissa + 3 */
+/* N = 3 + ---------------------------------------------- */
+/* 4 */
+
+/* # of bits per double precision exponent + 3 */
+/* + ---------------------------------------------- . */
+/* 4 */
+
+/* There should be one character position for the sign of */
+/* the mantissa, one for the sign of the exponent, one for */
+/* the exponentiation character, and one for each */
+/* hexadecimal digit that could be produced from a mantissa */
+/* and an exponent. */
+
+/* The following table contains minimum output string */
+/* lengths necessary to obtain the complete character */
+/* string produced by this routine for some typical */
+/* implementations of double precision numbers. */
+
+/* Double precision number */
+/* Size Mantissa Exponent Minimum output string length */
+/* bits bits bits */
+/* ---- -------- -------- ---------------------------- */
+/* 64 48 15 3 + 12 + 4 = 19 */
+/* 64 55+1 8 3 + 14 + 2 = 19 (VAX) */
+/* 64 52 11 3 + 13 + 3 = 19 (IEEE) */
+
+/* The base 16 ``scientific notation'' character string */
+/* produced by this routine will be left justified and */
+/* consist of a contiguous sequence of characters with one */
+/* of following formats: */
+
+/* (1) h h h h ... h ^H H ... H */
+/* 1 2 3 4 n 1 2 m */
+
+/* (2) -h h h h ... h ^H H ... H */
+/* 1 2 3 4 n 1 2 m */
+
+/* (3) h h h h ... h ^-H H ... H */
+/* 1 2 3 4 n 1 2 m */
+
+/* (4) -h h h h ... h ^-H H ... H */
+/* 1 2 3 4 n 1 2 m */
+
+/* where */
+
+/* h and H denote hexadecimal digits */
+/* i j */
+
+/* '^' denotes exponentiation ( base 16 ) */
+
+/* and */
+
+/* '+' and '-' have their usual interpretations. */
+
+/* The character string produced will be blank padded on */
+/* the right if LENGTH < LEN( STRING ). */
+
+/* LENGTH Length of the base 16 ``scientific notation'' character */
+/* string produced by this routine. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* Error free. */
+
+/* 1) If the output character string is not long enough to */
+/* contain the entire character string that was produced, */
+/* the string will be truncated on the right. */
+
+/* 2) If LEN( STRING ) > LENGTH, the output character string will */
+/* be blank padded on the right. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine converts a double precision number into an equivalent */
+/* character string using a base 16 ``scientific notation.'' This */
+/* representation allows the full precision of a number to be placed */
+/* in a format that is suitable for porting or archival storage. */
+
+/* This routine is one of a pair of routines which are used to */
+/* perform conversions between double precision numbers and */
+/* an equivalent base 16 ``scientific notation'' character string */
+/* representation: */
+
+/* DP2HX -- Convert a double precision number into a base 16 */
+/* ``scientific notation'' character string. */
+
+/* HX2DP -- Convert a base 16 ``scientific notation'' */
+/* character string into a double precision number. */
+
+/* $ Examples */
+
+/* The following input and output argument values illustrate the */
+/* action of DP2HX for various input values of NUMBER. */
+
+/* Note: The hat or carat, '^', signals an exponent. */
+
+/* NUMBER STRING LENGTH */
+/* ----------------- ----------------------------- ------ */
+/* 2.0D-9 89705F4136B4A6^-7 17 */
+/* 1.0D0 1^1 3 */
+/* -1.0D0 -1^1 4 */
+/* 1024.0D0 4^3 3 */
+/* -1024.0D0 -4^3 4 */
+/* 521707.0D0 7F5EB^5 7 */
+/* 27.0D0 1B^2 4 */
+/* 0.0D0 0^0 3 */
+
+/* $ Restrictions */
+
+/* The maximum number of characters permitted in the output string */
+/* is specified by the local parameter STRLEN. */
+
+/* $ Author_and_Institution */
+
+/* K.R. Gehringer (JPL) */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1994 (KRG) */
+
+/* Fixed a typo in the description of the input argument STRING. */
+/* The example showing the expansion of 160 into hexadecimal */
+/* was incorrect. 160 was replaced with 672 which makes the */
+/* example correct. */
+
+/* - SPICELIB Version 1.0.0, 26-OCT-1992 (KRG) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* convert d.p. to signed normalized hexadecimal string */
+/* convert d.p. number to encoded d.p. number */
+/* convert d.p. to base 16 scientific notation */
+
+/* -& */
+/* $ Revisions */
+
+/* - SPICELIB Version 1.0.1, 10-MAR-1994 (KRG) */
+
+/* Fixed a typo in the description of the input argument STRING. */
+/* The example showing the expansion of 160 into hexadecimal */
+/* was incorrect. 160 was replaced with 672 which makes the */
+/* example correct. */
+
+/* Old Example: */
+
+/* 160.0 = '2A^3' = ( 2/16 + 10/( 16**2 ) ) * 16**3 */
+
+/* New Example: */
+
+/* 672.0 = '2A^3' = ( 2/16 + 10/( 16**2 ) ) * 16**3 */
+
+/* -& */
+
+/* Local Parameters */
+
+
+/* Local variables */
+
+
+/* Saved variables */
+
+
+/* Initial values */
+
+
+/* Make a copy of the input so that it will not be changed by this */
+/* routine. Also, assume that we do not know the sign of the number. */
+
+ tmpnum = *number;
+ negtiv = FALSE_;
+ postiv = FALSE_;
+
+/* Check to see what the sign of the number is, because we treat */
+/* negative numbers, positive numbers and zero separately. This */
+/* simplifies the testing in the loop boundaries a bit, and removes */
+/* calls to DABS() that would otherwise have been necessary. */
+
+/* Set the appropriate logical flag for the sign of the input number. */
+
+ if (tmpnum < 0.) {
+ negtiv = TRUE_;
+ } else if (tmpnum > 0.) {
+ postiv = TRUE_;
+ }
+
+/* If nonzero, a double precision number is first normalized, */
+/* so that it has a value between 1.0D0/BASE and 1.0D0 or -1.0D0 */
+/* and -1/BASE. The hexadecimal digits in the mantissa are found */
+/* by repeated applications of multiplication and truncation */
+/* operations. The hexadecimal digits will be in the correct order */
+/* when finished. The string will be left justified, and its length */
+/* will be set before returning. */
+
+/* Calculate the exponent of the number using multiple scaling */
+/* levels. The different scale factors, 16**8, 16**4, and 16, */
+/* provide a significant speed improvement for the normalization */
+/* process. */
+
+ intexp = 0;
+ if (negtiv) {
+ if (tmpnum > -1.) {
+
+/* ABS(TMPNUM) .LT. 1.0 */
+
+ while(tmpnum * 4294967296. > -1.) {
+
+/* Scale the number and decrement the exponent. */
+
+ tmpnum *= 4294967296.;
+ intexp += -8;
+ }
+ while(tmpnum * 65536. > -1.) {
+
+/* Scale the number and decrement the exponent. */
+
+ tmpnum *= 65536.;
+ intexp += -4;
+ }
+ while(tmpnum * 16. > -1.) {
+
+/* Scale the number and decrement the exponent. */
+
+ tmpnum *= 16.;
+ --intexp;
+ }
+
+/* At this point, -1 < TMPNUM <= -1/BASE. */
+
+ } else {
+
+/* ABS(TMPNUM) .GE. 1.0 */
+
+ while(tmpnum * 2.3283064365386963e-10 <= -1.) {
+
+/* Scale the number and increment the exponent. */
+
+ tmpnum *= 2.3283064365386963e-10;
+ intexp += 8;
+ }
+ while(tmpnum * 1.52587890625e-5 <= -1.) {
+
+/* Scale the number and increment the exponent. */
+
+ tmpnum *= 1.52587890625e-5;
+ intexp += 4;
+ }
+ while(tmpnum <= -1.) {
+
+/* Scale the number and increment the exponent. */
+
+ tmpnum *= .0625;
+ ++intexp;
+ }
+
+/* At this point, -1 < TMPNUM <= -1/BASE. */
+
+ }
+ } else if (postiv) {
+ if (tmpnum < 1.) {
+
+/* ABS(TMPNUM) .LT. 1.0 */
+
+ while(tmpnum * 4294967296. < 1.) {
+
+/* Scale the number and decrement the exponent. */
+
+ tmpnum *= 4294967296.;
+ intexp += -8;
+ }
+ while(tmpnum * 65536. < 1.) {
+
+/* Scale the number and decrement the exponent. */
+
+ tmpnum *= 65536.;
+ intexp += -4;
+ }
+ while(tmpnum * 16. < 1.) {
+
+/* Scale the number and decrement the exponent. */
+
+ tmpnum *= 16.;
+ --intexp;
+ }
+
+/* At this point, 1/BASE <= TMPNUM < 1 */
+
+ } else {
+
+/* ABS(TMPNUM) .GE. 1.0 */
+
+ while(tmpnum * 2.3283064365386963e-10 >= 1.) {
+
+/* Scale the number and increment the exponent. */
+
+ tmpnum *= 2.3283064365386963e-10;
+ intexp += 8;
+ }
+ while(tmpnum * 1.52587890625e-5 >= 1.) {
+
+/* Scale the number and increment the exponent. */
+
+ tmpnum *= 1.52587890625e-5;
+ intexp += 4;
+ }
+ while(tmpnum >= 1.) {
+
+/* Scale the number and increment the exponent. */
+
+ tmpnum *= .0625;
+ ++intexp;
+ }
+
+/* At this point, 1/BASE <= TMPNUM < 1 */
+
+ }
+ }
+
+/* We do different things for the cases where the number to be */
+/* converted is positive, negative, or zero. */
+
+ if (negtiv) {
+
+/* Set the beginning position. */
+
+ positn = 1;
+
+/* Put the minus sign in place. */
+
+ *(unsigned char *)&tmpstr[positn - 1] = '-';
+
+/* Start with the remainder equal to the normalized value of the */
+/* original number. */
+
+ remndr = tmpnum;
+
+/* Collect all of the digits in the string. */
+
+/* This stopping test works because the base is a power of */
+/* 2 and the mantissa is composed of a sum of powers of 2. */
+
+ while(remndr != 0.) {
+
+/* -1 < REMNDR <= -1/BASE */
+
+ ++positn;
+ tmpnum = remndr * 16.;
+ result = (integer) tmpnum;
+ remndr = tmpnum - (doublereal) result;
+ *(unsigned char *)&tmpstr[positn - 1] = *(unsigned char *)&digits[
+ (i__1 = -result) < 16 && 0 <= i__1 ? i__1 : s_rnge("digi"
+ "ts", i__1, "dp2hx_", (ftnlen)554)];
+ }
+
+/* Put the exponent on the end of the number and update the */
+/* position. */
+
+ int2hx_(&intexp, expstr, &explen, (ftnlen)255);
+ i__1 = positn;
+/* Writing concatenation */
+ i__2[0] = 1, a__1[0] = "^";
+ i__2[1] = explen, a__1[1] = expstr;
+ s_cat(tmpstr + i__1, a__1, i__2, &c__2, 255 - i__1);
+ positn = positn + explen + 1;
+ } else if (postiv) {
+
+/* Set the beginning position. */
+
+ positn = 0;
+
+/* Start with the remainder equal to the normalized value of the */
+/* original number. */
+
+ remndr = tmpnum;
+
+/* Collect all of the digits in the string. */
+
+/* This stopping test works because the base is a power of */
+/* 2 and the mantissa is composed of a sum of powers of 2. */
+
+ while(remndr != 0.) {
+
+/* 1/BASE <= REMNDR < 1 */
+
+ ++positn;
+ tmpnum = remndr * 16.;
+ result = (integer) tmpnum;
+ remndr = tmpnum - (doublereal) result;
+ *(unsigned char *)&tmpstr[positn - 1] = *(unsigned char *)&digits[
+ (i__1 = result) < 16 && 0 <= i__1 ? i__1 : s_rnge("digits"
+ , i__1, "dp2hx_", (ftnlen)589)];
+ }
+
+/* Put the exponent on the end of the number and update the */
+/* position. */
+
+ int2hx_(&intexp, expstr, &explen, (ftnlen)255);
+ i__1 = positn;
+/* Writing concatenation */
+ i__2[0] = 1, a__1[0] = "^";
+ i__2[1] = explen, a__1[1] = expstr;
+ s_cat(tmpstr + i__1, a__1, i__2, &c__2, 255 - i__1);
+ positn = positn + explen + 1;
+ } else {
+
+/* Treat zero as a special case, because it's easier. */
+
+ positn = 3;
+ s_copy(tmpstr, "0^0", (ftnlen)3, (ftnlen)3);
+ }
+
+/* Set the value for the length of the character string produced */
+/* before returning. */
+
+ *length = positn;
+
+/* Set the value of the output string before returning. Let the */
+/* Fortran string assignment deal with the left justification, and */
+/* the truncation on the right if STRING is not long enough to */
+/* contain all of the characters produced. */
+
+ s_copy(string, tmpstr, string_len, (*length));
+ return 0;
+} /* dp2hx_ */
+
diff --git a/ext/spice/src/cspice/dp2hx_c.c b/ext/spice/src/cspice/dp2hx_c.c
new file mode 100644
index 0000000000..110ff59175
--- /dev/null
+++ b/ext/spice/src/cspice/dp2hx_c.c
@@ -0,0 +1,275 @@
+/*
+
+-Procedure dp2hx_c ( D.p. number to hexadecimal string )
+
+-Abstract
+
+ Convert a double precision number to an equivalent character
+ string using base 16 ``scientific notation.''
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ ALPHANUMERIC
+ CONVERSION
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZst.h"
+ #include "SpiceZmc.h"
+
+ void dp2hx_c ( SpiceDouble number,
+ SpiceInt lenout,
+ SpiceChar * string,
+ SpiceInt * length
+ )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ number I D.p. number to be converted.
+ lenout I Available space for output string 'string'.
+ string O Equivalent character string, left justified.
+ length O Length of the character string produced.
+
+-Detailed_Input
+
+ number The double precision number to be converted to a
+ character string representation.
+
+ lenout is the maximum length of the output 'string'. The value
+ defined by lenout should be one plus the value large
+ enough to hold any possible output.
+
+-Detailed_Output
+
+ string The character string produced by this routine that
+ represents 'number' in base 16 ``scientific notation,''
+ e.g.:
+
+ 672.0 = '2A^3' = ( 2/16 + 10/( 16**2 ) ) * 16**3
+
+ and
+
+ -11.0 = '-B^1' = - ( 11/16 ) * 16**1.
+
+ The following table describes the character set used to
+ represent the hexadecimal digits and their corresponding
+ values.
+
+ Character Value Character Value
+ --------- ------ --------- ------
+ '0' 0.0D0 '8' 8.0D0
+ '1' 1.0D0 '9' 9.0D0
+ '2' 2.0D0 'A' 10.0D0
+ '3' 3.0D0 'B' 11.0D0
+ '4' 4.0D0 'C' 12.0D0
+ '5' 5.0D0 'D' 13.0D0
+ '6' 6.0D0 'E' 14.0D0
+ '7' 7.0D0 'F' 15.0D0
+
+ The caret, or hat, character, '^', is used to distinguish
+ the exponent.
+
+ The plus sign, '+', and the minus sign, '-' have the expected
+ meanings.
+
+ In order to obtain the entire character string produced
+ by this routine, the output character string should be
+ at least N characters long, where
+
+
+ # of bits per double precision mantissa + 3
+ N = 3 + ----------------------------------------------
+ 4
+
+ # of bits per double precision exponent + 3
+ + ---------------------------------------------- .
+ 4
+
+ There should be one character position for the sign of
+ the mantissa, one for the sign of the exponent, one for
+ the exponentiation character, and one for each
+ hexadecimal digit that could be produced from a mantissa
+ and an exponent.
+
+ The following table contains minimum output string
+ lengths necessary to obtain the complete character
+ string produced by this routine for some typical
+ implementations of double precision numbers.
+
+ Double precision number
+ Size Mantissa Exponent Minimum output string length
+ bits bits bits
+ ---- -------- -------- ----------------------------
+ 64 48 15 3 + 12 + 4 = 19
+ 64 55+1 8 3 + 14 + 2 = 19 (VAX)
+ 64 52 11 3 + 13 + 3 = 19 (IEEE)
+
+ The base 16 ``scientific notation'' character string
+ produced by this routine will be left justified and
+ consist of a contiguous sequence of characters with one
+ of the following formats:
+
+ (1) h h h h ... h ^H H ... H
+ 1 2 3 4 n 1 2 m
+
+ (2) -h h h h ... h ^H H ... H
+ 1 2 3 4 n 1 2 m
+
+ (3) h h h h ... h ^-H H ... H
+ 1 2 3 4 n 1 2 m
+
+ (4) -h h h h ... h ^-H H ... H
+ 1 2 3 4 n 1 2 m
+
+ where
+
+ h and H denote hexadecimal digits
+ i j
+
+ '^' denotes exponentiation ( base 16 )
+
+ and
+
+ '+' and '-' have their usual interpretations.
+
+ length the length of the base 16 ``scientific notation'' character
+ 'string' returned by this routine.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ None.
+
+-Files
+
+ None.
+
+-Particulars
+
+ This routine converts a double precision number into an equivalent
+ character string using a base 16 ``scientific notation.'' This
+ representation allows the full precision of a number to be placed
+ in a format that is suitable for porting or archival storage.
+
+ This routine is one of a pair of routines which are used to
+ perform conversions between double precision numbers and
+ an equivalent base 16 ``scientific notation'' character string
+ representation:
+
+ dp2hx_c -- Convert a double precision number into a base 16
+ ``scientific notation'' character string.
+
+ hx2dp_c -- Convert a base 16 ``scientific notation''
+ character string into a double precision number.
+
+-Examples
+
+ The following input and output argument values illustrate the
+ action of dp2hx_c for various input values of 'number'.
+
+ Note: The hat or caret, '^', signals an exponent.
+
+ number string length
+ ----------------- ----------------------------- ------
+ 2.0D-9 89705F4136B4A6^-7 17
+ 1.0D0 1^1 3
+ -1.0D0 -1^1 4
+ 1024.0D0 4^3 3
+ -1024.0D0 -4^3 4
+ 521707.0D0 7F5EB^5 7
+ 27.0D0 1B^2 4
+ 0.0D0 0^0 3
+
+-Restrictions
+
+ The maximum number of characters permitted in the output string
+ is specified by the variable 'lenout'.
+
+-Literature_References
+
+ None.
+
+-Author_and_Institution
+
+ K.R. Gehringer (JPL)
+
+-Version
+
+ CSPICE Version 1.0.0, 10-APR-2010 (EDW)
+
+-Index_Entries
+
+ convert d.p. to signed normalized hexadecimal string
+ convert d.p. number to encoded d.p. number
+ convert d.p. to base 16 scientific notation
+
+-&
+*/
+
+{ /* Begin dp2hx_c */
+
+ /*
+ Participate in error tracing.
+ */
+ chkin_c ( "dp2hx_c" );
+
+ /*
+ Make sure the output string has at least enough room for one
+ output character and a null terminator. Also check for a null
+ pointer.
+ */
+
+ CHKOSTR ( CHK_STANDARD, "dp2hx_c", string, lenout );
+
+ (void) dp2hx_( ( doublereal * ) &number,
+ ( char * ) string,
+ ( integer * ) length,
+ ( ftnlen ) lenout -1 );
+
+
+ /*
+ Convert the output string from Fortran to C style.
+ */
+ F2C_ConvertStr( lenout, string );
+
+ chkout_c ( "dp2hx_c" );
+
+} /* End dp2hx_c */
diff --git a/ext/spice/src/cspice/dpfmt.c b/ext/spice/src/cspice/dpfmt.c
new file mode 100644
index 0000000000..cfb0f1572a
--- /dev/null
+++ b/ext/spice/src/cspice/dpfmt.c
@@ -0,0 +1,623 @@
+/* dpfmt.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static logical c_true = TRUE_;
+
+/* $Procedure DPFMT ( Format a double precision number ) */
+/* Subroutine */ int dpfmt_(doublereal *x, char *pictur, char *str, ftnlen
+ pictur_len, ftnlen str_len)
+{
+ /* System generated locals */
+ integer i__1, i__2, i__3, i__4;
+
+ /* Builtin functions */
+ integer i_len(char *, ftnlen), s_cmp(char *, char *, ftnlen, ftnlen);
+ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+
+ /* Local variables */
+ char fill[1];
+ integer dpat;
+ char sign[1];
+ integer i__;
+ extern /* Subroutine */ int zzvsbstr_(integer *, integer *, logical *,
+ char *, logical *, ftnlen);
+ doublereal y;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
+ ftnlen, ftnlen), zzvststr_(doublereal *, char *, integer *,
+ ftnlen);
+ logical shift;
+ extern integer ncpos_(char *, char *, integer *, ftnlen, ftnlen);
+ extern /* Subroutine */ int dpstr_(doublereal *, integer *, char *,
+ ftnlen);
+ integer start;
+ extern /* Subroutine */ int ljust_(char *, char *, ftnlen, ftnlen),
+ rjust_(char *, char *, ftnlen, ftnlen);
+ char mystr[32];
+ integer declen, sigdig;
+ logical needsn;
+ integer lastch, sgnlen, frstch, intlen, firstb;
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
+ ftnlen);
+ logical ovflow;
+ integer expsiz, sprsiz, exp__;
+ extern integer pos_(char *, char *, integer *, ftnlen, ftnlen);
+
+/* $ Abstract */
+
+/* Using a picture, create a formatted string that represents a */
+/* double precision number. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* ALPHANUMERIC */
+/* CONVERSION */
+/* UTILITY */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* X I a double precision number. */
+/* PICTUR I a string describing the appearance of the output */
+/* STR O a string representing X as prescribed by PICTUR */
+
+/* $ Detailed_Input */
+
+/* X is any double precision number. */
+
+/* PICTUR is a string used to describe the format of the */
+/* output string. There are four special characters */
+/* recognized by DPFMT --- a leading + or -, a leading */
+/* zero ( '0' ) or a zero that follows a leading + or -, */
+/* and the first decimal point of the string. */
+
+/* All other non-blank characters are regarded as */
+/* equivalent. The picture ends at the first blank */
+/* character. The effects associated with the various */
+/* characters in a picture are spelled out in the */
+/* description of the output STRING. */
+
+/* The following pictures are treated as errors. */
+
+/* ' ', '+', '-', '.', '+.', '-.' */
+
+/* $ Detailed_Output */
+
+/* STRING is a string representing X that matches the input */
+/* picture. The format of STRING is governed by PICTUR. */
+/* It will represent X rounded to the level of precision */
+/* specified by PICTUR. */
+
+/* If the first character of the picture is a minus sign, */
+/* the first character in the output string will be */
+/* a blank if the number is non-negative, a minus sign */
+/* if the number is negative. */
+
+/* If the first character of the picture is a plus sign, */
+/* the first character of the output string will be a */
+/* plus if the number is positive, a blank if the number */
+/* is zero, and a minus sign if the number is negative. */
+
+/* If the first character of the string is NOT a sign */
+/* (plus or minus) the first character of the output */
+/* string will be a minus sign if the number is negative */
+/* and will be the first character of the integer part */
+/* of the number otherwise. */
+
+/* The integer portion of STRING will contain the same */
+/* number of characters as appear before the decimal */
+/* point (or last character if there is no decimal */
+/* point) but after a leading + or -. */
+
+/* If the picture begins with any of the following */
+
+/* '+0', '-0', or '0' */
+
+/* it is said to have a leading zero. If a picture has */
+/* a leading zero and the integer portion is not large */
+/* enough to fill up the integer space specified by */
+/* PICTUR, STRING will be zero padded from the sign (if */
+/* one is required) up to the first character of the */
+/* integer part of the number. */
+
+/* If picture does NOT have a leading zero and the */
+/* integer portion is not large enough to fill up the */
+/* space specified by PICTUR, STRING will be blank */
+/* padded on the left between the sign (if one is */
+/* required) and the first character of the integer part */
+/* of the number. */
+
+/* If a decimal point ( '.' ) is present in PICTUR it */
+/* will be present following the integer portion of */
+/* STRING. Moreover, the decimal portion of STRING will */
+/* contain the same number of digits as there are */
+/* non-blank characters following the decimal point in */
+/* PICTUR. However, only the first 14 digits starting */
+/* with the first non-zero digit are meaningful. */
+
+/* If the format specified by PICTUR does not provide */
+/* enough room for the integer portion of X, the routine */
+/* determines whether or not the number of characters */
+/* present in the picture is sufficient to create a */
+/* representation for X using scientific notation. If */
+/* so, the output is displayed using scientific notation */
+/* (leading signs, if they are present in PICTUR, will */
+/* also appear in STRING). If the format specified by */
+/* PICTUR is too short to accommodate scientific */
+/* notation, the output string is filled with '*' to the */
+/* same length as the length of PICTUR. Leading signs */
+/* are not preserved in this overflow case. */
+
+/* STRING may overwrite PICTUR. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) A picture that begins with a blank will cause the error */
+/* 'SPICE(NOPICTURE)' to be signalled. */
+
+/* 2) A picture that consists only of '+', '-', '.', '+.' or '-.' */
+/* are regarded are regarded as errors (there's no significant */
+/* component to the picture.) These pictures cause the error */
+/* 'SPICE(BADPICTURE)' to be signalled. */
+
+/* 3) If the length of STR is less than the length of the first */
+/* non-blank portion of PICTUR, the error 'SPICE(OUTPUTTOOSHORT)' */
+/* will be signalled. */
+
+/* $ Files */
+
+/* None. */
+
+/* $ Particulars */
+
+/* This routine provides a mechanism for producing numeric strings */
+/* formatted according to a user supplied picture. We expect that */
+/* the string produced by this routine will be used to assist in */
+/* the construction of a string that can be read by people. */
+
+/* Note that the process of converting a double precision number */
+/* to a string, in not precisely invertible even if the string */
+/* contains all of the significant figures allowed by this */
+/* routine. You should not anticipate that the string produced */
+/* by this routine can be "read" into a double precision number */
+/* to reproduce the double precision number X. To the level of */
+/* accuracy implied by the string representation, they will be */
+/* the same. But, they are unlikely to have the same internal */
+/* binary representation. */
+
+/* $ Examples */
+
+/* Suppose that X has the binary representation of PI. Then the */
+/* table below illustrates the strings that would be produced */
+/* by a variety of different pictures. */
+
+/* PICTUR | STRING */
+/* ------------------------------- */
+/* '0x.xxx' | '03.142' */
+/* 'xx.xxx' | ' 3.142' */
+/* '+xxx.yyyy' | '+ 3.1416' */
+/* '-.yyyy' | '******' */
+/* 'xxxxxxxx' | ' 3' */
+/* '00xx' | '0003' */
+/* '-00.0000000' | ' 03.1415927' */
+/* '00' | '03' */
+/* 'x.' | '3.' */
+/* '.mynumber' | '3.142E+00' */
+/* 'my dog spot' | ' 3' */
+/* 'my.dog spot' | ' 3.142' */
+/* '+my.dog,spot' | '+ 3.14159265' */
+
+
+
+/* Suppose that X has the binary representation of 2/3. Then the */
+/* table below illustrates the strings that would be produced */
+/* by a variety of different pictures. */
+
+/* PICTUR | STRING */
+/* ------------------------------- */
+/* '+x.xxx' | '+0.667' */
+/* '+xx.xxx' | '+ 0.667' */
+/* 'xxx.yyyy' | ' 0.6667' */
+/* '.yyyy' | '.6667' */
+/* 'xxxxxxxx' | ' 1' */
+/* '00xx' | '0001' */
+/* '-0.0000000' | ' 0.6666667' */
+/* '00' | '01' */
+/* 'x.' | '1.' */
+/* 'mynumber' | ' 1' */
+/* 'my dog spot' | ' 1' */
+/* 'my.dog spot' | ' 0.667' */
+/* 'my.dog,spot' | ' 0.66666667' */
+
+/* Suppose that X has the binary representation of -8/9. Then the */
+/* table below illustrates the strings that would be produced */
+/* by a variety of different pictures. */
+
+
+/* PICTUR | STRING */
+/* ------------------------------- */
+/* '+x.xxx' | '-0.889' */
+/* '-00.xxxx' | '-00.8889' */
+/* 'xxx.xxx' | ' -0.889' */
+/* '000.000' | '-00.889' */
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* W.L. Taber (JPL) */
+/* B.V. Semenov (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.2, 31-JAN-2008 (BVS) */
+
+/* Removed non-standard end-of-declarations marker */
+/* 'C%&END_DECLARATIONS' from comments. */
+
+/* - Spicelib Version 1.0.1, 22-JUN-1998 (WLT) */
+
+/* A number of typographical and grammatical errors */
+/* were corrected in the header. */
+
+/* - Spicelib Version 1.0.0, 17-SEP-1996 (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* format a string representing a d.p. number */
+/* string from a d.p. number and format picture */
+
+/* -& */
+/* $ Revisions */
+
+/* None. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Initial values */
+
+
+/* Determine where the picture ends. */
+
+ firstb = pos_(pictur, " ", &c__1, pictur_len, (ftnlen)1);
+ if (firstb == 0) {
+ lastch = i_len(pictur, pictur_len);
+ } else {
+ lastch = firstb - 1;
+ }
+
+/* Make sure there is a picture to worry about. */
+
+ if (lastch == 0) {
+ chkin_("DPFMT", (ftnlen)5);
+ setmsg_("The format picture must begin with a non-blank character. "
+ "The picture supplied was began with a blank.", (ftnlen)103);
+ sigerr_("SPICE(NOPICTURE)", (ftnlen)16);
+ chkout_("DPFMT", (ftnlen)5);
+ return 0;
+ } else if (lastch == 1) {
+ if (s_cmp(pictur, "+", pictur_len, (ftnlen)1) == 0 || s_cmp(pictur,
+ "-", pictur_len, (ftnlen)1) == 0 || s_cmp(pictur, ".",
+ pictur_len, (ftnlen)1) == 0) {
+ chkin_("DPFMT", (ftnlen)5);
+ setmsg_("Format pictures must have at least one significant char"
+ "acter. The picture provided '#' does not. ", (ftnlen)97);
+ errch_("#", pictur, (ftnlen)1, (ftnlen)1);
+ sigerr_("SPICE(BADPICTURE)", (ftnlen)17);
+ chkout_("DPFMT", (ftnlen)5);
+ return 0;
+ }
+ } else if (lastch == 2) {
+ if (s_cmp(pictur, "+.", pictur_len, (ftnlen)2) == 0 || s_cmp(pictur,
+ "-.", pictur_len, (ftnlen)2) == 0) {
+ chkin_("DPFMT", (ftnlen)5);
+ setmsg_("Format pictures must have at least one significant char"
+ "acter. The picture provided '#' does not. ", (ftnlen)97);
+ errch_("#", pictur, (ftnlen)1, (ftnlen)2);
+ sigerr_("SPICE(BADPICTURE)", (ftnlen)17);
+ chkout_("DPFMT", (ftnlen)5);
+ return 0;
+ }
+ } else if (lastch > i_len(str, str_len)) {
+ chkin_("DPFMT", (ftnlen)5);
+ setmsg_("The output string is not long enough to accommodate a numbe"
+ "r formatted according the the supplied format picture. The "
+ "output string has length #. The output picture '#' requires"
+ " # characters. ", (ftnlen)194);
+ i__1 = i_len(str, str_len);
+ errint_("#", &i__1, (ftnlen)1);
+ errch_("#", pictur, (ftnlen)1, lastch);
+ errint_("#", &lastch, (ftnlen)1);
+ sigerr_("SPICE(OUTPUTTOOSHORT)", (ftnlen)21);
+ chkout_("DPFMT", (ftnlen)5);
+ return 0;
+ }
+
+/* If we get this far, the routine can go ahead and do its business. */
+/* Determine the sign of X. Also, determine how many characters */
+/* are needed to represent the sign if leading sign is suppressed for */
+/* positive numbers. */
+
+ if (*x > 0.) {
+ *(unsigned char *)sign = '+';
+ sprsiz = 0;
+ } else if (*x < 0.) {
+ *(unsigned char *)sign = '-';
+ sprsiz = 1;
+ } else {
+ *(unsigned char *)sign = ' ';
+ sprsiz = 0;
+ }
+
+/* Look at the picture and see if a leading sign is required and */
+/* if so whether the sign just determined should use a different */
+/* character and how many characters are needed for the sign. */
+
+ if (*(unsigned char *)pictur == '+') {
+ needsn = TRUE_;
+ sgnlen = 1;
+ } else if (*(unsigned char *)pictur == '-') {
+ needsn = TRUE_;
+ sgnlen = 1;
+ if (*x > 0.) {
+ *(unsigned char *)sign = ' ';
+ }
+ } else {
+ if (*x > 0.) {
+ *(unsigned char *)sign = ' ';
+ }
+ needsn = FALSE_;
+ sgnlen = sprsiz;
+ }
+
+/* If we need a leading sign. The numeric part of the string */
+/* will start at character 2. Otherwise it starts at character 1. */
+
+ if (needsn) {
+ start = 2;
+ } else {
+ start = 1;
+ }
+
+/* We can set the sign portion of the string now. */
+
+ s_copy(str, sign, str_len, (ftnlen)1);
+
+/* Determine what character should be use for leading characters */
+/* before the first significant character of the output string. */
+
+ if (*(unsigned char *)&pictur[start - 1] == '0') {
+ *(unsigned char *)fill = '0';
+ } else {
+ *(unsigned char *)fill = ' ';
+ }
+
+/* See if there is a decimal point. */
+
+ dpat = pos_(pictur, ".", &c__1, pictur_len, (ftnlen)1);
+
+/* The integer part is the stuff to the left of the first */
+/* decimal point and that follows the sign (if there is one */
+/* that is explicitly required. The length of the decimal */
+/* portion is the stuff to the right of the decimal point. */
+
+ if (dpat > 0) {
+ intlen = dpat - start;
+ declen = lastch - dpat;
+ } else {
+ intlen = lastch - start + 1;
+ declen = -1;
+ }
+
+/* If a sign was not explicitly requested by placing it in */
+/* the first digit of the picture START will be 1. If in */
+/* addition X is less than zero ( SGNLEN will be 1 in this */
+/* case) we have one fewer digits available for the integer */
+/* portion of the string than is currently set in INTLEN. */
+/* Adjust INTLEN to reflect the actual number of digits */
+/* available. */
+
+/* Also set the SHIFT flag to .TRUE. so that we know to swap */
+/* the sign and any blanks that might lie between the sign */
+/* and the first significant character of the output string. */
+
+ if (start == 1 && sgnlen == 1) {
+ --intlen;
+ shift = TRUE_;
+
+/* If INTLEN has become negative (i.e. -1) the picture */
+/* must be of the form .xxxxx and the input number must */
+/* be negative. Add 1 back onto the INTLEN but take one */
+/* away from the decimal length DECLEN. */
+
+ if (intlen == -1) {
+ intlen = 0;
+ --declen;
+ if (declen == 0 && intlen == 0) {
+
+/* There is no room for anything other than a */
+/* decimal point. We simply fill the output */
+/* string with the '*' character. */
+
+ i__1 = lastch;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ *(unsigned char *)&str[i__ - 1] = '*';
+ }
+ return 0;
+ }
+ }
+ } else {
+ shift = FALSE_;
+ }
+
+/* Create the "virtual decimal string" associated with the */
+/* unsigned part of X. */
+
+ y = abs(*x);
+ zzvststr_(&y, fill, &exp__, (ftnlen)1);
+
+/* The actual number of digits required to print the unsigned integer */
+/* portion X is EXP + 1 (provided EXP is at least 0.) We have */
+/* INTLEN slots available. So if EXP + 1 is more than INTLEN */
+/* ( which is equivalent to EXP being at least INTLEN) we don't */
+/* have enough room to print the unsigned integer portion of the */
+/* number. */
+
+ if (exp__ >= intlen && y != 0.) {
+
+/* See if we have room to print an exponential form. */
+/* First we need the number of characters for the */
+/* exponent which is always of the form 'E+dd...' */
+
+/* Computing MIN */
+ i__1 = 1, i__2 = exp__ / 1000;
+/* Computing MIN */
+ i__3 = 1, i__4 = exp__ / 100;
+ expsiz = min(i__1,i__2) + 4 + min(i__3,i__4);
+
+/* The number of significant digits that can be printed is the */
+/* size of the picture minus: the size of the sign */
+/* the size of the exponent */
+/* the size of the decimal point. */
+
+ sigdig = lastch - sgnlen - expsiz - 1;
+
+/* If we don't have room for at least one significant digit, */
+/* there's not much we can do. Fill the string with '*'. */
+
+ if (sigdig < 1) {
+ i__1 = lastch;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ *(unsigned char *)&str[i__ - 1] = '*';
+ }
+ } else {
+ dpstr_(x, &sigdig, mystr, (ftnlen)32);
+ *(unsigned char *)mystr = *(unsigned char *)sign;
+ ljust_(mystr, str, (ftnlen)32, str_len);
+ rjust_(str, str, lastch, lastch);
+ }
+ return 0;
+ }
+
+/* One more check. If -INTLEN is greater than DECLEN, or if */
+/* both are zero, we don't have room to create an output string. */
+
+ if (intlen == 0 && declen == 0 || -intlen > declen) {
+ i__1 = lastch;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ *(unsigned char *)&str[i__ - 1] = '*';
+ }
+ return 0;
+ }
+
+/* We have a reasonable chance of successfully constructing */
+/* the string without overflow. */
+
+ start = sgnlen + 1;
+ i__1 = -intlen;
+ zzvsbstr_(&i__1, &declen, &c_true, str + (start - 1), &ovflow, str_len - (
+ start - 1));
+
+/* We might be done at this point. The IF-THEN block below */
+/* handles the one snag that could arise. */
+
+/* If the first digit is a zero as a result of rounding it up */
+/* OVFLOW will be true. This means we don't have enough room */
+/* in the picture for the integer portion of the string. We try */
+/* to make an exponential picture. */
+
+ if (ovflow) {
+
+/* See if we have room to print an exponential form. */
+
+/* Computing MIN */
+ i__1 = 1, i__2 = exp__ / 1000;
+/* Computing MIN */
+ i__3 = 1, i__4 = exp__ / 100;
+ expsiz = min(i__1,i__2) + 4 + min(i__3,i__4);
+
+/* The number of significant digits that can be printed is the */
+/* size of the picture minus: the size of the sign */
+/* the size of the exponent */
+/* the size of the decimal point. */
+
+ sigdig = lastch - sgnlen - expsiz - 1;
+ if (sigdig < 1) {
+ i__1 = lastch;
+ for (i__ = 1; i__ <= i__1; ++i__) {
+ *(unsigned char *)&str[i__ - 1] = '*';
+ }
+ } else {
+ dpstr_(x, &sigdig, mystr, (ftnlen)32);
+ *(unsigned char *)mystr = *(unsigned char *)sign;
+ ljust_(mystr, str, (ftnlen)32, str_len);
+ rjust_(str, str, lastch, lastch);
+ return 0;
+ }
+ } else if (shift) {
+
+/* We need to move the sign right until, there are no */
+/* blanks between it and the next character. */
+
+ frstch = ncpos_(str, " -", &c__1, str_len, (ftnlen)2);
+ if (frstch > 2) {
+ i__1 = frstch - 2;
+ s_copy(str + i__1, str, frstch - 1 - i__1, (ftnlen)1);
+ *(unsigned char *)str = ' ';
+ }
+ }
+ return 0;
+} /* dpfmt_ */
+
diff --git a/ext/spice/src/cspice/dpgrdr.c b/ext/spice/src/cspice/dpgrdr.c
new file mode 100644
index 0000000000..568f7e6caa
--- /dev/null
+++ b/ext/spice/src/cspice/dpgrdr.c
@@ -0,0 +1,674 @@
+/* dpgrdr.f -- translated by f2c (version 19980913).
+ You must link the resulting object file with the libraries:
+ -lf2c -lm (in that order)
+*/
+
+#include "f2c.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static integer c__0 = 0;
+
+/* $Procedure DPGRDR ( Derivative of planetographic w.r.t. rectangular ) */
+/* Subroutine */ int dpgrdr_(char *body, doublereal *x, doublereal *y,
+ doublereal *z__, doublereal *re, doublereal *f, doublereal *jacobi,
+ ftnlen body_len)
+{
+ /* System generated locals */
+ integer i__1, i__2;
+
+ /* Builtin functions */
+ integer s_cmp(char *, char *, ftnlen, ftnlen), s_rnge(char *, integer,
+ char *, integer);
+
+ /* Local variables */
+ integer i__, n;
+ extern /* Subroutine */ int chkin_(char *, ftnlen), ucase_(char *, char *,
+ ftnlen, ftnlen), errch_(char *, char *, ftnlen, ftnlen);
+ logical found;
+ extern /* Subroutine */ int errdp_(char *, doublereal *, ftnlen);
+ integer sense;
+ extern /* Subroutine */ int repmi_(char *, char *, integer *, char *,
+ ftnlen, ftnlen, ftnlen), bods2c_(char *, integer *, logical *,
+ ftnlen), dgeodr_(doublereal *, doublereal *, doublereal *,
+ doublereal *, doublereal *, doublereal *);
+ integer bodyid;
+ extern /* Subroutine */ int gcpool_(char *, integer *, integer *, integer
+ *, char *, logical *, ftnlen, ftnlen);
+ char kvalue[80];
+ extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
+ ftnlen);
+ char pmkvar[32], pgrlon[4];
+ extern /* Subroutine */ int setmsg_(char *, ftnlen), cmprss_(char *,
+ integer *, char *, char *, ftnlen, ftnlen, ftnlen);
+ extern integer plnsns_(integer *);
+ extern logical return_(void);
+ char tmpstr[32];
+
+/* $ Abstract */
+
+/* This routine computes the Jacobian matrix of the transformation */
+/* from rectangular to planetographic coordinates. */
+
+/* $ Disclaimer */
+
+/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
+/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
+/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
+/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
+/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
+/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
+/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
+/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
+/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
+/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
+
+/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
+/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
+/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
+/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
+/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
+/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
+
+/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
+/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
+/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
+/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
+
+/* $ Required_Reading */
+
+/* None. */
+
+/* $ Keywords */
+
+/* COORDINATES */
+/* DERIVATIVES */
+/* MATRIX */
+
+/* $ Declarations */
+/* $ Brief_I/O */
+
+/* Variable I/O Description */
+/* -------- --- -------------------------------------------------- */
+/* BODY I Body with which coordinate system is associated. */
+/* X I X-coordinate of point. */
+/* Y I Y-coordinate of point. */
+/* Z I Z-coordinate of point. */
+/* RE I Equatorial radius of the reference spheroid. */
+/* F I Flattening coefficient. */
+/* JACOBI O Matrix of partial derivatives. */
+
+/* $ Detailed_Input */
+
+/* BODY Name of the body with which the planetographic */
+/* coordinate system is associated. */
+
+/* BODY is used by this routine to look up from the */
+/* kernel pool the prime meridian rate coefficient giving */
+/* the body's spin sense. See the Files and Particulars */
+/* header sections below for details. */
+
+/* X, */
+/* Y, */
+/* Z are the rectangular coordinates of the point at */
+/* which the Jacobian of the map from rectangular */
+/* to planetographic coordinates is desired. */
+
+/* RE Equatorial radius of the reference spheroid. */
+
+/* F Flattening coefficient = (RE-RP) / RE, where RP is */
+/* the polar radius of the spheroid. (More importantly */
+/* RP = RE*(1-F).) */
+
+/* $ Detailed_Output */
+
+/* JACOBI is the matrix of partial derivatives of the conversion */
+/* from rectangular to planetographic coordinates. It */
+/* has the form */
+
+/* .- -. */
+/* | DLON/DX DLON/DY DLON/DZ | */
+/* | DLAT/DX DLAT/DY DLAT/DZ | */
+/* | DALT/DX DALT/DY DALT/DZ | */
+/* `- -' */
+
+/* evaluated at the input values of X, Y, and Z. */
+
+/* $ Parameters */
+
+/* None. */
+
+/* $ Exceptions */
+
+/* 1) If the body name BODY cannot be mapped to a NAIF ID code, */
+/* and if BODY is not a string representation of an integer, */
+/* the error SPICE(IDCODENOTFOUND) will be signaled. */
+
+/* 2) If the kernel variable */
+
+/* BODY_PGR_POSITIVE_LON */
+
+/* is present in the kernel pool but has a value other */
+/* than one of */
+
+/* 'EAST' */
+/* 'WEST' */
+
+/* the error SPICE(INVALIDOPTION) will be signaled. Case */
+/* and blanks are ignored when these values are interpreted. */
+
+/* 3) If polynomial coefficients for the prime meridian of BODY */
+/* are not available in the kernel pool, and if the kernel */
+/* variable BODY_PGR_POSITIVE_LON is not present in */
+/* the kernel pool, the error SPICE(MISSINGDATA) will be signaled. */
+
+/* 4) If the equatorial radius is non-positive, the error */
+/* SPICE(VALUEOUTOFRANGE) is signaled. */
+
+/* 5) If the flattening coefficient is greater than or equal to one, */
+/* the error SPICE(VALUEOUTOFRANGE) is signaled. */
+
+/* 6) If the input point is on the Z-axis (X = 0 and Y = 0), the */
+/* Jacobian matrix is undefined. The error will be diagnosed */
+/* by routines in the call tree of this routine. */
+
+/* $ Files */
+
+/* This routine expects a kernel variable giving BODY's prime */
+/* meridian angle as a function of time to be available in the */
+/* kernel pool. Normally this item is provided by loading a PCK */
+/* file. The required kernel variable is named */
+
+/* BODY_PM */
+
+/* where represents a string containing the NAIF integer */
+/* ID code for BODY. For example, if BODY is 'JUPITER', then */
+/* the name of the kernel variable containing the prime meridian */
+/* angle coefficients is */
+
+/* BODY599_PM */
+
+/* See the PCK Required Reading for details concerning the prime */
+/* meridian kernel variable. */
+
+/* The optional kernel variable */
+
+/* BODY_PGR_POSITIVE_LON */
+
+/* also is normally defined via loading a text kernel. When this */
+/* variable is present in the kernel pool, the prime meridian */
+/* coefficients for BODY are not required by this routine. See the */
+/* Particulars section below for details. */
+
+/* $ Particulars */
+
+/* When performing vector calculations with velocities it is usually */
+/* most convenient to work in rectangular coordinates. However, once */
+/* the vector manipulations have been performed, it is often */
+/* desirable to convert the rectangular representations into */
+/* planetographic coordinates to gain insights about phenomena in */
+/* this coordinate frame. */
+
+/* To transform rectangular velocities to derivatives of coordinates */
+/* in a planetographic system, one uses the Jacobian of the */
+/* transformation between the two systems. */
+
+/* Given a state in rectangular coordinates */
+
+/* ( x, y, z, dx, dy, dz ) */
+
+/* the velocity in planetographic coordinates is given by the matrix */
+/* equation: */
+/* t | t */
+/* (dlon, dlat, dalt) = JACOBI| * (dx, dy, dz) */
+/* |(x,y,z) */
+
+/* This routine computes the matrix */
+
+/* | */
+/* JACOBI| */
+/* |(x, y, z) */
+
+
+/* The planetographic definition of latitude is identical to the */
+/* planetodetic (also called "geodetic" in SPICE documentation) */
+/* definition. In the planetographic coordinate system, latitude is */
+/* defined using a reference spheroid. The spheroid is */
+/* characterized by an equatorial radius and a polar radius. For a */
+/* point P on the spheroid, latitude is defined as the angle between */
+/* the X-Y plane and the outward surface normal at P. For a point P */
+/* off the spheroid, latitude is defined as the latitude of the */
+/* nearest point to P on the spheroid. Note if P is an interior */
+/* point, for example, if P is at the center of the spheroid, there */
+/* may not be a unique nearest point to P. */
+
+/* In the planetographic coordinate system, longitude is defined */
+/* using the spin sense of the body. Longitude is positive to the */
+/* west if the spin is prograde and positive to the east if the spin */
+/* is retrograde. The spin sense is given by the sign of the first */
+/* degree term of the time-dependent polynomial for the body's prime */
+/* meridian Euler angle "W": the spin is retrograde if this term is */
+/* negative and prograde otherwise. For the sun, planets, most */
+/* natural satellites, and selected asteroids, the polynomial */
+/* expression for W may be found in a SPICE PCK kernel. */
+
+/* The earth, moon, and sun are exceptions: planetographic longitude */
+/* is measured positive east for these bodies. */
+
+/* If you wish to override the default sense of positive longitude */
+/* for a particular body, you can do so by defining the kernel */
+/* variable */
+
+/* BODY_PGR_POSITIVE_LON */
+
+/* where represents the NAIF ID code of the body. This */
+/* variable may be assigned either of the values */
+
+/* 'WEST' */
+/* 'EAST' */
+
+/* For example, you can have this routine treat the longitude */
+/* of the earth as increasing to the west using the kernel */
+/* variable assignment */
+
+/* BODY399_PGR_POSITIVE_LON = 'WEST' */
+
+/* Normally such assignments are made by placing them in a text */
+/* kernel and loading that kernel via FURNSH. */
+
+/* The definition of this kernel variable controls the behavior of */
+/* the SPICELIB planetographic routines */
+
+/* PGRREC */
+/* RECPGR */
+/* DPGRDR */
+/* DRDPGR */
+
+/* It does not affect the other SPICELIB coordinate conversion */
+/* routines. */
+
+/* $ Examples */
+
+/* Numerical results shown for this example may differ between */
+/* platforms as the results depend on the SPICE kernels used as */
+/* input and the machine specific arithmetic implementation. */
+
+
+/* Find the planetographic state of the earth as seen from */
+/* Mars in the J2000 reference frame at January 1, 2005 TDB. */
+/* Map this state back to rectangular coordinates as a check. */
+
+
+/* PROGRAM EX1 */
+/* IMPLICIT NONE */
+/* C */
+/* C SPICELIB functions */
+/* C */
+/* DOUBLE PRECISION RPD */
+/* C */
+/* C Local variables */
+/* C */
+/* DOUBLE PRECISION ALT */
+/* DOUBLE PRECISION DRECTN ( 3 ) */
+/* DOUBLE PRECISION ET */
+/* DOUBLE PRECISION F */
+/* DOUBLE PRECISION JACOBI ( 3, 3 ) */
+/* DOUBLE PRECISION LAT */
+/* DOUBLE PRECISION LON */
+/* DOUBLE PRECISION LT */
+/* DOUBLE PRECISION PGRVEL ( 3 ) */
+/* DOUBLE PRECISION RADII ( 3 ) */
+/* DOUBLE PRECISION RE */
+/* DOUBLE PRECISION RECTAN ( 3 ) */
+/* DOUBLE PRECISION RP */
+/* DOUBLE PRECISION STATE ( 6 ) */
+
+/* INTEGER N */
+/* C */
+/* C Load a PCK file containing a triaxial */
+/* C ellipsoidal shape model and orientation */
+/* C data for Mars. */
+/* C */
+/* CALL FURNSH ( 'pck00008.tpc' ) */
+
+/* C */
+/* C Load an SPK file giving ephemerides of earth and Mars. */
+/* C */
+/* CALL FURNSH ( 'de405.bsp' ) */
+
+/* C */
+/* C Load a leapseconds kernel to support time conversion. */
+/* C */
+/* CALL FURNSH ( 'naif0007.tls' ) */
+
+/* C */
+/* C Look up the radii for Mars. Although we */
+/* C omit it here, we could first call BADKPV */
+/* C to make sure the variable BODY499_RADII */
+/* C has three elements and numeric data type. */
+/* C If the variable is not present in the kernel */
+/* C pool, BODVRD will signal an error. */
+/* C */
+/* CALL BODVRD ( 'MARS', 'RADII', 3, N, RADII ) */
+
+/* C */
+/* C Compute flattening coefficient. */
+/* C */
+/* RE = RADII(1) */
+/* RP = RADII(3) */
+/* F = ( RE - RP ) / RE */
+
+/* C */
+/* C Look up the geometric state of earth as seen from Mars at */
+/* C January 1, 2005 TDB, relative to the J2000 reference */
+/* C frame. */
+/* C */
+/* CALL STR2ET ( 'January 1, 2005 TDB', ET ) */
+
+/* CALL SPKEZR ( 'Earth', ET, 'J2000', 'LT+S', */
+/* . 'Mars', STATE, LT ) */
+
+/* C */
+/* C Convert position to planetographic coordinates. */
+/* C */
+/* CALL RECPGR ( 'MARS', STATE, RE, F, LON, LAT, ALT ) */
+
+/* C */
+/* C Convert velocity to planetographic coordinates. */
+/* C */
+
+/* CALL DPGRDR ( 'MARS', STATE(1), STATE(2), STATE(3), */
+/* . RE, F, JACOBI ) */
+
+/* CALL MXV ( JACOBI, STATE(4), PGRVEL ) */
+
+/* C */
+/* C As a check, convert the planetographic state back to */
+/* C rectangular coordinates. */
+/* C */
+/* CALL PGRREC ( 'MARS', LON, LAT, ALT, RE, F, RECTAN ) */
+
+/* CALL DRDPGR ( 'MARS', LON, LAT, ALT, RE, F, JACOBI ) */
+
+/* CALL MXV ( JACOBI, PGRVEL, DRECTN ) */
+
+
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) 'Rectangular coordinates:' */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) ' X (km) = ', STATE(1) */
+/* WRITE(*,*) ' Y (km) = ', STATE(2) */
+/* WRITE(*,*) ' Z (km) = ', STATE(3) */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) 'Rectangular velocity:' */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) ' dX/dt (km/s) = ', STATE(4) */
+/* WRITE(*,*) ' dY/dt (km/s) = ', STATE(5) */
+/* WRITE(*,*) ' dZ/dt (km/s) = ', STATE(6) */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) 'Ellipsoid shape parameters: ' */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) ' Equatorial radius (km) = ', RE */
+/* WRITE(*,*) ' Polar radius (km) = ', RP */
+/* WRITE(*,*) ' Flattening coefficient = ', F */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) 'Planetographic coordinates:' */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) ' Longitude (deg) = ', LON / RPD() */
+/* WRITE(*,*) ' Latitude (deg) = ', LAT / RPD() */
+/* WRITE(*,*) ' Altitude (km) = ', ALT */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) 'Planetographic velocity:' */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) ' d Longitude/dt (deg/s) = ', PGRVEL(1)/RPD() */
+/* WRITE(*,*) ' d Latitude/dt (deg/s) = ', PGRVEL(2)/RPD() */
+/* WRITE(*,*) ' d Altitude/dt (km/s) = ', PGRVEL(3) */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) 'Rectangular coordinates from inverse ' // */
+/* . 'mapping:' */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) ' X (km) = ', RECTAN(1) */
+/* WRITE(*,*) ' Y (km) = ', RECTAN(2) */
+/* WRITE(*,*) ' Z (km) = ', RECTAN(3) */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) 'Rectangular velocity from inverse mapping:' */
+/* WRITE(*,*) ' ' */
+/* WRITE(*,*) ' dX/dt (km/s) = ', DRECTN(1) */
+/* WRITE(*,*) ' dY/dt (km/s) = ', DRECTN(2) */
+/* WRITE(*,*) ' dZ/dt (km/s) = ', DRECTN(3) */
+/* WRITE(*,*) ' ' */
+/* END */
+
+
+/* Output from this program should be similar to the following */
+/* (rounding and formatting differ across platforms): */
+
+
+/* Rectangular coordinates: */
+
+/* X (km) = 146039732. */
+/* Y (km) = 278546607. */
+/* Z (km) = 119750315. */
+
+/* Rectangular velocity: */
+
+/* dX/dt (km/s) = -47.0428824 */
+/* dY/dt (km/s) = 9.07021778 */
+/* dZ/dt (km/s) = 4.75656274 */
+
+/* Ellipsoid shape parameters: */
+
+/* Equatorial radius (km) = 3396.19 */
+/* Polar radius (km) = 3376.2 */
+/* Flattening coefficient = 0.00588600756 */
+
+/* Planetographic coordinates: */
+
+/* Longitude (deg) = 297.667659 */
+/* Latitude (deg) = 20.844504 */
+/* Altitude (km) = 336531825. */
+
+/* Planetographic velocity: */
+
+/* d Longitude/dt (deg/s) = -8.35738632E-06 */
+/* d Latitude/dt (deg/s) = 1.59349355E-06 */
+/* d Altitude/dt (km/s) = -11.2144327 */
+
+/* Rectangular coordinates from inverse mapping: */
+
+/* X (km) = 146039732. */
+/* Y (km) = 278546607. */
+/* Z (km) = 119750315. */
+
+/* Rectangular velocity from inverse mapping: */
+
+/* dX/dt (km/s) = -47.0428824 */
+/* dY/dt (km/s) = 9.07021778 */
+/* dZ/dt (km/s) = 4.75656274 */
+
+
+/* $ Restrictions */
+
+/* None. */
+
+/* $ Literature_References */
+
+/* None. */
+
+/* $ Author_and_Institution */
+
+/* N.J. Bachman (JPL) */
+/* W.L. Taber (JPL) */
+
+/* $ Version */
+
+/* - SPICELIB Version 1.0.0, 26-DEC-2004 (NJB) (WLT) */
+
+/* -& */
+/* $ Index_Entries */
+
+/* Jacobian of planetographic w.r.t. rectangular coordinates */
+
+/* -& */
+/* $ Revisions */
+
+/* None. */
+
+/* -& */
+
+/* SPICELIB functions */
+
+
+/* Local parameters */
+
+
+/* Local variables */
+
+
+/* Standard SPICE error handling. */
+
+ if (return_()) {
+ return 0;
+ } else {
+ chkin_("DPGRDR", (ftnlen)6);
+ }
+
+/* Convert the body name to an ID code. */
+
+ bods2c_(body, &bodyid, &found, body_len);
+ if (! found) {
+ setmsg_("The value of the input argument BODY is #, this is not a re"
+ "cognized name of an ephemeris object. The cause of this prob"
+ "lem may be that you need an updated version of the SPICE Too"
+ "lkit. ", (ftnlen)185);
+ errch_("#", body, (ftnlen)1, body_len);
+ sigerr_("SPICE(IDCODENOTFOUND)", (ftnlen)21);
+ chkout_("DPGRDR", (ftnlen)6);
+ return 0;
+ }
+
+/* The equatorial radius must be positive. If not, signal an error */
+/* and check out. */
+
+ if (*re <= 0.) {
+ setmsg_("Equatorial radius was #.", (ftnlen)24);
+ errdp_("#", re, (ftnlen)1);
+ sigerr_("SPICE(VALUEOUTOFRANGE)", (ftnlen)22);
+ chkout_("DPGRDR", (ftnlen)6);
+ return 0;
+ }
+
+/* If the flattening coefficient is greater than 1, the polar radius */
+/* is negative. If F is equal to 1, the polar radius is zero. Either */
+/* case is a problem, so signal an error and check out. */
+
+ if (*f >= 1.) {
+ setmsg_("Flattening coefficient was #.", (ftnlen)29);
+ errdp_("#", f, (ftnlen)1);
+ sigerr_("SPICE(VALUEOUTOFRANGE)", (ftnlen)22);
+ chkout_("DPGRDR", (ftnlen)6);
+ return 0;
+ }
+
+/* Look up the longitude sense override variable from the */
+/* kernel pool. */
+
+ repmi_("BODY#_PGR_POSITIVE_LON", "#", &bodyid, pmkvar, (ftnlen)22, (
+ ftnlen)1, (ftnlen)32);
+ gcpool_(pmkvar, &c__1, &c__1, &n, kvalue, &found, (ftnlen)32, (ftnlen)80);
+ if (found) {
+
+/* Make sure we recognize the value of PGRLON. */
+
+ cmprss_(" ", &c__0, kvalue, tmpstr, (ftnlen)1, (ftnlen)80, (ftnlen)32)
+ ;
+ ucase_(tmpstr, pgrlon, (ftnlen)32, (ftnlen)4);
+ if (s_cmp(pgrlon, "EAST", (ftnlen)4, (ftnlen)4) == 0) {
+ sense = 1;
+ } else if (s_cmp(pgrlon, "WEST", (ftnlen)4, (ftnlen)4) == 0) {
+ sense = -1;
+ } else {
+ setmsg_("Kernel variable # may have the values EAST or WEST. Ac"
+ "tual value was #.", (ftnlen)72);
+ errch_("#", pmkvar, (ftnlen)1, (ftnlen)32);
+ errch_("#", kvalue, (ftnlen)1, (ftnlen)80);
+ sigerr_("SPICE(INVALIDOPTION)", (ftnlen)20);
+ chkout_("DPGRDR", (ftnlen)6);
+ return 0;
+ }
+ } else {
+
+/* Look up the spin sense of the body's prime meridian. */
+
+ sense = plnsns_(&bodyid);
+
+/* If the required prime meridian rate was not available, */
+/* PLNSNS returns the code 0. Here we consider this situation */
+/* to be an error. */
+
+ if (sense == 0) {
+ repmi_("BODY#_PM", "#", &bodyid, pmkvar, (ftnlen)8, (ftnlen)1, (
+ ftnlen)32);
+ setmsg_("Prime meridian rate coefficient defined by kernel varia"
+ "ble # is required but not available for body #. ", (
+ ftnlen)103);
+ errch_("#", pmkvar, (ftnlen)1, (ftnlen)32);
+ errch_("#", body, (ftnlen)1, body_len);
+ sigerr_("SPICE(MISSINGDATA)", (ftnlen)18);
+ chkout_("DPGRDR", (ftnlen)6);
+ return 0;
+ }
+
+/* Handle the special cases: earth, moon, and sun. */
+
+ if (bodyid == 399 || bodyid == 301 || bodyid == 10) {
+ sense = 1;
+ }
+ }
+
+/* At this point, SENSE is set to +/- 1. */
+
+/* To obtain the Jacobian matrix we want, first find the Jacobian */
+/* matrix of rectangular coordinates with respect to geodetic */
+/* coordinates. */
+
+ dgeodr_(x, y, z__, re, f, jacobi);
+
+/* Letting GLON represent geodetic longitude, the matrix JACOBI is */
+
+/* .- -. */
+/* | DGLON/DX DGLON/DY DGLON/DZ | */
+/* | DLAT/DX DLAT/DY DLAT/DZ | */
+/* | DALT/DX DALT/DY DALT/DZ | */
+/* `- -' */
+
+/* evaluated at the input values of X, Y, and Z. */
+
+/* Since planetographic longitude LON satisfies */
+
+/* LON = SENSE * GLON */
+
+/* applying the chain rule to D(*)/DGLON, the above is equivalent to */
+
+/* .- -. */
+/* | (1/SENSE)*DLON/DX (1/SENSE)*DLON/DY (1/SENSE)*DLON/DZ | */
+/* | DLAT/DX DLAT/DY DLAT/DZ | */
+/* | DALT/DX DALT/DY DALT/DZ | */
+/* `- -' */
+
+/* So, multiplying the first row of JACOBI by SENSE gives us the */
+/* matrix we actually want to compute: the Jacobian matrix of */
+/* rectangular coordinates with respect to planetographic */
+/* coordinates. */
+
+ for (i__ = 1; i__ <= 3; ++i__) {
+ jacobi[(i__1 = i__ * 3 - 3) < 9 && 0 <= i__1 ? i__1 : s_rnge("jacobi",
+ i__1, "dpgrdr_", (ftnlen)712)] = sense * jacobi[(i__2 = i__ *
+ 3 - 3) < 9 && 0 <= i__2 ? i__2 : s_rnge("jacobi", i__2,
+ "dpgrdr_", (ftnlen)712)];
+ }
+ chkout_("DPGRDR", (ftnlen)6);
+ return 0;
+} /* dpgrdr_ */
+
diff --git a/ext/spice/src/cspice/dpgrdr_c.c b/ext/spice/src/cspice/dpgrdr_c.c
new file mode 100644
index 0000000000..f05986858b
--- /dev/null
+++ b/ext/spice/src/cspice/dpgrdr_c.c
@@ -0,0 +1,555 @@
+/*
+
+-Procedure dpgrdr_c ( Derivative of planetographic w.r.t. rectangular )
+
+-Abstract
+
+ This routine computes the Jacobian matrix of the transformation
+ from rectangular to planetographic coordinates.
+
+-Disclaimer
+
+ THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
+ CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
+ GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
+ ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
+ PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
+ TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
+ WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
+ SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
+ SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
+
+ IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
+ BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
+ LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
+ REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
+ REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
+
+ RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
+ THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
+ CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
+ ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
+
+-Required_Reading
+
+ None.
+
+-Keywords
+
+ COORDINATES
+ DERIVATIVES
+ MATRIX
+
+*/
+
+ #include "SpiceUsr.h"
+ #include "SpiceZfc.h"
+ #include "SpiceZmc.h"
+
+
+ void dpgrdr_c ( ConstSpiceChar * body,
+ SpiceDouble x,
+ SpiceDouble y,
+ SpiceDouble z,
+ SpiceDouble re,
+ SpiceDouble f,
+ SpiceDouble jacobi[3][3] )
+
+/*
+
+-Brief_I/O
+
+ Variable I/O Description
+ -------- --- --------------------------------------------------
+ body I Body with which coordinate system is associated.
+ x I X-coordinate of point.
+ y I Y-coordinate of point.
+ z I Z-coordinate of point.
+ re I Equatorial radius of the reference spheroid.
+ f I Flattening coefficient.
+ jacobi O Matrix of partial derivatives.
+
+-Detailed_Input
+
+ body Name of the body with which the planetographic
+ coordinate system is associated.
+
+ `body' is used by this routine to look up from the
+ kernel pool the prime meridian rate coefficient giving
+ the body's spin sense. See the Files and Particulars
+ header sections below for details.
+
+ x,
+ y,
+ z are the rectangular coordinates of the point at
+ which the Jacobian of the map from rectangular
+ to planetographic coordinates is desired.
+
+ re Equatorial radius of the reference spheroid.
+
+ f Flattening coefficient = (re-rp) / re, where rp is
+ the polar radius of the spheroid. (More importantly
+ rp = re*(1-f).)
+
+-Detailed_Output
+
+ jacobi is the matrix of partial derivatives of the conversion
+ from rectangular to planetographic coordinates. It
+ has the form
+
+ .- -.
+ | DLON/DX DLON/DY DLON/DZ |
+ | DLAT/DX DLAT/DY DLAT/DZ |
+ | DALT/DX DALT/DY DALT/DZ |
+ `- -'
+
+ evaluated at the input values of `x', `y', and `z'.
+
+-Parameters
+
+ None.
+
+-Exceptions
+
+ 1) If the body name `body' cannot be mapped to a NAIF ID code,
+ and if `body' is not a string representation of an integer,
+ the error SPICE(IDCODENOTFOUND) will be signaled.
+
+ 2) If the kernel variable
+
+ BODY_PGR_POSITIVE_LON
+
+ is present in the kernel pool but has a value other
+ than one of
+
+ 'EAST'
+ 'WEST'
+
+ the error SPICE(INVALIDOPTION) will be signaled. Case
+ and blanks are ignored when these values are interpreted.
+
+ 3) If polynomial coefficients for the prime meridian of `body'
+ are not available in the kernel pool, and if the kernel
+ variable BODY_PGR_POSITIVE_LON is not present in
+ the kernel pool, the error SPICE(MISSINGDATA) will be signaled.
+
+ 4) If the equatorial radius is non-positive, the error
+ SPICE(VALUEOUTOFRANGE) is signaled.
+
+ 5) If the flattening coefficient is greater than or equal to one,
+ the error SPICE(VALUEOUTOFRANGE) is signaled.
+
+ 6) If the input point is on the Z-axis (X = 0 and Y = 0), the
+ Jacobian matrix is undefined. The error will be diagnosed
+ by routines in the call tree of this routine.
+
+ 7) The error SPICE(EMPTYSTRING) is signaled if the input
+ string `body' does not contain at least one character, since the
+ input string cannot be converted to a Fortran-style string in
+ this case.
+
+ 8) The error SPICE(NULLPOINTER) is signaled if the input string
+ pointer `body' is null.
+
+-Files
+
+ This routine expects a kernel variable giving body's prime
+ meridian angle as a function of time to be available in the
+ kernel pool. Normally this item is provided by loading a PCK
+ file. The required kernel variable is named
+
+ BODY_PM
+
+ where represents a string containing the NAIF integer
+ ID code for `body'. For example, if `body' is "JUPITER", then
+ the name of the kernel variable containing the prime meridian
+ angle coefficients is
+
+ BODY599_PM
+
+ See the PCK Required Reading for details concerning the prime
+ meridian kernel variable.
+
+ The optional kernel variable
+
+ BODY_PGR_POSITIVE_LON
+
+ also is normally defined via loading a text kernel. When this
+ variable is present in the kernel pool, the prime meridian
+ coefficients for `body' are not required by this routine. See the
+ Particulars section below for details.
+
+-Particulars
+
+ When performing vector calculations with velocities it is usually
+ most convenient to work in rectangular coordinates. However, once
+ the vector manipulations have been performed, it is often
+ desirable to convert the rectangular representations into
+ planetographic coordinates to gain insights about phenomena in
+ this coordinate frame.
+
+ To transform rectangular velocities to derivatives of coordinates
+ in a planetographic system, one uses the Jacobian of the
+ transformation between the two systems.
+
+ Given a state in rectangular coordinates
+
+ ( x, y, z, dx, dy, dz )
+
+ the velocity in planetographic coordinates is given by the matrix
+ equation:
+ t | t
+ (dlon, dlat, dalt) = jacobi| * (dx, dy, dz)
+ |(x,y,z)
+
+ This routine computes the matrix
+
+ |
+ jacobi|
+ |(x, y, z)
+
+
+ The planetographic definition of latitude is identical to the
+ planetodetic (also called "geodetic" in SPICE documentation)
+ definition. In the planetographic coordinate system, latitude is
+ defined using a reference spheroid. The spheroid is
+ characterized by an equatorial radius and a polar radius. For a
+ point P on the spheroid, latitude is defined as the angle between
+ the X-Y plane and the outward surface normal at P. For a point P
+ off the spheroid, latitude is defined as the latitude of the
+ nearest point to P on the spheroid. Note if P is an interior
+ point, for example, if P is at the center of the spheroid, there
+ may not be a unique nearest point to P.
+
+ In the planetographic coordinate system, longitude is defined
+ using the spin sense of the body. Longitude is positive to the
+ west if the spin is prograde and positive to the east if the spin
+ is retrograde. The spin sense is given by the sign of the first
+ degree term of the time-dependent polynomial for the body's prime
+ meridian Euler angle "W": the spin is retrograde if this term is
+ negative and prograde otherwise. For the sun, planets, most
+ natural satellites, and selected asteroids, the polynomial
+ expression for W may be found in a SPICE PCK kernel.
+
+ The earth, moon, and sun are exceptions: planetographic longitude
+ is measured positive east for these bodies.
+
+ If you wish to override the default sense of positive longitude
+ for a particular body, you can do so by defining the kernel
+ variable
+
+ BODY_PGR_POSITIVE_LON
+
+ where represents the NAIF ID code of the body. This
+ variable may be assigned either of the values
+
+ 'WEST'
+ 'EAST'
+
+ For example, you can have this routine treat the longitude
+ of the earth as increasing to the west using the kernel
+ variable assignment
+
+ BODY399_PGR_POSITIVE_LON = 'WEST'
+
+ Normally such assignments are made by placing them in a text
+ kernel and loading that kernel via furnsh_c.
+
+ The definition of this kernel variable controls the behavior of
+ the CSPICE planetographic routines
+
+ pgrrec_c
+ recpgr_c
+ dpgrdr_c
+ drdpgr_c
+
+ It does not affect the other CSPICE coordinate conversion
+ routines.
+
+-Examples
+
+ Numerical results shown for this example may differ between
+ platforms as the results depend on the SPICE kernels used as
+ input and the machine specific arithmetic implementation.
+
+
+ Find the planetographic state of the earth as seen from
+ Mars in the J2000 reference frame at January 1, 2005 TDB.
+ Map this state back to rectangular coordinates as a check.
+
+
+ #include