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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
const VNMLEN: i32 = 32;
const NUMLEN: i32 = 16;
/// Find values from the kernel pool
///
/// Determine whether values exist for some item for any body
/// in the kernel pool.
///
/// # Required Reading
///
/// * [KERNEL](crate::required_reading::kernel)
/// * [PCK](crate::required_reading::pck)
/// * [SPK](crate::required_reading::spk)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// BODY I ID code of body.
/// ITEM I Item to find ('RADII', 'NUT_AMP_RA', etc.).
///
/// The function returns .TRUE. if ITEM is in the kernel pool, .FALSE.
/// otherwise.
/// ```
///
/// # Detailed Input
///
/// ```text
/// BODY is the ID code of the body for which the item is
/// requested.
///
/// ITEM is the item to be returned. Together, the body and item
/// name combine to form a variable name, e.g.,
///
/// 'BODY599_RADII'
/// 'BODY4_POLE_RA'
/// ```
///
/// # Detailed Output
///
/// ```text
/// The function returns .TRUE. if ITEM is in the kernel pool, and
/// .FALSE. if it is not.
/// ```
///
/// # Exceptions
///
/// ```text
/// Error free.
/// ```
///
/// # Particulars
///
/// ```text
/// BODVCD, which returns values from the kernel pool, causes an
/// error to be signaled whenever the specified item is not found.
/// In many cases, this is appropriate. However, sometimes the
/// program may attempt to recover, by providing default values,
/// prompting for replacements, and so on.
/// ```
///
/// # Examples
///
/// ```text
/// In the following example, default values are substituted for
/// bodies for which axes are not found.
///
/// IF ( BODFND ( TARGET, 'RADII' ) ) THEN
/// CALL BODVCD ( TARGET, 'RADII', 3, N, RADII )
/// ELSE
/// CALL VPACK ( 100.D0, 100.D0, 100.D0, RADII )
/// END IF
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// H.A. Neilan (JPL)
/// W.L. Taber (JPL)
/// I.M. Underwood (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.3.0, 12-AUG-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard. Updated
/// input argument BODY detailed description. Added SPK and PCK to
/// the list of required readings.
///
/// - SPICELIB Version 1.2.1, 24-OCT-2005 (NJB)
///
/// Header update: calls to BODVAR in example code were replaced
/// with calls to BODVCD. The string 'AXES' and variable AXES
/// were replaced with the string 'RADII' and variable 'RADII'
/// throughout the header.
///
/// - SPICELIB Version 1.2.0, 15-MAR-2002 (NJB)
///
/// Bug fix: routine was updated to work with string-valued
/// kernel variables.
///
/// - SPICELIB Version 1.1.0, 17-MAY-1994 (HAN)
///
/// If the value of the function RETURN is .TRUE. upon execution of
/// this module, this function is assigned a default value of
/// either 0, 0.0D0, .FALSE., or blank depending on the type of
/// the function.
///
/// - 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, 31-JAN-1990 (WLT) (IMU)
/// ```
pub fn bodfnd(ctx: &mut SpiceContext, body: i32, item: &str) -> crate::Result<bool> {
let ret = BODFND(body, item.as_bytes(), ctx.raw_context())?;
ctx.handle_errors()?;
Ok(ret)
}
//$Procedure BODFND ( Find values from the kernel pool )
pub fn BODFND(BODY: i32, ITEM: &[u8], ctx: &mut Context) -> f2rust_std::Result<bool> {
let mut BODFND: bool = false;
let mut DTYPE = [b' '; 1 as usize];
let mut CODE = [b' '; NUMLEN as usize];
let mut VARNAM = [b' '; VNMLEN as usize];
let mut N: i32 = 0;
let mut FOUND: bool = false;
//
// SPICELIB functions
//
//
// Local parameters
//
//
// Local variables
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
BODFND = false;
return Ok(BODFND);
} else {
CHKIN(b"BODFND", ctx)?;
}
//
// Construct the variable name from BODY and ITEM.
//
fstr::assign(&mut VARNAM, b"BODY");
INTSTR(BODY, &mut CODE, ctx);
SUFFIX(&CODE, 0, &mut VARNAM);
SUFFIX(b"_", 0, &mut VARNAM);
SUFFIX(ITEM, 0, &mut VARNAM);
//
// Search the kernel pool for the item.
//
DTPOOL(&VARNAM, &mut FOUND, &mut N, &mut DTYPE, ctx)?;
//
// Was anything there?
//
BODFND = FOUND;
CHKOUT(b"BODFND", ctx)?;
Ok(BODFND)
}