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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
/// STAR catalog type 1, load catalog file
///
/// Load SPICE type 1 star catalog and return the catalog's
/// table name.
///
/// # Required Reading
///
/// * [EK](crate::required_reading::ek)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// CATFNM I Catalog file name.
/// TABNAM O Catalog table name.
/// HANDLE O Catalog file handle.
/// ```
///
/// # Detailed Input
///
/// ```text
/// CATFNM is the name of the catalog file.
/// ```
///
/// # Detailed Output
///
/// ```text
/// TABNAM is the name of the table loaded from the catalog
/// file. This name must be provided as an input argument
/// to STCF01 catalog search routine. Multiple catalogs
/// containing the table TABNAM may be loaded. Sets of
/// columns, column names and attributes must be
/// identical through all these files.
///
/// HANDLE is the integer handle of the catalog file.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If the indicated file cannot be opened, an error is signaled
/// by a routine in the call tree of this routine.
///
/// 2) If the indicated file has the wrong architecture version, an
/// error is signaled by a routine in the call tree of this
/// routine.
///
/// 3) If an I/O error occurs while reading the indicated file, the
/// error is signaled by a routine in the call tree of this
/// routine.
///
/// 4) If the catalog file is not a type 1 star catalog file, the
/// error SPICE(BADCATALOGFILE) is signaled.
/// ```
///
/// # Files
///
/// ```text
/// This routine loads a SPICE type 1 star catalog file.
///
/// SPICE type 1 star catalog files MUST contain a single data table.
/// It can occupy a single segment or it can spread across multiple
/// segments. This table MUST include the following columns:
///
/// column name data type units
/// ----------------------------------------------------
/// RA DOUBLE PRECISION DEGREES
/// DEC DOUBLE PRECISION DEGREES
/// RA_SIGMA DOUBLE PRECISION DEGREES
/// DEC_SIGMA DOUBLE PRECISION DEGREES
/// CATALOG_NUMBER INTEGER
/// SPECTRAL_TYPE CHARACTER*(4)
/// VISUAL_MAGNITUDE DOUBLE PRECISION
///
/// Nulls are not allowed in any of the columns.
/// Other columns can also be present in the table but their data
/// will NOT be accessible through STCF01 and STCG01 --
/// the interface used to access data in the catalog. Note
/// that the names and attributes of these additional columns
/// must be identical for all segments containing this table.
/// ```
///
/// # Particulars
///
/// ```text
/// This STCL01 routine is intended to be part of the user
/// interface to the SPICE type 1 star catalog. It loads a
/// SPICE type 1 star catalog file and makes its data available
/// for searches and retrieval.
///
/// Other routines in SPICE type 1 star catalog access family are:
///
/// STCF01 search through the catalog for all stars within
/// a specified RA-DEC rectangle.
///
/// STCG01 retrieve position and characteristics for
/// every single star found.
/// ```
///
/// # Examples
///
/// ```text
/// In the following code fragment, STCL01 is used to load
/// a SPICE type 1 star catalog.
///
/// C
/// C Load catalog file.
/// C
/// CALL STCL01 ( CATFN, TABNAM, HANDLE )
/// C
/// C Search through the loaded catalog.
/// C
/// CALL STCF01 ( TABNAM, RAMIN, RAMAX,
/// . DECMIN, DECMAX, NSTARS )
/// C
/// C Retrieve data for every star that matched the
/// C search criteria.
/// C
/// DO I = 1, NSTARS
///
/// CALL STCG01 ( I, RA, DEC, RASIG, DECSIG,
/// . CATNUM, SPTYPE, VMAG )
///
/// END DO
/// ```
///
/// # Author and Institution
///
/// ```text
/// J. Diaz del Rio (ODC Space)
/// B.V. Semenov (JPL)
/// W.L. Taber (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.2.0, 20-AUG-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard.
///
/// - SPICELIB Version 1.1.0, 18-JUN-1999 (WLT)
///
/// Balanced calls to CHKIN/CHKOUT.
///
/// - SPICELIB Version 1.0.0, 15-MAY-1996 (BVS)
/// ```
pub fn stcl01(
ctx: &mut SpiceContext,
catfnm: &str,
tabnam: &mut str,
handle: &mut i32,
) -> crate::Result<()> {
STCL01(
catfnm.as_bytes(),
fstr::StrBytes::new(tabnam).as_mut(),
handle,
ctx.raw_context(),
)?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure STCL01 ( STAR catalog type 1, load catalog file )
pub fn STCL01(
CATFNM: &[u8],
TABNAM: &mut [u8],
HANDLE: &mut i32,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let mut ISTYP1: bool = false;
let mut ERRMSG = [b' '; 256 as usize];
//
//
// SPICELIB functions
//
//
// Local variables
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
} else {
CHKIN(b"STCL01", ctx)?;
}
//
// Check whether the file is really a type 1 star catalog file.
// If not then signal an error.
//
STCC01(CATFNM, TABNAM, &mut ISTYP1, &mut ERRMSG, ctx)?;
if !ISTYP1 {
SETMSG(
&fstr::concat(b"File # is not type 1 star catalog file.", &ERRMSG),
ctx,
);
ERRCH(b"#", CATFNM, ctx);
SIGERR(b"SPICE(BADCATALOGFILE)", ctx)?;
CHKOUT(b"STCL01", ctx)?;
return Ok(());
}
//
// Load the catalog file with the high level EK loader.
//
EKLEF(CATFNM, HANDLE, ctx)?;
CHKOUT(b"STCL01", ctx)?;
Ok(())
}