1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
const NDELIM: i32 = 5;
const DELIMS: &[u8; NDELIM as usize] = &fstr::extend_const::<{ NDELIM as usize }>(b".:-, ");
const MXPART: i32 = 9999;
const PARTLN: i32 = 5;
const MXCOEF: i32 = 100000;
const MXNFLD: i32 = 10;
const DPLEN: i32 = 30;
const MXTSYS: i32 = 2;
const CTRSIZ: i32 = 2;
/// Spacecraft Clock Partition Information
///
/// Get spacecraft clock partition information from a spacecraft
/// clock kernel file.
///
/// # Required Reading
///
/// * [SCLK](crate::required_reading::sclk)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// SC I NAIF spacecraft identification code.
/// NPARTS O The number of spacecraft clock partitions.
/// PSTART O Array of partition start times.
/// PSTOP O Array of partition stop times.
/// MXPART P Maximum number of partitions.
/// ```
///
/// # Detailed Input
///
/// ```text
/// SC is the NAIF ID for the spacecraft whose clock partition
/// information is being requested.
/// ```
///
/// # Detailed Output
///
/// ```text
/// NPARTS is the number of spacecraft clock time partitions
/// described in the kernel file for spacecraft SC.
///
/// PSTART is an array containing NPARTS partition start times
/// represented as double precision, encoded SCLK
/// ("ticks"). The values contained in PSTART are whole
/// numbers.
///
/// PSTOP is an array containing NPARTS partition end times
/// represented as double precision, encoded SCLK
/// ("ticks"). The values contained in PSTOP are whole
/// numbers.
/// ```
///
/// # Parameters
///
/// ```text
/// See the include file
///
/// sclk.inc
///
/// for sizes and limits used by the SCLK system.
///
/// MXPART is the maximum number of partitions for any spacecraft
/// clock. SCLK kernels contain start and stop times for
/// each partition. See the include file sclk.inc for this
/// parameter's value.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If the kernel variables containing the spacecraft clock
/// partition start and stop times have not been loaded in the
/// kernel pool, an error is signaled by a routine in the call
/// tree of this routine.
///
/// 2) If the number of start and stop times are different,
/// the error SPICE(NUMPARTSUNEQUAL) is signaled.
/// ```
///
/// # Files
///
/// ```text
/// An SCLK kernel containing spacecraft clock partition start
/// and stop times for the spacecraft clock indicated by SC must
/// be loaded into the kernel pool.
/// ```
///
/// # Particulars
///
/// ```text
/// SCPART looks for two variables in the kernel pool for each
/// spacecraft's partition information. If SC = -nn, then the names of
/// the variables are
///
/// SCLK_PARTITION_START_nn
/// SCLK_PARTITION_END_nn
///
/// The start and stop times returned are in units of "ticks".
/// ```
///
/// # Examples
///
/// ```text
/// The numerical results shown for this example may differ across
/// platforms. The results depend on the SPICE kernels used as input,
/// the compiler and supporting libraries, and the machine specific
/// arithmetic implementation.
///
/// 1) The following code example finds partition start and stop
/// times for the Stardust spacecraft from a spacecraft clock
/// kernel file. Since those times are always returned in units
/// of ticks, the program uses SCFMT to print the times in
/// Stardust clock format.
///
/// Use the SCLK kernel below to load the Stardust time
/// correlation data and spacecraft clock partition information.
///
/// sdu_sclkscet_00074.tsc
///
///
/// Example code begins here.
///
///
/// PROGRAM SCPART_EX1
/// IMPLICIT NONE
///
/// C
/// C Include the parameters that define the sizes and limits
/// C of the SCLK system.
/// C
/// INCLUDE 'sclk.inc'
///
/// C
/// C Local parameters.
/// C
/// INTEGER CLKLEN
/// PARAMETER ( CLKLEN = 30 )
///
/// C
/// C Local variables.
/// C
/// CHARACTER*(CLKLEN) START
/// CHARACTER*(CLKLEN) STOP
///
/// DOUBLE PRECISION PSTART (MXPART)
/// DOUBLE PRECISION PSTOP (MXPART)
///
/// INTEGER I
/// INTEGER NPARTS
/// INTEGER SC
///
/// C
/// C Assign the value for the Stardust spacecraft ID.
/// C
/// SC = -29
///
/// C
/// C Load the SCLK file.
/// C
/// CALL FURNSH ( 'sdu_sclkscet_00074.tsc' )
///
/// C
/// C Retrieve the arrays for PSTART and PSTOP and the
/// C number of partitions within the SCLK.
/// C
/// CALL SCPART ( SC, NPARTS, PSTART, PSTOP )
///
/// C
/// C Loop over each array value.
/// C
/// DO I= 1, NPARTS
///
/// CALL SCFMT ( SC, PSTART( I ), START )
/// CALL SCFMT ( SC, PSTOP ( I ), STOP )
///
/// WRITE(*,*)
/// WRITE(*,*) 'Partition: ', I
/// WRITE(*,*) ' Start : ', START
/// WRITE(*,*) ' Stop : ', STOP
///
/// END DO
///
/// END
///
///
/// When this program was executed on a Mac/Intel/gfortran/64-bit
/// platform, the output was:
///
///
/// Partition: 1
/// Start : 0000000000.000
/// Stop : 0602741011.080
///
/// Partition: 2
/// Start : 0602741014.217
/// Stop : 0605660648.173
///
/// Partition: 3
/// Start : 0605660649.000
/// Stop : 0631375256.224
///
/// Partition: 4
/// Start : 0631375257.000
/// Stop : 0633545577.218
///
/// Partition: 5
/// Start : 0633545578.000
/// Stop : 0644853954.043
///
/// Partition: 6
/// Start : 0644853954.000
/// Stop : 0655316480.089
///
/// Partition: 7
/// Start : 0655316480.000
/// Stop : 0660405279.066
///
/// Partition: 8
/// Start : 0660405279.000
/// Stop : 0670256568.229
///
/// Partition: 9
/// Start : 0670256569.000
/// Stop : 0674564039.091
///
/// Partition: 10
/// Start : 0674564040.000
/// Stop : 4294537252.255
/// ```
///
/// # Restrictions
///
/// ```text
/// 1) This routine assumes that an SCLK kernel appropriate to the
/// spacecraft identified by SC has been loaded into the kernel
/// pool.
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// J.M. Lynch (JPL)
/// B.V. Semenov (JPL)
/// W.L. Taber (JPL)
/// R.E. Thurman (JPL)
/// E.D. Wright (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 2.4.0, 06-JUL-2021 (JDR) (NJB)
///
/// Code was re-written to fetch partition data from the SC01
/// subsystem. This routine no longer sets watches on kernel
/// variables.
///
/// Edited the header to comply with NAIF standard. Removed
/// unnecessary entries from $Revisions section.
///
/// Added complete code example based on existing code fragment.
///
/// - SPICELIB Version 2.3.1, 19-MAR-2014 (NJB)
///
/// Minor header comment updates were made.
///
/// - SPICELIB Version 2.3.0, 09-SEP-2013 (BVS)
///
/// Updated to keep track of the POOL counter and call ZZCVPOOL.
///
/// - SPICELIB Version 2.2.0, 05-MAR-2009 (NJB)
///
/// Bug fix: this routine now keeps track of whether its
/// kernel pool look-up succeeded. If not, a kernel pool
/// lookup is attempted on the next call to this routine.
///
/// - SPICELIB Version 2.1.0, 05-FEB-2008 (NJB)
///
/// The values of the parameter MXPART is now
/// provided by the INCLUDE file sclk.inc.
///
/// - SPICELIB Version 1.1.1, 22-AUG-2006 (EDW)
///
/// Replaced references to LDPOOL with references
/// to FURNSH.
///
/// - SPICELIB Version 1.1.0, 22-MAR-1993 (JML)
///
/// The routine now uses the kernel pool watch capability.
///
/// - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)
///
/// Comment section for permuted index source lines was added
/// following the header.
///
/// - SPICELIB Version 1.0.0, 03-SEP-1990 (NJB) (JML) (RET)
/// ```
///
/// # Revisions
///
/// ```text
/// - SPICELIB Version 2.4.0, 04-NOV-2020 (JDR) (NJB)
///
/// Code was re-written to fetch partition data from the SC01
/// subsystem. This routine no longer sets watches on kernel
/// variables. Setting watches "touches" the kernel pool, which
/// thwarts optimizations of many SPICE subsystems.
/// ```
pub fn scpart(
ctx: &mut SpiceContext,
sc: i32,
nparts: &mut i32,
pstart: &mut [f64],
pstop: &mut [f64],
) -> crate::Result<()> {
SCPART(sc, nparts, pstart, pstop, ctx.raw_context())?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure SCPART ( Spacecraft Clock Partition Information )
pub fn SCPART(
SC: i32,
NPARTS: &mut i32,
PSTART: &mut [f64],
PSTOP: &mut [f64],
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let mut PSTART = DummyArrayMut::new(PSTART, 1..);
let mut PSTOP = DummyArrayMut::new(PSTOP, 1..);
//
// SPICELIB functions
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
}
CHKIN(b"SCPART", ctx)?;
//
// Get the partition values from the type 1 subsystem. If the
// clock is not type 1, an error will be signaled.
//
SCPR01(SC, NPARTS, PSTART.as_slice_mut(), PSTOP.as_slice_mut(), ctx)?;
CHKOUT(b"SCPART", ctx)?;
Ok(())
}