1 /* zznamfrm.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 /* $Procedure ZZNAMFRM ( Frame name to ID translation, with bypass ) */
zznamfrm_(integer * usrctr,char * savnam,integer * savcde,char * frname,integer * frcode,ftnlen savnam_len,ftnlen frname_len)9 /* Subroutine */ int zznamfrm_(integer *usrctr, char *savnam, integer *savcde,
10 	 char *frname, integer *frcode, ftnlen savnam_len, ftnlen frname_len)
11 {
12     /* Builtin functions */
13     integer s_cmp(char *, char *, ftnlen, ftnlen);
14     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
15 
16     /* Local variables */
17     extern /* Subroutine */ int zzpctrck_(integer *, logical *), chkin_(char *
18 	    , ftnlen), namfrm_(char *, integer *, ftnlen);
19     logical update;
20     extern /* Subroutine */ int chkout_(char *, ftnlen);
21     extern logical return_(void);
22 
23 /* $ Abstract */
24 
25 /*     SPICE Private routine intended solely for the support of SPICE */
26 /*     routines.  Users should not call this routine directly due */
27 /*     to the volatile nature of this routine. */
28 
29 /*     Translate a string containing a frame name to its ID code, but */
30 /*     bypass calling NAMFRM and return saved value provided by the */
31 /*     caller if the name is the same as the saved name and the POOL */
32 /*     state did not change. */
33 
34 /* $ Disclaimer */
35 
36 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
37 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
38 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
39 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
40 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
41 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
42 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
43 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
44 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
45 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
46 
47 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
48 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
49 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
50 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
51 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
52 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
53 
54 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
55 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
56 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
57 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
58 
59 /* $ Required_Reading */
60 
61 /*     NAIF_IDS */
62 
63 /* $ Keywords */
64 
65 /*     PRIVATE */
66 /*     FRAME */
67 
68 /* $ Declarations */
69 /* $ Abstract */
70 
71 /*     This include file defines the dimension of the counter */
72 /*     array used by various SPICE subsystems to uniquely identify */
73 /*     changes in their states. */
74 
75 /* $ Disclaimer */
76 
77 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
78 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
79 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
80 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
81 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
82 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
83 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
84 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
85 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
86 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
87 
88 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
89 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
90 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
91 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
92 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
93 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
94 
95 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
96 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
97 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
98 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
99 
100 /* $ Parameters */
101 
102 /*     CTRSIZ      is the dimension of the counter array used by */
103 /*                 various SPICE subsystems to uniquely identify */
104 /*                 changes in their states. */
105 
106 /* $ Author_and_Institution */
107 
108 /*     B.V. Semenov    (JPL) */
109 
110 /* $ Literature_References */
111 
112 /*     None. */
113 
114 /* $ Version */
115 
116 /* -    SPICELIB Version 1.0.0, 29-JUL-2013 (BVS) */
117 
118 /* -& */
119 
120 /*     End of include file. */
121 
122 /* $ Brief_I/O */
123 
124 /*     Variable  I/O  Description */
125 /*     --------  ---  -------------------------------------------------- */
126 /*     USRCTR    I/O  POOL state counter saved by the caller. */
127 /*     SAVNAM    I/O  Frame name saved by the caller. */
128 /*     SAVCDE    I/O  Frame ID code saved by the caller. */
129 /*     FRNAME     I   Frame name. */
130 /*     FRCODE     O   Frame ID code. */
131 /*     CTRSIZ     P   Counter array size. */
132 
133 /* $ Detailed_Input */
134 
135 /*     USRCTR      is the value of the POOL state counter tracked by */
136 /*                 (saved in) the caller (user) routine specifically for */
137 /*                 this frame name/ID pair of variables. */
138 
139 /*     SAVNAM      is the frame name saved in the caller routine */
140 /*                 specifically for this frame name/ID pair of */
141 /*                 variables. For detailed description of allowed values */
142 /*                 see description of the FRNAME argument in NAMFRM. */
143 
144 /*     SAVCDE      is the frame ID code saved in the caller routine */
145 /*                 specifically for this frame name/ID pair of */
146 /*                 variables. For detailed description of allowed values */
147 /*                 see description of the FRCODE argument in NAMFRM. */
148 
149 /*     FRNAME      is the input frame name. For detailed description of */
150 /*                 allowed values see description of the FRNAME argument */
151 /*                 in NAMFRM. */
152 
153 /* $ Detailed_Output */
154 
155 /*     USRCTR      is the current POOL state counter. */
156 
157 /*     SAVNAM      is the frame name saved in the caller routine */
158 /*                 specifically for this frame name/ID pair of */
159 /*                 variables. On the output SAVNAM always equals FRNAME. */
160 
161 /*     SAVCDE      is the frame ID code saved in the caller routine */
162 /*                 specifically for this frame name/ID pair of */
163 /*                 variables. If the frame name cannot be mapped to an */
164 /*                 ID, FRCODE is returned as 0. On the output SAVCDE */
165 /*                 always equals FRCODE. */
166 
167 /*     FRCODE      is the output frame ID code. For detailed description */
168 /*                 of possible values see description of the FRCODE */
169 /*                 argument in NAMFRM. If the frame name cannot be */
170 /*                 mapped to an ID, FRCODE is returned as 0. On the */
171 /*                 output FRCODE always equals SAVCDE. */
172 
173 /* $ Parameters */
174 
175 /*     CTRSIZ      is the dimension of the counter array used by */
176 /*                 various SPICE subsystems to uniquely identify */
177 /*                 changes in their states. This parameter is */
178 /*                 defined in the private include file 'zzctr.inc'. */
179 
180 /* $ Exceptions */
181 
182 /*     1) Errors may be signaled by routines in the call tree of this */
183 /*        routine. */
184 
185 /* $ Files */
186 
187 /*     None. */
188 
189 /* $ Particulars */
190 
191 /*     This routine translates a string containing a frame name to an */
192 /*     integer code but bypasses calling NAMFRM to do the translation */
193 /*     and simply returns the saved ID value provided by the caller if */
194 /*     the input name is the same as the saved name provided by the */
195 /*     caller, the saved ID provided by the caller is not 0, and the */
196 /*     POOL state counter tracked by the caller is the same as the */
197 /*     current POOL state counter. */
198 
199 /*     The POOL state counter and name/ID pair of saved variables */
200 /*     tracked by the caller must be specific for each frame of */
201 /*     interest. I.e. if the caller routine needs to call this routine */
202 /*     to do translations for two distinct frames, the caller routine */
203 /*     mush use must have its own set of saved POOL state counter and */
204 /*     name/ID variables for each of the two frames. */
205 
206 /* $ Examples */
207 
208 /*     This example shows how a routine that needs to do frame name-ID */
209 /*     conversion for two distinct frames (FRA and FRB) can do it using */
210 /*     ZZNAMFRM. */
211 
212 /*           SUBROUTINE <name> ( FRA, FRB, ... ) */
213 /*           ... */
214 /*           INCLUDE               'zzctr.inc' */
215 /*           ... */
216 /*     C */
217 /*     C     Saved frame name length. */
218 /*     C */
219 /*           INTEGER               FRNMLN */
220 /*           PARAMETER           ( FRNMLN = 32 ) */
221 /*           .... */
222 /*     C */
223 /*     C */
224 /*     C     Saved name/ID item declarations. */
225 /*     C */
226 /*           INTEGER               SVCTR1 ( CTRSIZ ) */
227 /*           CHARACTER*(FRNMLN)    SVFRA */
228 /*           INTEGER               SVFRAI */
229 /*           INTEGER               SVCTR2 ( CTRSIZ ) */
230 /*           CHARACTER*(FRNMLN)    SVFRB */
231 /*           INTEGER               SVFRBI */
232 /*           LOGICAL               FIRST */
233 /*     C */
234 /*     C     Saved name/ID items. */
235 /*     C */
236 /*           SAVE                  SVCTR1 */
237 /*           SAVE                  SVFRA */
238 /*           SAVE                  SVFRAI */
239 /*           SAVE                  SVCTR2 */
240 /*           SAVE                  SVFRB */
241 /*           SAVE                  SVFRBI */
242 /*           SAVE                  FIRST */
243 /*     C */
244 /*     C     Initial values. */
245 /*     C */
246 /*           DATA                  FIRST   / .TRUE. / */
247 /*           ... */
248 /*     C */
249 /*     C     Initialization. */
250 /*     C */
251 /*           IF ( FIRST ) THEN */
252 /*     C */
253 /*     C        Initialize POOL counters. */
254 /*     C */
255 /*              CALL ZZCTRUIN( SVCTR1 ) */
256 /*              CALL ZZCTRUIN( SVCTR2 ) */
257 /*              FIRST = .FALSE. */
258 /*           END IF */
259 /*     C */
260 /*     C     Starting from translation of FRA name to ID. */
261 /*     C */
262 /*           CALL ZZNAMFRM ( SVCTR1, SVFRA, SVFRAI, FRA, FRAID ) */
263 
264 /*           IF ( FRAID .EQ. 0 ) THEN */
265 /*              CALL SETMSG ( '...' ) */
266 /*              CALL SIGERR ( 'SPICE(FRAMEAIDCODENOTFOUND)' ) */
267 /*              CALL CHKOUT ( '<name>' ) */
268 /*              RETURN */
269 /*           END IF */
270 /*     C */
271 /*     C     Now do the same for FRB. */
272 /*     C */
273 /*           CALL ZZNAMFRM ( SVCTR2, SVFRB, SVFRBI, FRB, FRBID ) */
274 
275 /*           IF ( FRBID .EQ. 0 ) THEN */
276 /*              CALL SETMSG ( '...' ) */
277 /*              CALL SIGERR ( 'SPICE(FRAMEBIDCODENOTFOUND)' ) */
278 /*              CALL CHKOUT ( '<name>' ) */
279 /*              RETURN */
280 /*           END IF */
281 /*           ... */
282 
283 /* $ Restrictions */
284 
285 /*     None. */
286 
287 /* $ Literature_References */
288 
289 /*     None. */
290 
291 /* $ Author_and_Institution */
292 
293 /*     B.V. Semenov    (JPL) */
294 
295 /* $ Version */
296 
297 /* -    SPICELIB Version 1.0.0, 23-SEP-2013 (BVS) */
298 
299 /* -& */
300 
301 /*     SPICE functions. */
302 
303 
304 /*     Local variables. */
305 
306 
307 /*     Standard SPICE error handling. */
308 
309     if (return_()) {
310 	return 0;
311     }
312 
313 /*     Check/update POOL state counter. */
314 
315     zzpctrck_(usrctr, &update);
316 
317 /*     Check update flag, saved ID, and saved name against the input. */
318 
319     if (! update && *savcde != 0 && s_cmp(savnam, frname, savnam_len,
320 	    frname_len) == 0) {
321 
322 /*        No change in the POOL state, the saved name was successfully */
323 /*        resolved earlier, and input and saved names are the same. */
324 /*        Return saved ID. */
325 
326 	*frcode = *savcde;
327     } else {
328 
329 /*        Check in because NAMFRM may fail. */
330 
331 	chkin_("ZZNAMFRM", (ftnlen)8);
332 
333 /*        POOL state changed, or the saved name was never successfully */
334 /*        resolved earlier, or input and saved names are different. Call */
335 /*        NAMFRM to look up ID and reset saved values. */
336 
337 	namfrm_(frname, frcode, frname_len);
338 	s_copy(savnam, frname, savnam_len, frname_len);
339 	*savcde = *frcode;
340 
341 /*        Check out. */
342 
343 	chkout_("ZZNAMFRM", (ftnlen)8);
344     }
345     return 0;
346 } /* zznamfrm_ */
347 
348