rsspice 0.1.0

Pure Rust port of the SPICE Toolkit for space geometry
Documentation
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
//
// GENERATED FILE
//

use super::*;
use f2rust_std::*;

const CNVTOL: f64 = 0.000001;
const NWMAX: i32 = 15;
const NWDIST: i32 = 5;
const NWSEP: i32 = 5;
const NWRR: i32 = 5;
const NWUDS: i32 = 5;
const NWPA: i32 = 5;
const NWILUM: i32 = 5;
const ADDWIN: f64 = 0.5;
const FRMNLN: i32 = 32;
const FOVTLN: i32 = 40;
const FTCIRC: &[u8] = b"CIRCLE";
const FTELLI: &[u8] = b"ELLIPSE";
const FTPOLY: &[u8] = b"POLYGON";
const FTRECT: &[u8] = b"RECTANGLE";
const ANNULR: &[u8] = b"ANNULAR";
const ANY: &[u8] = b"ANY";
const PARTL: &[u8] = b"PARTIAL";
const FULL: &[u8] = b"FULL";
const DSSHAP: &[u8] = b"DSK";
const EDSHAP: &[u8] = b"ELLIPSOID";
const PTSHAP: &[u8] = b"POINT";
const RYSHAP: &[u8] = b"RAY";
const SPSHAP: &[u8] = b"SPHERE";
const NOCTYP: i32 = 4;
const OCLLN: i32 = 7;
const SHPLEN: i32 = 9;
const MAXVRT: i32 = 10000;
const CIRFOV: &[u8] = b"CIRCLE";
const ELLFOV: &[u8] = b"ELLIPSE";
const POLFOV: &[u8] = b"POLYGON";
const RECFOV: &[u8] = b"RECTANGLE";
const RECSYS: &[u8] = b"RECTANGULAR";
const LATSYS: &[u8] = b"LATITUDINAL";
const SPHSYS: &[u8] = b"SPHERICAL";
const RADSYS: &[u8] = b"RA/DEC";
const CYLSYS: &[u8] = b"CYLINDRICAL";
const GEOSYS: &[u8] = b"GEODETIC";
const PGRSYS: &[u8] = b"PLANETOGRAPHIC";
const XCRD: &[u8] = b"X";
const YCRD: &[u8] = b"Y";
const ZCRD: &[u8] = b"Z";
const RADCRD: &[u8] = b"RADIUS";
const LONCRD: &[u8] = b"LONGITUDE";
const LATCRD: &[u8] = b"LATITUDE";
const RACRD: &[u8] = b"RIGHT ASCENSION";
const DECCRD: &[u8] = b"DECLINATION";
const RNGCRD: &[u8] = b"RANGE";
const CLTCRD: &[u8] = b"COLATITUDE";
const ALTCRD: &[u8] = b"ALTITUDE";
const POSDEF: &[u8] = b"POSITION";
const SOBDEF: &[u8] = b"SUB-OBSERVER POINT";
const SINDEF: &[u8] = b"SURFACE INTERCEPT POINT";
const NWREL: i32 = 5;
const NWLONG: i32 = 7;
const EXWIDX: i32 = ((NWREL + NWLONG) + 1);
const MXBEGM: i32 = 55;
const MXENDM: i32 = 13;
const MXMSG: i32 = ((MXBEGM + MXENDM) + 10);
const NABCOR: i32 = 15;
const ABATSZ: i32 = 6;
const GEOIDX: i32 = 1;
const LTIDX: i32 = (GEOIDX + 1);
const STLIDX: i32 = (LTIDX + 1);
const CNVIDX: i32 = (STLIDX + 1);
const XMTIDX: i32 = (CNVIDX + 1);
const RELIDX: i32 = (XMTIDX + 1);
const CORLEN: i32 = 5;
const NPCK: &[u8] = b"nat.tpc";
const NSPK: &[u8] = b"nat.bsp";
const NIK: &[u8] = b"nat.ti";
const TIGHT: f64 = 0.000000000001;
const BDNMLN: i32 = 36;
const FRNMLN: i32 = 32;
const LNSIZE: i32 = 80;
const LBCELL: i32 = -5;
const MAXWIN: i32 = 100;
const MXPASS: i32 = 20;
const MXCALL: i32 = 20000;
const MAXMSG: i32 = MXMSG;

struct SaveVars {
    ABCORR: Vec<u8>,
    INST: Vec<u8>,
    MSGLOG: ActualCharArray2D,
    QNAME: Vec<u8>,
    OBSRVR: Vec<u8>,
    TARGET: Vec<u8>,
    TFRAME: Vec<u8>,
    TSHAPE: Vec<u8>,
    CNFINE: StackArray<f64, 206>,
    CNFLOG: ActualArray2D<f64>,
    ET0: f64,
    ET1: f64,
    MEASUR: f64,
    RAYDIR: StackArray<f64, 3>,
    REPLOG: ActualArray2D<f64>,
    RESULT: StackArray<f64, 206>,
    STEP: f64,
    TOL: f64,
    XMESUR: f64,
    HAN2: i32,
    MW: i32,
    NCALLS: i32,
    NIVL: i32,
    NUPDAT: i32,
    SEQLOG: ActualArray<i32>,
    TRMLOG: ActualArray<i32>,
    XSQLOG: ActualArray<i32>,
    BAIL: bool,
    RPT: bool,
}

impl SaveInit for SaveVars {
    fn new() -> Self {
        let mut ABCORR = vec![b' '; CORLEN as usize];
        let mut INST = vec![b' '; BDNMLN as usize];
        let mut MSGLOG = ActualCharArray2D::new(MAXMSG, 1..=2, 1..=MXPASS);
        let mut QNAME = vec![b' '; LNSIZE as usize];
        let mut OBSRVR = vec![b' '; BDNMLN as usize];
        let mut TARGET = vec![b' '; BDNMLN as usize];
        let mut TFRAME = vec![b' '; FRNMLN as usize];
        let mut TSHAPE = vec![b' '; SHPLEN as usize];
        let mut CNFINE = StackArray::<f64, 206>::new(LBCELL..=(2 * MAXWIN));
        let mut CNFLOG = ActualArray2D::<f64>::new(LBCELL..=(2 * MAXWIN), 1..=MXPASS);
        let mut ET0: f64 = 0.0;
        let mut ET1: f64 = 0.0;
        let mut MEASUR: f64 = 0.0;
        let mut RAYDIR = StackArray::<f64, 3>::new(1..=3);
        let mut REPLOG = ActualArray2D::<f64>::new(1..=3, 1..=MXCALL);
        let mut RESULT = StackArray::<f64, 206>::new(LBCELL..=(2 * MAXWIN));
        let mut STEP: f64 = 0.0;
        let mut TOL: f64 = 0.0;
        let mut XMESUR: f64 = 0.0;
        let mut HAN2: i32 = 0;
        let mut MW: i32 = 0;
        let mut NCALLS: i32 = 0;
        let mut NIVL: i32 = 0;
        let mut NUPDAT: i32 = 0;
        let mut SEQLOG = ActualArray::<i32>::new(1..=MXCALL);
        let mut TRMLOG = ActualArray::<i32>::new(1..=MXCALL);
        let mut XSQLOG = ActualArray::<i32>::new(1..=MXCALL);
        let mut BAIL: bool = false;
        let mut RPT: bool = false;

        Self {
            ABCORR,
            INST,
            MSGLOG,
            QNAME,
            OBSRVR,
            TARGET,
            TFRAME,
            TSHAPE,
            CNFINE,
            CNFLOG,
            ET0,
            ET1,
            MEASUR,
            RAYDIR,
            REPLOG,
            RESULT,
            STEP,
            TOL,
            XMESUR,
            HAN2,
            MW,
            NCALLS,
            NIVL,
            NUPDAT,
            SEQLOG,
            TRMLOG,
            XSQLOG,
            BAIL,
            RPT,
        }
    }
}

//$Procedure      F_GFBIRP ( Test GF binary quantity progress reporting )
pub fn F_GFBIRP(OK: &mut bool, ctx: &mut Context) -> f2rust_std::Result<()> {
    let save = ctx.get_vars::<SaveVars>();
    let save = &mut *save.borrow_mut();

    //
    // SPICELIB functions
    //

    //
    // Local parameters
    //

    //
    // Maximum progress report prefix or suffix length.
    // MXMSG is declared in zzgf.inc.
    //

    //
    // Local Variables
    //

    //
    // Saved variables
    //

    //
    // Initial values
    //

    //
    // Begin every test family with an open call.
    //
    testutil::TOPEN(b"F_GFBIRP", ctx)?;

    //
    //---- Case -------------------------------------------------------------
    //
    testutil::TCASE(b"Setup: create and load SPK, PCK, LSK files.", ctx)?;

    // Leapseconds:  Note that the LSK is deleted after loading, so we
    // don't have to clean it up later.
    //
    testutil::TSTLSK(ctx)?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //
    // Create and load Nat's solar system SPK, PCK/FK, and IK
    // files.
    //
    testutil::NATPCK(NPCK, true, true, ctx)?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    testutil::NATSPK(NSPK, true, &mut save.HAN2, ctx)?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    testutil::NATIK(NIK, NSPK, NPCK, true, false, ctx)?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //*********************************************************************
    //*
    //*    Normal cases
    //*
    //*********************************************************************

    //*********************************************************************
    //*
    //*    Binary state search tests
    //*
    //*********************************************************************

    //
    //---- Case -------------------------------------------------------------
    //
    testutil::TCASE(b"Run simple occultation search using GFOCCE.", ctx)?;

    //
    // Search for any occultation of ALPHA by BETA, abcorr = NONE.
    //

    //
    // Initialize the progress reporting test utility package.
    //
    testutil::T_GFUINI(ctx)?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //
    // Initialize the confinement window log.
    //
    for I in 1..=MXPASS {
        spicelib::SSIZED((2 * MAXWIN), save.CNFLOG.subarray_mut([LBCELL, I]), ctx)?;
        testutil::CHCKXC(false, b" ", OK, ctx)?;
    }

    //
    // Note: the stellar aberration correction spec should be ignored.
    //
    spicelib::SSIZED((2 * MAXWIN), save.CNFINE.as_slice_mut(), ctx)?;
    spicelib::SSIZED((2 * MAXWIN), save.RESULT.as_slice_mut(), ctx)?;

    //
    // Create a confinement window with 5 intervals.
    //
    save.NIVL = 5;
    save.XMESUR = 0.0;

    for I in 1..=save.NIVL {
        save.ET0 = (-900.0 + (((I - 3) as f64) * 3600.0));
        save.ET1 = (save.ET0 + 1800.0);

        spicelib::WNINSD(save.ET0, save.ET1, save.CNFINE.as_slice_mut(), ctx)?;
        testutil::CHCKXC(false, b" ", OK, ctx)?;

        save.XMESUR = ((save.XMESUR + save.ET1) - save.ET0);
    }

    save.BAIL = false;
    save.RPT = true;

    save.STEP = 300.0;
    spicelib::GFSSTP(save.STEP, ctx)?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    save.TOL = CNVTOL;

    spicelib::GFOCCE(
        b"ANY",
        b"beta",
        b"ellipsoid",
        b"betafixed",
        b"alpha",
        b"ellipsoid",
        b"alphafixed",
        b"NONE",
        b"sun",
        save.TOL,
        spicelib::GFSTEP,
        spicelib::GFREFN,
        save.RPT,
        testutil::T_GFREPI,
        testutil::T_GFREPU,
        testutil::T_GFREPF,
        save.BAIL,
        spicelib::GFBAIL,
        save.CNFINE.as_slice(),
        save.RESULT.as_slice_mut(),
        ctx,
    )?;

    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //
    // Now that the search is done, the interesting work starts. We're
    // going to do a post-mortem on the progress reporting calls that
    // were made during the search.
    //
    // Start out by fetching the information that was passed to T_GFREPI
    // during the search.
    //
    save.MW = (2 * MAXWIN);
    testutil::T_GFRINI(
        MXPASS,
        save.MW,
        &mut save.NCALLS,
        save.SEQLOG.as_slice_mut(),
        save.CNFLOG.as_slice_mut(),
        save.MSGLOG.as_arg_mut(),
        ctx,
    )?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //
    // Occultation searches require one pass, so we expect that
    // just one call to T_GFREPI was made.
    //
    testutil::CHCKSI(b"No. of T_GFREPI calls", save.NCALLS, b"=", 1, 0, OK, ctx)?;

    //
    // Check the sequence number of the first call.
    //
    testutil::CHCKSI(b"SEQLOG(1)", save.SEQLOG[1], b"=", 1, 0, OK, ctx)?;

    //
    // Check the progress report message prefix and suffix.
    //
    testutil::CHCKSC(
        b"Prefix",
        &save.MSGLOG[[1, 1]],
        b"=",
        b"Occultation/transit search",
        OK,
        ctx,
    )?;

    testutil::CHCKSC(b"Suffix", &save.MSGLOG[[2, 1]], b"=", b"done.", OK, ctx)?;

    //
    // Retrieve the log of calls made to the update routine.
    //
    testutil::T_GFRPLO(
        MXCALL,
        &mut save.NUPDAT,
        save.SEQLOG.as_slice_mut(),
        save.REPLOG.as_slice_mut(),
        ctx,
    )?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //
    // Check the sequence numbers of the calls. They should
    // range from 2 to NUPDAT+1 and should be in increasing
    // order.
    //
    for I in 1..=save.NUPDAT {
        save.XSQLOG[I] = (I + 1);
    }

    testutil::CHCKAI(
        b"Update SEQLOG",
        save.SEQLOG.as_slice(),
        b"=",
        save.XSQLOG.as_slice(),
        save.NUPDAT,
        OK,
        ctx,
    )?;
    //
    // Make sure that:
    //
    //   - Each update time lies within the corresponding interval.
    //
    //   - Within each interval, the update times are monotonically
    //     non-decreasing.
    //
    // Also record the measure of the reported progress.
    //
    save.MEASUR = 0.0;

    for I in 1..=save.NUPDAT {
        fstr::assign(&mut save.QNAME, b"(0) Update time no. *");
        spicelib::REPMI(&save.QNAME.to_vec(), b"*", I, &mut save.QNAME, ctx);
        testutil::CHCKXC(false, b" ", OK, ctx)?;

        testutil::CHCKSD(
            &save.QNAME,
            save.REPLOG[[3, I]],
            b">=",
            save.REPLOG[[1, I]],
            0.0,
            OK,
            ctx,
        )?;
        testutil::CHCKSD(
            &save.QNAME,
            save.REPLOG[[3, I]],
            b"<=",
            save.REPLOG[[2, I]],
            0.0,
            OK,
            ctx,
        )?;

        if (I > 1) {
            if (save.REPLOG[[1, I]] == save.REPLOG[[1, (I - 1)]]) {
                //
                // The current interval is the same as the previous one.
                //
                fstr::assign(&mut save.QNAME, b"(1) Update time no. *");
                spicelib::REPMI(&save.QNAME.to_vec(), b"*", I, &mut save.QNAME, ctx);
                testutil::CHCKXC(false, b" ", OK, ctx)?;

                testutil::CHCKSD(
                    &save.QNAME,
                    save.REPLOG[[3, I]],
                    b">=",
                    save.REPLOG[[3, (I - 1)]],
                    0.0,
                    OK,
                    ctx,
                )?;

                save.MEASUR = ((save.MEASUR + save.REPLOG[[3, I]]) - save.REPLOG[[3, (I - 1)]]);
            }
        }
    }

    //
    // Compare the measure of the reported progress to that of the
    // confinement window.
    //
    testutil::CHCKSD(b"MEASUR", save.MEASUR, b"~", save.XMESUR, TIGHT, OK, ctx)?;

    //
    // Get the log of the report termination calls.
    //
    testutil::T_GFRTRM(MXPASS, &mut save.NCALLS, save.TRMLOG.as_slice_mut(), ctx)?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //
    // Occultation searches require one pass, so we expect that
    // just one call to T_GFRTRM was made.
    //
    testutil::CHCKSI(b"No. of T_GFRTRM calls", save.NCALLS, b"=", 1, 0, OK, ctx)?;

    //
    // Check the sequence number of the first termination call. Take
    // into account that the first call was to the init routine.
    //
    testutil::CHCKSI(
        b"T_GFREPF seq",
        save.TRMLOG[1],
        b"=",
        (save.NUPDAT + 2),
        0,
        OK,
        ctx,
    )?;

    //
    //---- Case -------------------------------------------------------------
    //
    testutil::TCASE(b"Run simple FOV search using GFFOVE.", ctx)?;

    //
    // We'll use the instrument defined in nat.ti:
    //
    //    ALPHA_ELLIPSE_NONE
    //
    // This instrument tracks body Alpha so body Beta's FOV entry and
    // exit times match the start and stop times of Beta's transit
    // across Alpha.
    //
    // Initialize inputs for the search.
    //
    spicelib::SCARDD(0, save.RESULT.as_slice_mut(), ctx)?;
    spicelib::SCARDD(0, save.CNFINE.as_slice_mut(), ctx)?;

    //
    // Initialize the progress reporting test utility package.
    //
    testutil::T_GFUINI(ctx)?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //
    // Initialize the confinement window log.
    //
    for I in 1..=MXPASS {
        spicelib::SSIZED((2 * MAXWIN), save.CNFLOG.subarray_mut([LBCELL, I]), ctx)?;
        testutil::CHCKXC(false, b" ", OK, ctx)?;
    }

    spicelib::SSIZED((2 * MAXWIN), save.CNFINE.as_slice_mut(), ctx)?;
    spicelib::SSIZED((2 * MAXWIN), save.RESULT.as_slice_mut(), ctx)?;

    //
    // Create a confinement window with 3 intervals.
    //
    save.NIVL = 3;
    save.XMESUR = 0.0;

    for I in 1..=save.NIVL {
        save.ET0 = (-800.0 + (((I - 3) as f64) * 3600.0));
        save.ET1 = (save.ET0 + 1600.0);

        spicelib::WNINSD(save.ET0, save.ET1, save.CNFINE.as_slice_mut(), ctx)?;
        testutil::CHCKXC(false, b" ", OK, ctx)?;

        save.XMESUR = ((save.XMESUR + save.ET1) - save.ET0);
    }

    fstr::assign(&mut save.INST, b"ALPHA_ELLIPSE_NONE");
    fstr::assign(&mut save.TARGET, b"BETA");
    fstr::assign(&mut save.TSHAPE, b"ELLIPSOID");
    fstr::assign(&mut save.TFRAME, b"BETAFIXED");
    fstr::assign(&mut save.OBSRVR, b"SUN");
    save.STEP = 300.0;
    save.TOL = CNVTOL;
    fstr::assign(&mut save.ABCORR, b"NONE");

    spicelib::CLEARD(3, save.RAYDIR.as_slice_mut());

    save.RPT = true;
    save.BAIL = false;

    spicelib::GFSSTP(save.STEP, ctx)?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //
    // Perform the search.
    //
    spicelib::GFFOVE(
        &save.INST,
        &save.TSHAPE,
        save.RAYDIR.as_slice(),
        &save.TARGET,
        &save.TFRAME,
        &save.ABCORR,
        &save.OBSRVR,
        save.TOL,
        spicelib::GFSTEP,
        spicelib::GFREFN,
        save.RPT,
        testutil::T_GFREPI,
        testutil::T_GFREPU,
        testutil::T_GFREPF,
        save.BAIL,
        spicelib::GFBAIL,
        save.CNFINE.as_slice(),
        save.RESULT.as_slice_mut(),
        ctx,
    )?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //
    // Now that the search is done, the interesting work starts. We're
    // going to do a post-mortem on the progress reporting calls that
    // were made during the search.
    //
    // Start out by fetching the information that was passed to T_GFREPI
    // during the search.
    //
    save.MW = (2 * MAXWIN);
    testutil::T_GFRINI(
        MXPASS,
        save.MW,
        &mut save.NCALLS,
        save.SEQLOG.as_slice_mut(),
        save.CNFLOG.as_slice_mut(),
        save.MSGLOG.as_arg_mut(),
        ctx,
    )?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //
    // FOV searches require one pass.
    //
    testutil::CHCKSI(b"No. of T_GFREPI calls", save.NCALLS, b"=", 1, 0, OK, ctx)?;

    //
    // Check the sequence number of the first call.
    //
    testutil::CHCKSI(b"SEQLOG(1)", save.SEQLOG[1], b"=", 1, 0, OK, ctx)?;

    //
    // Check the progress report message prefix and suffix.
    //
    testutil::CHCKSC(
        b"Prefix",
        &save.MSGLOG[[1, 1]],
        b"=",
        b"Target visibility search",
        OK,
        ctx,
    )?;

    testutil::CHCKSC(b"Suffix", &save.MSGLOG[[2, 1]], b"=", b"done.", OK, ctx)?;

    //
    // Retrieve the log of calls made to the update routine.
    //
    testutil::T_GFRPLO(
        MXCALL,
        &mut save.NUPDAT,
        save.SEQLOG.as_slice_mut(),
        save.REPLOG.as_slice_mut(),
        ctx,
    )?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //
    // Check the sequence numbers of the calls. They should
    // range from 2 to NUPDAT+1 and should be in increasing
    // order.
    //
    for I in 1..=save.NUPDAT {
        save.XSQLOG[I] = (I + 1);
    }

    testutil::CHCKAI(
        b"Update SEQLOG",
        save.SEQLOG.as_slice(),
        b"=",
        save.XSQLOG.as_slice(),
        save.NUPDAT,
        OK,
        ctx,
    )?;
    //
    // Make sure that:
    //
    //   - Each update time lies within the corresponding interval.
    //
    //   - Within each interval, the update times are monotonically
    //     non-decreasing.
    //
    // Also record the measure of the reported progress.
    //
    save.MEASUR = 0.0;

    for I in 1..=save.NUPDAT {
        fstr::assign(&mut save.QNAME, b"(0) Update time no. *");
        spicelib::REPMI(&save.QNAME.to_vec(), b"*", I, &mut save.QNAME, ctx);
        testutil::CHCKXC(false, b" ", OK, ctx)?;

        testutil::CHCKSD(
            &save.QNAME,
            save.REPLOG[[3, I]],
            b">=",
            save.REPLOG[[1, I]],
            0.0,
            OK,
            ctx,
        )?;
        testutil::CHCKSD(
            &save.QNAME,
            save.REPLOG[[3, I]],
            b"<=",
            save.REPLOG[[2, I]],
            0.0,
            OK,
            ctx,
        )?;

        if (I > 1) {
            if (save.REPLOG[[1, I]] == save.REPLOG[[1, (I - 1)]]) {
                //
                // The current interval is the same as the previous one.
                //
                fstr::assign(&mut save.QNAME, b"(1) Update time no. *");
                spicelib::REPMI(&save.QNAME.to_vec(), b"*", I, &mut save.QNAME, ctx);
                testutil::CHCKXC(false, b" ", OK, ctx)?;

                testutil::CHCKSD(
                    &save.QNAME,
                    save.REPLOG[[3, I]],
                    b">=",
                    save.REPLOG[[3, (I - 1)]],
                    0.0,
                    OK,
                    ctx,
                )?;

                save.MEASUR = ((save.MEASUR + save.REPLOG[[3, I]]) - save.REPLOG[[3, (I - 1)]]);
            }
        }
    }

    //
    // Compare the measure of the reported progress to that of the
    // confinement window.
    //
    testutil::CHCKSD(b"MEASUR", save.MEASUR, b"~", save.XMESUR, TIGHT, OK, ctx)?;

    //
    // Get the log of the report termination calls.
    //
    testutil::T_GFRTRM(MXPASS, &mut save.NCALLS, save.TRMLOG.as_slice_mut(), ctx)?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //
    // FOV searches require one pass, so we expect that
    // just one call to T_GFRTRM was made.
    //
    testutil::CHCKSI(b"No. of T_GFRTRM calls", save.NCALLS, b"=", 1, 0, OK, ctx)?;

    //
    // Check the sequence number of the first termination call. Take
    // into account that the first call was to the init routine.
    //
    testutil::CHCKSI(
        b"T_GFREPF seq",
        save.TRMLOG[1],
        b"=",
        (save.NUPDAT + 2),
        0,
        OK,
        ctx,
    )?;

    //
    // --- Case: ------------------------------------------------------
    //
    testutil::TCASE(b"Clean up:  delete kernels.", ctx)?;

    spicelib::SPKUEF(save.HAN2, ctx)?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    spicelib::DELFIL(NSPK, ctx)?;
    testutil::CHCKXC(false, b" ", OK, ctx)?;

    //*********************************************************************
    //*
    //*    Error cases
    //*
    //*********************************************************************

    //
    //---- Case -------------------------------------------------------------
    //

    testutil::T_SUCCESS(OK, ctx);
    Ok(())
}