1 /* pck03e.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 PCK03E ( PCK, end a type 3 segment ) */
pck03e_(integer * handle)9 /* Subroutine */ int pck03e_(integer *handle)
10 {
11     extern /* Subroutine */ int chkin_(char *, ftnlen), sgwes_(integer *),
12 	    chkout_(char *, ftnlen);
13     extern logical return_(void);
14 
15 /* $ Abstract */
16 
17 /*     End the type 03 PCK segment currently being written to the binary */
18 /*     PCK file associated with HANDLE. See also PCK03B and PCK03A. */
19 
20 /* $ Disclaimer */
21 
22 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
23 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
24 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
25 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
26 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
27 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
28 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
29 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
30 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
31 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
32 
33 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
34 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
35 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
36 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
37 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
38 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
39 
40 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
41 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
42 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
43 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
44 
45 /* $ Required_Reading */
46 
47 /*     PCK */
48 
49 /* $ Keywords */
50 
51 /*     PCK */
52 
53 /* $ Declarations */
54 /* $ Brief_I/O */
55 
56 /*     VARIABLE  I/O  DESCRIPTION */
57 /*     --------  ---  -------------------------------------------------- */
58 /*     HANDLE     I   The handle of a binary PCK file open for writing. */
59 
60 /* $ Detailed_Input */
61 
62 /*     HANDLE   is the file handle of a binary PCK file that has been */
63 /*              opened for writing and to which a type 03 PCK segment is */
64 /*              being written. */
65 
66 /* $ Detailed_Output */
67 
68 /*     None.    The segment in the PCK file associated with HANDLE will */
69 /*              be ended, making the addition of the data permanent. */
70 
71 /*              See the $ Particulars section for details about the */
72 /*              structure of a type 03 PCK segment. */
73 
74 /* $ Parameters */
75 
76 /*     None. */
77 
78 /* $ Exceptions */
79 
80 /*     None. */
81 
82 /* $ Files */
83 
84 /*     See the argument HANDLE. */
85 
86 /* $ Particulars */
87 
88 /*     This routine ends a type 03 PCK segment that is being written to */
89 /*     the binary PCK file associated with HANDLE. Ending the PCK segment */
90 /*     is a necessary step in the process of making the data a permanent */
91 /*     part of the binary PCK file. */
92 
93 /*     This routine is one of a set of three routines for creating and */
94 /*     adding data to type 03 PCK segments. These routines are: */
95 
96 /*        PCK03B: Begin a type 03 PCK segment. This routine must be */
97 /*                called before any data may be added to a type 03 */
98 /*                segment. */
99 
100 /*        PCK03A: Add data to a type 03 PCK segment. This routine may be */
101 /*                called any number of times after a call to PCK03B to */
102 /*                add type 03 records to the PCK segment that was */
103 /*                started. */
104 
105 /*        PCK03E: End a type 03 PCK segment. This routine is called to */
106 /*                make the type 03 segment a permanent addition to the */
107 /*                PCK file. Once this routine is called, no further type */
108 /*                03 records may be added to the segment. A new segment */
109 /*                must be started. */
110 
111 /*     A type 03 PCK segment consists of coefficient sets for fixed order */
112 /*     Chebyshev polynomials over consecutive time intervals, where the */
113 /*     time intervals need not all be of the same length. The Chebyshev */
114 /*     polynomials represent the orientation of a body specified relative */
115 /*     to an inertial frame by the angles RA, DEC, W and body fixed */
116 /*     angular rates for each axis of the body fixed coordinate system */
117 /*     defined by RA, DEC, and W. All of the angles and the angular rates */
118 /*     of the axes are given in degrees. */
119 
120 /*     The orientation data supplied to the type 03 PCK writer is packed */
121 /*     into an array as a sequence of logical records, */
122 
123 /*        ----------------------------------------------------- */
124 /*        | Record 1 | Record 2 | ... | Record N-1 | Record N | */
125 /*        ----------------------------------------------------- */
126 
127 /*     with each record has the following format. */
128 
129 /*           ------------------------------------------------ */
130 /*           |  The midpoint of the approximation interval  | */
131 /*           ------------------------------------------------ */
132 /*           |  The radius of the approximation interval    | */
133 /*           ------------------------------------------------ */
134 /*           |  CHBDEG+1 coefficients for RA                | */
135 /*           ------------------------------------------------ */
136 /*           |  CHBDEG+1 coefficients for DEC               | */
137 /*           ------------------------------------------------ */
138 /*           |  CHBDEG+1 coefficients for W                 | */
139 /*           ------------------------------------------------ */
140 /*           |  CHBDEG+1 coefficients for the X-axis rate   | */
141 /*           ------------------------------------------------ */
142 /*           |  CHBDEG+1 coefficients for the Y-axis rate   | */
143 /*           ------------------------------------------------ */
144 /*           |  CHBDEG+1 coefficients for the Z-axis rate   | */
145 /*           ------------------------------------------------ */
146 
147 /* $ Examples */
148 
149 /*     Assume we have the following for each of the examples that */
150 /*     follow. */
151 
152 /*        HANDLE   is the handle of a PCK file opened with write */
153 /*                 access. */
154 
155 /*        SEGID    is a character string of no more than 40 characters */
156 /*                 which provides a pedigree for the data in the PCK */
157 /*                 segment. */
158 
159 /*        BODY     is the SPICE ID code for the body whose orientation */
160 /*                 data is to be placed into the file. */
161 
162 /*        REFFRM   is the name of the SPICE inertial reference frame */
163 /*                 the orientation data is relative to. */
164 
165 /*        FIRST    is the starting epoch, in seconds past J2000, for */
166 /*                 the orientation data to be placed into the segment. */
167 
168 /*        LAST     is the ending epoch, in seconds past J2000, for */
169 /*                 the orientation data to be placed into the segment. */
170 
171 /*     Example 1: */
172 
173 /*        For this example, we also assume that: */
174 
175 /*           N        is the number of type 03 records that we want to */
176 /*                    put into a segment in PCK file. */
177 
178 /*           RECRDS   contains N type 03 records packaged for the PCK */
179 /*                    file. */
180 
181 /*           ETSTRT   contains the initial epochs for each of the */
182 /*                    records contained in RECRDS, where */
183 
184 /*                       ETSTRT(I) < ETSTRT(I+1), I = 1, N-1 */
185 
186 /*                       ETSTRT(1) <= FIRST, ETSTRT(N) < LAST */
187 
188 /*                       ETSTRT(I+1), I = 1, N-1, is the ending epoch for */
189 /*                       record I as well as the initial epoch for record */
190 /*                       I+1. */
191 
192 /*        Then the following code fragment demonstrates how to create a */
193 /*        type 03 PCK segment if all of the data for the segment is */
194 /*        available at one time. */
195 
196 /*        C */
197 /*        C     Begin the segment. */
198 /*        C */
199 /*              CALL PCK03B ( HANDLE, SEGID, BODY, REFFRM, */
200 /*             .              FIRST,  LAST,  CHBDEG        ) */
201 /*        C */
202 /*        C     Add the data to the segment all at once. */
203 /*        C */
204 /*              CALL PCK03A ( HANDLE, N, RECRDS, ETSTRT ) */
205 /*        C */
206 /*        C     End the segment, making the segment a permanent addition */
207 /*        C     to the PCK file. */
208 /*        C */
209 /*              CALL PCK03E ( HANDLE ) */
210 
211 /*     Example 2: */
212 
213 /*        In this example we want to add type O3 PCK records, as */
214 /*        described above in the $ Particulars section, to the segment */
215 /*        being written as they are generated. The ability to write the */
216 /*        records in this way is useful if computer memory is limited. It */
217 /*        may also be convenient from a programming perspective to write */
218 /*        the records one at a time. */
219 
220 /*        For this example, assume that we want to generate N type 03 PCK */
221 /*        records, one for each of N time intervals, writing them all to */
222 /*        the same segment in a PCK file. Let */
223 
224 /*           N        be the number of type 03 records that we want to */
225 /*                    generate and put into a segment in an PCK file. */
226 
227 /*           RECORD   be an array with enough room to hold a single type */
228 /*                    03 record, i.e. RECORD should have dimension at */
229 /*                    least 6 * (CHBDEG + 1 ) + 2. */
230 
231 /*           START    be an array of N times that are the beginning */
232 /*                    epochs for each of the intervals of interest. The */
233 /*                    times should be in increasing order and the start */
234 /*                    time for the first interval should equal the */
235 /*                    starting time for the segment. */
236 
237 /*                       START(I) < START(I+1), I = 1, N-1 */
238 
239 /*                       START(1) = FIRST */
240 
241 /*           STOP     be an array of N times that are the ending epochs */
242 /*                    for each of the intervals of interest. The times */
243 /*                    should be in increasing order and the stop time for */
244 /*                    interval I should equal the start time for interval */
245 /*                    I+1, i.e., we want to have continuous coverage in */
246 /*                    time across all of the records. Also, the stop time */
247 /*                    for the last interval should equal the ending time */
248 /*                    for the segment. */
249 
250 /*                       STOP(I) < STOP(I+1), I = 1, N-1 */
251 
252 /*                       STOP(I) = START(I+1), I = 1, N-1 */
253 
254 /*                       STOP(N) = LAST */
255 
256 /*           GENREC( TIME1, TIME2, RECORD ) */
257 
258 /*                    be a subroutine that generates a type 03 PCK record */
259 /*                    for a time interval specified by TIME1 and TIME2. */
260 
261 /*        Then the following code fragment demonstrates how to create a */
262 /*        type 03 PCK segment if all of the data for the segment is not */
263 /*        available at one time. */
264 
265 /*        C */
266 /*        C     Begin the segment. */
267 /*        C */
268 /*              CALL PCK03B ( HANDLE, SEGID, DESCR, CHBDEG ) */
269 
270 /*        C */
271 /*        C     Generate the records and write them to the segment in the */
272 /*        C     PCK file one at at time. */
273 /*        C */
274 /*              DO I = 1, N */
275 
276 /*                 CALL GENREC ( START(I), STOP(I), RECORD ) */
277 /*                 CALL PCK03A ( HANDLE, 1, RECORD, START(I) ) */
278 
279 /*              END DO */
280 
281 /*        C */
282 /*        C     End the segment, making the segment a permanent addition */
283 /*        C     to the PCK file. */
284 /*        C */
285 /*              CALL PCK03E ( HANDLE ) */
286 
287 /* $ Restrictions */
288 
289 /*     1) The type 03 binary PCK segment being closed must have been */
290 /*        started by the routine PCK03B, the routine which begins a type */
291 /*        03 PCK segment. */
292 
293 /* $ Literature_References */
294 
295 /*     None. */
296 
297 /* $ Author_and_Institution */
298 
299 /*     K.R. Gehringer      (JPL) */
300 
301 /* $ Version */
302 
303 /* -    SPICELIB Version 1.0.1, 03-JAN-2014 (EDW) */
304 
305 /*        Minor edits to Procedure; clean trailing whitespace. */
306 /*        Corrected order of header sections to conform to NAIF */
307 /*        standard. */
308 
309 /* -    SPICELIB Version 1.0.0, 06-MAR-1995 (KRG) */
310 
311 /* -& */
312 /* $ Index_Entries */
313 
314 /*     end a type_03 pck segment */
315 
316 /* -& */
317 
318 /*     Spicelib functions */
319 
320 
321 /*     Standard SPICELIB error handling. */
322 
323     if (return_()) {
324 	return 0;
325     } else {
326 	chkin_("PCK03E", (ftnlen)6);
327     }
328 
329 /*     This is simple, just call the routine which ends a generic */
330 /*     segment. */
331 
332     sgwes_(handle);
333 
334 /*     No need to check FAILED() since all we do is leave. The caller can */
335 /*     check it. */
336 
337     chkout_("PCK03E", (ftnlen)6);
338     return 0;
339 } /* pck03e_ */
340 
341