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
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
//$Procedure UTRANS_2 ( Translate Units To Default Units )
pub fn UTRANS_2(STRING: &mut [u8], PLACES: i32, ctx: &mut Context) -> f2rust_std::Result<()> {
let mut DPNUM = [b' '; 32 as usize];
let mut MYERR = [b' '; 80 as usize];
let mut BASICS = [b' '; 127 as usize];
let mut BEG: i32 = 0;
let mut BU: i32 = 0;
let mut END: i32 = 0;
let mut EU: i32 = 0;
let mut POINTR: i32 = 0;
let mut START: i32 = 0;
let mut F: i32 = 0;
let mut L: i32 = 0;
let mut ERASED: bool = false;
let mut MEASEQ: bool = false;
let mut X: f64 = 0.0;
let mut CONVERT: f64 = 0.0;
//
// NAIFLIB functions
//
//
// Local variables
//
//
// First thing, we left justify the command.
//
spicelib::LJUST(&STRING.to_vec(), STRING);
MEASEQ = false;
ERASED = false;
//
// Find the last word of the string.
//
START = (intrinsics::LEN(STRING) + 1);
FNDPTK(STRING, b" ", START, &mut BEG, &mut END, ctx)?;
while (BEG > 0) {
//
// If we are in a measurement sequence, then we need to see if
// the current word is a number.
//
if MEASEQ {
fstr::assign(&mut MYERR, b" ");
spicelib::NPARSD(
fstr::substr(STRING, BEG..=END),
&mut X,
&mut MYERR,
&mut POINTR,
ctx,
);
//
// If no error occurred in the attempt to parse this number
// the measurement sequence continues.
//
if fstr::eq(&MYERR, b" ") {
//
// If we haven't already erased the current unit, do so
// now and record our action.
//
if !ERASED {
fstr::assign(fstr::substr_mut(STRING, BU..=EU), b" ");
ERASED = true;
}
fstr::assign(fstr::substr_mut(STRING, BEG..=END), b" ");
X = (X * CONVERT);
spicelib::DPSTRF(X, PLACES, b"E", &mut DPNUM, ctx);
spicelib::SIGDGT(&DPNUM.clone(), &mut DPNUM);
spicelib::PREFIX(&DPNUM, 1, fstr::substr_mut(STRING, BEG..));
//
// If an error DID occur while attempting to parse the
// current word, we are ending the current measurment
// sequence. However, we might be beginning another ...
//
} else {
//
// ... search the list of recognized units for this word
//
//
if UNITP(fstr::substr(STRING, BEG..=END), ctx)? {
// WRITE (*,*) STRING(BEG:END)
fstr::assign(&mut BASICS, b" ");
TRANSU(fstr::substr(STRING, BEG..=END), &mut BASICS, ctx)?;
F = intrinsics::MAX0(&[1, spicelib::FRSTNB(&BASICS)]);
L = intrinsics::MAX0(&[1, spicelib::LASTNB(&BASICS)]);
// WRITE (*,*) BASICS(F:L)
CONVRT_2(
1.0,
fstr::substr(STRING, BEG..=END),
fstr::substr(&BASICS, F..=L),
&mut CONVERT,
ctx,
)?;
MEASEQ = true;
} else {
MEASEQ = false;
}
//
// ... if this word is on the list, record its place in the
// string.
//
if MEASEQ {
BU = BEG;
EU = END;
//
// We haven't erased this unit from the string yet.
// Record this observation.
//
ERASED = false;
}
}
} else {
//
// We were not in a measurment sequence, but we might be
// starting one. Search the list of known units for the
// current word.
//
if UNITP(fstr::substr(STRING, BEG..=END), ctx)? {
// WRITE (*,*) STRING(BEG:END)
fstr::assign(&mut BASICS, b" ");
TRANSU(fstr::substr(STRING, BEG..=END), &mut BASICS, ctx)?;
F = intrinsics::MAX0(&[1, spicelib::FRSTNB(&BASICS)]);
L = intrinsics::MAX0(&[1, spicelib::LASTNB(&BASICS)]);
// WRITE (*,*) BASICS(F:L)
CONVRT_2(
1.0,
fstr::substr(STRING, BEG..=END),
fstr::substr(&BASICS, F..=L),
&mut CONVERT,
ctx,
)?;
MEASEQ = true;
} else {
MEASEQ = false;
}
if MEASEQ {
BU = BEG;
EU = END;
//
// We certainly haven't erased this unit yet.
//
ERASED = false;
}
}
//
// Find the word previous to the current one.
//
START = BEG;
FNDPTK(STRING, b" ", START, &mut BEG, &mut END, ctx)?;
}
Ok(())
}