1 /* zzdynfid.f -- translated by f2c (version 19980913).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include "f2c.h"
7 
8 /* Table of constant values */
9 
10 static integer c__32 = 32;
11 static integer c__1 = 1;
12 
13 /* $Procedure ZZDYNFID ( Fetch frame ID kernel variable ) */
zzdynfid_(char * frname,integer * frcode,char * item,integer * idcode,ftnlen frname_len,ftnlen item_len)14 /* Subroutine */ int zzdynfid_(char *frname, integer *frcode, char *item,
15 	integer *idcode, ftnlen frname_len, ftnlen item_len)
16 {
17     integer n;
18     extern /* Subroutine */ int chkin_(char *, ftnlen);
19     extern logical beint_(char *, ftnlen);
20     extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen),
21 	    repmc_(char *, char *, char *, char *, ftnlen, ftnlen, ftnlen,
22 	    ftnlen);
23     logical found;
24     extern /* Subroutine */ int repmi_(char *, char *, integer *, char *,
25 	    ftnlen, ftnlen, ftnlen);
26     char dtype[1];
27     extern integer rtrim_(char *, ftnlen);
28     extern logical failed_(void);
29     integer codeln, nameln;
30     char kvname[32], cdestr[32];
31     integer itemln, reqnam;
32     extern /* Subroutine */ int chkout_(char *, ftnlen);
33     extern logical return_(void);
34     char outnam[32];
35     integer reqnum;
36     extern /* Subroutine */ int intstr_(integer *, char *, ftnlen), dtpool_(
37 	    char *, logical *, integer *, char *, ftnlen, ftnlen), setmsg_(
38 	    char *, ftnlen), errint_(char *, integer *, ftnlen), sigerr_(char
39 	    *, ftnlen), gcpool_(char *, integer *, integer *, integer *, char
40 	    *, logical *, ftnlen, ftnlen), namfrm_(char *, integer *, ftnlen),
41 	     prsint_(char *, integer *, ftnlen), gipool_(char *, integer *,
42 	    integer *, integer *, integer *, logical *, ftnlen);
43 
44 /* $ Abstract */
45 
46 /*     SPICE Private routine intended solely for the support of SPICE */
47 /*     routines.  Users should not call this routine directly due */
48 /*     to the volatile nature of this routine. */
49 
50 /*     Look up a frame definition kernel variable whose associated */
51 /*     value is a frame name or frame ID code.  The returned value is */
52 /*     always an ID code.  The kernel variable name can refer to */
53 /*     the frame being defined by either name or ID code. */
54 
55 /*     If the kernel variable is not present, or if the variable */
56 /*     is not a frame name or a numeric value, signal an error. */
57 
58 /* $ Disclaimer */
59 
60 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
61 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
62 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
63 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
64 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
65 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
66 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
67 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
68 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
69 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
70 
71 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
72 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
73 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
74 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
75 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
76 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
77 
78 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
79 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
80 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
81 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
82 
83 /* $ Required_Reading */
84 
85 /*     None. */
86 
87 /* $ Keywords */
88 
89 /*     FRAMES */
90 /*     KERNEL */
91 /*     PRIVATE */
92 /*     UTILITY */
93 
94 /* $ Declarations */
95 /* $ Abstract */
96 
97 /*     Include file zzdyn.inc */
98 
99 /*     SPICE private file intended solely for the support of SPICE */
100 /*     routines.  Users should not include this file directly due */
101 /*     to the volatile nature of this file */
102 
103 /*     The parameters defined below are used by the SPICELIB dynamic */
104 /*     frame subsystem. */
105 
106 /* $ Disclaimer */
107 
108 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
109 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
110 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
111 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
112 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
113 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
114 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
115 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
116 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
117 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
118 
119 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
120 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
121 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
122 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
123 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
124 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
125 
126 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
127 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
128 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
129 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
130 
131 /* $ Parameters */
132 
133 /*     This file declares parameters required by the dynamic */
134 /*     frame routines of the SPICELIB frame subsystem. */
135 
136 /* $ Restrictions */
137 
138 /*     The parameter BDNMLN is this routine must be kept */
139 /*     consistent with the parameter MAXL defined in */
140 
141 /*        zzbodtrn.inc */
142 
143 
144 /* $ Author_and_Institution */
145 
146 /*     N.J. Bachman    (JPL) */
147 
148 /* $ Literature_References */
149 
150 /*     None. */
151 
152 /* $ Version */
153 
154 /* -    SPICELIB Version 1.1.0, 12-JAN-2005 (NJB) */
155 
156 /*        Parameters KWX, KWY, KWZ renamed to KVX, KVY, KVZ. */
157 
158 /* -    SPICELIB Version 1.0.0, 22-DEC-2004 (NJB) */
159 
160 /* -& */
161 
162 /*     String length parameters */
163 /*     ======================== */
164 
165 
166 /*     Kernel variable name length.  This parameter must be */
167 /*     kept consistent with the parameter MAXLEN used in the */
168 /*     POOL umbrella routine. */
169 
170 
171 /*     Length of a character kernel pool datum. This parameter must be */
172 /*     kept consistent with the parameter MAXCHR used in the POOL */
173 /*     umbrella routine. */
174 
175 
176 /*     Reference frame name length.  This parameter must be */
177 /*     kept consistent with the parameter WDSIZE used in the */
178 /*     FRAMEX umbrella routine. */
179 
180 
181 /*     Body name length.  This parameter is used to provide a level */
182 /*     of indirection so the dynamic frame source code doesn't */
183 /*     have to change if the name of this SPICELIB-scope parameter */
184 /*     is changed.  The value MAXL used here is defined in the */
185 /*     INCLUDE file */
186 
187 /*        zzbodtrn.inc */
188 
189 /*     Current value of MAXL = 36 */
190 
191 
192 /*     Numeric parameters */
193 /*     =================================== */
194 
195 /*     The parameter MAXCOF is the maximum number of polynomial */
196 /*     coefficients that may be used to define an Euler angle */
197 /*     in an "Euler frame" definition */
198 
199 
200 /*     The parameter LBSEP is the default angular separation limit for */
201 /*     the vectors defining a two-vector frame.  The angular separation */
202 /*     of the vectors must differ from Pi and 0 by at least this amount. */
203 
204 
205 /*     The parameter QEXP is used to determine the width of */
206 /*     the interval DELTA used for the discrete differentiation */
207 /*     of velocity in the routines ZZDYNFRM, ZZDYNROT, and their */
208 /*     recursive analogs.  This parameter is appropriate for */
209 /*     64-bit IEEE double precision numbers; when SPICELIB */
210 /*     is hosted on platforms where longer mantissas are supported, */
211 /*     this parameter (and hence this INCLUDE file) will become */
212 /*     platform-dependent. */
213 
214 /*     The choice of QEXP is based on heuristics.  It's believed to */
215 /*     be a reasonable choice obtainable without expensive computation. */
216 
217 /*     QEXP is the largest power of 2 such that */
218 
219 /*        1.D0 + 2**QEXP  =  1.D0 */
220 
221 /*     Given an epoch T0 at which a discrete derivative is to be */
222 /*     computed, this choice provides a value of DELTA that usually */
223 /*     contributes no round-off error in the computation of the function */
224 /*     evaluation epochs */
225 
226 /*        T0 +/- DELTA */
227 
228 /*     while providing the largest value of DELTA having this form that */
229 /*     causes the order of the error term O(DELTA**2) in the quadratric */
230 /*     function approximation to round to zero.  Note that the error */
231 /*     itself will normally be small but doesn't necessarily round to */
232 /*     zero.  Note also that the small function approximation error */
233 /*     is not a measurement of the error in the discrete derivative */
234 /*     itself. */
235 
236 /*     For ET values T0 > 2**27 seconds past J2000, the value of */
237 /*     DELTA will be set to */
238 
239 /*        T0 * 2**QEXP */
240 
241 /*     For smaller values of T0, DELTA should be set to 1.D0. */
242 
243 
244 /*     Frame kernel parameters */
245 /*     ======================= */
246 
247 /*     Parameters relating to kernel variable names (keywords) start */
248 /*     with the letters */
249 
250 /*        KW */
251 
252 /*     Parameters relating to kernel variable values start with the */
253 /*     letters */
254 
255 /*        KV */
256 
257 
258 /*     Generic parameters */
259 /*     --------------------------------- */
260 
261 /*     Token used to build the base frame keyword: */
262 
263 
264 /*     Frame definition style parameters */
265 /*     --------------------------------- */
266 
267 /*     Token used to build the frame definition style keyword: */
268 
269 
270 /*     Token indicating parameterized dynamic frame. */
271 
272 
273 /*     Freeze epoch parameters */
274 /*     --------------------------------- */
275 
276 /*     Token used to build the freeze epoch keyword: */
277 
278 
279 /*     Rotation state parameters */
280 /*     --------------------------------- */
281 
282 /*     Token used to build the rotation state keyword: */
283 
284 
285 /*     Token indicating rotating rotation state: */
286 
287 
288 /*     Token indicating inertial rotation state: */
289 
290 
291 /*     Frame family parameters */
292 /*     --------------------------------- */
293 
294 /*     Token used to build the frame family keyword: */
295 
296 
297 /*     Token indicating mean equator and equinox of date frame. */
298 
299 
300 /*     Token indicating mean ecliptic and equinox of date frame. */
301 
302 
303 /*     Token indicating true equator and equinox of date frame. */
304 
305 
306 /*     Token indicating two-vector frame. */
307 
308 
309 /*     Token indicating Euler frame. */
310 
311 
312 /*     "Of date" frame family parameters */
313 /*     --------------------------------- */
314 
315 /*     Token used to build the precession model keyword: */
316 
317 
318 /*     Token used to build the nutation model keyword: */
319 
320 
321 /*     Token used to build the obliquity model keyword: */
322 
323 
324 /*     Mathematical models used to define "of date" frames will */
325 /*     likely accrue over time.  We will simply assign them */
326 /*     numbers. */
327 
328 
329 /*     Token indicating the Lieske earth precession model: */
330 
331 
332 /*     Token indicating the IAU 1980 earth nutation model: */
333 
334 
335 /*     Token indicating the IAU 1980 earth mean obliqity of */
336 /*     date model.  Note the name matches that of the preceding */
337 /*     nutation model---this is intentional.  The keyword */
338 /*     used in the kernel variable definition indicates what */
339 /*     kind of model is being defined. */
340 
341 
342 /*     Two-vector frame family parameters */
343 /*     --------------------------------- */
344 
345 /*     Token used to build the vector axis keyword: */
346 
347 
348 /*     Tokens indicating axis values: */
349 
350 
351 /*     Prefixes used for primary and secondary vector definition */
352 /*     keywords: */
353 
354 
355 /*     Token used to build the vector definition keyword: */
356 
357 
358 /*     Token indicating observer-target position vector: */
359 
360 
361 /*     Token indicating observer-target velocity vector: */
362 
363 
364 /*     Token indicating observer-target near point vector: */
365 
366 
367 /*     Token indicating constant vector: */
368 
369 
370 /*     Token used to build the vector observer keyword: */
371 
372 
373 /*     Token used to build the vector target keyword: */
374 
375 
376 /*     Token used to build the vector frame keyword: */
377 
378 
379 /*     Token used to build the vector aberration correction keyword: */
380 
381 
382 /*     Token used to build the constant vector specification keyword: */
383 
384 
385 /*     Token indicating rectangular coordinates used to */
386 /*     specify constant vector: */
387 
388 
389 /*     Token indicating latitudinal coordinates used to */
390 /*     specify constant vector: */
391 
392 
393 /*     Token indicating RA/DEC coordinates used to */
394 /*     specify constant vector: */
395 
396 
397 /*     Token used to build the cartesian vector literal keyword: */
398 
399 
400 /*     Token used to build the constant vector latitude keyword: */
401 
402 
403 /*     Token used to build the constant vector longitude keyword: */
404 
405 
406 /*     Token used to build the constant vector right ascension keyword: */
407 
408 
409 /*     Token used to build the constant vector declination keyword: */
410 
411 
412 /*     Token used to build the angular separation tolerance keyword: */
413 
414 
415 /*     See the section "Physical unit parameters" below for additional */
416 /*     parameters applicable to two-vector frames. */
417 
418 
419 /*     Euler frame family parameters */
420 /*     --------------------------------- */
421 
422 /*     Token used to build the epoch keyword: */
423 
424 
425 /*     Token used to build the Euler axis sequence keyword: */
426 
427 
428 /*     Tokens used to build the Euler angle coefficients keywords: */
429 
430 
431 /*     See the section "Physical unit parameters" below for additional */
432 /*     parameters applicable to Euler frames. */
433 
434 
435 /*     Physical unit parameters */
436 /*     --------------------------------- */
437 
438 /*     Token used to build the units keyword: */
439 
440 
441 /*     Token indicating radians: */
442 
443 
444 /*     Token indicating degrees: */
445 
446 
447 /*     End of include file zzdyn.inc */
448 
449 /* $ Brief_I/O */
450 
451 /*     VARIABLE  I/O  DESCRIPTION */
452 /*     --------  ---  ------------------------------------------------- */
453 /*     FRNAME     I   Frame name. */
454 /*     FRCODE     I   Frame ID code. */
455 /*     ITEM       I   Item associated with frame definition. */
456 /*     IDCODE     O   Output kernel variable. */
457 
458 /* $ Detailed_Input */
459 
460 /*     FRNAME         is the name of the reference frame with which */
461 /*                    the requested variable is associated.  This frame */
462 /*                    may be thought of as the frame associated with */
463 /*                    "left hand side" of the kernel variable */
464 /*                    assignment. */
465 
466 /*     FRCODE         is the frame ID code of the reference frame with */
467 /*                    which the requested variable is associated.  This */
468 /*                    is the ID code corresponding to FRNAME. */
469 
470 /*     ITEM           is a string identifying the specific datum */
471 /*                    to be fetched.  The kernel variable name */
472 /*                    has the form */
473 
474 /*                       FRAME_<frame ID code>_<ITEM> */
475 
476 /*                    or */
477 
478 /*                       FRAME_<frame name>_<ITEM> */
479 
480 /*                    The former of the two names takes precedence: */
481 /*                    this routine will look for a numeric variable */
482 /*                    of that name first. */
483 
484 /*                    The value associated with the kernel variable */
485 /*                    must be one of */
486 
487 /*                       - a reference frame ID code */
488 
489 /*                       - a string representation of an integer, */
490 /*                         for example '5' */
491 
492 /*                       - a reference frame name */
493 
494 /* $ Detailed_Output */
495 
496 /*     IDCODE         is the frame ID code associated with the value of */
497 /*                    the requested kernel variable. This frame may be */
498 /*                    regarded as being associated with the "right hand */
499 /*                    side." of the kernel variable assignment. The */
500 /*                    kernel variable name of the form */
501 
502 /*                       FRAME_<frame ID code>_<ITEM> */
503 
504 /*                    will be looked up first; if this variable */
505 /*                    is found and has numeric type, the associated */
506 /*                    value will be returned.  If this variable is */
507 /*                    found and has character type, the value will */
508 /*                    be converted to a frame ID code, and that */
509 /*                    code will be returned. */
510 
511 /*                    If this variable is not found, the variable */
512 
513 /*                       FRAME_<frame name>_<ITEM> */
514 
515 /*                    will be looked up.  If this variable is found and */
516 /*                    has numeric type, the associated value will be */
517 /*                    returned.  If this variable is found and has */
518 /*                    character type, the value will be converted to a */
519 /*                    frame ID code, and that code will be returned. */
520 
521 /*                    If a numeric value associated with the selected */
522 /*                    kernel variable is not integral, it will be */
523 /*                    rounded to the closest integer. */
524 
525 /* $ Parameters */
526 
527 /*     None. */
528 
529 /* $ Exceptions */
530 
531 
532 /*     1) If neither the frame-ID-based or frame-name-based form of the */
533 /*        requested kernel variable name matches a kernel variable */
534 /*        present in the kernel pool, the error SPICE(KERNELVARNOTFOUND) */
535 /*        will be signaled. */
536 
537 /*     2) If either the frame-ID-based or frame-name-based form of the */
538 /*        requested kernel variable name has length greater than KVNMLN, */
539 /*        the excessively long name will not be searched for. A search */
540 /*        will still be done using the alternative form of the name if */
541 /*        that form has length less than or equal to KVNMLN. */
542 
543 /*     3) If both the frame-ID-based and frame-name-based forms of the */
544 /*        requested kernel variable name have length greater than KVNMLN, */
545 /*        the error SPICE(VARNAMETOOLONG) will be signaled. */
546 
547 /*     4) If kernel variable matching one form of the requested kernel */
548 /*        variable names is found, but that variable has more than one */
549 /*        associated value, the error SPICE(BADVARIABLESIZE) will be */
550 /*        signaled. */
551 
552 /*     5) If a name match is found for a character kernel variable, but */
553 /*        the value associated with the variable cannot be mapped to a */
554 /*        frame ID code or an integer, the error SPICE(NOTRANSLATION) */
555 /*        is signaled. */
556 
557 /*     6) If a name match is found for a numeric kernel variable, */
558 /*        but that variable has a value that cannot be rounded to an */
559 /*        integer representable on the host platform, an error will */
560 /*        be signaled by a routine in the call tree of this routine. */
561 
562 /* $ Files */
563 
564 /*     1) Kernel variables fetched by this routine are normally */
565 /*        introduced into the kernel pool by loading one or more */
566 /*        frame kernels.  See the Frames Required Reading for */
567 /*        details. */
568 
569 /* $ Particulars */
570 
571 /*     This routine centralizes logic for kernel variable lookups that */
572 /*     must be performed by the SPICELIB frame subsystem. Part of the */
573 /*     functionality of this routine consists of handling error */
574 /*     conditions such as the unavailability of required kernel */
575 /*     variables; hence no "found" flag is returned to the caller. */
576 
577 /*     As indicated above, the requested kernel variable may have a name */
578 /*     of the form */
579 
580 /*        FRAME_<frame ID code>_<ITEM> */
581 
582 /*     or */
583 
584 /*        FRAME_<frame name>_<ITEM> */
585 
586 /*     Because most frame definition keywords have the first form, this */
587 /*     routine looks for a name of that form first. */
588 
589 /*     Note that although this routine considers the two forms of the */
590 /*     names to be synonymous, from the point of view of the kernel pool */
591 /*     data structure, these names are distinct.  Hence kernel variables */
592 /*     having names of both forms, but having possibly different */
593 /*     attributes, can be simultaneously present in the kernel pool. */
594 /*     Intentional use of this kernel pool feature is discouraged. */
595 
596 /* $ Examples */
597 
598 /*     1) See ZZDYNFRM. */
599 
600 /*     2) Applications of this routine include finding ID codes of */
601 /*        frames associated with velocity vectors or constant vectors */
602 /*        serving to define two-vector dynamic frames. */
603 
604 /* $ Restrictions */
605 
606 /*     1) This is a SPICE private routine; the routine is subject */
607 /*        to change without notice.  User applications should not */
608 /*        call this routine. */
609 
610 /*     2) An array-valued kernel variable matching the "ID code form" */
611 /*        of the requested kernel variable name could potentially */
612 /*        mask a scalar-valued kernel variable matching the "name */
613 /*        form" of the requested name.  This problem can be prevented */
614 /*        by sensible frame kernel design. */
615 
616 /* $ Author_and_Institution */
617 
618 /*     N.J. Bachman    (JPL) */
619 
620 /* $ Literature_References */
621 
622 /*     None. */
623 
624 /* $ Version */
625 
626 /* -    SPICELIB Version 1.0.0, 18-DEC-2004 (NJB) */
627 
628 /* -& */
629 
630 /*     SPICELIB functions */
631 
632 
633 /*     Local parameters */
634 
635 
636 /*     TEMPLN is the length of the keyword template, minus */
637 /*     the sum of the lengths of the two substitution markers ('#'). */
638 
639 
640 /*     Local variables */
641 
642     if (return_()) {
643 	return 0;
644     }
645     chkin_("ZZDYNFID", (ftnlen)8);
646 
647 /*     Prepare to check the name of the kernel variable we're about */
648 /*     to look up. */
649 
650 /*     Convert the frame code to a string. */
651 
652     intstr_(frcode, cdestr, (ftnlen)32);
653     if (failed_()) {
654 	chkout_("ZZDYNFID", (ftnlen)8);
655 	return 0;
656     }
657 
658 /*     Get the lengths of the input frame code, name and item. */
659 /*     Compute the length of the ID-based kernel variable name; */
660 /*     check this length against the maximum allowed value.  If */
661 /*     the name is too long, proceed to look up the form of the */
662 /*     kernel variable name based on the frame name. */
663 
664     codeln = rtrim_(cdestr, (ftnlen)32);
665     nameln = rtrim_(frname, frname_len);
666     itemln = rtrim_(item, item_len);
667     reqnum = codeln + itemln + 7;
668     if (reqnum <= 32) {
669 
670 /*        First try looking for a kernel variable including the frame ID */
671 /*        code. */
672 
673 /*        Note the template is */
674 
675 /*            'FRAME_#_#' */
676 
677 	repmi_("FRAME_#_#", "#", frcode, kvname, (ftnlen)9, (ftnlen)1, (
678 		ftnlen)32);
679 	repmc_(kvname, "#", item, kvname, (ftnlen)32, (ftnlen)1, item_len, (
680 		ftnlen)32);
681 	dtpool_(kvname, &found, &n, dtype, (ftnlen)32, (ftnlen)1);
682     } else {
683 
684 /*        The ID-based name is too long. We can't find the variable if */
685 /*        we can't look it up. */
686 
687 	found = FALSE_;
688     }
689     if (! found) {
690 
691 /*        We need to look up the frame name-based kernel variable. */
692 /*        Determine the length of the name of this variable; make */
693 /*        sure it's not too long. */
694 
695 	reqnam = nameln + itemln + 7;
696 	if (reqnam > 32 && reqnum > 32) {
697 
698 /*           Both forms of the name are too long. */
699 
700 	    setmsg_("Kernel variable FRAME_#_# has length #; kernel variable"
701 		    " FRAME_#_# has length #; maximum allowed length is #.  N"
702 		    "either variable could be searched for in the kernel pool"
703 		    " due to these name length errors.", (ftnlen)200);
704 	    errint_("#", frcode, (ftnlen)1);
705 	    errch_("#", item, (ftnlen)1, item_len);
706 	    errint_("#", &reqnum, (ftnlen)1);
707 	    errch_("#", frname, (ftnlen)1, frname_len);
708 	    errch_("#", item, (ftnlen)1, item_len);
709 	    errint_("#", &reqnam, (ftnlen)1);
710 	    errint_("#", &c__32, (ftnlen)1);
711 	    sigerr_("SPICE(VARNAMETOOLONG)", (ftnlen)21);
712 	    chkout_("ZZDYNFID", (ftnlen)8);
713 	    return 0;
714 	} else if (reqnam > 32) {
715 
716 /*           We couldn't find the variable having the ID-based name, */
717 /*           and the frame name-based variable name is too long to */
718 /*           look up. */
719 
720 /*           Note that at this point KVNAME contains the ID-based */
721 /*           kernel variable name. */
722 
723 	    setmsg_("Kernel variable # was expected to be present in the ker"
724 		    "nel pool but was not found.  The alternative form of ker"
725 		    "nel variable name FRAME_#_# was not searched for because"
726 		    " this name has excessive length (# characters vs allowed"
727 		    " maximum of #).  One of these variables is needed to def"
728 		    "ine the parameterized dynamic frame #.  Usually this typ"
729 		    "e of problem is due to a missing keyword assignment in a"
730 		    " frame kernel.  Another, less likely, possibility is tha"
731 		    "t other errors in a frame kernel have confused the frame"
732 		    " subsystem into wrongly deciding these variables are nee"
733 		    "ded.", (ftnlen)563);
734 	    errch_("#", kvname, (ftnlen)1, (ftnlen)32);
735 	    errch_("#", frname, (ftnlen)1, frname_len);
736 	    errch_("#", item, (ftnlen)1, item_len);
737 	    errint_("#", &reqnam, (ftnlen)1);
738 	    errint_("#", &c__32, (ftnlen)1);
739 	    errch_("#", frname, (ftnlen)1, frname_len);
740 	    sigerr_("SPICE(KERNELVARNOTFOUND)", (ftnlen)24);
741 	    chkout_("ZZDYNFID", (ftnlen)8);
742 	    return 0;
743 	}
744 
745 /*        Now try looking for a kernel variable including the frame */
746 /*        name. */
747 
748 	repmc_("FRAME_#_#", "#", frname, kvname, (ftnlen)9, (ftnlen)1,
749 		frname_len, (ftnlen)32);
750 	repmc_(kvname, "#", item, kvname, (ftnlen)32, (ftnlen)1, item_len, (
751 		ftnlen)32);
752 	dtpool_(kvname, &found, &n, dtype, (ftnlen)32, (ftnlen)1);
753 	if (! found && reqnum > 32) {
754 
755 /*           The kernel variable's presence (in one form or the other) */
756 /*           is mandatory:  signal an error.  The error message */
757 /*           depends on which variables we were able to try to */
758 /*           look up.  In this case, we never tried to look up the */
759 /*           frame ID-based name. */
760 
761 /*           Note that at this point KVNAME contains the name-based */
762 /*           kernel variable name. */
763 
764 	    setmsg_("Kernel variable # was expected to be present in the ker"
765 		    "nel pool but was not found.  The alternative form of ker"
766 		    "nel variable name FRAME_#_# was not searched for because"
767 		    " this name has excessive length (# characters vs allowed"
768 		    " maximum of #).  One of these variables is needed to def"
769 		    "ine the parameterized dynamic frame #.  Usually this typ"
770 		    "e of problem is due to a missing keyword assignment in a"
771 		    " frame kernel.  Another, less likely, possibility is tha"
772 		    "t other errors in a frame kernel have confused the frame"
773 		    " subsystem into wrongly deciding these variables are nee"
774 		    "ded.", (ftnlen)563);
775 	    errch_("#", kvname, (ftnlen)1, (ftnlen)32);
776 	    errint_("#", frcode, (ftnlen)1);
777 	    errch_("#", item, (ftnlen)1, item_len);
778 	    errint_("#", &reqnum, (ftnlen)1);
779 	    errint_("#", &c__32, (ftnlen)1);
780 	    errch_("#", frname, (ftnlen)1, frname_len);
781 	    sigerr_("SPICE(KERNELVARNOTFOUND)", (ftnlen)24);
782 	    chkout_("ZZDYNFID", (ftnlen)8);
783 	    return 0;
784 	} else if (! found) {
785 
786 /*           We tried to look up both names and failed. */
787 
788 	    setmsg_("At least one of the kernel variables FRAME_#_# or FRAME"
789 		    "_#_# was expected to be present in the kernel pool but n"
790 		    "either was found. One of these variables is needed to de"
791 		    "fine the parameterized dynamic frame #.  Usually this ty"
792 		    "pe of problem is due to a missing keyword assignment in "
793 		    "a frame kernel.  Another, less likely, possibility is th"
794 		    "at other errors in a frame kernel have confused the fram"
795 		    "e subsystem into wrongly deciding these variables are ne"
796 		    "eded.", (ftnlen)452);
797 	    errint_("#", frcode, (ftnlen)1);
798 	    errch_("#", item, (ftnlen)1, item_len);
799 	    errch_("#", frname, (ftnlen)1, frname_len);
800 	    errch_("#", item, (ftnlen)1, item_len);
801 	    errch_("#", frname, (ftnlen)1, frname_len);
802 	    sigerr_("SPICE(KERNELVARNOTFOUND)", (ftnlen)24);
803 	    chkout_("ZZDYNFID", (ftnlen)8);
804 	    return 0;
805 	}
806     }
807 
808 /*     Getting to this point means we found a kernel variable. The name */
809 /*     of the variable is KVNAME.  The data type is DTYPE and the */
810 /*     cardinality is N. */
811 
812     if (*(unsigned char *)dtype == 'C') {
813 
814 /*        Rather than using BADKPV, we check the cardinality of the */
815 /*        kernel variable in-line so we can create a more detailed error */
816 /*        message if need be. */
817 
818 	if (n > 1) {
819 	    setmsg_("The kernel variable # has used to define frame # was ex"
820 		    "pected to have size not exceeding 1 but in fact has size"
821 		    " #. Usually this type of problem is due to an error in a"
822 		    " frame definition provided in a frame kernel.", (ftnlen)
823 		    212);
824 	    errch_("#", kvname, (ftnlen)1, (ftnlen)32);
825 	    errch_("#", frname, (ftnlen)1, frname_len);
826 	    errint_("#", &n, (ftnlen)1);
827 	    sigerr_("SPICE(BADVARIABLESIZE)", (ftnlen)22);
828 	    chkout_("ZZDYNFID", (ftnlen)8);
829 	    return 0;
830 	}
831 
832 /*        Look up the kernel variable. */
833 
834 	gcpool_(kvname, &c__1, &c__1, &n, outnam, &found, (ftnlen)32, (ftnlen)
835 		32);
836 	if (! found) {
837 	    setmsg_("The kernel variable # has used to define frame # was no"
838 		    "t found after DTPOOL indicated it was present in pool.", (
839 		    ftnlen)109);
840 	    errch_("#", kvname, (ftnlen)1, (ftnlen)32);
841 	    errch_("#", frname, (ftnlen)1, frname_len);
842 	    sigerr_("SPICE(BUG)", (ftnlen)10);
843 	    chkout_("ZZDYNFID", (ftnlen)8);
844 	    return 0;
845 	}
846 
847 /*        Convert the output frame name to a frame code. */
848 
849 	namfrm_(outnam, idcode, (ftnlen)32);
850 	if (*idcode == 0) {
851 
852 /*           If IDCODE is zero, that means NAMFRM couldn't translate */
853 /*           the name.  Perhaps the name is an integer? */
854 
855 	    if (beint_(outnam, (ftnlen)32)) {
856 		prsint_(outnam, idcode, (ftnlen)32);
857 	    } else {
858 
859 /*              We're outta aces. */
860 
861 		setmsg_("The kernel variable # used to define frame # is ass"
862 			"igned the character value #.  This value was expecte"
863 			"d to be a reference frame name, but NAMFRM cannot tr"
864 			"anslate this name to a frame ID code.", (ftnlen)192);
865 		errch_("#", kvname, (ftnlen)1, (ftnlen)32);
866 		errch_("#", frname, (ftnlen)1, frname_len);
867 		errch_("#", outnam, (ftnlen)1, (ftnlen)32);
868 		sigerr_("SPICE(NOTRANSLATION)", (ftnlen)20);
869 		chkout_("ZZDYNFID", (ftnlen)8);
870 		return 0;
871 	    }
872 	}
873 
874 /*        IDCODE has been assigned a value at this point. */
875 
876     } else {
877 
878 /*        The variable has numeric type. */
879 
880 	if (n > 1) {
881 	    setmsg_("The kernel variable # has used to define frame # was ex"
882 		    "pected to have size not exceeding 1 but in fact has size"
883 		    " #. Usually this type of problem is due to an error in a"
884 		    " frame definition provided in a frame kernel.", (ftnlen)
885 		    212);
886 	    errch_("#", kvname, (ftnlen)1, (ftnlen)32);
887 	    errch_("#", frname, (ftnlen)1, frname_len);
888 	    errint_("#", &n, (ftnlen)1);
889 	    sigerr_("SPICE(BADVARIABLESIZE)", (ftnlen)22);
890 	    chkout_("ZZDYNFID", (ftnlen)8);
891 	    return 0;
892 	}
893 
894 /*        Look up the kernel variable. */
895 
896 	gipool_(kvname, &c__1, &c__1, &n, idcode, &found, (ftnlen)32);
897 	if (! found) {
898 	    setmsg_("The kernel variable # has used to define frame # was no"
899 		    "t found after DTPOOL indicated it was present in pool.", (
900 		    ftnlen)109);
901 	    errch_("#", kvname, (ftnlen)1, (ftnlen)32);
902 	    errch_("#", frname, (ftnlen)1, frname_len);
903 	    sigerr_("SPICE(BUG)", (ftnlen)10);
904 	    chkout_("ZZDYNFID", (ftnlen)8);
905 	    return 0;
906 	}
907     }
908     chkout_("ZZDYNFID", (ftnlen)8);
909     return 0;
910 } /* zzdynfid_ */
911 
912