1 /* sgfcon.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__1 = 1;
11 static integer c__2 = 2;
12
13 /* $Procedure SGFCON ( Generic Segments: Fetch constants ) */
sgfcon_(integer * handle,doublereal * descr,integer * first,integer * last,doublereal * values)14 /* Subroutine */ int sgfcon_(integer *handle, doublereal *descr, integer *
15 first, integer *last, doublereal *values)
16 {
17 integer base, b, e;
18 extern /* Subroutine */ int chkin_(char *, ftnlen), dafgda_(integer *,
19 integer *, integer *, doublereal *);
20 extern logical failed_(void);
21 extern /* Subroutine */ int sgmeta_(integer *, doublereal *, integer *,
22 integer *), sigerr_(char *, ftnlen), chkout_(char *, ftnlen),
23 setmsg_(char *, ftnlen);
24 integer myncon;
25 extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
26 extern logical return_(void);
27
28 /* $ Abstract */
29
30 /* Given the descriptor for a generic segment in a DAF file */
31 /* associated with HANDLE, fetch from the constants partition */
32 /* of the segment the double precision numbers from FIRST to */
33 /* LAST. */
34
35 /* $ Disclaimer */
36
37 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
38 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
39 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
40 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
41 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
42 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
43 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
44 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
45 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
46 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
47
48 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
49 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
50 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
51 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
52 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
53 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
54
55 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
56 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
57 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
58 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
59
60 /* $ Required_Reading */
61
62 /* DAF Required Reading. */
63
64 /* $ Keywords */
65
66 /* GENERIC SEGMENTS */
67
68 /* $ Declarations */
69 /* $ Brief_I/O */
70
71 /* VARIABLE I/O DESCRIPTION */
72 /* -------- --- -------------------------------------------------- */
73 /* HANDLE I Handle of a DAF open for reading. */
74 /* DESCR I Descriptor for a generic segment in the DAF. */
75 /* FIRST I The index of the first constant value to fetch. */
76 /* LAST I The index of the last constant value to fetch. */
77 /* VALUES O The constant values that were requested. */
78
79 /* $ Detailed_Input */
80
81 /* HANDLE is the handle of a DAF opened for reading that */
82 /* contains the segment described by DESCR. */
83
84 /* DESCR is the descriptor of the segment with the desired */
85 /* constant values. This must be the descriptor for a */
86 /* generic segment in the DAF associated with HANDLE. */
87
88 /* FIRST is the index of the first value to fetch from the */
89 /* constants section of the generic segment associated */
90 /* with HANDLE and DESCR. */
91
92 /* LAST is the index of the last value to fetch from the */
93 /* constants section of the generic segment associated */
94 /* with HANDLE and DESCR. */
95
96 /* $ Detailed_Output */
97
98 /* VALUES is the array of constant values obtained from the */
99 /* constants section of the generic segment associated */
100 /* with HANDLE and DESCR. */
101
102 /* $ Parameters */
103
104 /* This subroutine makes use of parameters defined in the file */
105 /* 'sgparam.inc'. */
106
107 /* $ Files */
108
109 /* See the description of HANDLE above. */
110
111 /* $ Exceptions */
112
113 /* 1) The error SPICE(REQUESTOUTOFBOUNDS) will be signalled */
114 /* if FIRST is less than 1 or LAST is greater than the */
115 /* number of constants. */
116
117 /* 2) The error SPICE(REQUESTOUTOFORDER) will be signalled */
118 /* if LAST is less than FIRST. */
119
120 /* $ Particulars */
121
122 /* This routine allows easy access to values from the constants */
123 /* partition of a generic segment in a DAF file. Please see the DAF */
124 /* Required Reading or the include file 'sgparam.inc' for a more */
125 /* detailed description of a generic segment. */
126
127 /* $ Examples */
128
129 /* Suppose that you have located a DAF generic segment. The */
130 /* fragment of code below shows how to fetch all of the */
131 /* constants from that segment. */
132
133 /* Declarations: */
134
135 /* DOUBLE PRECISION CONSTS(<enough room to hold constants>) */
136
137 /* INTEGER MYNCON */
138
139 /* Get the number of items in the constants section. */
140
141 /* CALL SGMETA ( HANDLE, DESCR, NCON, MYNCON ) */
142
143 /* Fetch the constants from the segment. */
144
145 /* CALL SGFCON ( HANDLE, DESCR, 1, MYNCON, CONSTS ) */
146
147 /* $ Restrictions */
148
149 /* The segment described by DESCR must be a generic segment, */
150 /* otherwise the results of this routine are not predictable. */
151
152 /* $ Author_and_Institution */
153
154 /* K.R. Gehringer (JPL) */
155 /* W.L. Taber (JPL) */
156
157 /* $ Literature_References */
158
159 /* None. */
160
161 /* $ Version */
162
163 /* - SPICELIB Version 1.1.0, 07-SEP-2001 (EDW) */
164
165 /* Replaced DAFRDA call with DAFGDA. */
166
167 /* - SPICELIB Version 1.0.0, 11-APR-1995 (KRG) (WLT) */
168
169 /* -& */
170 /* $ Index_Entries */
171
172 /* fetch constants from a generic segment */
173
174 /* -& */
175
176 /* Spicelib Functions */
177
178
179 /* Local Parameters */
180
181 /* Include the mnemonic values for the generic segment declarations. */
182
183
184 /* Local Variables */
185
186
187 /* $ Abstract */
188
189 /* Parameter declarations for the generic segments subroutines. */
190
191 /* $ Disclaimer */
192
193 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
194 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
195 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
196 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
197 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
198 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
199 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
200 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
201 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
202 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
203
204 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
205 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
206 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
207 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
208 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
209 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
210
211 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
212 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
213 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
214 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
215
216 /* $ Required_Reading */
217
218 /* DAF Required Reading */
219
220 /* $ Keywords */
221
222 /* GENERIC SEGMENTS */
223
224 /* $ Particulars */
225
226 /* This include file contains the parameters used by the generic */
227 /* segments subroutines, SGxxxx. A generic segment is a */
228 /* generalization of a DAF array which places a particular structure */
229 /* on the data contained in the array, as described below. */
230
231 /* This file defines the mnemonics that are used for the index types */
232 /* allowed in generic segments as well as mnemonics for the meta data */
233 /* items which are used to describe a generic segment. */
234
235 /* A DAF generic segment contains several logical data partitions: */
236
237 /* 1) A partition for constant values to be associated with each */
238 /* data packet in the segment. */
239
240 /* 2) A partition for the data packets. */
241
242 /* 3) A partition for reference values. */
243
244 /* 4) A partition for a packet directory, if the segment contains */
245 /* variable sized packets. */
246
247 /* 5) A partition for a reference value directory. */
248
249 /* 6) A reserved partition that is not currently used. This */
250 /* partition is only for the use of the NAIF group at the Jet */
251 /* Propulsion Laboratory (JPL). */
252
253 /* 7) A partition for the meta data which describes the locations */
254 /* and sizes of other partitions as well as providing some */
255 /* additional descriptive information about the generic */
256 /* segment. */
257
258 /* +============================+ */
259 /* | Constants | */
260 /* +============================+ */
261 /* | Packet 1 | */
262 /* |----------------------------| */
263 /* | Packet 2 | */
264 /* |----------------------------| */
265 /* | . | */
266 /* | . | */
267 /* | . | */
268 /* |----------------------------| */
269 /* | Packet N | */
270 /* +============================+ */
271 /* | Reference Values | */
272 /* +============================+ */
273 /* | Packet Directory | */
274 /* +============================+ */
275 /* | Reference Directory | */
276 /* +============================+ */
277 /* | Reserved Area | */
278 /* +============================+ */
279 /* | Segment Meta Data | */
280 /* +----------------------------+ */
281
282 /* Only the placement of the meta data at the end of a generic */
283 /* segment is required. The other data partitions may occur in any */
284 /* order in the generic segment because the meta data will contain */
285 /* pointers to their appropriate locations within the generic */
286 /* segment. */
287
288 /* The meta data for a generic segment should only be obtained */
289 /* through use of the subroutine SGMETA. The meta data should not be */
290 /* written through any mechanism other than the ending of a generic */
291 /* segment begun by SGBWFS or SGBWVS using SGWES. */
292
293 /* $ Restrictions */
294
295 /* 1) If new reference index types are added, the new type(s) should */
296 /* be defined to be the consecutive integer(s) after the last */
297 /* defined reference index type used. In this way a value for */
298 /* the maximum allowed index type may be maintained. This value */
299 /* must also be updated if new reference index types are added. */
300
301 /* 2) If new meta data items are needed, mnemonics for them must be */
302 /* added to the end of the current list of mnemonics and before */
303 /* the NMETA mnemonic. In this way compatibility with files having */
304 /* a different, but smaller, number of meta data items may be */
305 /* maintained. See the description and example below. */
306
307 /* $ Author_and_Institution */
308
309 /* N.J. Bachman (JPL) */
310 /* K.R. Gehringer (JPL) */
311 /* W.L. Taber (JPL) */
312 /* F.S. Turner (JPL) */
313
314 /* $ Literature_References */
315
316 /* Generic Segments Required Reading. */
317 /* DAF Required Reading. */
318
319 /* $ Version */
320
321 /* - SPICELIB Version 1.1.1, 28-JAN-2004 (NJB) */
322
323 /* Header update: equations for comptutations of packet indices */
324 /* for the cases of index types 0 and 1 were corrected. */
325
326 /* - SPICELIB Version 1.1.0, 25-09-98 (FST) */
327
328 /* Added parameter MNMETA, the minimum number of meta data items */
329 /* that must be present in a generic DAF segment. */
330
331 /* - SPICELIB Version 1.0.0, 04-03-95 (KRG) (WLT) */
332
333 /* -& */
334
335 /* Mnemonics for the type of reference value index. */
336
337 /* Two forms of indexing are provided: */
338
339 /* 1) An implicit form of indexing based on using two values, a */
340 /* starting value, which will have an index of 1, and a step */
341 /* size between reference values, which are used to compute an */
342 /* index and a reference value associated with a specified key */
343 /* value. See the descriptions of the implicit types below for */
344 /* the particular formula used in each case. */
345
346 /* 2) An explicit form of indexing based on a reference value for */
347 /* each data packet. */
348
349
350 /* Reference Index Type 0 */
351 /* ---------------------- */
352
353 /* Implied index. The index and reference value of a data packet */
354 /* associated with a specified key value are computed from the two */
355 /* generic segment reference values using the formula below. The two */
356 /* generic segment reference values, REF(1) and REF(2), represent, */
357 /* respectively, a starting value and a step size between reference */
358 /* values. The index of the data packet associated with a key value */
359 /* of VALUE is given by: */
360
361 /* / VALUE - REF(1) \ */
362 /* INDEX = 1 + INT | -------------------- | */
363 /* \ REF(2) / */
364
365 /* and the reference value associated with VALUE is given by: */
366
367 /* REFVAL = REF(1) + DBLE (INDEX-1) * REF(2) */
368
369
370 /* Reference Index Type 1 */
371 /* ---------------------- */
372
373 /* Implied index. The index and reference value of a data packet */
374 /* associated with a specified key value are computed from the two */
375 /* generic segment reference values using the formula below. The two */
376 /* generic segment reference values, REF(1) and REF(2), represent, */
377 /* respectively, a starting value and a step size between reference */
378 /* values. The index of the data packet associated with a key value */
379 /* of VALUE is given by: */
380
381 /* / VALUE - REF(1) \ */
382 /* INDEX = 1 + INT | 0.5 + -------------------- | */
383 /* \ REF(2) / */
384
385
386 /* and the reference value associated with VALUE is given by: */
387
388 /* REFVAL = REF(1) + DBLE (INDEX-1) * REF(2) */
389
390 /* We get the larger index in the event that VALUE is halfway between */
391 /* X(I) and X(I+1), where X(I) = BUFFER(1) + DBLE (I-1) * REFDAT(2). */
392
393
394 /* Reference Index Type 2 */
395 /* ---------------------- */
396
397 /* Explicit index. In this case the number of packets must equal the */
398 /* number of reference values. The index of the packet associated */
399 /* with a key value of VALUE is the index of the last reference item */
400 /* that is strictly less than VALUE. The reference values must be in */
401 /* ascending order, REF(I) < REF(I+1). */
402
403
404 /* Reference Index Type 3 */
405 /* ---------------------- */
406
407 /* Explicit index. In this case the number of packets must equal the */
408 /* number of reference values. The index of the packet associated */
409 /* with a key value of VALUE is the index of the last reference item */
410 /* that is less than or equal to VALUE. The reference values must be */
411 /* in ascending order, REF(I) < REF(I+1). */
412
413
414 /* Reference Index Type 4 */
415 /* ---------------------- */
416
417 /* Explicit index. In this case the number of packets must equal the */
418 /* number of reference values. The index of the packet associated */
419 /* with a key value of VALUE is the index of the reference item */
420 /* that is closest to the value of VALUE. In the event of a "tie" */
421 /* the larger index is selected. The reference values must be in */
422 /* ascending order, REF(I) < REF(I+1). */
423
424
425 /* These parameters define the valid range for the index types. An */
426 /* index type code, MYTYPE, for a generic segment must satisfy the */
427 /* relation MNIDXT <= MYTYPE <= MXIDXT. */
428
429
430 /* The following meta data items will appear in all generic segments. */
431 /* Other meta data items may be added if a need arises. */
432
433 /* 1) CONBAS Base Address of the constants in a generic segment. */
434
435 /* 2) NCON Number of constants in a generic segment. */
436
437 /* 3) RDRBAS Base Address of the reference directory for a */
438 /* generic segment. */
439
440 /* 4) NRDR Number of items in the reference directory of a */
441 /* generic segment. */
442
443 /* 5) RDRTYP Type of the reference directory 0, 1, 2 ... for a */
444 /* generic segment. */
445
446 /* 6) REFBAS Base Address of the reference items for a generic */
447 /* segment. */
448
449 /* 7) NREF Number of reference items in a generic segment. */
450
451 /* 8) PDRBAS Base Address of the Packet Directory for a generic */
452 /* segment. */
453
454 /* 9) NPDR Number of items in the Packet Directory of a generic */
455 /* segment. */
456
457 /* 10) PDRTYP Type of the packet directory 0, 1, ... for a generic */
458 /* segment. */
459
460 /* 11) PKTBAS Base Address of the Packets for a generic segment. */
461
462 /* 12) NPKT Number of Packets in a generic segment. */
463
464 /* 13) RSVBAS Base Address of the Reserved Area in a generic */
465 /* segment. */
466
467 /* 14) NRSV Number of items in the reserved area of a generic */
468 /* segment. */
469
470 /* 15) PKTSZ Size of the packets for a segment with fixed width */
471 /* data packets or the size of the largest packet for a */
472 /* segment with variable width data packets. */
473
474 /* 16) PKTOFF Offset of the packet data from the start of a packet */
475 /* record. Each data packet is placed into a packet */
476 /* record which may have some bookkeeping information */
477 /* prepended to the data for use by the generic */
478 /* segments software. */
479
480 /* 17) NMETA Number of meta data items in a generic segment. */
481
482 /* Meta Data Item 1 */
483 /* ----------------- */
484
485
486 /* Meta Data Item 2 */
487 /* ----------------- */
488
489
490 /* Meta Data Item 3 */
491 /* ----------------- */
492
493
494 /* Meta Data Item 4 */
495 /* ----------------- */
496
497
498 /* Meta Data Item 5 */
499 /* ----------------- */
500
501
502 /* Meta Data Item 6 */
503 /* ----------------- */
504
505
506 /* Meta Data Item 7 */
507 /* ----------------- */
508
509
510 /* Meta Data Item 8 */
511 /* ----------------- */
512
513
514 /* Meta Data Item 9 */
515 /* ----------------- */
516
517
518 /* Meta Data Item 10 */
519 /* ----------------- */
520
521
522 /* Meta Data Item 11 */
523 /* ----------------- */
524
525
526 /* Meta Data Item 12 */
527 /* ----------------- */
528
529
530 /* Meta Data Item 13 */
531 /* ----------------- */
532
533
534 /* Meta Data Item 14 */
535 /* ----------------- */
536
537
538 /* Meta Data Item 15 */
539 /* ----------------- */
540
541
542 /* Meta Data Item 16 */
543 /* ----------------- */
544
545
546 /* If new meta data items are to be added to this list, they should */
547 /* be added above this comment block as described below. */
548
549 /* INTEGER NEW1 */
550 /* PARAMETER ( NEW1 = PKTOFF + 1 ) */
551
552 /* INTEGER NEW2 */
553 /* PARAMETER ( NEW2 = NEW1 + 1 ) */
554
555 /* INTEGER NEWEST */
556 /* PARAMETER ( NEWEST = NEW2 + 1 ) */
557
558 /* and then the value of NMETA must be changed as well to be: */
559
560 /* INTEGER NMETA */
561 /* PARAMETER ( NMETA = NEWEST + 1 ) */
562
563 /* Meta Data Item 17 */
564 /* ----------------- */
565
566
567 /* Maximum number of meta data items. This is always set equal to */
568 /* NMETA. */
569
570
571 /* Minimum number of meta data items that must be present in a DAF */
572 /* generic segment. This number is to remain fixed even if more */
573 /* meta data items are added for compatibility with old DAF files. */
574
575
576 /* Standard SPICE error handling. */
577
578 if (return_()) {
579 return 0;
580 }
581 chkin_("SGFCON", (ftnlen)6);
582
583 /* Get the value for the base of the constants and the number of */
584 /* constants in the generic segment. */
585
586 sgmeta_(handle, descr, &c__1, &base);
587 sgmeta_(handle, descr, &c__2, &myncon);
588 if (failed_()) {
589 chkout_("SGFCON", (ftnlen)6);
590 return 0;
591 }
592
593 /* Perform checks on the inputs for reasonableness. */
594
595 if (*first < 1 || *last > myncon) {
596 setmsg_("The range of constants requested extends beyond the availab"
597 "le constant data. Constants are available for indices 1 to "
598 "#. You have requested data from # to #. ", (ftnlen)160);
599 errint_("#", &myncon, (ftnlen)1);
600 errint_("#", first, (ftnlen)1);
601 errint_("#", last, (ftnlen)1);
602 sigerr_("SPICE(REQUESTOUTOFBOUNDS)", (ftnlen)25);
603 chkout_("SGFCON", (ftnlen)6);
604 return 0;
605 }
606 if (*last < *first) {
607 setmsg_("The last constant item requested, #, is before the first co"
608 "nstant item requested, #.", (ftnlen)84);
609 errint_("#", last, (ftnlen)1);
610 errint_("#", first, (ftnlen)1);
611 sigerr_("SPICE(REQUESTOUTOFORDER)", (ftnlen)24);
612 chkout_("SGFCON", (ftnlen)6);
613 return 0;
614 }
615
616 /* Compute the addresses of the data within the file and then fetch */
617 /* the data. */
618
619 b = base + *first;
620 e = base + *last;
621 dafgda_(handle, &b, &e, values);
622 chkout_("SGFCON", (ftnlen)6);
623 return 0;
624 } /* sgfcon_ */
625
626