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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
/// Write a text line to a logical unit
///
/// Write a single line of text to the Fortran logical unit UNIT.
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// LINE I The line which is to be written to UNIT.
/// UNIT I The Fortran unit number to use for output.
/// ```
///
/// # Detailed Input
///
/// ```text
/// LINE is the text line which is to be written to UNIT.
///
/// The value of this variable is 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 an error occurs while attempting to write to the text
/// file attached to UNIT, the error SPICE(FILEWRITEFAILED) is
/// signaled.
/// ```
///
/// # Particulars
///
/// ```text
/// This routine will write a single text line to the device
/// specified by UNIT. UNIT may be the terminal, or it may be
/// a logical unit number obtained from a Fortran OPEN or INQUIRE
/// statement. When written, the line will have trailing spaces
/// removed.
/// ```
///
/// # Examples
///
/// ```text
/// CALL WRITLN( LINE, UNIT )
///
/// You have now written a line of text to unit UNIT.
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// K.R. Gehringer (JPL)
/// H.A. Neilan (JPL)
/// B.V. Semenov (JPL)
/// W.L. Taber (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 2.27.0, 28-NOV-2021 (BVS)
///
/// Updated for MAC-OSX-M1-64BIT-CLANG_C.
///
/// - SPICELIB Version 2.26.0, 16-AUG-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard. Removed
/// unnecessary $Revisions section.
///
/// Removed implementation detail (discovery check-in) from
/// $Exceptions section.
///
/// - SPICELIB Version 2.25.0, 10-MAR-2014 (BVS)
///
/// Updated for SUN-SOLARIS-64BIT-INTEL.
///
/// - SPICELIB Version 2.24.0, 10-MAR-2014 (BVS)
///
/// Updated for PC-LINUX-64BIT-IFORT.
///
/// - SPICELIB Version 2.23.0, 10-MAR-2014 (BVS)
///
/// Updated for PC-CYGWIN-GFORTRAN.
///
/// - SPICELIB Version 2.22.0, 10-MAR-2014 (BVS)
///
/// Updated for PC-CYGWIN-64BIT-GFORTRAN.
///
/// - SPICELIB Version 2.21.0, 10-MAR-2014 (BVS)
///
/// Updated for PC-CYGWIN-64BIT-GCC_C.
///
/// - SPICELIB Version 2.20.1, 18-MAY-2010 (BVS)
///
/// Removed "C$" marker from text in the header.
///
/// - SPICELIB Version 2.20.0, 13-MAY-2010 (BVS)
///
/// Updated for SUN-SOLARIS-INTEL.
///
/// - SPICELIB Version 2.19.0, 13-MAY-2010 (BVS)
///
/// Updated for SUN-SOLARIS-INTEL-CC_C.
///
/// - SPICELIB Version 2.18.0, 13-MAY-2010 (BVS)
///
/// Updated for SUN-SOLARIS-INTEL-64BIT-CC_C.
///
/// - SPICELIB Version 2.17.0, 13-MAY-2010 (BVS)
///
/// Updated for SUN-SOLARIS-64BIT-NATIVE_C.
///
/// - SPICELIB Version 2.16.0, 13-MAY-2010 (BVS)
///
/// Updated for PC-WINDOWS-64BIT-IFORT.
///
/// - SPICELIB Version 2.15.0, 13-MAY-2010 (BVS)
///
/// Updated for PC-LINUX-64BIT-GFORTRAN.
///
/// - SPICELIB Version 2.14.0, 13-MAY-2010 (BVS)
///
/// Updated for PC-64BIT-MS_C.
///
/// - SPICELIB Version 2.13.0, 13-MAY-2010 (BVS)
///
/// Updated for MAC-OSX-64BIT-INTEL_C.
///
/// - SPICELIB Version 2.12.0, 13-MAY-2010 (BVS)
///
/// Updated for MAC-OSX-64BIT-IFORT.
///
/// - SPICELIB Version 2.11.0, 13-MAY-2010 (BVS)
///
/// Updated for MAC-OSX-64BIT-GFORTRAN.
///
/// - SPICELIB Version 2.10.0, 18-MAR-2009 (BVS)
///
/// Updated for PC-LINUX-GFORTRAN.
///
/// - SPICELIB Version 2.9.0, 18-MAR-2009 (BVS)
///
/// Updated for MAC-OSX-GFORTRAN.
///
/// - SPICELIB Version 2.8.0, 19-FEB-2008 (BVS)
///
/// Updated for PC-LINUX-IFORT.
///
/// - SPICELIB Version 2.7.0, 14-NOV-2006 (BVS)
///
/// Updated for PC-LINUX-64BIT-GCC_C.
///
/// - SPICELIB Version 2.6.0, 14-NOV-2006 (BVS)
///
/// Updated for MAC-OSX-INTEL_C.
///
/// - SPICELIB Version 2.5.0, 14-NOV-2006 (BVS)
///
/// Updated for MAC-OSX-IFORT.
///
/// - SPICELIB Version 2.4.0, 14-NOV-2006 (BVS)
///
/// Updated for PC-WINDOWS-IFORT.
///
/// - SPICELIB Version 2.3.0, 26-OCT-2005 (BVS)
///
/// Updated for SUN-SOLARIS-64BIT-GCC_C.
///
/// - SPICELIB Version 2.2.0, 03-JAN-2005 (BVS)
///
/// Updated for PC-CYGWIN_C.
///
/// - SPICELIB Version 2.1.0, 03-JAN-2005 (BVS)
///
/// Updated for PC-CYGWIN.
///
/// - SPICELIB Version 2.0.5, 17-JUL-2002 (BVS)
///
/// Added MAC-OSX environments.
///
/// - SPICELIB Version 2.0.4, 08-OCT-1999 (WLT)
///
/// The environment lines were expanded so that the supported
/// environments are now explicitly given. New
/// environments are WIN-NT
///
/// - SPICELIB Version 2.0.3, 16-SEP-1999 (NJB)
///
/// CSPICE environments were added. Some typos were corrected.
///
/// - SPICELIB Version 2.0.2, 28-JUL-1999 (WLT)
///
/// The environment lines were expanded so that the supported
/// environments are now explicitly given. New
/// environments are PC-DIGITAL, SGI-O32 and SGI-N32.
///
/// - SPICELIB Version 2.0.1, 18-MAR-1999 (WLT)
///
/// The environment lines were expanded so that the supported
/// environments are now explicitly given. Previously,
/// environments such as SUN-SUNOS and SUN-SOLARIS were implied
/// by the environment label SUN.
///
/// - SPICELIB Version 2.0.0, 08-APR-1998 (NJB)
///
/// Module was updated for the PC-LINUX platform.
///
/// - SPICELIB Version 1.1.1, 20-AUG-1996 (WLT)
///
/// Corrected the heading for the $Index_Entries section.
///
/// - SPICELIB Version 1.1.0, 29-FEB-1996 (KRG)
///
/// For the Macintosh, we need to use real Fortran I/O, i.e.,
/// using the first column for carriage control. The change
/// was to move the MAC environment indicator from one
/// environment case to the other.
///
/// Also, for UNIX environments, the parameter STDOUT is no
/// longer defined. This only appears for platforms that
/// need it to differentiate between writing to a file and
/// the terminal screen (standard output), currently: VAX,
/// PC-LAHEY, PC-MS, and MAC.
///
/// - SPICELIB Version 1.0.0, 20-DEC-1995 (KRG) (HAN)
///
/// The routine graduated
///
/// Beta Version 3.1.0, 18-AUG-1995 (KRG)
///
/// Moved the PC-LAHEY environment indicator from one environment
/// case to the other. The Lahey compiler on the PC does treat text
/// files and the standard output device differently.
///
/// Beta Version 3.0.1, 01-JAN-1995 (KRG)
///
/// Moved the description of the input variable UNIT from the $
/// $Detailed_Output section of the header to the correct location
/// in the $Detailed_Input section of the header.
///
/// Beta Version 3.0.0, 11-JUL-1994 (HAN)
///
/// Edited master source file to correct the code for the
/// PC/Microsoft FORTRAN PowerStation environment. It should use
/// the same code as the VAX, not the PC/Lahey Fortran code. Also,
/// code was included for the DEC Alpha OpenVMS/DEC Fortran and
/// Sun Solaris/Sun Fortran environments.
///
/// Beta Version 2.0.0, 30-MAR-1994 (HAN)
///
/// Edited master source file to include new environments:
/// Silicon Graphics IRIX/Silicon Graphics Fortran,
/// DEC Alpha-OSF/1, and NeXT/Absoft Fortran.
///
/// Beta Version 1.0.0, 17-DEC-1992 (KRG)
/// ```
pub fn writln(ctx: &mut SpiceContext, line: &str, unit: i32) -> crate::Result<()> {
WRITLN(line.as_bytes(), unit, ctx.raw_context())?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure WRITLN ( Write a text line to a logical unit )
pub fn WRITLN(LINE: &[u8], UNIT: i32, ctx: &mut Context) -> f2rust_std::Result<()> {
let mut IOSTAT: i32 = 0;
//
// SPICELIB functions
//
//
// Local variables
//
//
// UNIX based fortran implementations typically do not distinguish
// between a text file and the standard output unit, so no leading
// vertical spacing character is required.
//
{
use f2rust_std::{
data::Val,
io::{self, Writer},
};
let mut writer = io::FormattedWriter::new(ctx.io_unit(UNIT)?, None, b"(A)")?;
IOSTAT = io::capture_iostat(|| {
writer.start()?;
writer.write_str(fstr::substr(LINE, 1..=RTRIM(LINE)))?;
writer.finish()?;
Ok(())
})?;
}
//
// Check to see if we got a write error, and signal it if we did.
// Also check in and check out.
//
if (IOSTAT != 0) {
CHKIN(b"WRITLN", ctx)?;
SETMSG(b"Error Writing to file: #. IOSTAT = #.", ctx);
ERRFNM(b"#", UNIT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(FILEWRITEFAILED)", ctx)?;
CHKOUT(b"WRITLN", ctx)?;
return Ok(());
}
Ok(())
}