1 /* dlabfs.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__2 = 2;
11
12 /* $Procedure DLABFS ( DLA, begin forward search ) */
dlabfs_(integer * handle,integer * descr,logical * found)13 /* Subroutine */ int dlabfs_(integer *handle, integer *descr, logical *found)
14 {
15 /* System generated locals */
16 integer i__1;
17
18 /* Local variables */
19 integer this__;
20 extern /* Subroutine */ int chkin_(char *, ftnlen);
21 extern logical failed_(void);
22 extern /* Subroutine */ int dasrdi_(integer *, integer *, integer *,
23 integer *), chkout_(char *, ftnlen);
24 extern logical return_(void);
25
26 /* $ Abstract */
27
28 /* Begin a forward segment search in a DLA file. */
29
30 /* $ Disclaimer */
31
32 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
33 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
34 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
35 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
36 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
37 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
38 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
39 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
40 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
41 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
42
43 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
44 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
45 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
46 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
47 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
48 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
49
50 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
51 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
52 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
53 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
54
55 /* $ Required_Reading */
56
57 /* DAS */
58 /* DLA */
59
60 /* $ Keywords */
61
62 /* DAS */
63 /* DLA */
64 /* FILES */
65
66 /* $ Declarations */
67
68 /* Include file dla.inc */
69
70 /* This include file declares parameters for DLA format */
71 /* version zero. */
72
73 /* Version 3.0.1 17-OCT-2016 (NJB) */
74
75 /* Corrected comment: VERIDX is now described as a DAS */
76 /* integer address rather than a d.p. address. */
77
78 /* Version 3.0.0 20-JUN-2006 (NJB) */
79
80 /* Changed name of parameter DSCSIZ to DLADSZ. */
81
82 /* Version 2.0.0 09-FEB-2005 (NJB) */
83
84 /* Changed descriptor layout to make backward pointer */
85 /* first element. Updated DLA format version code to 1. */
86
87 /* Added parameters for format version and number of bytes per */
88 /* DAS comment record. */
89
90 /* Version 1.0.0 28-JAN-2004 (NJB) */
91
92
93 /* DAS integer address of DLA version code. */
94
95
96 /* Linked list parameters */
97
98 /* Logical arrays (aka "segments") in a DAS linked array (DLA) file */
99 /* are organized as a doubly linked list. Each logical array may */
100 /* actually consist of character, double precision, and integer */
101 /* components. A component of a given data type occupies a */
102 /* contiguous range of DAS addresses of that type. Any or all */
103 /* array components may be empty. */
104
105 /* The segment descriptors in a SPICE DLA (DAS linked array) file */
106 /* are connected by a doubly linked list. Each node of the list is */
107 /* represented by a pair of integers acting as forward and backward */
108 /* pointers. Each pointer pair occupies the first two integers of a */
109 /* segment descriptor in DAS integer address space. The DLA file */
110 /* contains pointers to the first integers of both the first and */
111 /* last segment descriptors. */
112
113 /* At the DLA level of a file format implementation, there is */
114 /* no knowledge of the data contents. Hence segment descriptors */
115 /* provide information only about file layout (in contrast with */
116 /* the DAF system). Metadata giving specifics of segment contents */
117 /* are stored within the segments themselves in DLA-based file */
118 /* formats. */
119
120
121 /* Parameter declarations follow. */
122
123 /* DAS integer addresses of first and last segment linked list */
124 /* pointer pairs. The contents of these pointers */
125 /* are the DAS addresses of the first integers belonging */
126 /* to the first and last link pairs, respectively. */
127
128 /* The acronyms "LLB" and "LLE" denote "linked list begin" */
129 /* and "linked list end" respectively. */
130
131
132 /* Null pointer parameter. */
133
134
135 /* Segment descriptor parameters */
136
137 /* Each segment descriptor occupies a contiguous */
138 /* range of DAS integer addresses. */
139
140 /* The segment descriptor layout is: */
141
142 /* +---------------+ */
143 /* | BACKWARD PTR | Linked list backward pointer */
144 /* +---------------+ */
145 /* | FORWARD PTR | Linked list forward pointer */
146 /* +---------------+ */
147 /* | BASE INT ADDR | Base DAS integer address */
148 /* +---------------+ */
149 /* | INT COMP SIZE | Size of integer segment component */
150 /* +---------------+ */
151 /* | BASE DP ADDR | Base DAS d.p. address */
152 /* +---------------+ */
153 /* | DP COMP SIZE | Size of d.p. segment component */
154 /* +---------------+ */
155 /* | BASE CHR ADDR | Base DAS character address */
156 /* +---------------+ */
157 /* | CHR COMP SIZE | Size of character segment component */
158 /* +---------------+ */
159
160 /* Parameters defining offsets for segment descriptor elements */
161 /* follow. */
162
163
164 /* Descriptor size: */
165
166
167 /* Other DLA parameters: */
168
169
170 /* DLA format version. (This number is expected to occur very */
171 /* rarely at integer address VERIDX in uninitialized DLA files.) */
172
173
174 /* Characters per DAS comment record. */
175
176
177 /* End of include file dla.inc */
178
179 /* $ Brief_I/O */
180
181 /* Variable I/O Description */
182 /* -------- --- -------------------------------------------------- */
183 /* HANDLE I Handle of open DLA file. */
184 /* DESCR O Descriptor of first segment in DLA file. */
185 /* FOUND O Flag indicating whether a segment was found. */
186
187 /* $ Detailed_Input */
188
189 /* HANDLE is the integer handle associated with the file to be */
190 /* searched. This handle is used to identify the file in */
191 /* subsequent calls to other DLA or DAS routines. */
192
193 /* $ Detailed_Output */
194
195 /* DESCR is the descriptor of the first DLA segment in the */
196 /* file associated with HANDLE. */
197
198 /* The segment descriptor layout is: */
199
200 /* +---------------+ */
201 /* | BACKWARD PTR | Linked list backward pointer */
202 /* +---------------+ */
203 /* | FORWARD PTR | Linked list forward pointer */
204 /* +---------------+ */
205 /* | BASE INT ADDR | Base DAS integer address */
206 /* +---------------+ */
207 /* | INT COMP SIZE | Size of integer segment component */
208 /* +---------------+ */
209 /* | BASE DP ADDR | Base DAS d.p. address */
210 /* +---------------+ */
211 /* | DP COMP SIZE | Size of d.p. segment component */
212 /* +---------------+ */
213 /* | BASE CHR ADDR | Base DAS character address */
214 /* +---------------+ */
215 /* | CHR COMP SIZE | Size of character segment component */
216 /* +---------------+ */
217
218 /* DESCR is valid only if the output argument FOUND is */
219 /* .TRUE. */
220
221
222 /* FOUND is a logical flag indicating whether a segment was */
223 /* found. FOUND has the value .TRUE. if the file */
224 /* contains at least one segment; otherwise FOUND is */
225 /* .FALSE. */
226
227 /* $ Parameters */
228
229 /* None. */
230
231 /* $ Exceptions */
232
233 /* 1) If the input file handle is invalid, the error will be */
234 /* diagnosed by routines in the call tree of this routine. */
235
236 /* 2) If an error occurs while reading the DLA file, the error */
237 /* will be diagnosed by routines in the call tree of this */
238 /* routine. */
239
240 /* $ Files */
241
242 /* See description of input argument HANDLE. */
243
244 /* $ Particulars */
245
246 /* DLA files are built using the DAS low-level format; DLA files are */
247 /* a specialized type of DAS file in which data are organized as a */
248 /* doubly linked list of segments. Each segment's data belong to */
249 /* contiguous components of character, double precision, and integer */
250 /* type. */
251
252 /* This routine supports forward traversal of a DLA file's segment */
253 /* list. Note that it is not necessary to call this routine to */
254 /* conduct a forward traversal; all that is necessary is to have */
255 /* access to the first descriptor in the file, which this routine */
256 /* provides. */
257
258 /* $ Examples */
259
260 /* 1) Open a DLA file for read access, traverse the segment */
261 /* list from front to back, and display segment address */
262 /* and size attributes. */
263
264
265 /* PROGRAM EX1 */
266 /* IMPLICIT NONE */
267
268 /* INCLUDE 'dla.inc' */
269
270 /* C */
271 /* C Local parameters */
272 /* C */
273 /* INTEGER FILSIZ */
274 /* PARAMETER ( FILSIZ = 255 ) */
275
276 /* C */
277 /* C Local variables */
278 /* C */
279 /* CHARACTER*(FILSIZ) FNAME */
280
281 /* INTEGER CURRNT ( DLADSZ ) */
282 /* INTEGER DESCR ( DLADSZ ) */
283 /* INTEGER HANDLE */
284 /* INTEGER SEGNO */
285
286 /* LOGICAL FOUND */
287
288 /* C */
289 /* C Prompt for the name of the file to search. */
290 /* C */
291 /* CALL PROMPT ( 'Name of DLA file > ', FNAME ) */
292
293 /* C */
294 /* C Open the DLA file for read access. Since DLA */
295 /* C files use the DAS architecture, we can use DAS */
296 /* C routines to open and close the file. */
297 /* C */
298 /* CALL DASOPR ( FNAME, HANDLE ) */
299
300 /* C */
301 /* C Begin a forward search. Let DESCR contain */
302 /* C the descriptor of the first segment. */
303 /* C */
304 /* SEGNO = 0 */
305
306 /* CALL DLABFS ( HANDLE, DESCR, FOUND ) */
307
308 /* DO WHILE ( FOUND ) */
309 /* C */
310 /* C Display the contents of the current segment */
311 /* C descriptor. */
312 /* C */
313 /* SEGNO = SEGNO + 1 */
314
315 /* WRITE (*,*) ' ' */
316 /* WRITE (*,*) ' ' */
317 /* WRITE (*,*) 'Segment number = ', SEGNO */
318 /* WRITE (*,*) ' ' */
319 /* WRITE (*,*) 'Backward segment pointer = ', */
320 /* . DESCR(BWDIDX) */
321 /* WRITE (*,*) 'Forward segment pointer = ', */
322 /* . DESCR(FWDIDX) */
323 /* WRITE (*,*) 'Character component base address = ', */
324 /* . DESCR(CBSIDX) */
325 /* WRITE (*,*) 'Character component size = ', */
326 /* . DESCR(CSZIDX) */
327 /* WRITE (*,*) 'D.p. base address = ', */
328 /* . DESCR(DBSIDX) */
329 /* WRITE (*,*) 'D.p. component size = ', */
330 /* . DESCR(DSZIDX) */
331 /* WRITE (*,*) 'Integer base address = ', */
332 /* . DESCR(IBSIDX) */
333 /* WRITE (*,*) 'Integer component size = ', */
334 /* . DESCR(ISZIDX) */
335 /* WRITE (*,*) ' ' */
336
337 /* C */
338 /* C Find the next segment. */
339 /* C */
340 /* C To avoid using DESCR as both input and output */
341 /* C in the following call (this use is not allowed */
342 /* C by the ANSI Fortran 77 standard), we copy DESCR */
343 /* C into the variable CURRNT. We then find the */
344 /* C segment following CURRNT. */
345 /* C */
346 /* CALL MOVEI ( DESCR, DLADSZ, CURRNT ) */
347 /* CALL DLAFNS ( HANDLE, CURRNT, DESCR, FOUND ) */
348
349 /* END DO */
350
351 /* C */
352 /* C Close the file using the DAS close routine. */
353 /* C */
354 /* CALL DASCLS ( HANDLE ) */
355
356 /* END */
357
358
359 /* $ Restrictions */
360
361 /* None. */
362
363 /* $ Literature_References */
364
365 /* None. */
366
367 /* $ Author_and_Institution */
368
369 /* N.J. Bachman (JPL) */
370
371 /* $ Version */
372
373 /* - SPICELIB Version 1.0.0, 08-FEB-2017 (NJB) */
374
375 /* Updated version info. */
376
377 /* 23-JAN-2013 (NJB) */
378
379 /* Deleted third exception description from the Exceptions */
380 /* header section. */
381
382 /* 08-OCT-2009 (NJB) */
383
384 /* Updated header. */
385
386 /* 10-FEB-2005 (NJB) */
387
388 /* -& */
389 /* $ Index_Entries */
390
391 /* begin forward search in dla file */
392
393 /* -& */
394
395 /* SPICELIB functions */
396
397
398 /* Local variables */
399
400
401 /* Standard SPICE error handling. */
402
403 if (return_()) {
404 return 0;
405 }
406 chkin_("DLABFS", (ftnlen)6);
407
408 /* Nothing found yet. */
409
410 *found = FALSE_;
411
412 /* Look up the pointer to the first DLA segment descriptor in the */
413 /* file. Then look up the segment descriptor itself. */
414
415 dasrdi_(handle, &c__2, &c__2, &this__);
416 if (failed_() || this__ == -1) {
417
418 /* If the pointer THIS is null, there are no segments in the */
419 /* file. */
420
421 chkout_("DLABFS", (ftnlen)6);
422 return 0;
423 }
424
425 /* Return the first descriptor. */
426
427 i__1 = this__ + 7;
428 dasrdi_(handle, &this__, &i__1, descr);
429 *found = TRUE_;
430 chkout_("DLABFS", (ftnlen)6);
431 return 0;
432 } /* dlabfs_ */
433
434