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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
const MSGLEN: i32 = 320;
/// Parse d.p. number with error checking
///
/// Parse a string as a double precision number, encapsulating error
/// handling.
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// STRING I String representing a numeric value.
/// DPVAL O D.p. value obtained by parsing STRING.
/// ```
///
/// # Detailed Input
///
/// ```text
/// STRING is a string representing a numeric value. Commas and
/// spaces may be used in this string for ease of reading
/// and writing the number. They are treated as
/// insignificant but non-error-producing characters.
///
/// For exponential representation any of the characters
/// 'E','D','e','d' may be used.
///
/// The following are legitimate numeric expressions
///
/// +12.2 e-1
/// -3. 1415 9276
/// 1e12
/// E10
///
/// The program also recognizes the following mnemonics
///
/// 'PI', 'pi', 'Pi', 'pI'
/// '+PI', '+pi', '+Pi', '+pI'
/// '-PI', '-pi', '-Pi', '-pI'
///
/// and returns the value
///
/// ( + OR - ) 3.1415 9265 3589 7932 3846 26 ...
///
/// as appropriate.
/// ```
///
/// # Detailed Output
///
/// ```text
/// DPVAL is the double precision number obtained by parsing
/// STRING.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If the input string cannot be parsed due to use of an
/// unexpected or misplaced character or due to a string
/// representing a number too large for double precision, the
/// error SPICE(NOTADPNUMBER) is signaled.
/// ```
///
/// # Particulars
///
/// ```text
/// The purpose of this routine is to enable safe parsing of double
/// precision numbers without the necessity of in-line error checking.
/// ```
///
/// # 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) Parse into a DOUBLE PRECISION variable a set of strings
/// representing numeric values.
///
///
/// Example code begins here.
///
///
/// PROGRAM PRSDP_EX1
/// IMPLICIT NONE
///
/// C
/// C Local parameters.
/// C
/// INTEGER SETSIZ
/// PARAMETER ( SETSIZ = 8 )
///
/// INTEGER STRLEN
/// PARAMETER ( STRLEN = 11 )
///
/// C
/// C Local variables.
/// C
/// CHARACTER*(STRLEN) STRVAL ( SETSIZ )
///
/// DOUBLE PRECISION DPVAL
///
/// INTEGER I
///
/// C
/// C Initialize the array of strings.
/// C
/// DATA STRVAL / '100,000,000',
/// . ' -2 690 192',
/// . ' +12.2 e-1',
/// . '-3. 141 592',
/// . ' 1.2e12',
/// . ' E10',
/// . ' Pi',
/// . ' -PI' /
///
/// C
/// C Parse each string into a DOUBLE PRECISION variable.
/// C
/// WRITE(*,'(A)') ' STRVAL DPVAL'
/// WRITE(*,'(A)') '----------- --------------------------'
/// DO I = 1, SETSIZ
///
/// CALL PRSDP ( STRVAL(I), DPVAL )
///
/// WRITE(*,'(A11,F28.12)') STRVAL(I), DPVAL
///
/// END DO
///
///
/// END
///
///
/// When this program was executed on a Mac/Intel/gfortran/64-bit
/// platform, the output was:
///
///
/// STRVAL DPVAL
/// ----------- --------------------------
/// 100,000,000 100000000.000000000000
/// -2 690 192 -2690192.000000000000
/// +12.2 e-1 1.220000000000
/// -3. 141 592 -3.141592000000
/// 1.2e12 1200000000000.000000000000
/// E10 10000000000.000000000000
/// Pi 3.141592653590
/// -PI -3.141592653590
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.1.1, 28-MAY-2020 (JDR)
///
/// Edited the header to comply with NAIF standard. Added complete
/// code example.
///
/// Updated the header to properly describe its input, output,
/// exceptions and particulars.
///
/// - SPICELIB Version 1.1.0, 15-SEP-1997 (NJB)
///
/// Bug fix: output argument declaration changed from INTEGER
/// to DOUBLE PRECISION.
///
/// - SPICELIB Version 1.0.0, 22-JUL-1997 (NJB)
/// ```
pub fn prsdp(ctx: &mut SpiceContext, string: &str, dpval: &mut f64) -> crate::Result<()> {
PRSDP(string.as_bytes(), dpval, ctx.raw_context())?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure PRSDP ( Parse d.p. number with error checking )
pub fn PRSDP(STRING: &[u8], DPVAL: &mut f64, ctx: &mut Context) -> f2rust_std::Result<()> {
let mut ERRMSG = [b' '; MSGLEN as usize];
let mut PTR: i32 = 0;
//
// Local parameters
//
//
// Local variables
//
//
// Use discovery check-in.
//
NPARSD(STRING, DPVAL, &mut ERRMSG, &mut PTR, ctx);
if fstr::ne(&ERRMSG, b" ") {
CHKIN(b"PRSDP", ctx)?;
SETMSG(&ERRMSG, ctx);
SIGERR(b"SPICE(NOTADPNUMBER)", ctx)?;
CHKOUT(b"PRSDP", ctx)?;
return Ok(());
}
Ok(())
}