Bug Summary

File:test/aim.c
Warning:line 847, column 3
Value stored to 'stat' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name aim.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=none -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -D REVISION=7.7 -I /home/jenkins/workspace/ESP_Stanalizer/LINUX64/CAPS/scan-build/ESP/LINUX64/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-dangling-else -Wno-parentheses -Wno-unused-result -Wno-format-truncation -fdebug-compilation-dir /home/jenkins/workspace/ESP_Stanalizer/LINUX64/CAPS/scan-build/CAPS/test -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /home/jenkins/workspace/ESP_Stanalizer/LINUX64/CAPS/scan-build/scanCAPS/2023-04-27-181024-118559-1 -x c aim.c
1/*
2 * CAPS: Computational Aircraft Prototype Syntheses
3 *
4 * AIM excerciser -- uses testingAIM
5 *
6 * * Copyright 2014-2023, Massachusetts Institute of Technology
7 * Licensed under The GNU Lesser General Public License, version 2.1
8 * See http://www.opensource.org/licenses/lgpl-2.1.php
9 *
10 */
11
12//#define VIEWER
13//#define DUP
14//#define CYCLIC
15//#define NEWCSM
16
17#include "caps.h"
18#include <string.h>
19
20#ifdef VIEWER
21
22#include <unistd.h> // usleep
23
24#define NCOLOR 256
25
26#ifdef WIN32
27#ifndef WIN32_LEAN_AND_MEAN
28#define WIN32_LEAN_AND_MEAN
29#endif
30#include <winsock2.h>
31#endif
32
33#include "wsserver.h"
34#ifdef WIN32
35#define snprintf _snprintf
36#endif
37
38static int scalar = -1, pending = 0;
39
40static float cols[NCOLOR*3] =
41{ 0.0000, 0.0000, 1.0000, 0.0000, 0.0157, 1.0000,
42 0.0000, 0.0314, 1.0000, 0.0000, 0.0471, 1.0000,
43 0.0000, 0.0627, 1.0000, 0.0000, 0.0784, 1.0000,
44 0.0000, 0.0941, 1.0000, 0.0000, 0.1098, 1.0000,
45 0.0000, 0.1255, 1.0000, 0.0000, 0.1412, 1.0000,
46 0.0000, 0.1569, 1.0000, 0.0000, 0.1725, 1.0000,
47 0.0000, 0.1882, 1.0000, 0.0000, 0.2039, 1.0000,
48 0.0000, 0.2196, 1.0000, 0.0000, 0.2353, 1.0000,
49 0.0000, 0.2510, 1.0000, 0.0000, 0.2667, 1.0000,
50 0.0000, 0.2824, 1.0000, 0.0000, 0.2980, 1.0000,
51 0.0000, 0.3137, 1.0000, 0.0000, 0.3294, 1.0000,
52 0.0000, 0.3451, 1.0000, 0.0000, 0.3608, 1.0000,
53 0.0000, 0.3765, 1.0000, 0.0000, 0.3922, 1.0000,
54 0.0000, 0.4078, 1.0000, 0.0000, 0.4235, 1.0000,
55 0.0000, 0.4392, 1.0000, 0.0000, 0.4549, 1.0000,
56 0.0000, 0.4706, 1.0000, 0.0000, 0.4863, 1.0000,
57 0.0000, 0.5020, 1.0000, 0.0000, 0.5176, 1.0000,
58 0.0000, 0.5333, 1.0000, 0.0000, 0.5490, 1.0000,
59 0.0000, 0.5647, 1.0000, 0.0000, 0.5804, 1.0000,
60 0.0000, 0.5961, 1.0000, 0.0000, 0.6118, 1.0000,
61 0.0000, 0.6275, 1.0000, 0.0000, 0.6431, 1.0000,
62 0.0000, 0.6588, 1.0000, 0.0000, 0.6745, 1.0000,
63 0.0000, 0.6902, 1.0000, 0.0000, 0.7059, 1.0000,
64 0.0000, 0.7216, 1.0000, 0.0000, 0.7373, 1.0000,
65 0.0000, 0.7529, 1.0000, 0.0000, 0.7686, 1.0000,
66 0.0000, 0.7843, 1.0000, 0.0000, 0.8000, 1.0000,
67 0.0000, 0.8157, 1.0000, 0.0000, 0.8314, 1.0000,
68 0.0000, 0.8471, 1.0000, 0.0000, 0.8627, 1.0000,
69 0.0000, 0.8784, 1.0000, 0.0000, 0.8941, 1.0000,
70 0.0000, 0.9098, 1.0000, 0.0000, 0.9255, 1.0000,
71 0.0000, 0.9412, 1.0000, 0.0000, 0.9569, 1.0000,
72 0.0000, 0.9725, 1.0000, 0.0000, 0.9882, 1.0000,
73 0.0000, 1.0000, 0.9961, 0.0000, 1.0000, 0.9804,
74 0.0000, 1.0000, 0.9647, 0.0000, 1.0000, 0.9490,
75 0.0000, 1.0000, 0.9333, 0.0000, 1.0000, 0.9176,
76 0.0000, 1.0000, 0.9020, 0.0000, 1.0000, 0.8863,
77 0.0000, 1.0000, 0.8706, 0.0000, 1.0000, 0.8549,
78 0.0000, 1.0000, 0.8392, 0.0000, 1.0000, 0.8235,
79 0.0000, 1.0000, 0.8078, 0.0000, 1.0000, 0.7922,
80 0.0000, 1.0000, 0.7765, 0.0000, 1.0000, 0.7608,
81 0.0000, 1.0000, 0.7451, 0.0000, 1.0000, 0.7294,
82 0.0000, 1.0000, 0.7137, 0.0000, 1.0000, 0.6980,
83 0.0000, 1.0000, 0.6824, 0.0000, 1.0000, 0.6667,
84 0.0000, 1.0000, 0.6510, 0.0000, 1.0000, 0.6353,
85 0.0000, 1.0000, 0.6196, 0.0000, 1.0000, 0.6039,
86 0.0000, 1.0000, 0.5882, 0.0000, 1.0000, 0.5725,
87 0.0000, 1.0000, 0.5569, 0.0000, 1.0000, 0.5412,
88 0.0000, 1.0000, 0.5255, 0.0000, 1.0000, 0.5098,
89 0.0000, 1.0000, 0.4941, 0.0000, 1.0000, 0.4784,
90 0.0000, 1.0000, 0.4627, 0.0000, 1.0000, 0.4471,
91 0.0000, 1.0000, 0.4314, 0.0000, 1.0000, 0.4157,
92 0.0000, 1.0000, 0.4000, 0.0000, 1.0000, 0.3843,
93 0.0000, 1.0000, 0.3686, 0.0000, 1.0000, 0.3529,
94 0.0000, 1.0000, 0.3373, 0.0000, 1.0000, 0.3216,
95 0.0000, 1.0000, 0.3059, 0.0000, 1.0000, 0.2902,
96 0.0000, 1.0000, 0.2745, 0.0000, 1.0000, 0.2588,
97 0.0000, 1.0000, 0.2431, 0.0000, 1.0000, 0.2275,
98 0.0000, 1.0000, 0.2118, 0.0000, 1.0000, 0.1961,
99 0.0000, 1.0000, 0.1804, 0.0000, 1.0000, 0.1647,
100 0.0000, 1.0000, 0.1490, 0.0000, 1.0000, 0.1333,
101 0.0000, 1.0000, 0.1176, 0.0000, 1.0000, 0.1020,
102 0.0000, 1.0000, 0.0863, 0.0000, 1.0000, 0.0706,
103 0.0000, 1.0000, 0.0549, 0.0000, 1.0000, 0.0392,
104 0.0000, 1.0000, 0.0235, 0.0000, 1.0000, 0.0078,
105 0.0078, 1.0000, 0.0000, 0.0235, 1.0000, 0.0000,
106 0.0392, 1.0000, 0.0000, 0.0549, 1.0000, 0.0000,
107 0.0706, 1.0000, 0.0000, 0.0863, 1.0000, 0.0000,
108 0.1020, 1.0000, 0.0000, 0.1176, 1.0000, 0.0000,
109 0.1333, 1.0000, 0.0000, 0.1490, 1.0000, 0.0000,
110 0.1647, 1.0000, 0.0000, 0.1804, 1.0000, 0.0000,
111 0.1961, 1.0000, 0.0000, 0.2118, 1.0000, 0.0000,
112 0.2275, 1.0000, 0.0000, 0.2431, 1.0000, 0.0000,
113 0.2588, 1.0000, 0.0000, 0.2745, 1.0000, 0.0000,
114 0.2902, 1.0000, 0.0000, 0.3059, 1.0000, 0.0000,
115 0.3216, 1.0000, 0.0000, 0.3373, 1.0000, 0.0000,
116 0.3529, 1.0000, 0.0000, 0.3686, 1.0000, 0.0000,
117 0.3843, 1.0000, 0.0000, 0.4000, 1.0000, 0.0000,
118 0.4157, 1.0000, 0.0000, 0.4314, 1.0000, 0.0000,
119 0.4471, 1.0000, 0.0000, 0.4627, 1.0000, 0.0000,
120 0.4784, 1.0000, 0.0000, 0.4941, 1.0000, 0.0000,
121 0.5098, 1.0000, 0.0000, 0.5255, 1.0000, 0.0000,
122 0.5412, 1.0000, 0.0000, 0.5569, 1.0000, 0.0000,
123 0.5725, 1.0000, 0.0000, 0.5882, 1.0000, 0.0000,
124 0.6039, 1.0000, 0.0000, 0.6196, 1.0000, 0.0000,
125 0.6353, 1.0000, 0.0000, 0.6510, 1.0000, 0.0000,
126 0.6667, 1.0000, 0.0000, 0.6824, 1.0000, 0.0000,
127 0.6980, 1.0000, 0.0000, 0.7137, 1.0000, 0.0000,
128 0.7294, 1.0000, 0.0000, 0.7451, 1.0000, 0.0000,
129 0.7608, 1.0000, 0.0000, 0.7765, 1.0000, 0.0000,
130 0.7922, 1.0000, 0.0000, 0.8078, 1.0000, 0.0000,
131 0.8235, 1.0000, 0.0000, 0.8392, 1.0000, 0.0000,
132 0.8549, 1.0000, 0.0000, 0.8706, 1.0000, 0.0000,
133 0.8863, 1.0000, 0.0000, 0.9020, 1.0000, 0.0000,
134 0.9176, 1.0000, 0.0000, 0.9333, 1.0000, 0.0000,
135 0.9490, 1.0000, 0.0000, 0.9647, 1.0000, 0.0000,
136 0.9804, 1.0000, 0.0000, 0.9961, 1.0000, 0.0000,
137 1.0000, 0.9882, 0.0000, 1.0000, 0.9725, 0.0000,
138 1.0000, 0.9569, 0.0000, 1.0000, 0.9412, 0.0000,
139 1.0000, 0.9255, 0.0000, 1.0000, 0.9098, 0.0000,
140 1.0000, 0.8941, 0.0000, 1.0000, 0.8784, 0.0000,
141 1.0000, 0.8627, 0.0000, 1.0000, 0.8471, 0.0000,
142 1.0000, 0.8314, 0.0000, 1.0000, 0.8157, 0.0000,
143 1.0000, 0.8000, 0.0000, 1.0000, 0.7843, 0.0000,
144 1.0000, 0.7686, 0.0000, 1.0000, 0.7529, 0.0000,
145 1.0000, 0.7373, 0.0000, 1.0000, 0.7216, 0.0000,
146 1.0000, 0.7059, 0.0000, 1.0000, 0.6902, 0.0000,
147 1.0000, 0.6745, 0.0000, 1.0000, 0.6588, 0.0000,
148 1.0000, 0.6431, 0.0000, 1.0000, 0.6275, 0.0000,
149 1.0000, 0.6118, 0.0000, 1.0000, 0.5961, 0.0000,
150 1.0000, 0.5804, 0.0000, 1.0000, 0.5647, 0.0000,
151 1.0000, 0.5490, 0.0000, 1.0000, 0.5333, 0.0000,
152 1.0000, 0.5176, 0.0000, 1.0000, 0.5020, 0.0000,
153 1.0000, 0.4863, 0.0000, 1.0000, 0.4706, 0.0000,
154 1.0000, 0.4549, 0.0000, 1.0000, 0.4392, 0.0000,
155 1.0000, 0.4235, 0.0000, 1.0000, 0.4078, 0.0000,
156 1.0000, 0.3922, 0.0000, 1.0000, 0.3765, 0.0000,
157 1.0000, 0.3608, 0.0000, 1.0000, 0.3451, 0.0000,
158 1.0000, 0.3294, 0.0000, 1.0000, 0.3137, 0.0000,
159 1.0000, 0.2980, 0.0000, 1.0000, 0.2824, 0.0000,
160 1.0000, 0.2667, 0.0000, 1.0000, 0.2510, 0.0000,
161 1.0000, 0.2353, 0.0000, 1.0000, 0.2196, 0.0000,
162 1.0000, 0.2039, 0.0000, 1.0000, 0.1882, 0.0000,
163 1.0000, 0.1725, 0.0000, 1.0000, 0.1569, 0.0000,
164 1.0000, 0.1412, 0.0000, 1.0000, 0.1255, 0.0000,
165 1.0000, 0.1098, 0.0000, 1.0000, 0.0941, 0.0000,
166 1.0000, 0.0784, 0.0000, 1.0000, 0.0627, 0.0000,
167 1.0000, 0.0471, 0.0000, 1.0000, 0.0314, 0.0000,
168 1.0000, 0.0157, 0.0000, 1.0000, 0.0000, 0.0000 };
169
170#else
171
172extern int caps_outputVertexSet( const capsObj object, const char *filename );
173
174#endif
175
176extern int caps_outputObjects( capsObj problemObj, /*@null@*/ char **stream );
177
178
179void reportStatus(capsObj pobj, const char *info, int status,
180 int nErr, capsErrs *errors)
181{
182 if ((status == CAPS_SUCCESS0) && (nErr != 0))
183 caps_printErrors(NULL((void*)0), nErr, errors);
184 if (status == CAPS_SUCCESS0) return;
185
186 if (nErr != 0) caps_printErrors(NULL((void*)0), nErr, errors);
187 printf(" %s status = %d\n", info, status);
188 if (pobj != NULL((void*)0)) caps_close(pobj, 0, NULL((void*)0));
189 exit(1);
190}
191
192
193#ifdef VIEWER
194
195static void
196spec_col(double scalar, float beg, float end, float *color)
197{
198 int indx;
199 float frac;
200
201 if (beg == end) {
202 color[0] = 0.0;
203 color[1] = 1.0;
204 color[2] = 0.0;
205 } else if (scalar <= beg) {
206 color[0] = cols[0];
207 color[1] = cols[1];
208 color[2] = cols[2];
209 } else if (scalar >= end) {
210 color[0] = cols[3*(NCOLOR-1) ];
211 color[1] = cols[3*(NCOLOR-1)+1];
212 color[2] = cols[3*(NCOLOR-1)+2];
213 } else {
214 frac = (NCOLOR-1) * (scalar - beg) / (end - beg);
215 if (frac < 0) frac = 0;
216 if (frac > NCOLOR-1) frac = NCOLOR-1;
217 indx = frac;
218 frac -= indx;
219 if (indx == NCOLOR-1) {
220 indx--;
221 frac += 1.0;
222 }
223
224 color[0] = frac * cols[3*(indx+1) ] + (1.0-frac) * cols[3*indx ];
225 color[1] = frac * cols[3*(indx+1)+1] + (1.0-frac) * cols[3*indx+1];
226 color[2] = frac * cols[3*(indx-1)+2] + (1.0-frac) * cols[3*indx+2];
227 }
228}
229
230
231static void
232nextScalar(wvContext *cntxt, capsObj vsobj, int index)
233{
234 int i, j, k, l, n, npts, rank, total, stat, nErr;
235 char line[80], *units, *name;
236 float beg, end, *colors;
237 double *data;
238 capsErrs *errors;
239 capsObj dso, link, parent;
240 capsOwn last;
241 enum capsoType type;
242 enum capssType subtype;
243 wvData item;
244
245 stat = caps_size(vsobj, DATASET, NONE, &n, &nErr, &errors);
246 if (stat != CAPS_SUCCESS0) {
247 printf(" caps_size = %d!\n", stat);
248 return;
249 }
250 for (total = i = 0; i < n; i++) {
251 stat = caps_childByIndex(vsobj, DATASET, NONE, i+1, &dso);
252 if (stat != CAPS_SUCCESS0) continue;
253 stat = caps_getData(dso, &npts, &rank, &data, &units, &nErr, &errors);
254 if (stat != CAPS_SUCCESS0) continue;
255 if (npts == 0) continue;
256 total += rank;
257 }
258 if (total == 0) return;
259 if (scalar >= total) scalar = 0;
260
261 for (j = i = 0; i < n; i++) {
262 stat = caps_childByIndex(vsobj, DATASET, NONE, i+1, &dso);
263 if (stat != CAPS_SUCCESS0) continue;
264 stat = caps_getData(dso, &npts, &rank, &data, &units, &nErr, &errors);
265 if (stat != CAPS_SUCCESS0) continue;
266 if (npts == 0) continue;
267 /* get dataset name */
268 stat = caps_info(dso, &name, &type, &subtype, &link, &parent, &last);
269 if (stat != CAPS_SUCCESS0) printf(" caps_info = %d!\n", stat);
270 /* find our scalar */
271 for (k = 0; k < rank; k++, j++) {
272 if (j == scalar) {
273 colors = (float *) malloc(3*npts*sizeof(float));
274 if (colors == NULL((void*)0)) {
275 printf(" Cannot Malloc %d floats!\n", npts);
276 return;
277 }
278
279 /* auto-scale the key */
280 beg = end = data[k];
281 for (l = 1; l < npts; l++) {
282 if (beg > data[rank*l+k]) beg = data[rank*l+k];
283 if (end < data[rank*l+k]) end = data[rank*l+k];
284 }
285
286 /* (re)set the key */
287 snprintf(line, 80, "%s #%d", name, k+1);
288 wv_setKey(cntxt, NCOLOR, cols, beg, end, line);
289
290 /* get the colors to mod the GPrim */
291 for (l = 0; l < npts; l++)
292 spec_col(data[rank*l+k], beg, end, &colors[3*l]);
293 stat = wv_setData(WV_REAL32, npts, (void *) colors, WV_COLORS, &item);
294 if (stat < 0) printf(" wv_setData = %d!\n", stat);
295 stat = wv_modGPrim(cntxt, index, 1, &item);
296 if (stat < 0) printf(" wv_modGPrim = %d!\n", stat);
297
298 free(colors);
299 pending = 0;
300 break;
301 }
302 }
303 if (pending == 0) break;
304 }
305
306}
307
308
309void browserMessage(/*@unused@*/ void *uPtr, /*@unused@*/ void *wsi,
310 char *text, /*@unused@*/ int lena)
311{
312 if (strcmp(text,"next") == 0) {
313 if (pending != 0) return;
314 scalar++;
315 pending = 1;
316 }
317}
318
319#endif
320
321
322int main(int argc, char *argv[])
323{
324 int i, j, n, stat, major, minor, nFields, *ranks, *fInOut, dirty;
325 int len, rank, nIn, nOut, exe, nErr;
326 int nGtris, *Gtris, nDtris, *Dtris, nGsegs, nDsegs;
327 char *apath, **fnames, *name, *units, *unitSys, *lunits;
328 char *fname, *intents, *tname = "Interface"; /* "Top" */
329 char *stream=NULL((void*)0);
330 double *data, eight = 8.0, startup[3] = {0.0, 0.0, 0.0};
331 capsObj pobj, aobj, bobj, dobj1, dobj2, obj, link, parent, vobj = NULL((void*)0);
332 capsObj paobj, dobj1a, paramObj, *objs, vsobj = NULL((void*)0);
333 const char *root, *phrase = "Child Execute", *start = "Starting";
334#ifdef CYCLIC
335 capsObj dobj2a;
336#endif
337 capsValue value;
338 capsErrs *errors;
339 capsOwn current;
340 ego body;
341 capsTuple *tuple;
342 enum capsoType type;
343 enum capssType subtype;
344#ifdef VIEWER
345 int index, *segs;
346 char gpname[33], *startapp;
347 double box[6], size;
348 capsObj *dsets;
349 wvData items[5];
350 wvContext *cntxt;
351 float focus[4], color[3];
352 float eye[3] = {0.0, 0.0, 7.0};
353 float center[3] = {0.0, 0.0, 0.0};
354 float up[3] = {0.0, 1.0, 0.0};
355
356 /* get our starting application line
357 *
358 * for example on a Mac:
359 * setenv wvStart "open -a /Applications/Firefox.app ../client/wv.html"
360 */
361 startapp = getenv("wvStart");
362#endif
363
364#ifdef NEWCSM
365 if (argc != 1) {
366 printf(" usage: aim!\n");
367 return 1;
368 }
369
370 j = oPNewCSM; /* new start */
371 stat = caps_phaseState("aimTest", "Start", &n);
372 if (stat == CAPS_SUCCESS0) {
373 if (n == 0) {
374 j = oContinue; /* a continuation */
375 }
376 }
377 stat = caps_open("aimTest", "Start", j, NULL((void*)0), 1, &pobj, &nErr, &errors);
378#else
379 if (argc != 2) {
380 printf(" usage: aim filename!\n");
381 return 1;
382 }
383
384 j = oFileName; /* new start */
385 stat = caps_phaseState("aimTest", NULL((void*)0), &n);
386 if (stat == CAPS_SUCCESS0) {
387 if (n == 0) {
388 j = oContinue; /* a continuation */
389 }
390 }
391 stat = caps_open("aimTest", NULL((void*)0), j, argv[1], 1, &pobj, &nErr, &errors);
392#endif
393 reportStatus(NULL((void*)0), "caps_open", stat, nErr, errors);
394
395 stat = caps_getRootPath(pobj, &root);
396 if (stat == CAPS_SUCCESS0) printf(" Root Path = %s\n", root);
397
398 /* do the query functions */
399 stat = caps_queryAnalysis(pobj, "testingAIM", &nIn, &nOut, &exe);
400 printf(" caps_queryAnalysis = %d %d %d %d\n", stat, nIn, nOut, exe);
401 if (stat == CAPS_SUCCESS0) {
402 for (i = 1; i <= nIn; i++) {
403 stat = caps_getInput(pobj, "testingAIM", i, &name, &value);
404 printf(" in %d: %s %d\n", i, name, stat);
405 if (stat == CAPS_SUCCESS0) {
406 EG_free(name);
407 caps_freeValue(&value);
408 }
409 }
410 for (i = 1; i <= nOut; i++) {
411 stat = caps_getOutput(pobj, "testingAIM", i, &name, &value);
412 printf(" out %d: %s %d\n", i, name, stat);
413 if (stat == CAPS_SUCCESS0) {
414 EG_free(name);
415 caps_freeValue(&value);
416 }
417 }
418 }
419 printf("\n");
420
421 stat = caps_intentPhrase(pobj, 1, &start);
422 reportStatus(pobj, "intentPhrase start", stat, nErr, errors);
423
424 /* make some Parameter & User Value Objects */
425 stat = caps_makeValue(pobj, "ParamName", PARAMETER, Double, 1, 1, startup,
426 NULL((void*)0), NULL((void*)0), &paramObj);
427 reportStatus(pobj, "caps_makeValue PN", stat, 0, NULL((void*)0));
428 i = 99;
429 stat = caps_makeValue(pobj, "Param", PARAMETER, Integer, 1, 1, &i, NULL((void*)0), NULL((void*)0),
430 &obj);
431 reportStatus(pobj, "caps_makeValue P", stat, 0, NULL((void*)0));
432 i = 1;
433 stat = caps_makeValue(pobj, "UserName", USER, Integer, 1, 1, &i, NULL((void*)0), NULL((void*)0),
434 &obj);
435 reportStatus(pobj, "caps_makeValue U1", stat, 0, NULL((void*)0));
436 i = 2;
437 stat = caps_makeValue(pobj, "UserName", USER, Integer, 1, 1, &i, NULL((void*)0), NULL((void*)0),
438 &obj);
439 reportStatus(pobj, "caps_makeValue U2", stat, 0, NULL((void*)0));
440
441 /* set a GeomIn */
442 stat = caps_childByName(pobj, VALUE, GEOMETRYIN, "num", &obj,
443 &nErr, &errors);
444 reportStatus(pobj, "childByName for num", stat, nErr, errors);
445 stat = caps_setValue(obj, Double, 1, 1, &eight, NULL((void*)0), NULL((void*)0), &nErr, &errors);
446 reportStatus(pobj, "caps_setValue", stat, nErr, errors);
447
448 /* make a link */
449 stat = caps_childByName(pobj, VALUE, GEOMETRYIN, "unused", &obj,
450 &nErr, &errors);
451 reportStatus(pobj, "childByName for unused", stat, nErr, errors);
452 stat = caps_linkValue(paramObj, Copy, obj, &nErr, &errors);
453 reportStatus(pobj, "caps_linkValue", stat, nErr, errors);
454
455 /* make a faux parent analysis object */
456 exe = 0;
457 stat = caps_makeAnalysis(pobj, "testingAIM", NULL((void*)0), "m", "parent", &exe,
458 &paobj, &nErr, &errors);
459 reportStatus(pobj, "caps_makeAnalysis 0", stat, nErr, errors);
460
461 /* communicate (via Backdoor) */
462 stat = caps_AIMbackdoor(paobj, "Input String", &name);
463 reportStatus(pobj, "caps_AIMbackdoor", stat, 0, NULL((void*)0));
464 printf(" Backdoor return string = %s\n", name);
465 EG_free(name);
466
467#ifdef DUP
468 stat = caps_dupAnalysis(paobj, NULL((void*)0), &aobj);
469 reportStatus(pobj, "caps_dupAnalysis", stat, 0, NULL((void*)0));
470#else
471 exe = 0;
472 stat = caps_makeAnalysis(pobj, "testingAIM", NULL((void*)0), NULL((void*)0), "child", &exe,
473 &aobj, &nErr, &errors);
474 reportStatus(pobj, "caps_makeAnalysis 1", stat, nErr, errors);
475#endif
476
477 stat = caps_info(pobj, &name, &type, &subtype, &link, &parent, &current);
478 reportStatus(pobj, "caps_info", stat, 0, NULL((void*)0));
479
480 /* reset the Tuple on the child analysis */
481 stat = caps_childByName(aobj, VALUE, ANALYSISIN, "table", &obj, &nErr, &errors);
482 reportStatus(pobj, "childByName for table", stat, nErr, errors);
483
484 tuple = (capsTuple *) EG_alloc(3*sizeof(capsTuple));
485 if (tuple != NULL((void*)0)) {
486 tuple[0].name = EG_strdup("Entry1");
487 tuple[1].name = EG_strdup("Entry2");
488 tuple[2].name = EG_strdup("Entry3");
489 tuple[0].value = EG_strdup("newValue1");
490 tuple[1].value = EG_strdup("newValue2");
491 tuple[2].value = EG_strdup("newValue3");
492 stat = caps_setValue(obj, Tuple, 1, 3, tuple, NULL((void*)0), NULL((void*)0), &nErr, &errors);
493 reportStatus(pobj, "caps_setValue", stat, nErr, errors);
494 for (i = 0; i < 3; i++) {
495 EG_free(tuple[i].name);
496 EG_free(tuple[i].value);
497 }
498 EG_free(tuple);
499 }
500
501 /* link parent output to child input */
502 i = 0;
503 stat = caps_childByName(paobj, VALUE, ANALYSISOUT, "tessOut", &dobj1, &nErr,
504 &errors);
505 if (stat != CAPS_SUCCESS0) {
506 printf(" childByName for tessOut = %d\n", stat);
507 i++;
508 }
509 stat = caps_childByName(aobj, VALUE, ANALYSISIN, "tessIn", &dobj2, &nErr,
510 &errors);
511 if (stat != CAPS_SUCCESS0) {
512 printf(" childByName for tessIn = %d\n", stat);
513 i++;
514 }
515 if (i == 0) {
516 stat = caps_linkValue(dobj1, Copy, dobj2, &nErr, &errors);
517 reportStatus(pobj, "caps_linkValue", stat, nErr, errors);
518 } else {
519 caps_close(pobj, 0, NULL((void*)0));
520 return CAPS_NOTFOUND-303;
521 }
522
523 /* make a bound */
524 stat = caps_makeBound(pobj, 2, tname, &bobj);
525 reportStatus(pobj, "caps_makeBound", stat, 0, NULL((void*)0));
526 stat = caps_makeVertexSet(bobj, aobj, NULL((void*)0), &vobj, &nErr, &errors);
527 reportStatus(pobj, "caps_makeVertexSet child", stat, nErr, errors);
528 stat = caps_makeDataSet(vobj, "scalar", FieldIn, 0, &dobj1, &nErr, &errors);
529 reportStatus(pobj, "caps_makeDataSet scalar", stat, nErr, errors);
530 stat = caps_initDataSet(dobj1, 1, startup, &nErr, &errors);
531 reportStatus(pobj, "caps_initDataSet", stat, nErr, errors);
532/*
533 stat = caps_makeDataSet(vobj, "vector", Analysis, 3, &dobj2,
534 &nErr, &errors);
535 reportStatus(pobj, "caps_makeDataSet vector", stat, nErr, errors);
536*/
537#ifdef CYCLIC
538 stat = caps_makeDataSet(vobj, "vector", Interpolate, 3, &dobj2a,
539 &nErr, &errors);
540 reportStatus(pobj, "caps_makeDataSet vectorI", stat, nErr, errors);
541#endif
542 /* Vertex Set on Parent AIM */
543 stat = caps_makeVertexSet(bobj, paobj, NULL((void*)0), &vsobj, &nErr, &errors);
544 reportStatus(pobj, "caps_makeVertexSet parent", stat, nErr, errors);
545 stat = caps_makeDataSet(vsobj, "scalar", FieldOut, 0, &dobj1a,
546 &nErr, &errors);
547 reportStatus(pobj, "caps_makeDataSet scalarP", stat, nErr, errors);
548 stat = caps_makeDataSet(vsobj, "vector", FieldOut, 0, &dobj2,
549 &nErr, &errors);
550 reportStatus(pobj, "caps_makeDataSet vector", stat, nErr, errors);
551
552 stat = caps_linkDataSet(dobj1a, Conserve, dobj1, &nErr, &errors);
553 reportStatus(pobj, "caps_linkDataSet", stat, nErr, errors);
554
555 stat = caps_closeBound(bobj);
556 reportStatus(pobj, "caps_closeBound", stat, 0, NULL((void*)0));
557
558 /* get analysis info */
559 stat = caps_analysisInfo(aobj, &apath, &unitSys, &major, &minor, &intents,
560 &nFields, &fnames, &ranks, &fInOut, &exe, &dirty);
561 reportStatus(pobj, "caps_analysisInfo", stat, 0, NULL((void*)0));
562 printf("\n Intent = %s", intents);
563 printf("\n APath = %s", apath);
564 printf("\n UnitSys = %s", unitSys);
565 printf("\n Exec = %d", exe);
566 printf("\n Fields =");
567 for (i = 0; i < nFields; i++)
568 printf(" %s (%d %d)", fnames[i], ranks[i], fInOut[i]);
569 printf("\n Dirty = %d\n", dirty);
570
571 /* do the analysis */
572 if (dirty != 0) {
573
574 stat = caps_dirtyAnalysis(pobj, &n, &objs);
575 if (objs != NULL((void*)0)) EG_free(objs);
576 reportStatus(pobj, "caps_dirtyAnalysisP", stat, 0, NULL((void*)0));
577 printf("\n Problem: # Dirty Analyses = %d!\n", n);
578 stat = caps_dirtyAnalysis(bobj, &n, &objs);
579 if (objs != NULL((void*)0)) EG_free(objs);
580 reportStatus(pobj, "caps_dirtyAnalysisB", stat, 0, NULL((void*)0));
581 printf(" Bound: # Dirty Analyses = %d!\n", n);
582 stat = caps_dirtyAnalysis(paobj, &n, &objs);
583 if (objs != NULL((void*)0)) EG_free(objs);
584 reportStatus(pobj, "caps_dirtyAnalysisPA", stat, 0, NULL((void*)0));
585 printf(" Analys0: # Dirty Analyses = %d!\n", n);
586 stat = caps_dirtyAnalysis(aobj, &n, &objs);
587 if (objs != NULL((void*)0)) EG_free(objs);
588 reportStatus(pobj, "caps_dirtyAnalysisCA", stat, 0, NULL((void*)0));
589 printf(" Analys1: # Dirty Analyses = %d!\n", n);
590
591 /* just do the parent */
592#ifdef CYCLIC
593 if (dobj1a != NULL((void*)0)) {
594 /* we need the scalar */
595 stat = caps_getData(dobj1a, &len, &rank, &data, &units, &nErr, &errors);
596 reportStatus(pobj, "caps_getData", stat, nErr, errors);
597 if (len == 1) {
598 printf(" startup with scalar = %lf\n", data[0]);
599 } else {
600 printf(" startup with %d scalars!\n", len);
601 }
602 }
603#endif
604 stat = caps_execute(paobj, &n, &nErr, &errors);
605 reportStatus(pobj, "caps_execute parent", stat, nErr, errors);
606 printf(" After Execute on Parent\n");
607
608 stat = caps_dirtyAnalysis(pobj, &n, &objs);
609 if (objs != NULL((void*)0)) EG_free(objs);
610 reportStatus(pobj, "caps_dirtyAnalysisP", stat, 0, NULL((void*)0));
611 printf("\n Problem: # Dirty Analyses = %d!\n", n);
612 stat = caps_dirtyAnalysis(bobj, &n, &objs);
613 if (objs != NULL((void*)0)) EG_free(objs);
614 reportStatus(pobj, "caps_dirtyAnalysisB", stat, 0, NULL((void*)0));
615 printf(" Bound: # Dirty Analyses = %d!\n", n);
616 stat = caps_dirtyAnalysis(paobj, &n, &objs);
617 if (objs != NULL((void*)0)) EG_free(objs);
618 reportStatus(pobj, "caps_dirtyAnalysisPA", stat, 0, NULL((void*)0));
619 printf(" Analys0: # Dirty Analyses = %d!\n", n);
620 stat = caps_dirtyAnalysis(aobj, &n, &objs);
621 if (objs != NULL((void*)0)) EG_free(objs);
622 reportStatus(pobj, "caps_dirtyAnalysisCA", stat, 0, NULL((void*)0));
623 printf(" Analys1: # Dirty Analyses = %d!\n", n);
624
625#ifdef CYCLIC
626 if (dobj2a != NULL((void*)0)) {
627 /* we need the vector */
628 stat = caps_getData(dobj2a, &len, &rank, &data, &units, &nErr, &errors);
629 reportStatus(pobj, "caps_getData2", stat, nErr, errors);
630 if (len == 1) {
631 printf(" startup with vector = %lf %lf %lf\n",
632 data[0], data[1], data[2]);
633 } else {
634 printf(" startup with %d vectors\n", len);
635 }
636 }
637#endif
638 stat = caps_intentPhrase(pobj, 1, &phrase);
639 reportStatus(pobj, "intentPhrase execute", stat, nErr, errors);
640
641 stat = caps_execute(aobj, &n, &nErr, &errors);
642 reportStatus(pobj, "caps_execute child", stat, nErr, errors);
643
644 stat = caps_analysisInfo(aobj, &apath, &unitSys, &major, &minor, &intents,
645 &nFields, &fnames, &ranks, &fInOut, &exe, &dirty);
646 reportStatus(pobj, "caps_analysisInfo child", stat, nErr, errors);
647 printf("\n Dirty = %d\n", dirty);
648
649 stat = caps_dirtyAnalysis(pobj, &n, &objs);
650 if (objs != NULL((void*)0)) EG_free(objs);
651 reportStatus(pobj, "caps_dirtyAnalysisP", stat, 0, NULL((void*)0));
652 printf("\n Problem: # Dirty Analyses = %d!\n", n);
653 stat = caps_dirtyAnalysis(bobj, &n, &objs);
654 if (objs != NULL((void*)0)) EG_free(objs);
655 reportStatus(pobj, "caps_dirtyAnalysisB", stat, 0, NULL((void*)0));
656 printf(" Bound: # Dirty Analyses = %d!\n", n);
657 stat = caps_dirtyAnalysis(paobj, &n, &objs);
658 if (objs != NULL((void*)0)) EG_free(objs);
659 reportStatus(pobj, "caps_dirtyAnalysisPA", stat, 0, NULL((void*)0));
660 printf(" Analys0: # Dirty Analyses = %d!\n", n);
661 stat = caps_dirtyAnalysis(aobj, &n, &objs);
662 if (objs != NULL((void*)0)) EG_free(objs);
663 reportStatus(pobj, "caps_dirtyAnalysisCA", stat, 0, NULL((void*)0));
664 printf(" Analys1: # Dirty Analyses = %d!\n", n);
665 }
666
667 /* look at the bodies and report units */
668 printf("\n");
669 stat = caps_size(pobj, BODIES, NONE, &n, &nErr, &errors);
670 reportStatus(pobj, "caps_size", stat, 0, NULL((void*)0));
671 for (i = 1; i <= n; i++) {
672 stat = caps_bodyByIndex(pobj, i, &body, &lunits);
673 reportStatus(pobj, "caps_bodyByIndex", stat, 0, NULL((void*)0));
674 printf(" Body %d has length units = %s\n", i, lunits);
675 }
676 len = strlen(root) + 15;
677 fname = malloc((len+1)*sizeof(char));
678 if (fname != NULL((void*)0)) {
679#ifdef WIN32
680 snprintf(fname, len, "%s\\testing.egads", root);
681#else
682 snprintf(fname, len, "%s/testing.egads", root);
683#endif
684 stat = caps_writeGeometry(pobj, 1, fname, &nErr, &errors);
685 reportStatus(pobj, "caps_writeGeometry", stat, nErr, errors);
686 free(fname);
687 }
688
689 /* output what we have */
690 printf("\n");
691 caps_printObjects(pobj, pobj, 0);
692 printf("\n");
693
694#ifndef VIEWER
695 if (dobj1 != NULL((void*)0)) {
696 stat = caps_getData(dobj1, &len, &rank, &data, &units, &nErr, &errors);
697 if (stat != CAPS_SUCCESS0) {
698 printf(" CAPS Error: caps_getData (Interp/Conserve) = %d!\n", stat);
699 } else {
700 if (rank == 1) {
701 for (i = 0; i < len; i+=7) {
702 printf(" %4d:", i+1);
703 for (j = 0; j < 7; j++)
704 if (i+j < len) printf(" %lf", data[i+j]);
705 printf("\n");
706 }
707 } else if (rank == 3) {
708 for (i = 0; i < len; i++)
709 printf(" %4d: %lf %lf %lf\n",
710 i+1, data[3*i ], data[3*i+1], data[3*i+2]);
711 }
712 }
713 }
714/*
715 caps_outputVertexSet(vobj, "source.vs");
716 caps_outputVertexSet(vsobj, "destin.vs");
717 */
718 stat = caps_getTriangles(vobj, &nGtris, &Gtris, &nGsegs, NULL((void*)0),
719 &nDtris, &Dtris, &nDsegs, NULL((void*)0));
720 printf(" source getTriangles = %d, nGtris = %d, nGsegs = %d, Ds = %d %d\n",
721 stat, nGtris, nGsegs, nDtris, nDsegs);
722 EG_free(Gtris);
723 EG_free(Dtris);
724 stat = caps_getTriangles(vsobj, &nGtris, &Gtris, &nGsegs, NULL((void*)0),
725 &nDtris, &Dtris, &nDsegs, NULL((void*)0));
726 printf(" destin getTriangles = %d, nGtris = %d, nGsegs = %d, Ds = %d %d\n",
727 stat, nGtris, nGsegs, nDtris, nDsegs);
728 EG_free(Gtris);
729 EG_free(Dtris);
730#endif
731
732#ifdef CYCLIC
733 stat = caps_dirtyAnalysis(pobj, &n, &objs);
734 if (stat != CAPS_SUCCESS0) {
735 printf(" caps_dirtyAnalysis = %d\n", stat);
736 caps_close(pobj, 0, NULL((void*)0));
737 return stat;
738 }
739 if (objs != NULL((void*)0)) EG_free(objs);
740 printf("\n Problem: # Dirty Analyses = %d!\n\n", n);
741#endif
742
743#ifdef VIEWER
744 if ((vobj != NULL((void*)0)) && (bobj != NULL((void*)0))) {
745 stat = caps_getDataSets(bobj, "xyz", &n, &dsets);
746 printf(" # xyz dsets = %d, stat = %d\n", n, stat);
747 stat = caps_getData(dsets[0], &len, &rank, &data, &units, &nErr, &errors);
748 printf(" len of verts = %d (rank = %d) stat = %d\n", len, rank, stat);
749 box[0] = box[3] = data[0];
750 box[1] = box[4] = data[1];
751 box[2] = box[5] = data[2];
752 for (i = 1; i < len; i++) {
753 if (data[3*i ] < box[0]) box[0] = data[3*i ];
754 if (data[3*i ] > box[3]) box[3] = data[3*i ];
755 if (data[3*i+1] < box[1]) box[1] = data[3*i+1];
756 if (data[3*i+1] > box[4]) box[4] = data[3*i+1];
757 if (data[3*i+2] < box[2]) box[2] = data[3*i+2];
758 if (data[3*i+2] > box[5]) box[5] = data[3*i+2];
759 }
760 size = box[3]-box[0];
761 if (size < box[4]-box[1]) size = box[4]-box[1];
762 if (size < box[5]-box[2]) size = box[5]-box[2];
763 focus[0] = 0.5*(box[0]+box[3]);
764 focus[1] = 0.5*(box[1]+box[4]);
765 focus[2] = 0.5*(box[2]+box[5]);
766 focus[3] = size;
767 stat = caps_getTriangles(vobj, &nGtris, &Gtris, &nGsegs, NULL((void*)0),
768 &nDtris, &Dtris, &nDsegs, NULL((void*)0));
769 printf(" getTriangles = %d, nGtris = %d, nGsegs = %d, Ds = %d %d\n",
770 stat, nGtris, nGsegs, nDtris, nDsegs);
771 if (nGtris > 0) {
772 /* create the WebViewer context */
773 cntxt = wv_createContext(1, 30.0, 1.0, 10.0, eye, center, up);
774 if (cntxt == NULL((void*)0)) {
775 printf(" failed to create wvContext!\n");
776 } else {
777 snprintf(gpname, 33, "Body %d Face %s", 0, tname);
778 stat = wv_setData(WV_REAL64, len, (void *) data, WV_VERTICES,
779 &items[0]);
780 if (stat < 0) printf(" wv_setData = %d for %s/item 0!\n", i, gpname);
781 wv_adjustVerts(&items[0], focus);
782 stat = wv_setData(WV_INT32, 3*nGtris, (void *) Gtris, WV_INDICES,
783 &items[1]);
784 if (stat < 0) printf(" wv_setData = %d for %s/item 1!\n", i, gpname);
785 color[0] = 1.0;
786 color[1] = 0.0;
787 color[2] = 0.0;
788 stat = wv_setData(WV_REAL32, 1, (void *) color, WV_COLORS, &items[2]);
789 if (stat < 0) printf(" wv_setData = %d for %s/item 2!\n", i, gpname);
790 color[0] = color[1] = color[2] = 0.0;
791 stat = wv_setData(WV_REAL32, 1, (void *) color, WV_LCOLOR, &items[3]);
792 if (stat < 0) printf(" wv_setData = %d for %s/item 3!\n", i, gpname);
793 segs = (int *) malloc(6*nGtris*sizeof(int));
794 if (segs == NULL((void*)0)) {
795 printf(" Can not allocate %d Sides!\n", 6*nGtris);
796 } else {
797 for (j = 0; j < nGtris; j++) {
798 segs[6*j ] = Gtris[3*j ];
799 segs[6*j+1] = Gtris[3*j+1];
800 segs[6*j+2] = Gtris[3*j+1];
801 segs[6*j+3] = Gtris[3*j+2];
802 segs[6*j+4] = Gtris[3*j+2];
803 segs[6*j+5] = Gtris[3*j ];
804 }
805 stat = wv_setData(WV_INT32, 6*nGtris, (void *) segs, WV_LINDICES,
806 &items[4]);
807 if (stat < 0) printf(" wv_setData = %d for %s/item 4!\n", i, gpname);
808 free(segs);
809 }
810 index = wv_addGPrim(cntxt, gpname, WV_TRIANGLE,
811 WV_ON|WV_ORIENTATION|WV_SHADING, 5, items);
812 if (index < 0)
813 printf(" wv_addGPrim = %d for %s!\n", index, gpname);
814
815 stat = 0;
816 wv_setCallBack(cntxt, browserMessage);
817 if (wv_startServer(7681, NULL((void*)0), NULL((void*)0), NULL((void*)0), 0, cntxt) == 0) {
818
819 /* single valid server -- stay alive as long as the clients are */
820 while (wv_statusServer(0)) {
821 if (stat == 0) {
822 if (startapp != NULL((void*)0)) system(startapp);
823 stat++;
824 }
825 usleep(100000);
826 /* do we have any pending requests? */
827 if (pending != 0) {
828 if (wv_handShake(cntxt) != 1)
829 printf(" Error: HandShake out of Sync1!\n");
830
831 nextScalar(cntxt, vobj, index);
832
833 if (wv_handShake(cntxt) != 0)
834 printf(" Error: HandShake out of Sync0!\n");
835 }
836 }
837 }
838 wv_cleanupServers();
839 }
840 }
841 EG_free(dsets);
842 EG_free(Gtris);
843 if (Dtris != NULL((void*)0)) EG_free(Dtris);
844 }
845#endif
846
847 stat = caps_outputObjects(pobj, &stream);
Value stored to 'stat' is never read
848 EG_free(stream);
849
850/* test out delete functions */
851
852 stat = caps_markForDelete(paramObj);
853 reportStatus(pobj, "caps_delete Parameter", stat, 0, NULL((void*)0));
854/*
855 stat = caps_markForDelete(bobj);
856 reportStatus(pobj, "caps_delete Bound", stat, 0, NULL);
857
858 stat = caps_markForDelete(aobj);
859 reportStatus(pobj, "caps_delete Analysis", stat, 0, NULL);
860 */
861
862 stat = caps_close(pobj, 1, NULL((void*)0));
863 if (stat != CAPS_SUCCESS0) printf(" caps_close = %d\n", stat);
864
865 return 0;
866}