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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
const CHR: i32 = 1;
const DP: i32 = 2;
const INT: i32 = 3;
/// DAS, last logical addresses
///
/// Return last DAS logical addresses of character, double precision
/// and integer type that are currently in use in a specified DAS
/// file.
///
/// # Required Reading
///
/// * [DAS](crate::required_reading::das)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// HANDLE I DAS file handle.
/// LASTC O Last character address in use.
/// LASTD O Last double precision address in use.
/// LASTI O Last integer address in use.
/// ```
///
/// # Detailed Input
///
/// ```text
/// HANDLE is the file handle of a DAS file whose active
/// logical address ranges are desired.
/// ```
///
/// # Detailed Output
///
/// ```text
/// LASTC,
/// LASTD,
/// LASTI are, respectively, the last 1-based logical addresses of
/// character, double precision, and integer type in use in
/// the specified DAS file.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If the input file handle is invalid, an error is signaled by
/// a routine in the call tree of this routine.
/// ```
///
/// # Particulars
///
/// ```text
/// This routine is a utility that allows a calling program to
/// find the range of logical addresses currently in use in any
/// DAS file.
/// ```
///
/// # 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) Create a DAS file containing 10 integers, 5 double precision
/// numbers, and 4 characters, then use DASLLA to find the logical
/// address ranges in use.
///
///
/// Example code begins here.
///
///
/// PROGRAM DASLLA_EX1
/// IMPLICIT NONE
///
/// C
/// C Local parameters.
/// C
/// CHARACTER*(*) FNAME
/// PARAMETER ( FNAME = 'daslla_ex1.das' )
///
/// INTEGER IFNMLN
/// PARAMETER ( IFNMLN = 60 )
///
/// C
/// C Local variables.
/// C
/// CHARACTER*(IFNMLN) IFNAME
/// CHARACTER*(4) TYPE
///
/// INTEGER HANDLE
/// INTEGER I
/// INTEGER LASTC
/// INTEGER LASTD
/// INTEGER LASTI
///
/// C
/// C Open a new DAS file. Use the file name as the internal
/// C file name, and reserve no records for comments.
/// C
/// TYPE = 'TEST'
/// IFNAME = 'TEST.DAS/NAIF/NJB/11-NOV-1992-20:12:20'
///
/// CALL DASONW ( FNAME, TYPE, IFNAME, 0, HANDLE )
///
/// DO I = 1, 10
/// CALL DASADI ( HANDLE, 1, I )
/// END DO
///
/// DO I = 1, 5
/// CALL DASADD ( HANDLE, 1, DBLE(I) )
/// END DO
///
/// C
/// C Add character data to the file. DAS character data are
/// C treated as a character array, not as a string. The
/// C following call adds only the first 4 characters to the
/// C DAS file.
/// C
/// CALL DASADC ( HANDLE, 4, 1, 4, 'SPUDWXY' )
///
/// C
/// C Now check the logical address ranges.
/// C
/// CALL DASLLA ( HANDLE, LASTC, LASTD, LASTI )
///
/// WRITE (*,*) 'Last character address in use: ', LASTC
/// WRITE (*,*) 'Last d.p. address in use : ', LASTD
/// WRITE (*,*) 'Last integer address in use : ', LASTI
///
/// C
/// C Close the DAS file.
/// C
/// CALL DASCLS ( HANDLE )
///
/// END
///
///
/// When this program was executed on a Mac/Intel/gfortran/64-bit
/// platform, the output was:
///
///
/// Last character address in use: 4
/// Last d.p. address in use : 5
/// Last integer address in use : 10
///
///
/// Note that after run completion, a new DAS file exists in the
/// output directory.
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// W.L. Taber (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.1.0, 30-JUN-2021 (JDR)
///
/// Added IMPLICIT NONE statement. Local parameter declarations
/// have been moved from the $Declarations section to the
/// procedure's code.
///
/// Edited the header to comply with NAIF standard. Added complete
/// code example from existing fragment.
///
/// - SPICELIB Version 1.0.0, 11-NOV-1992 (NJB) (WLT)
/// ```
pub fn daslla(
ctx: &mut SpiceContext,
handle: i32,
lastc: &mut i32,
lastd: &mut i32,
lasti: &mut i32,
) -> crate::Result<()> {
DASLLA(handle, lastc, lastd, lasti, ctx.raw_context())?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure DASLLA ( DAS, last logical addresses )
pub fn DASLLA(
HANDLE: i32,
LASTC: &mut i32,
LASTD: &mut i32,
LASTI: &mut i32,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let mut FREE: i32 = 0;
let mut NCOMC: i32 = 0;
let mut NCOMR: i32 = 0;
let mut NRESVC: i32 = 0;
let mut NRESVR: i32 = 0;
let mut LASTLA = StackArray::<i32, 3>::new(1..=3);
let mut LASTRC = StackArray::<i32, 3>::new(1..=3);
let mut LASTWD = StackArray::<i32, 3>::new(1..=3);
//
// SPICELIB functions
//
//
// Local parameters.
//
//
// Local variables
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
}
CHKIN(b"DASLLA", ctx)?;
//
// The file summary for the indicated DAS file contains all of the
// information we need.
//
DASHFS(
HANDLE,
&mut NRESVR,
&mut NRESVC,
&mut NCOMR,
&mut NCOMC,
&mut FREE,
LASTLA.as_slice_mut(),
LASTRC.as_slice_mut(),
LASTWD.as_slice_mut(),
ctx,
)?;
*LASTC = LASTLA[CHR];
*LASTD = LASTLA[DP];
*LASTI = LASTLA[INT];
CHKOUT(b"DASLLA", ctx)?;
Ok(())
}