1 /* zzsrfker.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__3 = 3;
11 static integer c__2000 = 2000;
12 static integer c__1 = 1;
13 static integer c__2003 = 2003;
14 
15 /* $Procedure ZZSRFKER ( Surface translation, process kernel update ) */
zzsrfker_(char * kernam,char * nornam,integer * kersid,integer * kerbid,logical * extker,integer * nkvar,integer * snmhls,integer * snmpol,integer * snmidx,integer * sidhls,integer * sidpol,integer * sididx,ftnlen kernam_len,ftnlen nornam_len)16 /* Subroutine */ int zzsrfker_(char *kernam, char *nornam, integer *kersid,
17 	integer *kerbid, logical *extker, integer *nkvar, integer *snmhls,
18 	integer *snmpol, integer *snmidx, integer *sidhls, integer *sidpol,
19 	integer *sididx, ftnlen kernam_len, ftnlen nornam_len)
20 {
21     /* Initialized data */
22 
23     static logical pass1 = TRUE_;
24     static char names[32*3] = "NAIF_SURFACE_BODY               " "NAIF_SURFA"
25 	    "CE_CODE               " "NAIF_SURFACE_NAME               ";
26 
27     /* System generated locals */
28     integer i__1;
29 
30     /* Builtin functions */
31     integer s_cmp(char *, char *, ftnlen, ftnlen);
32 
33     /* Local variables */
34     extern /* Subroutine */ int zzsrfini_(char *, integer *, integer *,
35 	    integer *, integer *, integer *, integer *, integer *, integer *,
36 	    integer *, integer *, ftnlen);
37     integer i__, ncode;
38     extern /* Subroutine */ int chkin_(char *, ftnlen);
39     integer nname;
40     extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
41     integer nbody;
42     logical fndcde;
43     extern logical failed_(void);
44     logical fndbod, fndnam;
45     extern /* Subroutine */ int gcpool_(char *, integer *, integer *, integer
46 	    *, char *, logical *, ftnlen, ftnlen);
47     char bdtype[1], cdtype[1];
48     extern /* Subroutine */ int gipool_(char *, integer *, integer *, integer
49 	    *, integer *, logical *, ftnlen), sigerr_(char *, ftnlen),
50 	    chkout_(char *, ftnlen), dtpool_(char *, logical *, integer *,
51 	    char *, ftnlen, ftnlen);
52     char ndtype[1];
53     extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
54 	    integer *, ftnlen), ljucrs_(integer *, char *, char *, ftnlen,
55 	    ftnlen);
56     extern logical return_(void);
57     extern /* Subroutine */ int swpool_(char *, integer *, char *, ftnlen,
58 	    ftnlen);
59 
60 /* $ Abstract */
61 
62 /*     SPICE Private routine intended solely for the support of SPICE */
63 /*     routines. Users should not call this routine directly due to the */
64 /*     volatile nature of this routine. */
65 
66 /*     Update ZZSRFTRN's name-based and ID-based data structure arrays */
67 /*     using the contents of kernel variables that define the surface */
68 /*     name/ID mapping. */
69 
70 /* $ Disclaimer */
71 
72 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
73 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
74 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
75 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
76 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
77 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
78 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
79 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
80 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
81 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
82 
83 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
84 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
85 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
86 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
87 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
88 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
89 
90 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
91 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
92 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
93 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
94 
95 /* $ Required_Reading */
96 
97 /*     None. */
98 
99 /* $ Keywords */
100 
101 /*     UTILITY */
102 
103 /* $ Declarations */
104 /* $ Abstract */
105 
106 /*     Declare public surface name/ID mapping parameters. */
107 
108 /* $ Disclaimer */
109 
110 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
111 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
112 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
113 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
114 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
115 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
116 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
117 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
118 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
119 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
120 
121 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
122 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
123 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
124 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
125 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
126 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
127 
128 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
129 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
130 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
131 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
132 
133 /* $ Required_Reading */
134 
135 /*     NAIF_IDS */
136 
137 /* $ Keywords */
138 
139 /*     CONVERSION */
140 /*     NAME */
141 /*     STRING */
142 /*     SURFACE */
143 
144 /* $ Restrictions */
145 
146 /*     None. */
147 
148 /* $ Author_and_Institution */
149 
150 /*     N.J. Bachman      (JPL) */
151 
152 /* $ Literature_References */
153 
154 /*     None. */
155 
156 /* $ Version */
157 
158 /* -    SPICELIB Version 1.0.0, 02-DEC-2015 (NJB) */
159 
160 /* -& */
161 
162 /*     Maximum number of surface name/ID mapping entries: */
163 
164 
165 /*     Maximum length of a surface name string: */
166 
167 
168 /*     End of file srftrn.inc. */
169 
170 /* $ Abstract */
171 
172 /*     SPICE private include file intended solely for the support of */
173 /*     SPICE routines. User software should not include this file */
174 /*     due to the volatile nature of this file. */
175 
176 /*     Declare private surface name/ID mapping parameters. */
177 
178 /* $ Disclaimer */
179 
180 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
181 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
182 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
183 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
184 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
185 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
186 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
187 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
188 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
189 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
190 
191 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
192 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
193 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
194 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
195 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
196 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
197 
198 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
199 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
200 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
201 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
202 
203 /* $ Required_Reading */
204 
205 /*     NAIF_IDS */
206 
207 /* $ Keywords */
208 
209 /*     CONVERSION */
210 /*     NAME */
211 /*     STRING */
212 /*     SURFACE */
213 
214 /* $ Restrictions */
215 
216 /*     None. */
217 
218 /* $ Author_and_Institution */
219 
220 /*     N.J. Bachman      (JPL) */
221 
222 /* $ Literature_References */
223 
224 /*     None. */
225 
226 /* $ Version */
227 
228 /* -    SPICELIB Version 1.0.0, 04-FEB-2017 (NJB) */
229 
230 /*        Original version 03-DEC-2015 (NJB) */
231 
232 /* -& */
233 
234 /*     Size of the lists and hashes storing the POOL-defined name/ID */
235 /*     mappings. To ensure efficient hashing, this size is set to the */
236 /*     first prime number greater than MXNSRF defined in the public */
237 /*     include file */
238 
239 /*        srftrn.inc. */
240 
241 
242 /*     Singly-linked list pool lower bound: */
243 
244 
245 /*     End of file zzsrftrn.inc. */
246 
247 /* $ Brief_I/O */
248 
249 /*     Variable  I/O  Description */
250 /*     --------  ---  -------------------------------------------------- */
251 /*     KERNAM     O   Array of surface names from kernel pool. */
252 /*     NORNAM     O   Array of normalized surface names. */
253 /*     KERSID     O   Array of surface ID codes from kernel pool. */
254 /*     KERBID     O   Array of body ID codes from kernel pool. */
255 /*     EXTKER     O   Logical flag indicating kernel data are present. */
256 /*     NKVAR      O   Number of surface name, code, body tuples. */
257 /*     SNMHLS     O   Surface name-based hash head node pointer list */
258 /*     SNMPOL     O   Surface name-based hash node collision list */
259 /*     SNMIDX     O   Surface name-based hash index storage array */
260 /*     SIDHLS     O   Surface ID-based hash head node pointer list */
261 /*     SIDPOL     O   Surface ID-based hash node collision list */
262 /*     SIDIDX     O   Surface ID-based hash index storage array */
263 /*     LBSNGL     P   Lower bound of hash pool arrays */
264 /*     SFNMLN     P   Maximum length of surface name strings */
265 
266 /* $ Detailed_Input */
267 
268 /*     None. */
269 
270 /* $ Detailed_Output */
271 
272 /*     KERNAM    is an array containing surface names from kernel pool */
273 /*               assignments to the kernel variable NAIF_SURFACE_NAME. */
274 
275 /*               Array elements from masked assignments are not included */
276 /*               in KERNAM. */
277 
278 /*     NORNAM    is an array parallel to KERNAM containing normalized */
279 /*               names. The Ith element of NORNAM is obtained from the */
280 /*               Ith element of KERNAM by conversion to uppercase, */
281 /*               left-justification, and compression of consecutive */
282 /*               embedded blanks to a single blank. */
283 
284 /*     KERSID    is an array containing surface names from kernel pool */
285 /*               assignments to the kernel variable NAIF_SURFACE_CODE. */
286 /*               The Ith element of KERSID is the code associated with */
287 /*               the Ith element of KERNAM. */
288 
289 /*     KERBID    is an array containing surface names from kernel pool */
290 /*               assignments to the kernel variable NAIF_SURFACE_BODY. */
291 /*               The Ith element of KERBID is the code associated with */
292 /*               the Ith element of KERNAM. */
293 
294 /*     EXTKER    is a logical flag indicating whether kernel data */
295 /*               defining a surface name/ID mapping are available. */
296 /*               EXTKER is set to .TRUE. if the data are present and is */
297 /*               .FALSE. otherwise. */
298 
299 /*     NKVAR     is the count of names in the array KERNAM; the */
300 /*               arrays NORNAM, KERSID, and KERBID also contain NKVAR */
301 /*               entries. */
302 
303 /*     SNMHLS */
304 /*     SNMPOL    are the surface name-based hash head node pointer and */
305 /*               collision lists. Together with the arrays SNMIDX, */
306 /*               NORNAM, KERBID, and KERSID, they enable mapping pairs */
307 /*               of normalized surface names and body ID codes to */
308 /*               surface ID codes. */
309 
310 /*     SNMIDX    is the surface name-based hash index storage array. It */
311 /*               maps nodes in the name collision list to entries in the */
312 /*               parallel NORNAM, KERBID, and KERSID arrays. */
313 
314 /*     SIDHLS */
315 /*     SIDPOL    are the surface ID-based hash head node pointer and */
316 /*               collision lists. Together with the arrays SIDIDX, */
317 /*               KERSID, KERBID, and KERNAM, they enable mapping pairs of */
318 /*               surface ID codes and body ID codes to surface names. */
319 
320 /*     SIDIDX    is the surface ID-based hash index storage array. It */
321 /*               maps nodes in the ID collision list to entries in the */
322 /*               parallel KERSID, KERBID, and KERNAM arrays. */
323 
324 /* $ Parameters */
325 
326 /*     LBSNGL    is the lower bound of the hashes' collision list array. */
327 
328 /*     SFNMLN    is the maximum length of a surface name. Defined in the */
329 /*               include file 'srftrn.inc'. */
330 
331 /* $ Exceptions */
332 
333 /*     1)  If an error occurs while fetching kernel variables, the error */
334 /*         will be signaled by a routine in the call tree of this */
335 /*         routine. */
336 
337 /*     2)  All three of the kernel variables defining the surface name/ID */
338 /*         map must be present in the kernel pool, or all must be absent. */
339 /*         If this condition is not met, the error SPICE(BADSURFACEMAP) */
340 /*         will be signaled. */
341 
342 /*     3)  All three of the kernel variables defining the surface name/ID */
343 /*         map must have the correct data type; if not, the error */
344 /*         SPICE(BADVARIABLETYPE) will be signaled. */
345 
346 /*     4)  If any of the kernel variables defining the surface name/ID */
347 /*         map have size exceeding MXNSRF, the error */
348 /*         SPICE(TOOMANYSURFACES) will be signaled. */
349 
350 /*     5)  All three of the kernel variables defining the surface name/ID */
351 /*         map must have the same number of elements; if not, the error */
352 /*         SPICE(ARRAYSIZEMISMATCH) will be signaled. */
353 
354 /*     6)  If any surface name is blank, the error */
355 /*         SPICE(BLANKNAMEASSIGNED) will be signaled. */
356 
357 /*     7)  Any error occurring during initialization of the hash data */
358 /*         structures will be signaled by a routine in the call tree */
359 /*         of this routine. */
360 
361 /* $ Files */
362 
363 /*     None. */
364 
365 /* $ Particulars */
366 
367 /*     This routine manages updates of the surface name/ID mapping */
368 /*     subsystem data structures. The outputs of this routine contain */
369 /*     mapping information provided by kernel variables, as well as */
370 /*     associated bookkeeping information. */
371 
372 /*     On the first pass through this routine, the routine sets a watch */
373 /*     on the kernel variables that define the surface name/ID mapping. */
374 /*     This routine must be called after any change to these variables. */
375 
376 /* $ Examples */
377 
378 /*     See the routine ZZSRFTRN. */
379 
380 /* $ Restrictions */
381 
382 /*     1)  This routine is intended only for use by ZZSRFTRN and */
383 /*         ZZSRFKER. */
384 
385 /*     2)  All output hash arrays must be declared with the same */
386 /*         dimension which is greater than or equal to MAXVAL. */
387 
388 /*     3)  The order of mappings in the input arrays determines the */
389 /*         priority, with the mapping with the lowest priority being the */
390 /*         first and the mapping with the highest priority being the */
391 /*         last. */
392 
393 /* $ Literature_References */
394 
395 /*     None. */
396 
397 /* $ Author_and_Institution */
398 
399 /*     B.V. Semenov       (JPL) */
400 /*     M.J. Spencer       (JPL) */
401 /*     W.L. Taber         (JPL) */
402 /*     F.S. Turner        (JPL) */
403 /*     E.D. Wright        (JPL) */
404 
405 /* $ Version */
406 
407 /* -    SPICELIB Version 1.0.0, 04-DEC-2015 (NJB) (BVS) (EDW) */
408 
409 /* -& */
410 
411 /*     SPICELIB functions */
412 
413 
414 /*     Local parameters */
415 
416 
417 /*     Local variables */
418 
419 
420 /*     Saved variables */
421 
422 
423 /*     Initial values */
424 
425     if (return_()) {
426 	return 0;
427     }
428     chkin_("ZZSRFKER", (ftnlen)8);
429 
430 /*     The primary functions performed inline in this routine are */
431 
432 /*        - Setting a watch on the mapping kernel variables */
433 
434 /*        - Fetching the mapping kernel variables' values */
435 
436 /*        - Performing error checks on the kernel variables that define */
437 /*          the surface name/ID mapping. Initialization of data */
438 /*          structures is delegated to ZZSRFINI. */
439 
440 
441     if (pass1) {
442 
443 /*        Set watch on kernel variables used for the surface mapping. */
444 
445 	swpool_("ZZSRFTRN", &c__3, names, (ftnlen)8, (ftnlen)32);
446 	if (failed_()) {
447 	    chkout_("ZZSRFKER", (ftnlen)8);
448 	    return 0;
449 	}
450 	pass1 = FALSE_;
451     }
452 
453 /*     Indicate that no data are available until we find out */
454 /*     otherwise. */
455 
456     *extker = FALSE_;
457     *nkvar = 0;
458 
459 /*     Fetch attributes of the surface mapping kernel variables. */
460 
461     dtpool_("NAIF_SURFACE_NAME", &fndnam, &nname, ndtype, (ftnlen)17, (ftnlen)
462 	    1);
463     dtpool_("NAIF_SURFACE_CODE", &fndcde, &ncode, cdtype, (ftnlen)17, (ftnlen)
464 	    1);
465     dtpool_("NAIF_SURFACE_BODY", &fndbod, &nbody, bdtype, (ftnlen)17, (ftnlen)
466 	    1);
467     if (failed_()) {
468 	chkout_("ZZSRFKER", (ftnlen)8);
469 	return 0;
470     }
471 
472 /*     The variables must all be present or all be absent. */
473 
474     if (fndcde != fndnam || fndbod != fndnam) {
475 	setmsg_("Surface mapping kernel variables are in an inconsistent sta"
476 		"te. # was #; # was #; # was #.", (ftnlen)89);
477 	errch_("#", "NAIF_SURFACE_NAME", (ftnlen)1, (ftnlen)17);
478 	if (fndnam) {
479 	    errch_("#", "found", (ftnlen)1, (ftnlen)5);
480 	} else {
481 	    errch_("#", "not found", (ftnlen)1, (ftnlen)9);
482 	}
483 	errch_("#", "NAIF_SURFACE_CODE", (ftnlen)1, (ftnlen)17);
484 	if (fndcde) {
485 	    errch_("#", "found", (ftnlen)1, (ftnlen)5);
486 	} else {
487 	    errch_("#", "not found", (ftnlen)1, (ftnlen)9);
488 	}
489 	errch_("#", "NAIF_SURFACE_BODY", (ftnlen)1, (ftnlen)17);
490 	if (fndbod) {
491 	    errch_("#", "found", (ftnlen)1, (ftnlen)5);
492 	} else {
493 	    errch_("#", "not found", (ftnlen)1, (ftnlen)9);
494 	}
495 	sigerr_("SPICE(BADSURFACEMAP)", (ftnlen)20);
496 	chkout_("ZZSRFKER", (ftnlen)8);
497 	return 0;
498     }
499 
500 /*     If the variables are not present, leave now. */
501 
502     *extker = fndnam && fndcde && fndbod;
503     if (! (*extker)) {
504 	chkout_("ZZSRFKER", (ftnlen)8);
505 	return 0;
506     }
507 
508 /*     Make sure the kernel variables aren't larger than our arrays. */
509 /*     Also make sure the variable have matching dimensions. */
510 
511 /*     Check variable types. */
512 
513     if (*(unsigned char *)ndtype != 'C' || *(unsigned char *)cdtype != 'N' ||
514 	    *(unsigned char *)bdtype != 'N') {
515 	setmsg_("Surface mapping kernel variable types are: # = #; # = #; # "
516 		"= #. These types must be, respectively, 'C', 'N', 'N'.", (
517 		ftnlen)113);
518 	errch_("#", "NAIF_SURFACE_NAME", (ftnlen)1, (ftnlen)17);
519 	errch_("#", ndtype, (ftnlen)1, (ftnlen)1);
520 	errch_("#", "NAIF_SURFACE_CODE", (ftnlen)1, (ftnlen)17);
521 	errch_("#", cdtype, (ftnlen)1, (ftnlen)1);
522 	errch_("#", "NAIF_SURFACE_BODY", (ftnlen)1, (ftnlen)17);
523 	errch_("#", bdtype, (ftnlen)1, (ftnlen)1);
524 	sigerr_("SPICE(BADVARIABLETYPE)", (ftnlen)22);
525 	chkout_("ZZSRFKER", (ftnlen)8);
526 	return 0;
527     }
528 
529 /*     Check variable dimensions. */
530 
531     if (nname > 2000 || ncode > 2000 || nbody > 2000) {
532 	setmsg_("Surface mapping kernel variable sizes are: # = #; # = #; # "
533 		"= #. Maximum allowed size is #.", (ftnlen)90);
534 	errch_("#", "NAIF_SURFACE_NAME", (ftnlen)1, (ftnlen)17);
535 	errint_("#", &nname, (ftnlen)1);
536 	errch_("#", "NAIF_SURFACE_CODE", (ftnlen)1, (ftnlen)17);
537 	errint_("#", &ncode, (ftnlen)1);
538 	errch_("#", "NAIF_SURFACE_BODY", (ftnlen)1, (ftnlen)17);
539 	errint_("#", &nbody, (ftnlen)1);
540 	errint_("#", &c__2000, (ftnlen)1);
541 	sigerr_("SPICE(TOOMANYSURFACES)", (ftnlen)22);
542 	chkout_("ZZSRFKER", (ftnlen)8);
543 	return 0;
544     }
545     if (ncode != nname || nbody != nname) {
546 	setmsg_("Surface variable sizes do not match. Size of # is #; size o"
547 		"f # is #; size of # is #.", (ftnlen)84);
548 	errch_("#", "NAIF_SURFACE_NAME", (ftnlen)1, (ftnlen)17);
549 	errint_("#", &nname, (ftnlen)1);
550 	errch_("#", "NAIF_SURFACE_CODE", (ftnlen)1, (ftnlen)17);
551 	errint_("#", &ncode, (ftnlen)1);
552 	errch_("#", "NAIF_SURFACE_BODY", (ftnlen)1, (ftnlen)17);
553 	errint_("#", &nbody, (ftnlen)1);
554 	sigerr_("SPICE(ARRAYSIZEMISMATCH)", (ftnlen)24);
555 	chkout_("ZZSRFKER", (ftnlen)8);
556 	return 0;
557     }
558 
559 /*     Fetch mapping variables. */
560 
561 /*     Note that we'll check the variable sizes below. */
562 
563     gcpool_("NAIF_SURFACE_NAME", &c__1, &c__2000, &nname, kernam, &fndnam, (
564 	    ftnlen)17, (ftnlen)36);
565     gipool_("NAIF_SURFACE_CODE", &c__1, &c__2000, &ncode, kersid, &fndcde, (
566 	    ftnlen)17);
567     gipool_("NAIF_SURFACE_BODY", &c__1, &c__2000, &nbody, kerbid, &fndbod, (
568 	    ftnlen)17);
569     if (failed_()) {
570 	chkout_("ZZSRFKER", (ftnlen)8);
571 	return 0;
572     }
573     *nkvar = nname;
574 
575 /*     Produce normalized name array. Check for blank names */
576 /*     as we go. */
577 
578     i__1 = *nkvar;
579     for (i__ = 1; i__ <= i__1; ++i__) {
580 	if (s_cmp(kernam + (i__ - 1) * 36, " ", (ftnlen)36, (ftnlen)1) == 0) {
581 	    setmsg_("An attempt to assign the code, #, to a blank string was"
582 		    " made.  Check loaded text kernels for a blank string in "
583 		    "the NAIF_SURFACE_NAME array.", (ftnlen)139);
584 	    errint_("#", &i__, (ftnlen)1);
585 	    sigerr_("SPICE(BLANKNAMEASSIGNED)", (ftnlen)24);
586 	    chkout_("ZZSRFKER", (ftnlen)8);
587 	    return 0;
588 	}
589 	ljucrs_(&c__1, kernam + (i__ - 1) * 36, nornam + (i__ - 1) * 36, (
590 		ftnlen)36, (ftnlen)36);
591     }
592 
593 /*     Initialize hash data structures. */
594 
595     zzsrfini_(nornam, kersid, kerbid, nkvar, &c__2003, snmhls, snmpol, snmidx,
596 	     sidhls, sidpol, sididx, (ftnlen)36);
597     chkout_("ZZSRFKER", (ftnlen)8);
598     return 0;
599 } /* zzsrfker_ */
600 
601