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 crate::SpiceContext;
use f2rust_std::*;
pub const LBCELL: i32 = -5;
/// Size of a double precision cell
///
/// Return the size (maximum cardinality) of a double precision
/// cell.
///
/// # Required Reading
///
/// * [CELLS](crate::required_reading::cells)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// CELL I Input cell.
///
/// The function returns the size of the input cell.
/// ```
///
/// # Detailed Input
///
/// ```text
/// CELL is a cell.
/// ```
///
/// # Detailed Output
///
/// ```text
/// The function returns the size of (maximum number of elements in)
/// the input cell.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If the input array has invalid cardinality, the error
/// SPICE(INVALIDCARDINALITY) is signaled. SIZEI returns
/// an unspecified value in this case.
///
/// 2) If the input array has invalid size, the error
/// SPICE(INVALIDSIZE) is signaled. SIZEI returns
/// an unspecified value in this case.
/// ```
///
/// # Examples
///
/// ```text
/// The size (SIZE) functions are typically used in conjunction
/// with the cardinality functions to predict (and subsequently
/// avoid) overflows when manipulating cells. In the following
/// example, SIZEI is used to determine whether the integer cell
/// ORIGINAL can be safely copied into the integer cell SAVE before
/// actually attempting the operation. (If ORIGINAL contains more
/// elements than SAVE is capable of holding, then the operation
/// will fail.)
///
/// IF ( CARDI ( ORIGINAL ) .LE. SIZEI ( SAVE ) ) THEN
/// CALL COPYI ( ORIGINAL, SAVE, ERROR )
///
/// ELSE
/// .
/// .
/// END DO
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// C.A. Curzon (JPL)
/// J. Diaz del Rio (ODC Space)
/// H.A. Neilan (JPL)
/// W.L. Taber (JPL)
/// I.M. Underwood (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.2.0, 12-AUG-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard.
///
/// - SPICELIB Version 1.1.0, 17-MAY-1994 (HAN)
///
/// If the value of the function RETURN is .TRUE. upon execution of
/// this module, this function is assigned a default value of
/// either 0, 0.0D0, .FALSE., or blank depending on the type of the
/// function.
///
/// - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)
///
/// Comment section for permuted index source lines was added
/// following the header.
///
/// - SPICELIB Version 1.0.0, 31-JAN-1990 (CAC) (WLT) (IMU) (NJB)
/// ```
///
/// # Revisions
///
/// ```text
/// - Beta Version 2.0.0, 13-MAR-1989 (NJB)
///
/// Check for valid input cell added. The input cell must
/// have valid size and cardinality values.
/// ```
pub fn sized(ctx: &mut SpiceContext, cell: &[f64]) -> crate::Result<i32> {
let ret = SIZED(cell, ctx.raw_context())?;
ctx.handle_errors()?;
Ok(ret)
}
//$Procedure SIZED ( Size of a double precision cell )
pub fn SIZED(CELL: &[f64], ctx: &mut Context) -> f2rust_std::Result<i32> {
let CELL = DummyArray::new(CELL, LBCELL..);
let mut SIZED: i32 = 0;
//
// SPICELIB functions
//
if RETURN(ctx) {
SIZED = 0;
return Ok(SIZED);
} else {
CHKIN(b"SIZED", ctx)?;
}
//
// Set return value, regardless of validity.
//
SIZED = (CELL[-1] as i32);
//
// Squeal if something is awry.
//
if ((CELL[-1] as i32) < 0) {
SETMSG(b"Invalid cell size. The size was #.", ctx);
ERRINT(b"#", (CELL[-1] as i32), ctx);
SIGERR(b"SPICE(INVALIDSIZE)", ctx)?;
CHKOUT(b"SIZED", ctx)?;
return Ok(SIZED);
} else if ((CELL[0] as i32) < 0) {
SETMSG(b"Invalid cell cardinality. The cardinality was #.", ctx);
ERRINT(b"#", (CELL[0] as i32), ctx);
SIGERR(b"SPICE(INVALIDCARDINALITY)", ctx)?;
CHKOUT(b"SIZED", ctx)?;
return Ok(SIZED);
} else if ((CELL[0] as i32) > (CELL[-1] as i32)) {
SETMSG(b"Invalid cell cardinality; cardinality exceeds cell size. The cardinality was #. The size was #.", ctx);
ERRINT(b"#", (CELL[0] as i32), ctx);
ERRINT(b"#", (CELL[-1] as i32), ctx);
SIGERR(b"SPICE(INVALIDCARDINALITY)", ctx)?;
CHKOUT(b"SIZED", ctx)?;
return Ok(SIZED);
}
CHKOUT(b"SIZED", ctx)?;
Ok(SIZED)
}