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
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
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 RNAME: &[u8] = b"ZZSPKAC0";
const DELTA: f64 = 1.0;
const SSB: i32 = 0;
struct SaveVars {
PRVCOR: Vec<u8>,
FIRST: bool,
USESTL: bool,
}
impl SaveInit for SaveVars {
fn new() -> Self {
let mut PRVCOR = vec![b' '; CORLEN as usize];
let mut FIRST: bool = false;
let mut USESTL: bool = false;
FIRST = true;
fstr::assign(&mut PRVCOR, b" ");
Self {
PRVCOR,
FIRST,
USESTL,
}
}
}
//$Procedure ZZSPKAC0 ( S/P Kernel, aberration corrected state )
pub fn ZZSPKAC0(
TARG: i32,
ET: f64,
REF: &[u8],
ABCORR: &[u8],
OBS: i32,
STARG: &mut [f64],
LT: &mut f64,
DLT: &mut f64,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let save = ctx.get_vars::<SaveVars>();
let save = &mut *save.borrow_mut();
let mut STARG = DummyArrayMut::new(STARG, 1..=6);
let mut ACC = StackArray::<f64, 3>::new(1..=3);
let mut LTSSB: f64 = 0.0;
let mut SSBLT: f64 = 0.0;
let mut SSBOBS = StackArray::<f64, 6>::new(1..=6);
let mut STOBS = StackArray2D::<f64, 12>::new(1..=6, 1..=2);
let mut T: f64 = 0.0;
let mut REFID: i32 = 0;
let mut ATTBLK = StackArray::<bool, 15>::new(1..=NABCOR);
//
// SPICELIB functions
//
//
// Local parameters
//
//
// Local variables
//
//
// Saved variables
//
//
// Initial values
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
} else {
CHKIN(RNAME, ctx)?;
}
if (save.FIRST || fstr::ne(ABCORR, &save.PRVCOR)) {
//
// The aberration correction flag differs from the value it
// had on the previous call, if any. Analyze the new flag.
//
ZZVALCOR(ABCORR, ATTBLK.as_slice_mut(), ctx)?;
if FAILED(ctx) {
CHKOUT(RNAME, ctx)?;
return Ok(());
}
//
// The aberration correction flag is recognized; save it.
//
fstr::assign(&mut save.PRVCOR, ABCORR);
//
// Set logical flags indicating the attributes of the requested
// correction:
//
// USESTL is .TRUE. when stellar aberration correction is
// specified.
//
// The above definitions are consistent with those used by
// ZZVALCOR.
//
save.USESTL = ATTBLK[STLIDX];
save.FIRST = false;
}
//
// See if the reference frame is a recognized inertial frame.
//
IRFNUM(REF, &mut REFID, ctx);
if (REFID == 0) {
SETMSG(
b"The requested frame \'#\' is not a recognized inertial frame. ",
ctx,
);
ERRCH(b"#", REF, ctx);
SIGERR(b"SPICE(BADFRAME)", ctx)?;
CHKOUT(RNAME, ctx)?;
return Ok(());
}
//
// Prepare to look up the apparent state of the target
// as seen by the observer. We'll need the geometric
// state of the observer relative to the solar system
// barycenter. If we're using stellar aberration
// corrections, we'll need the observer's acceleration
// as well.
//
// Get the geometric state of the observer relative to the SSB,
// which we'll call SSBOBS.
//
ZZSPKGO0(OBS, ET, REF, SSB, SSBOBS.as_slice_mut(), &mut SSBLT, ctx)?;
if save.USESTL {
//
// Numerically differentiate the observer velocity relative to
// the SSB to obtain acceleration. We first evaluate the
// geometric state of the observer relative to the solar system
// barycenter at ET +/- DELTA.
for I in 1..=2 {
T = (ET + ((((2 * I) - 3) as f64) * DELTA));
ZZSPKGO0(
OBS,
T,
REF,
SSB,
STOBS.subarray_mut([1, I]),
&mut LTSSB,
ctx,
)?;
}
QDERIV(
3,
STOBS.subarray([4, 1]),
STOBS.subarray([4, 2]),
DELTA,
ACC.as_slice_mut(),
ctx,
)?;
} else {
CLEARD(3, ACC.as_slice_mut());
}
//
// Look up the apparent state. The light time and light
// rate are returned as well.
//
ZZSPKAS0(
TARG,
ET,
REF,
ABCORR,
SSBOBS.as_slice(),
ACC.as_slice(),
STARG.as_slice_mut(),
LT,
DLT,
ctx,
)?;
CHKOUT(RNAME, ctx)?;
Ok(())
}