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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
/// Write array of lines to a logical unit
///
/// Write an array of text lines to a Fortran logical unit.
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// NUMLIN I Number of lines to be written to the file.
/// ARRAY I Array containing the lines to be written.
/// UNIT I Fortran unit number to use for output.
/// ```
///
/// # Detailed Input
///
/// ```text
/// NUMLIN is the number of text lines in ARRAY which are to be
/// written to UNIT. NUMLIN > 0.
///
/// ARRAY is the array which contains the text lines to be written
/// to UNIT.
///
/// The contents of this variable are not modified.
///
/// UNIT is the Fortran unit number for the output. This may
/// be either the unit number for the terminal, or the
/// unit number of a previously opened text file.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If the number of lines, NUMLIN, is not positive, the error
/// SPICE(INVALIDARGUMENT) is signaled.
///
/// 2) If an error occurs while attempting to write to the text file
/// attached to UNIT, the error is signaled by a routine in the
/// call tree of this routine.
/// ```
///
/// # Files
///
/// ```text
/// See the description of UNIT above.
/// ```
///
/// # Particulars
///
/// ```text
/// This routine writes an array of character strings to a specified
/// Fortran logical unit, writing each array element as a line of
/// output.
/// ```
///
/// # 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) The following example demonstrates the use of this routine,
/// displaying a short poem on the standard output device,
/// typically a terminal screen.
///
/// Example code begins here.
///
///
/// PROGRAM WRITLA_EX1
/// IMPLICIT NONE
///
/// C
/// C Example program for WRITLA.
/// C
/// CHARACTER*(80) LINES(4)
///
/// LINES(1) = 'Mary had a little lamb'
/// LINES(2) = 'Whose fleece was white as snow'
/// LINES(3) = 'And everywhere that mary went'
/// LINES(4) = 'The lamb was sure to go'
///
/// CALL WRITLA ( 4, LINES, 6 )
///
/// END
///
///
/// When this program was executed on a Mac/Intel/gfortran/64-bit
/// platform, the output was:
///
///
/// Mary had a little lamb
/// Whose fleece was white as snow
/// And everywhere that mary went
/// The lamb was sure to go
/// ```
///
/// # Author and Institution
///
/// ```text
/// J. Diaz del Rio (ODC Space)
/// K.R. Gehringer (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.1.0, 03-JUN-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Updated to remove unnecessary lines of code in the
/// Standard SPICE error handling CHKIN statements.
///
/// Edited the header to comply with NAIF standard.
///
/// - SPICELIB Version 1.0.0, 20-DEC-1995 (KRG)
///
/// The routine graduated
///
/// Beta Version 2.0.0, 13-OCT-1994 (KRG)
///
/// This routine now participates fully with the SPICELIB error
/// handler, checking in on entry and checking out on exit. The
/// overhead associated with the error handler should not be
/// significant relative to the operation of this routine.
///
/// Beta Version 1.0.0, 18-DEC-1992 (KRG)
/// ```
pub fn writla(
ctx: &mut SpiceContext,
numlin: i32,
array: CharArray,
unit: i32,
) -> crate::Result<()> {
WRITLA(numlin, array, unit, ctx.raw_context())?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure WRITLA ( Write array of lines to a logical unit )
pub fn WRITLA(
NUMLIN: i32,
ARRAY: CharArray,
UNIT: i32,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let ARRAY = DummyCharArray::new(ARRAY, None, 1..);
//
// SPICELIB functions
//
//
// Local variables
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
}
CHKIN(b"WRITLA", ctx)?;
//
// Check to see if the maximum number of lines is positive.
//
if (NUMLIN <= 0) {
SETMSG(
b"The number of lines to be written was not positive. It was #.",
ctx,
);
ERRINT(b"#", NUMLIN, ctx);
SIGERR(b"SPICE(INVALIDARGUMENT)", ctx)?;
CHKOUT(b"WRITLA", ctx)?;
return Ok(());
}
//
// Begin writing the lines to UNIT. Stop when an error occurs, or
// when we have finished writing all of the lines.
//
for I in 1..=NUMLIN {
WRITLN(&ARRAY[I], UNIT, ctx)?;
if FAILED(ctx) {
//
// If the write failed, an appropriate error message has
// already been set, so we simply need to return.
//
CHKOUT(b"WRITLA", ctx)?;
return Ok(());
}
}
CHKOUT(b"WRITLA", ctx)?;
Ok(())
}