ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/proj/util/apps/arithtool.c
Revision: 1.30
Committed: Wed May 13 20:54:46 2020 UTC (3 years, 4 months ago) by arta
Content type: text/plain
Branch: MAIN
CVS Tags: Ver_LATEST, Ver_9-3, Ver_9-41, Ver_9-5, HEAD
Changes since 1.29: +523 -518 lines
Log Message:
do not write segments until date keyword has been set in DRMS structs

File Contents

# Content
1 /* arithTool.c */
2
3 /* Mapping from vds/sds to drms:
4 * VDS (a set of datasets) -> Set of record sets (not implemented in DRMS yet)
5 * Dataset (a set of records) -> Record set
6 * Record (a set of SDSs) -> Record
7 * SDS (a FITS file) -> Segment
8 *
9 * VDS is implemented as an array (indexed by var number) of datasets
10 *
11 * <recSetIn> - Record set on which to operate
12 * <withRecSet> - For binary operations, the second set of records on which to operate.
13 * The data series containing these two record sets must have equivalent primary keyword sets
14 * and overlapping segment sets. Otherwise, the two sets are too dissimilar to operate on.
15 * The number of records in this set must be either equal to the number of records in
16 * <recSetIn>, or it must be equal to one record. If it is the former, then
17 * there is a one-to-one correspondence between the records in <recSetIn> and
18 * <withRecSet>. The keyword-tuple that selects one record in <recSetIn> should
19 * also select one record in <withRecSet>. Each record in <recSetIn> is paired with
20 * its corresponding record in <withRecSet>. The binary operation is then performed
21 * on each pair of records. If the number of records in <withRecSet> is equal to one,
22 * then each
23 * record in <recSetIn> is paired with the single record in <withRecSet>. Then
24 * the binary operation is performed on each pair. The binary operation is
25 * only performed between equivalently named segments. In other words, if a record
26 * from <recSetIn> contains three segments named SegA, SegB, and SegC, and the corresponding
27 * record from <withRecSet< contains two semgnets named SegA and SegB, the binary operation is
28 * performed between <recSetIn>:SegA and <withRecSet>:SegA and between <recSetIn>:SegB
29 * and <withRecSet>:SegB.
30 *
31 */
32
33 /* Adding a comment for testing. */
34
35 #include "jsoc_main.h"
36
37 #define kRecSetIn "recSetIn"
38 #define kWithRecSet "withRecSet"
39 #define kSeriesOut "seriesOut"
40 #define kSegList "segments"
41 #define kOp "op"
42 #define kBzero "bzero"
43 #define kBscale "bscale"
44 #define kDatatype "dtype"
45 #define kNoSegsFlag "n"
46 #define kNotSpecified "NOT SPECIFIED"
47 #define kMaxSegs 1024
48 #define kMaxQuery 2048
49 #define kOutSeriesDesc "Output series for arithTool calculation."
50 #define kInSliceLower "sl"
51 #define kInSliceUpper "su"
52 #define kPosOut "pout"
53
54 #define TESTER 0
55
56 typedef enum
57 {
58 kArithOpUnknown = 0,
59 kArithOpMul,
60 kArithOpDiv,
61 kArithOpAdd,
62 kArithOpSub,
63 kArithOpBinaryDummy, /* Delimits binary from unary ops */
64 kArithOpAbs,
65 kArithOpSqrt,
66 kArithOpLog,
67 kArithOpPow,
68 kArithOpSqr,
69 kArithOpRecip,
70 kArithOpSubmean,
71 kArithOpNop,
72 kArithOpLastDummy
73 } ArithOp_t;
74
75 ModuleArgs_t module_args[] =
76 {
77 {ARG_FLAG, "h", "0", "help - print usage info"},
78 {ARG_STRING, kRecSetIn, "", "A set of records with segments upon which to operate."},
79 {ARG_INTS, kInSliceLower, "-1", "Bottom-left corner of slice (-1 means no slicing)"},
80 {ARG_INTS, kInSliceUpper, "-1", "Upper-right corner of slice (-1 means no slicing)"},
81 {ARG_STRING, kWithRecSet, kNotSpecified, "For binary operations, the second operand."},
82 {ARG_STRING, kSeriesOut, kNotSpecified, "Name of series in which to save extracted data."},
83 {ARG_INTS, kPosOut, "-1", "Bottom-left corner of the output data array at which data are to be written."},
84 {ARG_STRING, kSegList, kNotSpecified, "Comma-separated list of segments on which to operate."},
85 {ARG_STRING, kOp, "", "The operation to perform."},
86 {ARG_DOUBLE, kBzero, "0.0", "For integer output, the bzero to use."},
87 {ARG_DOUBLE, kBscale, "1.0", "For integer output, the bscale to use."},
88 {ARG_NUME, kDatatype, "double", "Data type of in-memory data array.", "char,short,int,longlong,float,double,raw"},
89 {ARG_FLAG, kNoSegsFlag, NULL, "Don't create an output segmetn file - just copy keywords.", NULL},
90 {ARG_END}
91 };
92
93 char *module_name = "arithTool";
94
95 typedef struct DRMSContainer_struct
96 {
97 HContainer_t *items;
98 void (*Free)(HContainer_t *);
99 HIterator_t iter;
100 } DRMSContainer_t;
101
102
103
104 static int NiceIntro()
105 {
106 int usage = cmdparams_get_int(&cmdparams, "h", NULL);
107 if (usage)
108 {
109 printf ("Usage:\n\tarithTool [-h] "
110 "op=<operation> recSetIn=<recspec> [withRecSet=<recspec>] [seriesOut=<seriesname>] [segList=<segments>]\n"
111 " details are:\n"
112 " -h: help - show this message then exit\n"
113 " <seriesname> - fully qualified series name.\n"
114 " <timerange> - time value range set.\n"
115 " seriesIn defaults to sdo.fds.\n"
116 " timeRange defaults to all records in seriesIn.\n"
117 " seriesOut defaults to sdo.fdsStateVectors.\n"
118 " example - extractFdsStateV seriesIn=su_arta.TestFDSData timeRange=2006.11.20_22:38:00-2006.11.20_22:45:00,2006.11.20_22:52:00. seriesOut=su_arta.TestFDSHelio\n");
119 return 1;
120 }
121
122 return 0;
123 }
124
125 /* No need for an associative array since this mapping will be performed one time. */
126 static ArithOp_t MapOp(char *opStr)
127 {
128 ArithOp_t op = kArithOpUnknown;
129
130 if (strncmp(opStr, "mul", 3) == 0)
131 {
132 op = kArithOpMul;
133 }
134 else if (strncmp(opStr, "div", 3) == 0)
135 {
136 op = kArithOpDiv;
137 }
138 else if (strncmp(opStr, "add", 3) == 0)
139 {
140 op = kArithOpAdd;
141 }
142 else if (strncmp(opStr, "sub", 3) == 0)
143 {
144 op = kArithOpSub;
145 }
146 else if (strncmp(opStr, "abs", 3) == 0)
147 {
148 op = kArithOpAbs;
149 }
150 else if (strncmp(opStr, "sqrt", 4) == 0)
151 {
152 op = kArithOpSqrt;
153 }
154 else if (strncmp(opStr, "log", 3) == 0)
155 {
156 op = kArithOpLog;
157 }
158 else if (strncmp(opStr, "pow", 3) == 0)
159 {
160 op = kArithOpPow;
161 }
162 else if (strncmp(opStr, "sqr", 3) == 0)
163 {
164 op = kArithOpSqr;
165 }
166 else if (strncmp(opStr, "recip", 5) == 0)
167 {
168 op = kArithOpRecip;
169 }
170 else if (strncmp(opStr, "nomean", 6) == 0)
171 {
172 op = kArithOpSubmean;
173 }
174 else if (strncmp(opStr, "nop", 3) == 0)
175 {
176 op = kArithOpNop;
177 }
178
179 return op;
180 }
181
182 /* hconFree performs non-standard cleaning up of HContainer_t. */
183 static int CreateDRMSPrimeKeyContainer(DRMS_Record_t *recTemplate, DRMSContainer_t *conPrimeKeys,
184 void (*hconFree)(HContainer_t *hc))
185 {
186 int error = 0;
187 int drmsst = DRMS_SUCCESS;
188
189 /* There is no HContainer_t of primary keys - make one. */
190
191 if (conPrimeKeys != NULL)
192 {
193 /* Create new HContainer_t. */
194 conPrimeKeys->items = (HContainer_t *)malloc(sizeof(HContainer_t));
195
196 if (conPrimeKeys->items != NULL)
197 {
198 hcon_init(conPrimeKeys->items, sizeof(DRMS_Keyword_t *), DRMS_MAXKEYNAMELEN, NULL, NULL);
199 int iPrimeKeys = 0;
200 int nkeys = 0;
201
202 char **keyarr =
203 drms_series_createpkeyarray(drms_env, recTemplate->seriesinfo->seriesname, &nkeys, &drmsst);
204
205 while (iPrimeKeys < nkeys)
206 {
207 DRMS_Keyword_t *keyword = drms_keyword_lookup(recTemplate, keyarr[iPrimeKeys], 1);
208
209 if (keyword != NULL)
210 {
211 DRMS_Keyword_t **newKeyword =
212 (DRMS_Keyword_t **)hcon_allocslot_lower(conPrimeKeys->items,
213 keyword->info->name);
214
215 if (newKeyword != NULL)
216 {
217 *newKeyword = keyword;
218 }
219 else
220 {
221 error = 1;
222 break;
223 }
224 }
225 else
226 {
227 error = 1;
228 break;
229 }
230
231 iPrimeKeys++;
232 }
233
234 drms_series_destroypkeyarray(&keyarr, nkeys);
235
236 /* Create iterator too. */
237 conPrimeKeys->Free = hconFree;
238 hiter_new(&(conPrimeKeys->iter), conPrimeKeys->items);
239 }
240 }
241 else
242 {
243 error = 1;
244 }
245
246 return error;
247 }
248
249 /* hconFree performs non-standard cleaning up of HContainer_t. */
250 static void CreateDRMSSegmentContainer(DRMS_Record_t *recTemplate, DRMSContainer_t *conSegs,
251 void (*hconFree)(HContainer_t *hc))
252 {
253 /* Create iterator too. */
254 conSegs->items = &(recTemplate->segments);
255 conSegs->Free = hconFree;
256 hiter_new(&(conSegs->iter), conSegs->items);
257 }
258
259 static void DestroyDRMSContainer(DRMSContainer_t *pCon)
260 {
261 int wasinit = (pCon->items != NULL);
262
263 if (pCon != NULL)
264 {
265 if (pCon->Free != NULL && pCon->items != NULL)
266 {
267 (*(pCon->Free))(pCon->items);
268 }
269
270 pCon->items = NULL;
271
272 if (wasinit)
273 {
274 hiter_free(&(pCon->iter));
275 }
276 }
277 }
278
279 static void ReleaseHContainer(HContainer_t *hcon)
280 {
281 if (hcon != NULL)
282 {
283 /* Standard cleaning up of HContainer_t. */
284 hcon_free(hcon);
285 free(hcon);
286 }
287 }
288
289 static int IsValidOp(ArithOp_t op)
290 {
291 return (op >= kArithOpUnknown && op < kArithOpLastDummy);
292 }
293
294 static int IsBinaryOp(ArithOp_t op)
295 {
296 if (IsValidOp(op))
297 {
298 return op < kArithOpBinaryDummy;
299 }
300
301 return 0;
302 }
303
304 /* Returns 0 on error. */
305 /* Returns 1 if keys2 is equal to keys1. */
306 static int KeysEqual(DRMSContainer_t *keys1, DRMSContainer_t *keys2)
307 {
308 int ret = 1;
309
310 /* Iterate through keys1, looking up the keyword name in the keys2 collection.
311 * This should be relatively efficient since the lookup is a hash function.
312 */
313
314 if (hcon_size(keys1->items) != hcon_size(keys2->items))
315 {
316 ret = 0;
317 }
318 else
319 {
320 hiter_rewind(&(keys1->iter));
321 DRMS_Keyword_t **currKey = NULL;
322 DRMS_Keyword_t **currKey2 = NULL;
323 while ((currKey = (DRMS_Keyword_t **)hiter_getnext(&(keys1->iter))) != NULL)
324 {
325 if ((currKey2 = hcon_lookup_lower(keys2->items, (*currKey)->info->name)) == NULL)
326 {
327 ret = 0;
328 break;
329 }
330 else
331 {
332 /* Ensure matching keys are the same type. */
333 if (drms_keyword_type(*currKey) != drms_keyword_type(*currKey2))
334 {
335 ret = 0;
336 break;
337 }
338 }
339 }
340 }
341
342 return ret;
343 }
344
345
346 /* Returns the number of matching segments. If matchSet != NULL,
347 * returns the actual segs1 segments
348 * matching in matchSet. Returns -1 on error.
349 */
350 static int CreateMatchingSegs(DRMSContainer_t *segs1, DRMSContainer_t *segs2, DRMSContainer_t *matchSet)
351 {
352 int nMatch = 0;
353
354 hiter_rewind(&(segs1->iter));
355 DRMS_Segment_t *currSeg = NULL;
356
357 while ((currSeg = (DRMS_Segment_t *)hiter_getnext(&(segs1->iter))) != NULL)
358 {
359 if (segs1 == segs2 ||
360 hcon_lookup_lower(segs2->items, currSeg->info->name) != NULL)
361 {
362 nMatch++;
363
364 if (matchSet != NULL)
365 {
366 if (nMatch == 1)
367 {
368 matchSet->items = (HContainer_t *)malloc(sizeof(HContainer_t));
369 if (matchSet->items != NULL)
370 {
371 hcon_init(matchSet->items, sizeof(DRMS_Segment_t *),
372 DRMS_MAXSEGNAMELEN,
373 NULL,
374 NULL);
375 }
376 else
377 {
378 nMatch = -1;
379 break;
380 }
381 }
382
383 DRMS_Segment_t **newSeg =
384 (DRMS_Segment_t **)hcon_allocslot_lower(matchSet->items, currSeg->info->name);
385
386 if (newSeg != NULL)
387 {
388 *newSeg = currSeg;
389 }
390 else
391 {
392 nMatch = -1;
393 break;
394 }
395 }
396 }
397 }
398
399 if (nMatch > 0 && matchSet != NULL)
400 {
401 matchSet->Free = ReleaseHContainer;
402 hiter_new(&(matchSet->iter), matchSet->items);
403 }
404
405 return nMatch;
406 }
407
408 static int ValidateBinaryOperands(char *recSetIn,
409 char **segNameArr,
410 int nSegs,
411 DRMSContainer_t *inKeys, DRMSContainer_t *inSegs,
412 DRMSContainer_t *withKeys, DRMSContainer_t *withSegs,
413 DRMSContainer_t *segsToProc)
414 {
415 int error = 0;
416 int status = 0;
417
418 int nWithRecs = 0;
419 DRMS_RecordSet_t *recSet = drms_open_records(drms_env, recSetIn, &status);
420 error = (status != DRMS_SUCCESS);
421
422 if (error == 0)
423 {
424 nWithRecs = recSet->n;
425 drms_close_records(recSet, DRMS_FREE_RECORD);
426 }
427
428 /* If the number of records in the withSeries != 1, then the
429 * primary keys must match.
430 */
431 if (!error)
432 {
433 if (nWithRecs > 1)
434 {
435 if (!KeysEqual(inKeys, withKeys))
436 {
437 error = 1;
438 }
439 }
440 }
441
442 if (!error)
443 {
444 int nMatch = 0;
445
446 if (nSegs > 0)
447 {
448
449 /* If a segment list is specified, then both the 'in' and 'with' series
450 * must contain all items in the segment list
451 */
452 int iSeg = 0;
453
454 for (; iSeg < nSegs; iSeg++)
455 {
456 char *aSegName = segNameArr[iSeg];
457
458 if (hcon_lookup_lower(inSegs->items, aSegName) == NULL ||
459 hcon_lookup_lower(withSegs->items, aSegName) == NULL)
460 {
461 error = 1;
462 fprintf(stderr, "Segment %s not present in an input recordset.\n",
463 aSegName);
464 break;
465 }
466 }
467
468 /* Create segsToProc list - a copy of segs in inSegs. */
469 if (!error)
470 {
471 nMatch = CreateMatchingSegs(inSegs, inSegs, segsToProc);
472 }
473 }
474 else
475 {
476 /* If no segments are specified, at least one segment must match */
477 nMatch = CreateMatchingSegs(inSegs, withSegs, segsToProc);
478 }
479
480 if (nMatch == -1)
481 {
482 DestroyDRMSContainer(segsToProc);
483 error = 1;
484 }
485
486 if (!error && nMatch == 0)
487 {
488 error = 1;
489 }
490 }
491
492 return error;
493 }
494
495 /* Must free malloc'd memory if ret != NULL. */
496 static char *CreateStrFromDRMSValue(DRMS_Record_t *rec, char *keyName, int *error)
497 {
498 return drms_getkey_string(rec, keyName, error);
499 }
500
501 static int MultChar(const char *pInData, const char *pWithData, arraylen_t nElements, char *pOutData)
502 {
503 int error = 0;
504
505 int first = 1;
506 int percentDone = 0;
507 int update = 0;
508
509 const char *rop = NULL;
510 const char *lop = NULL;
511
512 if (!pInData)
513 {
514 error = 1;
515 fprintf(stderr, "Missing input data.\n");
516 }
517 else if (!pWithData)
518 {
519 error = 1;
520 fprintf(stderr, "Missing input data.\n");
521 }
522 else
523 {
524 char *result = NULL;
525 arraylen_t index = 0;
526
527 for (; index < nElements; index++)
528 {
529 result = &(pOutData[index]);
530 *result = DRMS_MISSING_CHAR;
531
532 if (!drms_ismissing_char(pInData[index]) &&
533 (!!drms_ismissing_char(pWithData[index])))
534 {
535 percentDone = index * 100/nElements;
536
537 if (first)
538 {
539 fprintf(stdout, "%03d%% done", percentDone);
540 first = 0;
541 }
542 else if (percentDone == update)
543 {
544 update++;
545 fprintf(stdout,
546 "\b\b\b\b\b\b\b\b\b%03d%% done",
547 percentDone);
548 fflush(stdout);
549 }
550
551 lop = &(pInData[index]);
552 rop = &(pWithData[index]);
553 *result = *lop * *rop;
554 }
555 }
556
557 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
558 fflush(stdout);
559 }
560
561 return error;
562 }
563
564 static int MultShort(const short *pInData, const short *pWithData, arraylen_t nElements, short *pOutData)
565 {
566 int error = 0;
567
568 int first = 1;
569 int percentDone = 0;
570 int update = 0;
571
572 const short *rop = NULL;
573 const short *lop = NULL;
574
575 if (!pInData)
576 {
577 error = 1;
578 fprintf(stderr, "Missing input data.\n");
579 }
580 else if (!pWithData)
581 {
582 error = 1;
583 fprintf(stderr, "Missing input data.\n");
584 }
585 else
586 {
587 short *result = NULL;
588 arraylen_t index = 0;
589
590 for (; index < nElements; index++)
591 {
592 result = &(pOutData[index]);
593 *result = DRMS_MISSING_SHORT;
594
595 if (!drms_ismissing_short(pInData[index]) &&
596 (!!drms_ismissing_short(pWithData[index])))
597 {
598 percentDone = index * 100/nElements;
599
600 if (first)
601 {
602 fprintf(stdout, "%03d%% done", percentDone);
603 first = 0;
604 }
605 else if (percentDone == update)
606 {
607 update++;
608 fprintf(stdout,
609 "\b\b\b\b\b\b\b\b\b%03d%% done",
610 percentDone);
611 fflush(stdout);
612 }
613
614 lop = &(pInData[index]);
615 rop = &(pWithData[index]);
616 *result = *lop * *rop;
617
618 }
619 }
620
621 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
622 fflush(stdout);
623 }
624
625 return error;
626 }
627
628 static int MultInt(const int *pInData, const int *pWithData, arraylen_t nElements, int *pOutData)
629 {
630 int error = 0;
631
632 int first = 1;
633 int percentDone = 0;
634 int update = 0;
635
636 const int *rop = NULL;
637 const int *lop = NULL;
638
639 if (!pInData)
640 {
641 error = 1;
642 fprintf(stderr, "Missing input data.\n");
643 }
644 else if (!pWithData)
645 {
646 error = 1;
647 fprintf(stderr, "Missing input data.\n");
648 }
649 else
650 {
651 int *result = NULL;
652 arraylen_t index = 0;
653
654 for (; index < nElements; index++)
655 {
656 result = &(pOutData[index]);
657 *result = DRMS_MISSING_INT;
658
659 if (!drms_ismissing_int(pInData[index]) &&
660 (!!drms_ismissing_int(pWithData[index])))
661 {
662 percentDone = index * 100/nElements;
663
664 if (first)
665 {
666 fprintf(stdout, "%03d%% done", percentDone);
667 first = 0;
668 }
669 else if (percentDone == update)
670 {
671 update++;
672 fprintf(stdout,
673 "\b\b\b\b\b\b\b\b\b%03d%% done",
674 percentDone);
675 fflush(stdout);
676 }
677
678 lop = &(pInData[index]);
679 rop = &(pWithData[index]);
680 *result = *lop * *rop;
681
682 }
683 }
684
685 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
686 fflush(stdout);
687 }
688
689 return error;
690 }
691
692 static int MultLongLong(const long long *pInData,
693 const long long *pWithData,
694 arraylen_t nElements,
695 long long *pOutData)
696 {
697 int error = 0;
698
699 int first = 1;
700 int percentDone = 0;
701 int update = 0;
702
703 const long long *rop = NULL;
704 const long long *lop = NULL;
705
706 if (!pInData)
707 {
708 error = 1;
709 fprintf(stderr, "Missing input data.\n");
710 }
711 else if (!pWithData)
712 {
713 error = 1;
714 fprintf(stderr, "Missing input data.\n");
715 }
716 else
717 {
718 long long *result = NULL;
719 arraylen_t index = 0;
720
721 for (; index < nElements; index++)
722 {
723 result = &(pOutData[index]);
724 *result = DRMS_MISSING_LONGLONG;
725
726 if (!drms_ismissing_longlong(pInData[index]) &&
727 (!!drms_ismissing_longlong(pWithData[index])))
728 {
729 percentDone = index * 100/nElements;
730
731 if (first)
732 {
733 fprintf(stdout, "%03d%% done", percentDone);
734 first = 0;
735 }
736 else if (percentDone == update)
737 {
738 update++;
739 fprintf(stdout,
740 "\b\b\b\b\b\b\b\b\b%03d%% done",
741 percentDone);
742 fflush(stdout);
743 }
744
745 lop = &(pInData[index]);
746 rop = &(pWithData[index]);
747 *result = *lop * *rop;
748
749 }
750 }
751
752 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
753 fflush(stdout);
754 }
755
756 return error;
757 }
758
759 static int MultFloat(const float *pInData, const float *pWithData, arraylen_t nElements, float *pOutData)
760 {
761 int error = 0;
762
763 int first = 1;
764 int percentDone = 0;
765 int update = 0;
766
767 const float *rop = NULL;
768 const float *lop = NULL;
769
770 if (!pInData)
771 {
772 error = 1;
773 fprintf(stderr, "Missing input data.\n");
774 }
775 else if (!pWithData)
776 {
777 error = 1;
778 fprintf(stderr, "Missing input data.\n");
779 }
780 else
781 {
782 float *result = NULL;
783 arraylen_t index = 0;
784
785 for (; index < nElements; index++)
786 {
787 result = &(pOutData[index]);
788 *result = DRMS_MISSING_FLOAT;
789
790 if (!drms_ismissing_float(pInData[index]) &&
791 (!!drms_ismissing_float(pWithData[index])))
792 {
793 percentDone = index * 100/nElements;
794
795 if (first)
796 {
797 fprintf(stdout, "%03d%% done", percentDone);
798 first = 0;
799 }
800 else if (percentDone == update)
801 {
802 update++;
803 fprintf(stdout,
804 "\b\b\b\b\b\b\b\b\b%03d%% done",
805 percentDone);
806 fflush(stdout);
807 }
808
809 lop = &(pInData[index]);
810 rop = &(pWithData[index]);
811 *result = *lop * *rop;
812
813 }
814 }
815
816 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
817 fflush(stdout);
818 }
819
820 return error;
821 }
822
823 static int MultDouble(const double *pInData, const double *pWithData, arraylen_t nElements, double *pOutData)
824 {
825 int error = 0;
826
827 int first = 1;
828 int percentDone = 0;
829 int update = 0;
830
831 const double *rop = NULL;
832 const double *lop = NULL;
833
834 if (!pInData)
835 {
836 error = 1;
837 fprintf(stderr, "Missing input data.\n");
838 }
839 else if (!pWithData)
840 {
841 error = 1;
842 fprintf(stderr, "Missing input data.\n");
843 }
844 else
845 {
846 double *result = NULL;
847 arraylen_t index = 0;
848
849 for (; index < nElements; index++)
850 {
851 result = &(pOutData[index]);
852 *result = DRMS_MISSING_DOUBLE;
853
854 if (!drms_ismissing_double(pInData[index]) &&
855 (!!drms_ismissing_double(pWithData[index])))
856 {
857 percentDone = index * 100/nElements;
858
859 if (first)
860 {
861 fprintf(stdout, "%03d%% done", percentDone);
862 first = 0;
863 }
864 else if (percentDone == update)
865 {
866 update++;
867 fprintf(stdout,
868 "\b\b\b\b\b\b\b\b\b%03d%% done",
869 percentDone);
870 fflush(stdout);
871 }
872
873 lop = &(pInData[index]);
874 rop = &(pWithData[index]);
875 *result = *lop * *rop;
876
877 }
878 }
879
880 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
881 fflush(stdout);
882 }
883
884 return error;
885 }
886
887 static int DivChar(const char *pInData, const char *pWithData, arraylen_t nElements, char *pOutData)
888 {
889 int error = 0;
890
891 int first = 1;
892 int percentDone = 0;
893 int update = 0;
894
895 const char *rop = NULL;
896 const char *lop = NULL;
897
898 if (!pInData)
899 {
900 error = 1;
901 fprintf(stderr, "Missing input data.\n");
902 }
903 else if (!pWithData)
904 {
905 error = 1;
906 fprintf(stderr, "Missing input data.\n");
907 }
908 else
909 {
910 char *result = NULL;
911 arraylen_t index = 0;
912
913 for (; index < nElements; index++)
914 {
915 result = &(pOutData[index]);
916 *result = DRMS_MISSING_CHAR;
917
918 if (!drms_ismissing_char(pInData[index]) &&
919 (!!drms_ismissing_char(pWithData[index])))
920 {
921 percentDone = index * 100/nElements;
922
923 if (first)
924 {
925 fprintf(stdout, "%03d%% done", percentDone);
926 first = 0;
927 }
928 else if (percentDone == update)
929 {
930 update++;
931 fprintf(stdout,
932 "\b\b\b\b\b\b\b\b\b%03d%% done",
933 percentDone);
934 fflush(stdout);
935 }
936
937 lop = &(pInData[index]);
938 rop = &(pWithData[index]);
939 *result = *lop / *rop;
940
941 }
942 }
943
944 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
945 fflush(stdout);
946 }
947
948 return error;
949 }
950
951 static int DivShort(const short *pInData, const short *pWithData, arraylen_t nElements, short *pOutData)
952 {
953 int error = 0;
954
955 int first = 1;
956 int percentDone = 0;
957 int update = 0;
958
959 const short *rop = NULL;
960 const short *lop = NULL;
961
962 if (!pInData)
963 {
964 error = 1;
965 fprintf(stderr, "Missing input data.\n");
966 }
967 else if (!pWithData)
968 {
969 error = 1;
970 fprintf(stderr, "Missing input data.\n");
971 }
972 else
973 {
974 short *result = NULL;
975 arraylen_t index = 0;
976
977 for (; index < nElements; index++)
978 {
979 result = &(pOutData[index]);
980 *result = DRMS_MISSING_SHORT;
981
982 if (!drms_ismissing_short(pInData[index]) &&
983 (!!drms_ismissing_short(pWithData[index])))
984 {
985 percentDone = index * 100/nElements;
986
987 if (first)
988 {
989 fprintf(stdout, "%03d%% done", percentDone);
990 first = 0;
991 }
992 else if (percentDone == update)
993 {
994 update++;
995 fprintf(stdout,
996 "\b\b\b\b\b\b\b\b\b%03d%% done",
997 percentDone);
998 fflush(stdout);
999 }
1000
1001 lop = &(pInData[index]);
1002 rop = &(pWithData[index]);
1003 *result = *lop / *rop;
1004
1005 }
1006 }
1007
1008 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1009 fflush(stdout);
1010 }
1011
1012 return error;
1013 }
1014
1015 static int DivInt(const int *pInData, const int *pWithData, arraylen_t nElements, int *pOutData)
1016 {
1017 int error = 0;
1018
1019 int first = 1;
1020 int percentDone = 0;
1021 int update = 0;
1022
1023 const int *rop = NULL;
1024 const int *lop = NULL;
1025
1026 if (!pInData)
1027 {
1028 error = 1;
1029 fprintf(stderr, "Missing input data.\n");
1030 }
1031 else if (!pWithData)
1032 {
1033 error = 1;
1034 fprintf(stderr, "Missing input data.\n");
1035 }
1036 else
1037 {
1038 int *result = NULL;
1039 arraylen_t index = 0;
1040
1041 for (; index < nElements; index++)
1042 {
1043 result = &(pOutData[index]);
1044 *result = DRMS_MISSING_INT;
1045
1046 if (!drms_ismissing_int(pInData[index]) &&
1047 (!!drms_ismissing_int(pWithData[index])))
1048 {
1049 percentDone = index * 100/nElements;
1050
1051 if (first)
1052 {
1053 fprintf(stdout, "%03d%% done", percentDone);
1054 first = 0;
1055 }
1056 else if (percentDone == update)
1057 {
1058 update++;
1059 fprintf(stdout,
1060 "\b\b\b\b\b\b\b\b\b%03d%% done",
1061 percentDone);
1062 fflush(stdout);
1063 }
1064
1065 lop = &(pInData[index]);
1066 rop = &(pWithData[index]);
1067 *result = *lop / *rop;
1068
1069 }
1070 }
1071
1072 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1073 fflush(stdout);
1074 }
1075
1076 return error;
1077 }
1078
1079 static int DivLongLong(const long long *pInData,
1080 const long long *pWithData,
1081 arraylen_t nElements,
1082 long long *pOutData)
1083 {
1084 int error = 0;
1085
1086 int first = 1;
1087 int percentDone = 0;
1088 int update = 0;
1089
1090 const long long *rop = NULL;
1091 const long long *lop = NULL;
1092
1093 if (!pInData)
1094 {
1095 error = 1;
1096 fprintf(stderr, "Missing input data.\n");
1097 }
1098 else if (!pWithData)
1099 {
1100 error = 1;
1101 fprintf(stderr, "Missing input data.\n");
1102 }
1103 else
1104 {
1105 long long *result = NULL;
1106 arraylen_t index = 0;
1107
1108 for (; index < nElements; index++)
1109 {
1110 result = &(pOutData[index]);
1111 *result = DRMS_MISSING_LONGLONG;
1112
1113 if (!drms_ismissing_longlong(pInData[index]) &&
1114 (!!drms_ismissing_longlong(pWithData[index])))
1115 {
1116 percentDone = index * 100/nElements;
1117
1118 if (first)
1119 {
1120 fprintf(stdout, "%03d%% done", percentDone);
1121 first = 0;
1122 }
1123 else if (percentDone == update)
1124 {
1125 update++;
1126 fprintf(stdout,
1127 "\b\b\b\b\b\b\b\b\b%03d%% done",
1128 percentDone);
1129 fflush(stdout);
1130 }
1131
1132 lop = &(pInData[index]);
1133 rop = &(pWithData[index]);
1134 *result = *lop / *rop;
1135
1136 }
1137 }
1138
1139 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1140 fflush(stdout);
1141 }
1142
1143 return error;
1144 }
1145
1146 static int DivFloat(const float *pInData, const float *pWithData, arraylen_t nElements, float *pOutData)
1147 {
1148 int error = 0;
1149
1150 int first = 1;
1151 int percentDone = 0;
1152 int update = 0;
1153
1154 const float *rop = NULL;
1155 const float *lop = NULL;
1156
1157 if (!pInData)
1158 {
1159 error = 1;
1160 fprintf(stderr, "Missing input data.\n");
1161 }
1162 else if (!pWithData)
1163 {
1164 error = 1;
1165 fprintf(stderr, "Missing input data.\n");
1166 }
1167 else
1168 {
1169 float *result = NULL;
1170 arraylen_t index = 0;
1171
1172 for (; index < nElements; index++)
1173 {
1174 result = &(pOutData[index]);
1175 *result = DRMS_MISSING_FLOAT;
1176
1177 if (!drms_ismissing_float(pInData[index]) &&
1178 (!!drms_ismissing_float(pWithData[index])))
1179 {
1180 percentDone = index * 100/nElements;
1181
1182 if (first)
1183 {
1184 fprintf(stdout, "%03d%% done", percentDone);
1185 first = 0;
1186 }
1187 else if (percentDone == update)
1188 {
1189 update++;
1190 fprintf(stdout,
1191 "\b\b\b\b\b\b\b\b\b%03d%% done",
1192 percentDone);
1193 fflush(stdout);
1194 }
1195
1196 lop = &(pInData[index]);
1197 rop = &(pWithData[index]);
1198 *result = *lop / *rop;
1199
1200 }
1201 }
1202
1203 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1204 fflush(stdout);
1205 }
1206
1207 return error;
1208 }
1209
1210 static int DivDouble(const double *pInData, const double *pWithData, arraylen_t nElements, double *pOutData)
1211 {
1212 int error = 0;
1213
1214 int first = 1;
1215 int percentDone = 0;
1216 int update = 0;
1217
1218 const double *rop = NULL;
1219 const double *lop = NULL;
1220
1221 if (!pInData)
1222 {
1223 error = 1;
1224 fprintf(stderr, "Missing input data.\n");
1225 }
1226 else if (!pWithData)
1227 {
1228 error = 1;
1229 fprintf(stderr, "Missing input data.\n");
1230 }
1231 else
1232 {
1233 double *result = NULL;
1234 arraylen_t index = 0;
1235
1236 for (; index < nElements; index++)
1237 {
1238 result = &(pOutData[index]);
1239 *result = DRMS_MISSING_DOUBLE;
1240
1241 if (!drms_ismissing_double(pInData[index]) &&
1242 (!!drms_ismissing_double(pWithData[index])))
1243 {
1244 percentDone = index * 100/nElements;
1245
1246 if (first)
1247 {
1248 fprintf(stdout, "%03d%% done", percentDone);
1249 first = 0;
1250 }
1251 else if (percentDone == update)
1252 {
1253 update++;
1254 fprintf(stdout,
1255 "\b\b\b\b\b\b\b\b\b%03d%% done",
1256 percentDone);
1257 fflush(stdout);
1258 }
1259
1260 lop = &(pInData[index]);
1261 rop = &(pWithData[index]);
1262 *result = *lop / *rop;
1263
1264 }
1265 }
1266
1267 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1268 fflush(stdout);
1269 }
1270
1271 return error;
1272 }
1273
1274 static int AddChar(const char *pInData, const char *pWithData, arraylen_t nElements, char *pOutData)
1275 {
1276 int error = 0;
1277
1278 int first = 1;
1279 int percentDone = 0;
1280 int update = 0;
1281
1282 const char *rop = NULL;
1283 const char *lop = NULL;
1284
1285 if (!pInData)
1286 {
1287 error = 1;
1288 fprintf(stderr, "Missing input data.\n");
1289 }
1290 else if (!pWithData)
1291 {
1292 error = 1;
1293 fprintf(stderr, "Missing input data.\n");
1294 }
1295 else
1296 {
1297 char *result = NULL;
1298 arraylen_t index = 0;
1299
1300 for (; index < nElements; index++)
1301 {
1302 result = &(pOutData[index]);
1303 *result = DRMS_MISSING_CHAR;
1304
1305 if (!drms_ismissing_char(pInData[index]) &&
1306 (!!drms_ismissing_char(pWithData[index])))
1307 {
1308 percentDone = index * 100/nElements;
1309
1310 if (first)
1311 {
1312 fprintf(stdout, "%03d%% done", percentDone);
1313 first = 0;
1314 }
1315 else if (percentDone == update)
1316 {
1317 update++;
1318 fprintf(stdout,
1319 "\b\b\b\b\b\b\b\b\b%03d%% done",
1320 percentDone);
1321 fflush(stdout);
1322 }
1323
1324 lop = &(pInData[index]);
1325 rop = &(pWithData[index]);
1326 *result = *lop + *rop;
1327 }
1328 }
1329
1330 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1331 fflush(stdout);
1332 }
1333
1334 return error;
1335 }
1336
1337 static int AddShort(const short *pInData, const short *pWithData, arraylen_t nElements, short *pOutData)
1338 {
1339 int error = 0;
1340
1341 int first = 1;
1342 int percentDone = 0;
1343 int update = 0;
1344
1345 const short *rop = NULL;
1346 const short *lop = NULL;
1347
1348 if (!pInData)
1349 {
1350 error = 1;
1351 fprintf(stderr, "Missing input data.\n");
1352 }
1353 else if (!pWithData)
1354 {
1355 error = 1;
1356 fprintf(stderr, "Missing input data.\n");
1357 }
1358 else
1359 {
1360 short *result = NULL;
1361 arraylen_t index = 0;
1362
1363 for (; index < nElements; index++)
1364 {
1365 result = &(pOutData[index]);
1366 *result = DRMS_MISSING_SHORT;
1367
1368 if (!drms_ismissing_short(pInData[index]) &&
1369 (!!drms_ismissing_short(pWithData[index])))
1370 {
1371 percentDone = index * 100/nElements;
1372
1373 if (first)
1374 {
1375 fprintf(stdout, "%03d%% done", percentDone);
1376 first = 0;
1377 }
1378 else if (percentDone == update)
1379 {
1380 update++;
1381 fprintf(stdout,
1382 "\b\b\b\b\b\b\b\b\b%03d%% done",
1383 percentDone);
1384 fflush(stdout);
1385 }
1386
1387 lop = &(pInData[index]);
1388 rop = &(pWithData[index]);
1389 *result = *lop + *rop;
1390 }
1391 }
1392
1393 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1394 fflush(stdout);
1395 }
1396
1397 return error;
1398 }
1399
1400 static int AddInt(const int *pInData, const int *pWithData, arraylen_t nElements, int *pOutData)
1401 {
1402 int error = 0;
1403
1404 int first = 1;
1405 int percentDone = 0;
1406 int update = 0;
1407
1408 const int *rop = NULL;
1409 const int *lop = NULL;
1410
1411 if (!pInData)
1412 {
1413 error = 1;
1414 fprintf(stderr, "Missing input data.\n");
1415 }
1416 else if (!pWithData)
1417 {
1418 error = 1;
1419 fprintf(stderr, "Missing input data.\n");
1420 }
1421 else
1422 {
1423 int *result = NULL;
1424 arraylen_t index = 0;
1425
1426 for (; index < nElements; index++)
1427 {
1428 result = &(pOutData[index]);
1429 *result = DRMS_MISSING_INT;
1430
1431 if (!drms_ismissing_int(pInData[index]) &&
1432 (!!drms_ismissing_int(pWithData[index])))
1433 {
1434 percentDone = index * 100/nElements;
1435
1436 if (first)
1437 {
1438 fprintf(stdout, "%03d%% done", percentDone);
1439 first = 0;
1440 }
1441 else if (percentDone == update)
1442 {
1443 update++;
1444 fprintf(stdout,
1445 "\b\b\b\b\b\b\b\b\b%03d%% done",
1446 percentDone);
1447 fflush(stdout);
1448 }
1449
1450 lop = &(pInData[index]);
1451 rop = &(pWithData[index]);
1452 *result = *lop + *rop;
1453 }
1454 }
1455
1456 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1457 fflush(stdout);
1458 }
1459
1460 return error;
1461 }
1462
1463 static int AddLongLong(const long long *pInData,
1464 const long long *pWithData,
1465 arraylen_t nElements,
1466 long long *pOutData)
1467 {
1468 int error = 0;
1469
1470 int first = 1;
1471 int percentDone = 0;
1472 int update = 0;
1473
1474 const long long *rop = NULL;
1475 const long long *lop = NULL;
1476
1477 if (!pInData)
1478 {
1479 error = 1;
1480 fprintf(stderr, "Missing input data.\n");
1481 }
1482 else if (!pWithData)
1483 {
1484 error = 1;
1485 fprintf(stderr, "Missing input data.\n");
1486 }
1487 else
1488 {
1489 long long *result = NULL;
1490 arraylen_t index = 0;
1491
1492 for (; index < nElements; index++)
1493 {
1494 result = &(pOutData[index]);
1495 *result = DRMS_MISSING_LONGLONG;
1496
1497 if (!drms_ismissing_longlong(pInData[index]) &&
1498 (!!drms_ismissing_longlong(pWithData[index])))
1499 {
1500 percentDone = index * 100/nElements;
1501
1502 if (first)
1503 {
1504 fprintf(stdout, "%03d%% done", percentDone);
1505 first = 0;
1506 }
1507 else if (percentDone == update)
1508 {
1509 update++;
1510 fprintf(stdout,
1511 "\b\b\b\b\b\b\b\b\b%03d%% done",
1512 percentDone);
1513 fflush(stdout);
1514 }
1515
1516 lop = &(pInData[index]);
1517 rop = &(pWithData[index]);
1518 *result = *lop + *rop;
1519 }
1520 }
1521
1522 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1523 fflush(stdout);
1524 }
1525
1526 return error;
1527 }
1528
1529 static int AddFloat(const float *pInData, const float *pWithData, arraylen_t nElements, float *pOutData)
1530 {
1531 int error = 0;
1532
1533 int first = 1;
1534 int percentDone = 0;
1535 int update = 0;
1536
1537 const float *rop = NULL;
1538 const float *lop = NULL;
1539
1540 if (!pInData)
1541 {
1542 error = 1;
1543 fprintf(stderr, "Missing input data.\n");
1544 }
1545 else if (!pWithData)
1546 {
1547 error = 1;
1548 fprintf(stderr, "Missing input data.\n");
1549 }
1550 else
1551 {
1552 float *result = NULL;
1553 arraylen_t index = 0;
1554
1555 for (; index < nElements; index++)
1556 {
1557 result = &(pOutData[index]);
1558 *result = DRMS_MISSING_FLOAT;
1559
1560 if (!drms_ismissing_float(pInData[index]) &&
1561 (!!drms_ismissing_float(pWithData[index])))
1562 {
1563 percentDone = index * 100/nElements;
1564
1565 if (first)
1566 {
1567 fprintf(stdout, "%03d%% done", percentDone);
1568 first = 0;
1569 }
1570 else if (percentDone == update)
1571 {
1572 update++;
1573 fprintf(stdout,
1574 "\b\b\b\b\b\b\b\b\b%03d%% done",
1575 percentDone);
1576 fflush(stdout);
1577 }
1578
1579 lop = &(pInData[index]);
1580 rop = &(pWithData[index]);
1581 *result = *lop + *rop;
1582 }
1583 }
1584
1585 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1586 fflush(stdout);
1587 }
1588
1589 return error;
1590 }
1591
1592 static int AddDouble(const double *pInData, const double *pWithData, arraylen_t nElements, double *pOutData)
1593 {
1594 int error = 0;
1595
1596 int first = 1;
1597 int percentDone = 0;
1598 int update = 0;
1599
1600 const double *rop = NULL;
1601 const double *lop = NULL;
1602
1603 if (!pInData)
1604 {
1605 error = 1;
1606 fprintf(stderr, "Missing input data.\n");
1607 }
1608 else if (!pWithData)
1609 {
1610 error = 1;
1611 fprintf(stderr, "Missing input data.\n");
1612 }
1613 else
1614 {
1615 double *result = NULL;
1616 arraylen_t index = 0;
1617
1618 for (; index < nElements; index++)
1619 {
1620 result = &(pOutData[index]);
1621 *result = DRMS_MISSING_DOUBLE;
1622
1623 if (!drms_ismissing_double(pInData[index]) &&
1624 (!!drms_ismissing_double(pWithData[index])))
1625 {
1626 percentDone = index * 100/nElements;
1627
1628 if (first)
1629 {
1630 fprintf(stdout, "%03d%% done", percentDone);
1631 first = 0;
1632 }
1633 else if (percentDone == update)
1634 {
1635 update++;
1636 fprintf(stdout,
1637 "\b\b\b\b\b\b\b\b\b%03d%% done",
1638 percentDone);
1639 fflush(stdout);
1640 }
1641
1642 lop = &(pInData[index]);
1643 rop = &(pWithData[index]);
1644 *result = *lop + *rop;
1645 }
1646 }
1647
1648 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1649 fflush(stdout);
1650 }
1651
1652 return error;
1653 }
1654
1655 static int SubChar(const char *pInData, const char *pWithData, arraylen_t nElements, char *pOutData)
1656 {
1657 int error = 0;
1658
1659 int first = 1;
1660 int percentDone = 0;
1661 int update = 0;
1662
1663 const char *rop = NULL;
1664 const char *lop = NULL;
1665
1666 if (!pInData)
1667 {
1668 error = 1;
1669 fprintf(stderr, "Missing input data.\n");
1670 }
1671 else if (!pWithData)
1672 {
1673 error = 1;
1674 fprintf(stderr, "Missing input data.\n");
1675 }
1676 else
1677 {
1678 char *result = NULL;
1679 arraylen_t index = 0;
1680
1681 for (; index < nElements; index++)
1682 {
1683 result = &(pOutData[index]);
1684 *result = DRMS_MISSING_CHAR;
1685
1686 if (!drms_ismissing_char(pInData[index]) &&
1687 (!!drms_ismissing_char(pWithData[index])))
1688 {
1689 percentDone = index * 100/nElements;
1690
1691 if (first)
1692 {
1693 fprintf(stdout, "%03d%% done", percentDone);
1694 first = 0;
1695 }
1696 else if (percentDone == update)
1697 {
1698 update++;
1699 fprintf(stdout,
1700 "\b\b\b\b\b\b\b\b\b%03d%% done",
1701 percentDone);
1702 fflush(stdout);
1703 }
1704
1705 lop = &(pInData[index]);
1706 rop = &(pWithData[index]);
1707 *result = *lop - *rop;
1708 }
1709 }
1710
1711 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1712 fflush(stdout);
1713 }
1714
1715 return error;
1716 }
1717
1718 static int SubShort(const short *pInData, const short *pWithData, arraylen_t nElements, short *pOutData)
1719 {
1720 int error = 0;
1721
1722 int first = 1;
1723 int percentDone = 0;
1724 int update = 0;
1725
1726 const short *rop = NULL;
1727 const short *lop = NULL;
1728
1729 if (!pInData)
1730 {
1731 error = 1;
1732 fprintf(stderr, "Missing input data.\n");
1733 }
1734 else if (!pWithData)
1735 {
1736 error = 1;
1737 fprintf(stderr, "Missing input data.\n");
1738 }
1739 else
1740 {
1741 short *result = NULL;
1742 arraylen_t index = 0;
1743
1744 for (; index < nElements; index++)
1745 {
1746 result = &(pOutData[index]);
1747 *result = DRMS_MISSING_SHORT;
1748
1749 if (!drms_ismissing_short(pInData[index]) &&
1750 (!!drms_ismissing_short(pWithData[index])))
1751 {
1752 percentDone = index * 100/nElements;
1753
1754 if (first)
1755 {
1756 fprintf(stdout, "%03d%% done", percentDone);
1757 first = 0;
1758 }
1759 else if (percentDone == update)
1760 {
1761 update++;
1762 fprintf(stdout,
1763 "\b\b\b\b\b\b\b\b\b%03d%% done",
1764 percentDone);
1765 fflush(stdout);
1766 }
1767
1768 lop = &(pInData[index]);
1769 rop = &(pWithData[index]);
1770 *result = *lop - *rop;
1771 }
1772 }
1773
1774 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1775 fflush(stdout);
1776 }
1777
1778 return error;
1779 }
1780
1781 static int SubInt(const int *pInData, const int *pWithData, arraylen_t nElements, int *pOutData)
1782 {
1783 int error = 0;
1784
1785 int first = 1;
1786 int percentDone = 0;
1787 int update = 0;
1788
1789 const int *rop = NULL;
1790 const int *lop = NULL;
1791
1792 if (!pInData)
1793 {
1794 error = 1;
1795 fprintf(stderr, "Missing input data.\n");
1796 }
1797 else if (!pWithData)
1798 {
1799 error = 1;
1800 fprintf(stderr, "Missing input data.\n");
1801 }
1802 else
1803 {
1804 int *result = NULL;
1805 arraylen_t index = 0;
1806
1807 for (; index < nElements; index++)
1808 {
1809 result = &(pOutData[index]);
1810 *result = DRMS_MISSING_INT;
1811
1812 if (!drms_ismissing_int(pInData[index]) &&
1813 (!!drms_ismissing_int(pWithData[index])))
1814 {
1815 percentDone = index * 100/nElements;
1816
1817 if (first)
1818 {
1819 fprintf(stdout, "%03d%% done", percentDone);
1820 first = 0;
1821 }
1822 else if (percentDone == update)
1823 {
1824 update++;
1825 fprintf(stdout,
1826 "\b\b\b\b\b\b\b\b\b%03d%% done",
1827 percentDone);
1828 fflush(stdout);
1829 }
1830
1831 lop = &(pInData[index]);
1832 rop = &(pWithData[index]);
1833 *result = *lop - *rop;
1834 }
1835 }
1836
1837 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1838 fflush(stdout);
1839 }
1840
1841 return error;
1842 }
1843
1844 static int SubLongLong(const long long *pInData,
1845 const long long *pWithData,
1846 arraylen_t nElements,
1847 long long *pOutData)
1848 {
1849 int error = 0;
1850
1851 int first = 1;
1852 int percentDone = 0;
1853 int update = 0;
1854
1855 const long long *rop = NULL;
1856 const long long *lop = NULL;
1857
1858 if (!pInData)
1859 {
1860 error = 1;
1861 fprintf(stderr, "Missing input data.\n");
1862 }
1863 else if (!pWithData)
1864 {
1865 error = 1;
1866 fprintf(stderr, "Missing input data.\n");
1867 }
1868 else
1869 {
1870 long long *result = NULL;
1871 arraylen_t index = 0;
1872
1873 for (; index < nElements; index++)
1874 {
1875 result = &(pOutData[index]);
1876 *result = DRMS_MISSING_LONGLONG;
1877
1878 if (!drms_ismissing_longlong(pInData[index]) &&
1879 (!!drms_ismissing_longlong(pWithData[index])))
1880 {
1881 percentDone = index * 100/nElements;
1882
1883 if (first)
1884 {
1885 fprintf(stdout, "%03d%% done", percentDone);
1886 first = 0;
1887 }
1888 else if (percentDone == update)
1889 {
1890 update++;
1891 fprintf(stdout,
1892 "\b\b\b\b\b\b\b\b\b%03d%% done",
1893 percentDone);
1894 fflush(stdout);
1895 }
1896
1897 lop = &(pInData[index]);
1898 rop = &(pWithData[index]);
1899 *result = *lop - *rop;
1900 }
1901 }
1902
1903 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1904 fflush(stdout);
1905 }
1906
1907 return error;
1908 }
1909
1910 static int SubFloat(const float *pInData, const float *pWithData, arraylen_t nElements, float *pOutData)
1911 {
1912 int error = 0;
1913
1914 int first = 1;
1915 int percentDone = 0;
1916 int update = 0;
1917
1918 const float *rop = NULL;
1919 const float *lop = NULL;
1920
1921 if (!pInData)
1922 {
1923 error = 1;
1924 fprintf(stderr, "Missing input data.\n");
1925 }
1926 else if (!pWithData)
1927 {
1928 error = 1;
1929 fprintf(stderr, "Missing input data.\n");
1930 }
1931 else
1932 {
1933 float *result = NULL;
1934 arraylen_t index = 0;
1935
1936 for (; index < nElements; index++)
1937 {
1938 result = &(pOutData[index]);
1939 *result = DRMS_MISSING_FLOAT;
1940
1941 if (!drms_ismissing_float(pInData[index]) &&
1942 (!!drms_ismissing_float(pWithData[index])))
1943 {
1944 percentDone = index * 100/nElements;
1945
1946 if (first)
1947 {
1948 fprintf(stdout, "%03d%% done", percentDone);
1949 first = 0;
1950 }
1951 else if (percentDone == update)
1952 {
1953 update++;
1954 fprintf(stdout,
1955 "\b\b\b\b\b\b\b\b\b%03d%% done",
1956 percentDone);
1957 fflush(stdout);
1958 }
1959
1960 lop = &(pInData[index]);
1961 rop = &(pWithData[index]);
1962 *result = *lop - *rop;
1963 }
1964 }
1965
1966 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
1967 fflush(stdout);
1968 }
1969
1970 return error;
1971 }
1972
1973 static int SubDouble(const double *pInData, const double *pWithData, arraylen_t nElements, double *pOutData)
1974 {
1975 int error = 0;
1976
1977 int first = 1;
1978 int percentDone = 0;
1979 int update = 0;
1980
1981 const double *rop = NULL;
1982 const double *lop = NULL;
1983
1984 if (!pInData)
1985 {
1986 error = 1;
1987 fprintf(stderr, "Missing input data.\n");
1988 }
1989 else if (!pWithData)
1990 {
1991 error = 1;
1992 fprintf(stderr, "Missing input data.\n");
1993 }
1994 else
1995 {
1996 double *result = NULL;
1997 arraylen_t index = 0;
1998
1999 for (; index < nElements; index++)
2000 {
2001 result = &(pOutData[index]);
2002 *result = DRMS_MISSING_DOUBLE;
2003
2004 if (!drms_ismissing_double(pInData[index]) &&
2005 (!!drms_ismissing_double(pWithData[index])))
2006 {
2007 percentDone = index * 100/nElements;
2008
2009 if (first)
2010 {
2011 fprintf(stdout, "%03d%% done", percentDone);
2012 first = 0;
2013 }
2014 else if (percentDone == update)
2015 {
2016 update++;
2017 fprintf(stdout,
2018 "\b\b\b\b\b\b\b\b\b%03d%% done",
2019 percentDone);
2020 fflush(stdout);
2021 }
2022
2023 lop = &(pInData[index]);
2024 rop = &(pWithData[index]);
2025 *result = *lop - *rop;
2026 }
2027 }
2028
2029 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2030 fflush(stdout);
2031 }
2032
2033 return error;
2034 }
2035
2036 static int AbsChar(const char *pInData, arraylen_t nElements, char *pOutData)
2037 {
2038 int error = 0;
2039
2040 int first = 1;
2041 int percentDone = 0;
2042 int update = 0;
2043
2044 const char *lop = NULL;
2045
2046 if (!pInData)
2047 {
2048 error = 1;
2049 fprintf(stderr, "Missing input data.\n");
2050 }
2051 else
2052 {
2053 char *result = NULL;
2054 arraylen_t index = 0;
2055
2056 for (; index < nElements; index++)
2057 {
2058 result = &(pOutData[index]);
2059 *result = DRMS_MISSING_CHAR;
2060
2061 if (!drms_ismissing_char(pInData[index]))
2062 {
2063 percentDone = index * 100/nElements;
2064
2065 if (first)
2066 {
2067 fprintf(stdout, "%03d%% done", percentDone);
2068 first = 0;
2069 }
2070 else if (percentDone == update)
2071 {
2072 update++;
2073 fprintf(stdout,
2074 "\b\b\b\b\b\b\b\b\b%03d%% done",
2075 percentDone);
2076 fflush(stdout);
2077 }
2078
2079 lop = &(pInData[index]);
2080 *result = abs(*lop);
2081 }
2082 }
2083
2084 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2085 fflush(stdout);
2086 }
2087
2088 return error;
2089 }
2090
2091 static int AbsShort(const short *pInData, arraylen_t nElements, short *pOutData)
2092 {
2093 int error = 0;
2094
2095 int first = 1;
2096 int percentDone = 0;
2097 int update = 0;
2098
2099 const short *lop = NULL;
2100
2101 if (!pInData)
2102 {
2103 error = 1;
2104 fprintf(stderr, "Missing input data.\n");
2105 }
2106 else
2107 {
2108 short *result = NULL;
2109 arraylen_t index = 0;
2110
2111 for (; index < nElements; index++)
2112 {
2113 result = &(pOutData[index]);
2114 *result = DRMS_MISSING_SHORT;
2115
2116 if (!drms_ismissing_short(pInData[index]))
2117 {
2118 percentDone = index * 100/nElements;
2119
2120 if (first)
2121 {
2122 fprintf(stdout, "%03d%% done", percentDone);
2123 first = 0;
2124 }
2125 else if (percentDone == update)
2126 {
2127 update++;
2128 fprintf(stdout,
2129 "\b\b\b\b\b\b\b\b\b%03d%% done",
2130 percentDone);
2131 fflush(stdout);
2132 }
2133
2134 lop = &(pInData[index]);
2135 *result = abs(*lop);
2136 }
2137 }
2138
2139 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2140 fflush(stdout);
2141 }
2142
2143 return error;
2144 }
2145
2146 static int AbsInt(const int *pInData, arraylen_t nElements, int *pOutData)
2147 {
2148 int error = 0;
2149
2150 int first = 1;
2151 int percentDone = 0;
2152 int update = 0;
2153
2154 const int *lop = NULL;
2155
2156 if (!pInData)
2157 {
2158 error = 1;
2159 fprintf(stderr, "Missing input data.\n");
2160 }
2161 else
2162 {
2163 int *result = NULL;
2164 arraylen_t index = 0;
2165
2166 for (; index < nElements; index++)
2167 {
2168 result = &(pOutData[index]);
2169 *result = DRMS_MISSING_INT;
2170
2171 if (!drms_ismissing_int(pInData[index]))
2172 {
2173 percentDone = index * 100/nElements;
2174
2175 if (first)
2176 {
2177 fprintf(stdout, "%03d%% done", percentDone);
2178 first = 0;
2179 }
2180 else if (percentDone == update)
2181 {
2182 update++;
2183 fprintf(stdout,
2184 "\b\b\b\b\b\b\b\b\b%03d%% done",
2185 percentDone);
2186 fflush(stdout);
2187 }
2188
2189 lop = &(pInData[index]);
2190 *result = abs(*lop);
2191 }
2192 }
2193
2194 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2195 fflush(stdout);
2196 }
2197
2198 return error;
2199 }
2200
2201 static int AbsLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
2202 {
2203 int error = 0;
2204
2205 int first = 1;
2206 int percentDone = 0;
2207 int update = 0;
2208
2209 const long long *lop = NULL;
2210
2211 if (!pInData)
2212 {
2213 error = 1;
2214 fprintf(stderr, "Missing input data.\n");
2215 }
2216 else
2217 {
2218 long long *result = NULL;
2219 arraylen_t index = 0;
2220
2221 for (; index < nElements; index++)
2222 {
2223 result = &(pOutData[index]);
2224 *result = DRMS_MISSING_LONGLONG;
2225
2226 if (!drms_ismissing_longlong(pInData[index]))
2227 {
2228 percentDone = index * 100/nElements;
2229
2230 if (first)
2231 {
2232 fprintf(stdout, "%03d%% done", percentDone);
2233 first = 0;
2234 }
2235 else if (percentDone == update)
2236 {
2237 update++;
2238 fprintf(stdout,
2239 "\b\b\b\b\b\b\b\b\b%03d%% done",
2240 percentDone);
2241 fflush(stdout);
2242 }
2243
2244 lop = &(pInData[index]);
2245 *result = llabs(*lop);
2246 }
2247 }
2248
2249 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2250 fflush(stdout);
2251 }
2252
2253 return error;
2254 }
2255
2256 static int AbsFloat(const float *pInData, arraylen_t nElements, float *pOutData)
2257 {
2258 int error = 0;
2259
2260 int first = 1;
2261 int percentDone = 0;
2262 int update = 0;
2263
2264 const float *lop = NULL;
2265
2266 if (!pInData)
2267 {
2268 error = 1;
2269 fprintf(stderr, "Missing input data.\n");
2270 }
2271 else
2272 {
2273 float *result = NULL;
2274 arraylen_t index = 0;
2275
2276 for (; index < nElements; index++)
2277 {
2278 result = &(pOutData[index]);
2279 *result = DRMS_MISSING_FLOAT;
2280
2281 if (!drms_ismissing_float(pInData[index]))
2282 {
2283 percentDone = index * 100/nElements;
2284
2285 if (first)
2286 {
2287 fprintf(stdout, "%03d%% done", percentDone);
2288 first = 0;
2289 }
2290 else if (percentDone == update)
2291 {
2292 update++;
2293 fprintf(stdout,
2294 "\b\b\b\b\b\b\b\b\b%03d%% done",
2295 percentDone);
2296 fflush(stdout);
2297 }
2298
2299 lop = &(pInData[index]);
2300 *result = fabsf(*lop);
2301 }
2302 }
2303
2304 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2305 fflush(stdout);
2306 }
2307
2308 return error;
2309 }
2310
2311 static int AbsDouble(const double *pInData, arraylen_t nElements, double *pOutData)
2312 {
2313 int error = 0;
2314
2315 int first = 1;
2316 int percentDone = 0;
2317 int update = 0;
2318
2319 const double *lop = NULL;
2320
2321 if (!pInData)
2322 {
2323 error = 1;
2324 fprintf(stderr, "Missing input data.\n");
2325 }
2326 else
2327 {
2328 double *result = NULL;
2329 arraylen_t index = 0;
2330
2331 for (; index < nElements; index++)
2332 {
2333 result = &(pOutData[index]);
2334 *result = DRMS_MISSING_DOUBLE;
2335
2336 if (!drms_ismissing_double(pInData[index]))
2337 {
2338 percentDone = index * 100/nElements;
2339
2340 if (first)
2341 {
2342 fprintf(stdout, "%03d%% done", percentDone);
2343 first = 0;
2344 }
2345 else if (percentDone == update)
2346 {
2347 update++;
2348 fprintf(stdout,
2349 "\b\b\b\b\b\b\b\b\b%03d%% done",
2350 percentDone);
2351 fflush(stdout);
2352 }
2353
2354 lop = &(pInData[index]);
2355 *result = fabs(*lop);
2356 }
2357 }
2358
2359 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2360 fflush(stdout);
2361 }
2362
2363 return error;
2364 }
2365
2366 static int SqrtChar(const char *pInData, arraylen_t nElements, char *pOutData)
2367 {
2368 int error = 0;
2369
2370 int first = 1;
2371 int percentDone = 0;
2372 int update = 0;
2373
2374 const char *lop = NULL;
2375
2376 if (!pInData)
2377 {
2378 error = 1;
2379 fprintf(stderr, "Missing input data.\n");
2380 }
2381 else
2382 {
2383 char *result = NULL;
2384 arraylen_t index = 0;
2385
2386 for (; index < nElements; index++)
2387 {
2388 result = &(pOutData[index]);
2389 *result = DRMS_MISSING_CHAR;
2390
2391 if (!drms_ismissing_char(pInData[index]))
2392 {
2393 percentDone = index * 100/nElements;
2394
2395 if (first)
2396 {
2397 fprintf(stdout, "%03d%% done", percentDone);
2398 first = 0;
2399 }
2400 else if (percentDone == update)
2401 {
2402 update++;
2403 fprintf(stdout,
2404 "\b\b\b\b\b\b\b\b\b%03d%% done",
2405 percentDone);
2406 fflush(stdout);
2407 }
2408
2409 lop = &(pInData[index]);
2410 *result = sqrt(abs(*lop));
2411 }
2412 }
2413
2414 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2415 fflush(stdout);
2416 }
2417
2418 return error;
2419 }
2420
2421 static int SqrtShort(const short *pInData, arraylen_t nElements, short *pOutData)
2422 {
2423 int error = 0;
2424
2425 int first = 1;
2426 int percentDone = 0;
2427 int update = 0;
2428
2429 const short *lop = NULL;
2430
2431 if (!pInData)
2432 {
2433 error = 1;
2434 fprintf(stderr, "Missing input data.\n");
2435 }
2436 else
2437 {
2438 short *result = NULL;
2439 arraylen_t index = 0;
2440
2441 for (; index < nElements; index++)
2442 {
2443 result = &(pOutData[index]);
2444 *result = DRMS_MISSING_SHORT;
2445
2446 if (!drms_ismissing_short(pInData[index]))
2447 {
2448 percentDone = index * 100/nElements;
2449
2450 if (first)
2451 {
2452 fprintf(stdout, "%03d%% done", percentDone);
2453 first = 0;
2454 }
2455 else if (percentDone == update)
2456 {
2457 update++;
2458 fprintf(stdout,
2459 "\b\b\b\b\b\b\b\b\b%03d%% done",
2460 percentDone);
2461 fflush(stdout);
2462 }
2463
2464 lop = &(pInData[index]);
2465 *result = sqrt(abs(*lop));
2466 }
2467 }
2468
2469 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2470 fflush(stdout);
2471 }
2472
2473 return error;
2474 }
2475
2476 static int SqrtInt(const int *pInData, arraylen_t nElements, int *pOutData)
2477 {
2478 int error = 0;
2479
2480 int first = 1;
2481 int percentDone = 0;
2482 int update = 0;
2483
2484 const int *lop = NULL;
2485
2486 if (!pInData)
2487 {
2488 error = 1;
2489 fprintf(stderr, "Missing input data.\n");
2490 }
2491 else
2492 {
2493 int *result = NULL;
2494 arraylen_t index = 0;
2495
2496 for (; index < nElements; index++)
2497 {
2498 result = &(pOutData[index]);
2499 *result = DRMS_MISSING_INT;
2500
2501 if (!drms_ismissing_int(pInData[index]))
2502 {
2503 percentDone = index * 100/nElements;
2504
2505 if (first)
2506 {
2507 fprintf(stdout, "%03d%% done", percentDone);
2508 first = 0;
2509 }
2510 else if (percentDone == update)
2511 {
2512 update++;
2513 fprintf(stdout,
2514 "\b\b\b\b\b\b\b\b\b%03d%% done",
2515 percentDone);
2516 fflush(stdout);
2517 }
2518
2519 lop = &(pInData[index]);
2520 *result = sqrt(abs(*lop));
2521 }
2522 }
2523
2524 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2525 fflush(stdout);
2526 }
2527
2528 return error;
2529 }
2530
2531 static int SqrtLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
2532 {
2533 int error = 0;
2534
2535 int first = 1;
2536 int percentDone = 0;
2537 int update = 0;
2538
2539 const long long *lop = NULL;
2540
2541 if (!pInData)
2542 {
2543 error = 1;
2544 fprintf(stderr, "Missing input data.\n");
2545 }
2546 else
2547 {
2548 long long *result = NULL;
2549 arraylen_t index = 0;
2550
2551 for (; index < nElements; index++)
2552 {
2553 result = &(pOutData[index]);
2554 *result = DRMS_MISSING_LONGLONG;
2555
2556 if (!drms_ismissing_longlong(pInData[index]))
2557 {
2558 percentDone = index * 100/nElements;
2559
2560 if (first)
2561 {
2562 fprintf(stdout, "%03d%% done", percentDone);
2563 first = 0;
2564 }
2565 else if (percentDone == update)
2566 {
2567 update++;
2568 fprintf(stdout,
2569 "\b\b\b\b\b\b\b\b\b%03d%% done",
2570 percentDone);
2571 fflush(stdout);
2572 }
2573
2574 lop = &(pInData[index]);
2575 *result = sqrt(llabs(*lop));
2576 }
2577 }
2578
2579 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2580 fflush(stdout);
2581 }
2582
2583 return error;
2584 }
2585
2586 static int SqrtFloat(const float *pInData, arraylen_t nElements, float *pOutData)
2587 {
2588 int error = 0;
2589
2590 int first = 1;
2591 int percentDone = 0;
2592 int update = 0;
2593
2594 const float *lop = NULL;
2595
2596 if (!pInData)
2597 {
2598 error = 1;
2599 fprintf(stderr, "Missing input data.\n");
2600 }
2601 else
2602 {
2603 float *result = NULL;
2604 arraylen_t index = 0;
2605
2606 for (; index < nElements; index++)
2607 {
2608 result = &(pOutData[index]);
2609 *result = DRMS_MISSING_FLOAT;
2610
2611 if (!drms_ismissing_float(pInData[index]))
2612 {
2613 percentDone = index * 100/nElements;
2614
2615 if (first)
2616 {
2617 fprintf(stdout, "%03d%% done", percentDone);
2618 first = 0;
2619 }
2620 else if (percentDone == update)
2621 {
2622 update++;
2623 fprintf(stdout,
2624 "\b\b\b\b\b\b\b\b\b%03d%% done",
2625 percentDone);
2626 fflush(stdout);
2627 }
2628
2629 lop = &(pInData[index]);
2630 *result = sqrt(fabsf(*lop));
2631 }
2632 }
2633
2634 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2635 fflush(stdout);
2636 }
2637
2638 return error;
2639 }
2640
2641 static int SqrtDouble(const double *pInData, arraylen_t nElements, double *pOutData)
2642 {
2643 int error = 0;
2644
2645 int first = 1;
2646 int percentDone = 0;
2647 int update = 0;
2648
2649 const double *lop = NULL;
2650
2651 if (!pInData)
2652 {
2653 error = 1;
2654 fprintf(stderr, "Missing input data.\n");
2655 }
2656 else
2657 {
2658 double *result = NULL;
2659 arraylen_t index = 0;
2660
2661 for (; index < nElements; index++)
2662 {
2663 result = &(pOutData[index]);
2664 *result = DRMS_MISSING_DOUBLE;
2665
2666 if (!drms_ismissing_double(pInData[index]))
2667 {
2668 percentDone = index * 100/nElements;
2669
2670 if (first)
2671 {
2672 fprintf(stdout, "%03d%% done", percentDone);
2673 first = 0;
2674 }
2675 else if (percentDone == update)
2676 {
2677 update++;
2678 fprintf(stdout,
2679 "\b\b\b\b\b\b\b\b\b%03d%% done",
2680 percentDone);
2681 fflush(stdout);
2682 }
2683
2684 lop = &(pInData[index]);
2685 *result = sqrt(fabs(*lop));
2686 }
2687 }
2688
2689 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2690 fflush(stdout);
2691 }
2692
2693 return error;
2694 }
2695
2696 static int LogChar(const char *pInData, arraylen_t nElements, char *pOutData)
2697 {
2698 int error = 0;
2699
2700 int first = 1;
2701 int percentDone = 0;
2702 int update = 0;
2703
2704 const char *lop = NULL;
2705
2706 if (!pInData)
2707 {
2708 error = 1;
2709 fprintf(stderr, "Missing input data.\n");
2710 }
2711 else
2712 {
2713 char *result = NULL;
2714 arraylen_t index = 0;
2715
2716 for (; index < nElements; index++)
2717 {
2718 result = &(pOutData[index]);
2719 *result = DRMS_MISSING_CHAR;
2720
2721 if (!drms_ismissing_char(pInData[index]))
2722 {
2723 percentDone = index * 100/nElements;
2724
2725 if (first)
2726 {
2727 fprintf(stdout, "%03d%% done", percentDone);
2728 first = 0;
2729 }
2730 else if (percentDone == update)
2731 {
2732 update++;
2733 fprintf(stdout,
2734 "\b\b\b\b\b\b\b\b\b%03d%% done",
2735 percentDone);
2736 fflush(stdout);
2737 }
2738
2739 lop = &(pInData[index]);
2740 *result = log10(*lop);
2741 }
2742 }
2743
2744 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2745 fflush(stdout);
2746 }
2747
2748 return error;
2749 }
2750
2751 static int LogShort(const short *pInData, arraylen_t nElements, short *pOutData)
2752 {
2753 int error = 0;
2754
2755 int first = 1;
2756 int percentDone = 0;
2757 int update = 0;
2758
2759 const short *lop = NULL;
2760
2761 if (!pInData)
2762 {
2763 error = 1;
2764 fprintf(stderr, "Missing input data.\n");
2765 }
2766 else
2767 {
2768 short *result = NULL;
2769 arraylen_t index = 0;
2770
2771 for (; index < nElements; index++)
2772 {
2773 result = &(pOutData[index]);
2774 *result = DRMS_MISSING_SHORT;
2775
2776 if (!drms_ismissing_short(pInData[index]))
2777 {
2778 percentDone = index * 100/nElements;
2779
2780 if (first)
2781 {
2782 fprintf(stdout, "%03d%% done", percentDone);
2783 first = 0;
2784 }
2785 else if (percentDone == update)
2786 {
2787 update++;
2788 fprintf(stdout,
2789 "\b\b\b\b\b\b\b\b\b%03d%% done",
2790 percentDone);
2791 fflush(stdout);
2792 }
2793
2794 lop = &(pInData[index]);
2795 *result = log10(*lop);
2796 }
2797 }
2798
2799 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2800 fflush(stdout);
2801 }
2802
2803 return error;
2804 }
2805
2806 static int LogInt(const int *pInData, arraylen_t nElements, int *pOutData)
2807 {
2808 int error = 0;
2809
2810 int first = 1;
2811 int percentDone = 0;
2812 int update = 0;
2813
2814 const int *lop = NULL;
2815
2816 if (!pInData)
2817 {
2818 error = 1;
2819 fprintf(stderr, "Missing input data.\n");
2820 }
2821 else
2822 {
2823 int *result = NULL;
2824 arraylen_t index = 0;
2825
2826 for (; index < nElements; index++)
2827 {
2828 result = &(pOutData[index]);
2829 *result = DRMS_MISSING_INT;
2830
2831 if (!drms_ismissing_int(pInData[index]))
2832 {
2833 percentDone = index * 100/nElements;
2834
2835 if (first)
2836 {
2837 fprintf(stdout, "%03d%% done", percentDone);
2838 first = 0;
2839 }
2840 else if (percentDone == update)
2841 {
2842 update++;
2843 fprintf(stdout,
2844 "\b\b\b\b\b\b\b\b\b%03d%% done",
2845 percentDone);
2846 fflush(stdout);
2847 }
2848
2849 lop = &(pInData[index]);
2850 *result = log10(*lop);
2851 }
2852 }
2853
2854 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2855 fflush(stdout);
2856 }
2857
2858 return error;
2859 }
2860
2861 static int LogLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
2862 {
2863 int error = 0;
2864
2865 int first = 1;
2866 int percentDone = 0;
2867 int update = 0;
2868
2869 const long long *lop = NULL;
2870
2871 if (!pInData)
2872 {
2873 error = 1;
2874 fprintf(stderr, "Missing input data.\n");
2875 }
2876 else
2877 {
2878 long long *result = NULL;
2879 arraylen_t index = 0;
2880
2881 for (; index < nElements; index++)
2882 {
2883 result = &(pOutData[index]);
2884 *result = DRMS_MISSING_LONGLONG;
2885
2886 if (!drms_ismissing_longlong(pInData[index]))
2887 {
2888 percentDone = index * 100/nElements;
2889
2890 if (first)
2891 {
2892 fprintf(stdout, "%03d%% done", percentDone);
2893 first = 0;
2894 }
2895 else if (percentDone == update)
2896 {
2897 update++;
2898 fprintf(stdout,
2899 "\b\b\b\b\b\b\b\b\b%03d%% done",
2900 percentDone);
2901 fflush(stdout);
2902 }
2903
2904 lop = &(pInData[index]);
2905 *result = log10(*lop);
2906 }
2907 }
2908
2909 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2910 fflush(stdout);
2911 }
2912
2913 return error;
2914 }
2915
2916 static int LogFloat(const float *pInData, arraylen_t nElements, float *pOutData)
2917 {
2918 int error = 0;
2919
2920 int first = 1;
2921 int percentDone = 0;
2922 int update = 0;
2923
2924 const float *lop = NULL;
2925
2926 if (!pInData)
2927 {
2928 error = 1;
2929 fprintf(stderr, "Missing input data.\n");
2930 }
2931 else
2932 {
2933 float *result = NULL;
2934 arraylen_t index = 0;
2935
2936 for (; index < nElements; index++)
2937 {
2938 result = &(pOutData[index]);
2939 *result = DRMS_MISSING_FLOAT;
2940
2941 if (!drms_ismissing_float(pInData[index]))
2942 {
2943 percentDone = index * 100/nElements;
2944
2945 if (first)
2946 {
2947 fprintf(stdout, "%03d%% done", percentDone);
2948 first = 0;
2949 }
2950 else if (percentDone == update)
2951 {
2952 update++;
2953 fprintf(stdout,
2954 "\b\b\b\b\b\b\b\b\b%03d%% done",
2955 percentDone);
2956 fflush(stdout);
2957 }
2958
2959 lop = &(pInData[index]);
2960 *result = log10f(*lop);
2961 }
2962 }
2963
2964 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
2965 fflush(stdout);
2966 }
2967
2968 return error;
2969 }
2970
2971 static int LogDouble(const double *pInData, arraylen_t nElements, double *pOutData)
2972 {
2973 int error = 0;
2974
2975 int first = 1;
2976 int percentDone = 0;
2977 int update = 0;
2978
2979 const double *lop = NULL;
2980
2981 if (!pInData)
2982 {
2983 error = 1;
2984 fprintf(stderr, "Missing input data.\n");
2985 }
2986 else
2987 {
2988 double *result = NULL;
2989 arraylen_t index = 0;
2990
2991 for (; index < nElements; index++)
2992 {
2993 result = &(pOutData[index]);
2994 *result = DRMS_MISSING_DOUBLE;
2995
2996 if (!drms_ismissing_double(pInData[index]))
2997 {
2998 percentDone = index * 100/nElements;
2999
3000 if (first)
3001 {
3002 fprintf(stdout, "%03d%% done", percentDone);
3003 first = 0;
3004 }
3005 else if (percentDone == update)
3006 {
3007 update++;
3008 fprintf(stdout,
3009 "\b\b\b\b\b\b\b\b\b%03d%% done",
3010 percentDone);
3011 fflush(stdout);
3012 }
3013
3014 lop = &(pInData[index]);
3015 *result = log10(*lop);
3016 }
3017 }
3018
3019 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3020 fflush(stdout);
3021 }
3022
3023 return error;
3024 }
3025
3026 static int PowChar(const char *pInData, arraylen_t nElements, char *pOutData)
3027 {
3028 int error = 0;
3029
3030 int first = 1;
3031 int percentDone = 0;
3032 int update = 0;
3033
3034 const char *lop = NULL;
3035
3036 if (!pInData)
3037 {
3038 error = 1;
3039 fprintf(stderr, "Missing input data.\n");
3040 }
3041 else
3042 {
3043 char *result = NULL;
3044 arraylen_t index = 0;
3045
3046 for (; index < nElements; index++)
3047 {
3048 result = &(pOutData[index]);
3049 *result = DRMS_MISSING_CHAR;
3050
3051 if (!drms_ismissing_char(pInData[index]))
3052 {
3053 percentDone = index * 100/nElements;
3054
3055 if (first)
3056 {
3057 fprintf(stdout, "%03d%% done", percentDone);
3058 first = 0;
3059 }
3060 else if (percentDone == update)
3061 {
3062 update++;
3063 fprintf(stdout,
3064 "\b\b\b\b\b\b\b\b\b%03d%% done",
3065 percentDone);
3066 fflush(stdout);
3067 }
3068
3069 lop = &(pInData[index]);
3070 *result = pow(10.0, *lop);
3071 }
3072 }
3073
3074 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3075 fflush(stdout);
3076 }
3077
3078 return error;
3079 }
3080
3081 static int PowShort(const short *pInData, arraylen_t nElements, short *pOutData)
3082 {
3083 int error = 0;
3084
3085 int first = 1;
3086 int percentDone = 0;
3087 int update = 0;
3088
3089 const short *lop = NULL;
3090
3091 if (!pInData)
3092 {
3093 error = 1;
3094 fprintf(stderr, "Missing input data.\n");
3095 }
3096 else
3097 {
3098 short *result = NULL;
3099 arraylen_t index = 0;
3100
3101 for (; index < nElements; index++)
3102 {
3103 result = &(pOutData[index]);
3104 *result = DRMS_MISSING_SHORT;
3105
3106 if (!drms_ismissing_short(pInData[index]))
3107 {
3108 percentDone = index * 100/nElements;
3109
3110 if (first)
3111 {
3112 fprintf(stdout, "%03d%% done", percentDone);
3113 first = 0;
3114 }
3115 else if (percentDone == update)
3116 {
3117 update++;
3118 fprintf(stdout,
3119 "\b\b\b\b\b\b\b\b\b%03d%% done",
3120 percentDone);
3121 fflush(stdout);
3122 }
3123
3124 lop = &(pInData[index]);
3125 *result = pow(10.0, *lop);
3126 }
3127 }
3128
3129 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3130 fflush(stdout);
3131 }
3132
3133 return error;
3134 }
3135
3136 static int PowInt(const int *pInData, arraylen_t nElements, int *pOutData)
3137 {
3138 int error = 0;
3139
3140 int first = 1;
3141 int percentDone = 0;
3142 int update = 0;
3143
3144 const int *lop = NULL;
3145
3146 if (!pInData)
3147 {
3148 error = 1;
3149 fprintf(stderr, "Missing input data.\n");
3150 }
3151 else
3152 {
3153 int *result = NULL;
3154 arraylen_t index = 0;
3155
3156 for (; index < nElements; index++)
3157 {
3158 result = &(pOutData[index]);
3159 *result = DRMS_MISSING_INT;
3160
3161 if (!drms_ismissing_int(pInData[index]))
3162 {
3163 percentDone = index * 100/nElements;
3164
3165 if (first)
3166 {
3167 fprintf(stdout, "%03d%% done", percentDone);
3168 first = 0;
3169 }
3170 else if (percentDone == update)
3171 {
3172 update++;
3173 fprintf(stdout,
3174 "\b\b\b\b\b\b\b\b\b%03d%% done",
3175 percentDone);
3176 fflush(stdout);
3177 }
3178
3179 lop = &(pInData[index]);
3180 *result = pow(10.0, *lop);
3181 }
3182 }
3183
3184 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3185 fflush(stdout);
3186 }
3187
3188 return error;
3189 }
3190
3191 static int PowLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
3192 {
3193 int error = 0;
3194
3195 int first = 1;
3196 int percentDone = 0;
3197 int update = 0;
3198
3199 const long long *lop = NULL;
3200
3201 if (!pInData)
3202 {
3203 error = 1;
3204 fprintf(stderr, "Missing input data.\n");
3205 }
3206 else
3207 {
3208 long long *result = NULL;
3209 arraylen_t index = 0;
3210
3211 for (; index < nElements; index++)
3212 {
3213 result = &(pOutData[index]);
3214 *result = DRMS_MISSING_LONGLONG;
3215
3216 if (!drms_ismissing_longlong(pInData[index]))
3217 {
3218 percentDone = index * 100/nElements;
3219
3220 if (first)
3221 {
3222 fprintf(stdout, "%03d%% done", percentDone);
3223 first = 0;
3224 }
3225 else if (percentDone == update)
3226 {
3227 update++;
3228 fprintf(stdout,
3229 "\b\b\b\b\b\b\b\b\b%03d%% done",
3230 percentDone);
3231 fflush(stdout);
3232 }
3233
3234 lop = &(pInData[index]);
3235 *result = pow(10.0, *lop);
3236 }
3237 }
3238
3239 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3240 fflush(stdout);
3241 }
3242
3243 return error;
3244 }
3245
3246 static int PowFloat(const float *pInData, arraylen_t nElements, float *pOutData)
3247 {
3248 int error = 0;
3249
3250 int first = 1;
3251 int percentDone = 0;
3252 int update = 0;
3253
3254 const float *lop = NULL;
3255
3256 if (!pInData)
3257 {
3258 error = 1;
3259 fprintf(stderr, "Missing input data.\n");
3260 }
3261 else
3262 {
3263 float *result = NULL;
3264 arraylen_t index = 0;
3265
3266 for (; index < nElements; index++)
3267 {
3268 result = &(pOutData[index]);
3269 *result = DRMS_MISSING_FLOAT;
3270
3271 if (!drms_ismissing_float(pInData[index]))
3272 {
3273 percentDone = index * 100/nElements;
3274
3275 if (first)
3276 {
3277 fprintf(stdout, "%03d%% done", percentDone);
3278 first = 0;
3279 }
3280 else if (percentDone == update)
3281 {
3282 update++;
3283 fprintf(stdout,
3284 "\b\b\b\b\b\b\b\b\b%03d%% done",
3285 percentDone);
3286 fflush(stdout);
3287 }
3288
3289 lop = &(pInData[index]);
3290 *result = powf(10.0, *lop);
3291 }
3292 }
3293
3294 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3295 fflush(stdout);
3296 }
3297
3298 return error;
3299 }
3300
3301 static int PowDouble(const double *pInData, arraylen_t nElements, double *pOutData)
3302 {
3303 int error = 0;
3304
3305 int first = 1;
3306 int percentDone = 0;
3307 int update = 0;
3308
3309 const double *lop = NULL;
3310
3311 if (!pInData)
3312 {
3313 error = 1;
3314 fprintf(stderr, "Missing input data.\n");
3315 }
3316 else
3317 {
3318 double *result = NULL;
3319 arraylen_t index = 0;
3320
3321 for (; index < nElements; index++)
3322 {
3323 result = &(pOutData[index]);
3324 *result = DRMS_MISSING_DOUBLE;
3325
3326 if (!drms_ismissing_double(pInData[index]))
3327 {
3328 percentDone = index * 100/nElements;
3329
3330 if (first)
3331 {
3332 fprintf(stdout, "%03d%% done", percentDone);
3333 first = 0;
3334 }
3335 else if (percentDone == update)
3336 {
3337 update++;
3338 fprintf(stdout,
3339 "\b\b\b\b\b\b\b\b\b%03d%% done",
3340 percentDone);
3341 fflush(stdout);
3342 }
3343
3344 lop = &(pInData[index]);
3345 *result = pow(10.0, *lop);
3346 }
3347 }
3348
3349 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3350 fflush(stdout);
3351 }
3352
3353 return error;
3354 }
3355
3356 static int SqrChar(const char *pInData, arraylen_t nElements, char *pOutData)
3357 {
3358 int error = 0;
3359
3360 int first = 1;
3361 int percentDone = 0;
3362 int update = 0;
3363
3364 const char *lop = NULL;
3365
3366 if (!pInData)
3367 {
3368 error = 1;
3369 fprintf(stderr, "Missing input data.\n");
3370 }
3371 else
3372 {
3373 char *result = NULL;
3374 arraylen_t index = 0;
3375
3376 for (; index < nElements; index++)
3377 {
3378 result = &(pOutData[index]);
3379 *result = DRMS_MISSING_CHAR;
3380
3381 if (!drms_ismissing_char(pInData[index]))
3382 {
3383 percentDone = index * 100/nElements;
3384
3385 if (first)
3386 {
3387 fprintf(stdout, "%03d%% done", percentDone);
3388 first = 0;
3389 }
3390 else if (percentDone == update)
3391 {
3392 update++;
3393 fprintf(stdout,
3394 "\b\b\b\b\b\b\b\b\b%03d%% done",
3395 percentDone);
3396 fflush(stdout);
3397 }
3398
3399 lop = &(pInData[index]);
3400 *result = *lop * *lop;
3401 }
3402 }
3403
3404 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3405 fflush(stdout);
3406 }
3407
3408 return error;
3409 }
3410
3411 static int SqrShort(const short *pInData, arraylen_t nElements, short *pOutData)
3412 {
3413 int error = 0;
3414
3415 int first = 1;
3416 int percentDone = 0;
3417 int update = 0;
3418
3419 const short *lop = NULL;
3420
3421 if (!pInData)
3422 {
3423 error = 1;
3424 fprintf(stderr, "Missing input data.\n");
3425 }
3426 else
3427 {
3428 short *result = NULL;
3429 arraylen_t index = 0;
3430
3431 for (; index < nElements; index++)
3432 {
3433 result = &(pOutData[index]);
3434 *result = DRMS_MISSING_SHORT;
3435
3436 if (!drms_ismissing_short(pInData[index]))
3437 {
3438 percentDone = index * 100/nElements;
3439
3440 if (first)
3441 {
3442 fprintf(stdout, "%03d%% done", percentDone);
3443 first = 0;
3444 }
3445 else if (percentDone == update)
3446 {
3447 update++;
3448 fprintf(stdout,
3449 "\b\b\b\b\b\b\b\b\b%03d%% done",
3450 percentDone);
3451 fflush(stdout);
3452 }
3453
3454 lop = &(pInData[index]);
3455 *result = *lop * *lop;
3456 }
3457 }
3458
3459 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3460 fflush(stdout);
3461 }
3462
3463 return error;
3464 }
3465
3466 static int SqrInt(const int *pInData, arraylen_t nElements, int *pOutData)
3467 {
3468 int error = 0;
3469
3470 int first = 1;
3471 int percentDone = 0;
3472 int update = 0;
3473
3474 const int *lop = NULL;
3475
3476 if (!pInData)
3477 {
3478 error = 1;
3479 fprintf(stderr, "Missing input data.\n");
3480 }
3481 else
3482 {
3483 int *result = NULL;
3484 arraylen_t index = 0;
3485
3486 for (; index < nElements; index++)
3487 {
3488 result = &(pOutData[index]);
3489 *result = DRMS_MISSING_INT;
3490
3491 if (!drms_ismissing_int(pInData[index]))
3492 {
3493 percentDone = index * 100/nElements;
3494
3495 if (first)
3496 {
3497 fprintf(stdout, "%03d%% done", percentDone);
3498 first = 0;
3499 }
3500 else if (percentDone == update)
3501 {
3502 update++;
3503 fprintf(stdout,
3504 "\b\b\b\b\b\b\b\b\b%03d%% done",
3505 percentDone);
3506 fflush(stdout);
3507 }
3508
3509 lop = &(pInData[index]);
3510 *result = *lop * *lop;
3511 }
3512 }
3513
3514 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3515 fflush(stdout);
3516 }
3517
3518 return error;
3519 }
3520
3521 static int SqrLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
3522 {
3523 int error = 0;
3524
3525 int first = 1;
3526 int percentDone = 0;
3527 int update = 0;
3528
3529 const long long *lop = NULL;
3530
3531 if (!pInData)
3532 {
3533 error = 1;
3534 fprintf(stderr, "Missing input data.\n");
3535 }
3536 else
3537 {
3538 long long *result = NULL;
3539 arraylen_t index = 0;
3540
3541 for (; index < nElements; index++)
3542 {
3543 result = &(pOutData[index]);
3544 *result = DRMS_MISSING_LONGLONG;
3545
3546 if (!drms_ismissing_longlong(pInData[index]))
3547 {
3548 percentDone = index * 100/nElements;
3549
3550 if (first)
3551 {
3552 fprintf(stdout, "%03d%% done", percentDone);
3553 first = 0;
3554 }
3555 else if (percentDone == update)
3556 {
3557 update++;
3558 fprintf(stdout,
3559 "\b\b\b\b\b\b\b\b\b%03d%% done",
3560 percentDone);
3561 fflush(stdout);
3562 }
3563
3564 lop = &(pInData[index]);
3565 *result = *lop * *lop;
3566 }
3567 }
3568
3569 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3570 fflush(stdout);
3571 }
3572
3573 return error;
3574 }
3575
3576 static int SqrFloat(const float *pInData, arraylen_t nElements, float *pOutData)
3577 {
3578 int error = 0;
3579
3580 int first = 1;
3581 int percentDone = 0;
3582 int update = 0;
3583
3584 const float *lop = NULL;
3585
3586 if (!pInData)
3587 {
3588 error = 1;
3589 fprintf(stderr, "Missing input data.\n");
3590 }
3591 else
3592 {
3593 float *result = NULL;
3594 arraylen_t index = 0;
3595
3596 for (; index < nElements; index++)
3597 {
3598 result = &(pOutData[index]);
3599 *result = DRMS_MISSING_FLOAT;
3600
3601 if (!drms_ismissing_float(pInData[index]))
3602 {
3603 percentDone = index * 100/nElements;
3604
3605 if (first)
3606 {
3607 fprintf(stdout, "%03d%% done", percentDone);
3608 first = 0;
3609 }
3610 else if (percentDone == update)
3611 {
3612 update++;
3613 fprintf(stdout,
3614 "\b\b\b\b\b\b\b\b\b%03d%% done",
3615 percentDone);
3616 fflush(stdout);
3617 }
3618
3619 lop = &(pInData[index]);
3620 *result = *lop * *lop;
3621 }
3622 }
3623
3624 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3625 fflush(stdout);
3626 }
3627
3628 return error;
3629 }
3630
3631 static int SqrDouble(const double *pInData, arraylen_t nElements, double *pOutData)
3632 {
3633 int error = 0;
3634
3635 int first = 1;
3636 int percentDone = 0;
3637 int update = 0;
3638
3639 const double *lop = NULL;
3640
3641 if (!pInData)
3642 {
3643 error = 1;
3644 fprintf(stderr, "Missing input data.\n");
3645 }
3646 else
3647 {
3648 double *result = NULL;
3649 arraylen_t index = 0;
3650
3651 for (; index < nElements; index++)
3652 {
3653 result = &(pOutData[index]);
3654 *result = DRMS_MISSING_DOUBLE;
3655
3656 if (!drms_ismissing_double(pInData[index]))
3657 {
3658 percentDone = index * 100/nElements;
3659
3660 if (first)
3661 {
3662 fprintf(stdout, "%03d%% done", percentDone);
3663 first = 0;
3664 }
3665 else if (percentDone == update)
3666 {
3667 update++;
3668 fprintf(stdout,
3669 "\b\b\b\b\b\b\b\b\b%03d%% done",
3670 percentDone);
3671 fflush(stdout);
3672 }
3673
3674 lop = &(pInData[index]);
3675 *result = *lop * *lop;
3676 }
3677 }
3678
3679 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3680 fflush(stdout);
3681 }
3682
3683 return error;
3684 }
3685
3686 static int RecipChar(const char *pInData, arraylen_t nElements, char *pOutData)
3687 {
3688 int error = 0;
3689
3690 int first = 1;
3691 int percentDone = 0;
3692 int update = 0;
3693
3694 const char *lop = NULL;
3695
3696 if (!pInData)
3697 {
3698 error = 1;
3699 fprintf(stderr, "Missing input data.\n");
3700 }
3701 else
3702 {
3703 char *result = NULL;
3704 arraylen_t index = 0;
3705
3706 for (; index < nElements; index++)
3707 {
3708 result = &(pOutData[index]);
3709 *result = DRMS_MISSING_CHAR;
3710
3711 if (!drms_ismissing_char(pInData[index]))
3712 {
3713 percentDone = index * 100/nElements;
3714
3715 if (first)
3716 {
3717 fprintf(stdout, "%03d%% done", percentDone);
3718 first = 0;
3719 }
3720 else if (percentDone == update)
3721 {
3722 update++;
3723 fprintf(stdout,
3724 "\b\b\b\b\b\b\b\b\b%03d%% done",
3725 percentDone);
3726 fflush(stdout);
3727 }
3728
3729 lop = &(pInData[index]);
3730 *result = ((*lop != 0.0) ? 1.0 / *lop : DRMS_MISSING_CHAR);
3731 }
3732 }
3733
3734 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3735 fflush(stdout);
3736 }
3737
3738 return error;
3739 }
3740
3741 static int RecipShort(const short *pInData, arraylen_t nElements, short *pOutData)
3742 {
3743 int error = 0;
3744
3745 int first = 1;
3746 int percentDone = 0;
3747 int update = 0;
3748
3749 const short *lop = NULL;
3750
3751 if (!pInData)
3752 {
3753 error = 1;
3754 fprintf(stderr, "Missing input data.\n");
3755 }
3756 else
3757 {
3758 short *result = NULL;
3759 arraylen_t index = 0;
3760
3761 for (; index < nElements; index++)
3762 {
3763 result = &(pOutData[index]);
3764 *result = DRMS_MISSING_SHORT;
3765
3766 if (!drms_ismissing_short(pInData[index]))
3767 {
3768 percentDone = index * 100/nElements;
3769
3770 if (first)
3771 {
3772 fprintf(stdout, "%03d%% done", percentDone);
3773 first = 0;
3774 }
3775 else if (percentDone == update)
3776 {
3777 update++;
3778 fprintf(stdout,
3779 "\b\b\b\b\b\b\b\b\b%03d%% done",
3780 percentDone);
3781 fflush(stdout);
3782 }
3783
3784 lop = &(pInData[index]);
3785 *result = ((*lop != 0.0) ? 1.0 / *lop : DRMS_MISSING_SHORT);
3786 }
3787 }
3788
3789 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3790 fflush(stdout);
3791 }
3792
3793 return error;
3794 }
3795
3796 static int RecipInt(const int *pInData, arraylen_t nElements, int *pOutData)
3797 {
3798 int error = 0;
3799
3800 int first = 1;
3801 int percentDone = 0;
3802 int update = 0;
3803
3804 const int *lop = NULL;
3805
3806 if (!pInData)
3807 {
3808 error = 1;
3809 fprintf(stderr, "Missing input data.\n");
3810 }
3811 else
3812 {
3813 int *result = NULL;
3814 arraylen_t index = 0;
3815
3816 for (; index < nElements; index++)
3817 {
3818 result = &(pOutData[index]);
3819 *result = DRMS_MISSING_INT;
3820
3821 if (!drms_ismissing_int(pInData[index]))
3822 {
3823 percentDone = index * 100/nElements;
3824
3825 if (first)
3826 {
3827 fprintf(stdout, "%03d%% done", percentDone);
3828 first = 0;
3829 }
3830 else if (percentDone == update)
3831 {
3832 update++;
3833 fprintf(stdout,
3834 "\b\b\b\b\b\b\b\b\b%03d%% done",
3835 percentDone);
3836 fflush(stdout);
3837 }
3838
3839 lop = &(pInData[index]);
3840 *result = ((*lop != 0.0) ? 1.0 / *lop : DRMS_MISSING_INT);
3841 }
3842 }
3843
3844 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3845 fflush(stdout);
3846 }
3847
3848 return error;
3849 }
3850
3851 static int RecipLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
3852 {
3853 int error = 0;
3854
3855 int first = 1;
3856 int percentDone = 0;
3857 int update = 0;
3858
3859 const long long *lop = NULL;
3860
3861 if (!pInData)
3862 {
3863 error = 1;
3864 fprintf(stderr, "Missing input data.\n");
3865 }
3866 else
3867 {
3868 long long *result = NULL;
3869 arraylen_t index = 0;
3870
3871 for (; index < nElements; index++)
3872 {
3873 result = &(pOutData[index]);
3874 *result = DRMS_MISSING_LONGLONG;
3875
3876 if (!drms_ismissing_longlong(pInData[index]))
3877 {
3878 percentDone = index * 100/nElements;
3879
3880 if (first)
3881 {
3882 fprintf(stdout, "%03d%% done", percentDone);
3883 first = 0;
3884 }
3885 else if (percentDone == update)
3886 {
3887 update++;
3888 fprintf(stdout,
3889 "\b\b\b\b\b\b\b\b\b%03d%% done",
3890 percentDone);
3891 fflush(stdout);
3892 }
3893
3894 lop = &(pInData[index]);
3895 *result = ((*lop != 0.0) ? 1.0 / *lop : DRMS_MISSING_LONGLONG);
3896 }
3897 }
3898
3899 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3900 fflush(stdout);
3901 }
3902
3903 return error;
3904 }
3905
3906 static int RecipFloat(const float *pInData, arraylen_t nElements, float *pOutData)
3907 {
3908 int error = 0;
3909
3910 int first = 1;
3911 int percentDone = 0;
3912 int update = 0;
3913
3914 const float *lop = NULL;
3915
3916 if (!pInData)
3917 {
3918 error = 1;
3919 fprintf(stderr, "Missing input data.\n");
3920 }
3921 else
3922 {
3923 float *result = NULL;
3924 arraylen_t index = 0;
3925
3926 for (; index < nElements; index++)
3927 {
3928 result = &(pOutData[index]);
3929 *result = DRMS_MISSING_FLOAT;
3930
3931 if (!drms_ismissing_float(pInData[index]))
3932 {
3933 percentDone = index * 100/nElements;
3934
3935 if (first)
3936 {
3937 fprintf(stdout, "%03d%% done", percentDone);
3938 first = 0;
3939 }
3940 else if (percentDone == update)
3941 {
3942 update++;
3943 fprintf(stdout,
3944 "\b\b\b\b\b\b\b\b\b%03d%% done",
3945 percentDone);
3946 fflush(stdout);
3947 }
3948
3949 lop = &(pInData[index]);
3950 *result = ((*lop != 0.0) ? 1.0 / *lop : DRMS_MISSING_FLOAT);
3951 }
3952 }
3953
3954 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
3955 fflush(stdout);
3956 }
3957
3958 return error;
3959 }
3960
3961 static int RecipDouble(const double *pInData, arraylen_t nElements, double *pOutData)
3962 {
3963 int error = 0;
3964
3965 int first = 1;
3966 int percentDone = 0;
3967 int update = 0;
3968
3969 const double *lop = NULL;
3970
3971 if (!pInData)
3972 {
3973 error = 1;
3974 fprintf(stderr, "Missing input data.\n");
3975 }
3976 else
3977 {
3978 double *result = NULL;
3979 arraylen_t index = 0;
3980
3981 for (; index < nElements; index++)
3982 {
3983 result = &(pOutData[index]);
3984 *result = DRMS_MISSING_DOUBLE;
3985
3986 if (!drms_ismissing_double(pInData[index]))
3987 {
3988 percentDone = index * 100/nElements;
3989
3990 if (first)
3991 {
3992 fprintf(stdout, "%03d%% done", percentDone);
3993 first = 0;
3994 }
3995 else if (percentDone == update)
3996 {
3997 update++;
3998 fprintf(stdout,
3999 "\b\b\b\b\b\b\b\b\b%03d%% done",
4000 percentDone);
4001 fflush(stdout);
4002 }
4003
4004 lop = &(pInData[index]);
4005 *result = ((*lop != 0.0) ? 1.0 / *lop : DRMS_MISSING_DOUBLE);
4006 }
4007 }
4008
4009 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4010 fflush(stdout);
4011 }
4012
4013 return error;
4014 }
4015
4016 static int SubmeanChar(const char *pInData, arraylen_t nElements, char *pOutData, double mean)
4017 {
4018 int error = 0;
4019
4020 int first = 1;
4021 int percentDone = 0;
4022 int update = 0;
4023
4024 const char *lop = NULL;
4025
4026 if (!pInData)
4027 {
4028 error = 1;
4029 fprintf(stderr, "Missing input data.\n");
4030 }
4031 else
4032 {
4033 char *result = NULL;
4034 arraylen_t index = 0;
4035
4036 for (; index < nElements; index++)
4037 {
4038 result = &(pOutData[index]);
4039 *result = DRMS_MISSING_CHAR;
4040
4041 if (!drms_ismissing_char(pInData[index]))
4042 {
4043 percentDone = index * 100/nElements;
4044
4045 if (first)
4046 {
4047 fprintf(stdout, "%03d%% done", percentDone);
4048 first = 0;
4049 }
4050 else if (percentDone == update)
4051 {
4052 update++;
4053 fprintf(stdout,
4054 "\b\b\b\b\b\b\b\b\b%03d%% done",
4055 percentDone);
4056 fflush(stdout);
4057 }
4058
4059 lop = &(pInData[index]);
4060 *result = *lop - mean;
4061 }
4062 }
4063
4064 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4065 fflush(stdout);
4066 }
4067
4068 return error;
4069 }
4070
4071 static int SubmeanShort(const short *pInData, arraylen_t nElements, short *pOutData, double mean)
4072 {
4073 int error = 0;
4074
4075 int first = 1;
4076 int percentDone = 0;
4077 int update = 0;
4078
4079 const short *lop = NULL;
4080
4081 if (!pInData)
4082 {
4083 error = 1;
4084 fprintf(stderr, "Missing input data.\n");
4085 }
4086 else
4087 {
4088 short *result = NULL;
4089 arraylen_t index = 0;
4090
4091 for (; index < nElements; index++)
4092 {
4093 result = &(pOutData[index]);
4094 *result = DRMS_MISSING_SHORT;
4095
4096 if (!drms_ismissing_short(pInData[index]))
4097 {
4098 percentDone = index * 100/nElements;
4099
4100 if (first)
4101 {
4102 fprintf(stdout, "%03d%% done", percentDone);
4103 first = 0;
4104 }
4105 else if (percentDone == update)
4106 {
4107 update++;
4108 fprintf(stdout,
4109 "\b\b\b\b\b\b\b\b\b%03d%% done",
4110 percentDone);
4111 fflush(stdout);
4112 }
4113
4114 lop = &(pInData[index]);
4115 *result = *lop - mean;
4116 }
4117 }
4118
4119 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4120 fflush(stdout);
4121 }
4122
4123 return error;
4124 }
4125
4126 static int SubmeanInt(const int *pInData, arraylen_t nElements, int *pOutData, double mean)
4127 {
4128 int error = 0;
4129
4130 int first = 1;
4131 int percentDone = 0;
4132 int update = 0;
4133
4134 const int *lop = NULL;
4135
4136 if (!pInData)
4137 {
4138 error = 1;
4139 fprintf(stderr, "Missing input data.\n");
4140 }
4141 else
4142 {
4143 int *result = NULL;
4144 arraylen_t index = 0;
4145
4146 for (; index < nElements; index++)
4147 {
4148 result = &(pOutData[index]);
4149 *result = DRMS_MISSING_INT;
4150
4151 if (!drms_ismissing_int(pInData[index]))
4152 {
4153 percentDone = index * 100/nElements;
4154
4155 if (first)
4156 {
4157 fprintf(stdout, "%03d%% done", percentDone);
4158 first = 0;
4159 }
4160 else if (percentDone == update)
4161 {
4162 update++;
4163 fprintf(stdout,
4164 "\b\b\b\b\b\b\b\b\b%03d%% done",
4165 percentDone);
4166 fflush(stdout);
4167 }
4168
4169 lop = &(pInData[index]);
4170 *result = *lop - mean;
4171 }
4172 }
4173
4174 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4175 fflush(stdout);
4176 }
4177
4178 return error;
4179 }
4180
4181 static int SubmeanLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData, double mean)
4182 {
4183 int error = 0;
4184
4185 int first = 1;
4186 int percentDone = 0;
4187 int update = 0;
4188
4189 const long long *lop = NULL;
4190
4191 if (!pInData)
4192 {
4193 error = 1;
4194 fprintf(stderr, "Missing input data.\n");
4195 }
4196 else
4197 {
4198 long long *result = NULL;
4199 arraylen_t index = 0;
4200
4201 for (; index < nElements; index++)
4202 {
4203 result = &(pOutData[index]);
4204 *result = DRMS_MISSING_LONGLONG;
4205
4206 if (!drms_ismissing_longlong(pInData[index]))
4207 {
4208 percentDone = index * 100/nElements;
4209
4210 if (first)
4211 {
4212 fprintf(stdout, "%03d%% done", percentDone);
4213 first = 0;
4214 }
4215 else if (percentDone == update)
4216 {
4217 update++;
4218 fprintf(stdout,
4219 "\b\b\b\b\b\b\b\b\b%03d%% done",
4220 percentDone);
4221 fflush(stdout);
4222 }
4223
4224 lop = &(pInData[index]);
4225 *result = *lop - mean;
4226 }
4227 }
4228
4229 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4230 fflush(stdout);
4231 }
4232
4233 return error;
4234 }
4235
4236 static int SubmeanFloat(const float *pInData, arraylen_t nElements, float *pOutData, double mean)
4237 {
4238 int error = 0;
4239
4240 int first = 1;
4241 int percentDone = 0;
4242 int update = 0;
4243
4244 const float *lop = NULL;
4245
4246 if (!pInData)
4247 {
4248 error = 1;
4249 fprintf(stderr, "Missing input data.\n");
4250 }
4251 else
4252 {
4253 float *result = NULL;
4254 arraylen_t index = 0;
4255
4256 for (; index < nElements; index++)
4257 {
4258 result = &(pOutData[index]);
4259 *result = DRMS_MISSING_FLOAT;
4260
4261 if (!drms_ismissing_float(pInData[index]))
4262 {
4263 percentDone = index * 100/nElements;
4264
4265 if (first)
4266 {
4267 fprintf(stdout, "%03d%% done", percentDone);
4268 first = 0;
4269 }
4270 else if (percentDone == update)
4271 {
4272 update++;
4273 fprintf(stdout,
4274 "\b\b\b\b\b\b\b\b\b%03d%% done",
4275 percentDone);
4276 fflush(stdout);
4277 }
4278
4279 lop = &(pInData[index]);
4280 *result = *lop - mean;
4281 }
4282 }
4283
4284 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4285 fflush(stdout);
4286 }
4287
4288 return error;
4289 }
4290
4291 static int SubmeanDouble(const double *pInData, arraylen_t nElements, double *pOutData, double mean)
4292 {
4293 int error = 0;
4294
4295 int first = 1;
4296 int percentDone = 0;
4297 int update = 0;
4298
4299 const double *lop = NULL;
4300
4301 if (!pInData)
4302 {
4303 error = 1;
4304 fprintf(stderr, "Missing input data.\n");
4305 }
4306 else
4307 {
4308 double *result = NULL;
4309 arraylen_t index = 0;
4310
4311 for (; index < nElements; index++)
4312 {
4313 result = &(pOutData[index]);
4314 *result = DRMS_MISSING_DOUBLE;
4315
4316 if (!drms_ismissing_double(pInData[index]))
4317 {
4318 percentDone = index * 100/nElements;
4319
4320 if (first)
4321 {
4322 fprintf(stdout, "%03d%% done", percentDone);
4323 first = 0;
4324 }
4325 else if (percentDone == update)
4326 {
4327 update++;
4328 fprintf(stdout,
4329 "\b\b\b\b\b\b\b\b\b%03d%% done",
4330 percentDone);
4331 fflush(stdout);
4332 }
4333
4334 lop = &(pInData[index]);
4335 *result = *lop - mean;
4336 }
4337 }
4338
4339 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4340 fflush(stdout);
4341 }
4342
4343 return error;
4344 }
4345
4346 static int NopChar(const char *pInData, arraylen_t nElements, char *pOutData)
4347 {
4348 int error = 0;
4349
4350 int first = 1;
4351 int percentDone = 0;
4352 int update = 0;
4353
4354 const char *lop = NULL;
4355
4356 if (!pInData)
4357 {
4358 error = 1;
4359 fprintf(stderr, "Missing input data.\n");
4360 }
4361 else
4362 {
4363 char *result = NULL;
4364 arraylen_t index = 0;
4365
4366 for (; index < nElements; index++)
4367 {
4368 result = &(pOutData[index]);
4369 *result = DRMS_MISSING_CHAR;
4370
4371 if (!drms_ismissing_char(pInData[index]))
4372 {
4373 percentDone = index * 100/nElements;
4374
4375 if (first)
4376 {
4377 fprintf(stdout, "%03d%% done", percentDone);
4378 first = 0;
4379 }
4380 else if (percentDone == update)
4381 {
4382 update++;
4383 fprintf(stdout,
4384 "\b\b\b\b\b\b\b\b\b%03d%% done",
4385 percentDone);
4386 fflush(stdout);
4387 }
4388
4389 lop = &(pInData[index]);
4390 *result = *lop;
4391 }
4392 }
4393
4394 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4395 fflush(stdout);
4396 }
4397
4398 return error;
4399 }
4400
4401 static int NopShort(const short *pInData, arraylen_t nElements, short *pOutData)
4402 {
4403 int error = 0;
4404
4405 int first = 1;
4406 int percentDone = 0;
4407 int update = 0;
4408
4409 const short *lop = NULL;
4410
4411 if (!pInData)
4412 {
4413 error = 1;
4414 fprintf(stderr, "Missing input data.\n");
4415 }
4416 else
4417 {
4418 short *result = NULL;
4419 arraylen_t index = 0;
4420
4421 for (; index < nElements; index++)
4422 {
4423 result = &(pOutData[index]);
4424 *result = DRMS_MISSING_SHORT;
4425
4426 if (!drms_ismissing_short(pInData[index]))
4427 {
4428 percentDone = index * 100/nElements;
4429
4430 if (first)
4431 {
4432 fprintf(stdout, "%03d%% done", percentDone);
4433 first = 0;
4434 }
4435 else if (percentDone == update)
4436 {
4437 update++;
4438 fprintf(stdout,
4439 "\b\b\b\b\b\b\b\b\b%03d%% done",
4440 percentDone);
4441 fflush(stdout);
4442 }
4443
4444 lop = &(pInData[index]);
4445 *result = *lop;
4446 }
4447 }
4448
4449 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4450 fflush(stdout);
4451 }
4452
4453 return error;
4454 }
4455
4456 static int NopInt(const int *pInData, arraylen_t nElements, int *pOutData)
4457 {
4458 int error = 0;
4459
4460 int first = 1;
4461 int percentDone = 0;
4462 int update = 0;
4463
4464 const int *lop = NULL;
4465
4466 if (!pInData)
4467 {
4468 error = 1;
4469 fprintf(stderr, "Missing input data.\n");
4470 }
4471 else
4472 {
4473 int *result = NULL;
4474 arraylen_t index = 0;
4475
4476 for (; index < nElements; index++)
4477 {
4478 result = &(pOutData[index]);
4479 *result = DRMS_MISSING_INT;
4480
4481 if (!drms_ismissing_int(pInData[index]))
4482 {
4483 percentDone = index * 100/nElements;
4484
4485 if (first)
4486 {
4487 fprintf(stdout, "%03d%% done", percentDone);
4488 first = 0;
4489 }
4490 else if (percentDone == update)
4491 {
4492 update++;
4493 fprintf(stdout,
4494 "\b\b\b\b\b\b\b\b\b%03d%% done",
4495 percentDone);
4496 fflush(stdout);
4497 }
4498
4499 lop = &(pInData[index]);
4500 *result = *lop;
4501 }
4502 }
4503
4504 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4505 fflush(stdout);
4506 }
4507
4508 return error;
4509 }
4510
4511 static int NopLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
4512 {
4513 int error = 0;
4514
4515 int first = 1;
4516 int percentDone = 0;
4517 int update = 0;
4518
4519 const long long *lop = NULL;
4520
4521 if (!pInData)
4522 {
4523 error = 1;
4524 fprintf(stderr, "Missing input data.\n");
4525 }
4526 else
4527 {
4528 long long *result = NULL;
4529 arraylen_t index = 0;
4530
4531 for (; index < nElements; index++)
4532 {
4533 result = &(pOutData[index]);
4534 *result = DRMS_MISSING_LONGLONG;
4535
4536 if (!drms_ismissing_longlong(pInData[index]))
4537 {
4538 percentDone = index * 100/nElements;
4539
4540 if (first)
4541 {
4542 fprintf(stdout, "%03d%% done", percentDone);
4543 first = 0;
4544 }
4545 else if (percentDone == update)
4546 {
4547 update++;
4548 fprintf(stdout,
4549 "\b\b\b\b\b\b\b\b\b%03d%% done",
4550 percentDone);
4551 fflush(stdout);
4552 }
4553
4554 lop = &(pInData[index]);
4555 *result = *lop;
4556 }
4557 }
4558
4559 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4560 fflush(stdout);
4561 }
4562
4563 return error;
4564 }
4565
4566 static int NopFloat(const float *pInData, arraylen_t nElements, float *pOutData)
4567 {
4568 int error = 0;
4569
4570 int first = 1;
4571 int percentDone = 0;
4572 int update = 0;
4573
4574 const float *lop = NULL;
4575
4576 if (!pInData)
4577 {
4578 error = 1;
4579 fprintf(stderr, "Missing input data.\n");
4580 }
4581 else
4582 {
4583 float *result = NULL;
4584 arraylen_t index = 0;
4585
4586 for (; index < nElements; index++)
4587 {
4588 result = &(pOutData[index]);
4589 *result = DRMS_MISSING_FLOAT;
4590
4591 if (!drms_ismissing_float(pInData[index]))
4592 {
4593 percentDone = index * 100/nElements;
4594
4595 if (first)
4596 {
4597 fprintf(stdout, "%03d%% done", percentDone);
4598 first = 0;
4599 }
4600 else if (percentDone == update)
4601 {
4602 update++;
4603 fprintf(stdout,
4604 "\b\b\b\b\b\b\b\b\b%03d%% done",
4605 percentDone);
4606 fflush(stdout);
4607 }
4608
4609 lop = &(pInData[index]);
4610 *result = *lop;
4611 }
4612 }
4613
4614 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4615 fflush(stdout);
4616 }
4617
4618 return error;
4619 }
4620
4621 static int NopDouble(const double *pInData, arraylen_t nElements, double *pOutData)
4622 {
4623 int error = 0;
4624
4625 int first = 1;
4626 int percentDone = 0;
4627 int update = 0;
4628
4629 const double *lop = NULL;
4630
4631 if (!pInData)
4632 {
4633 error = 1;
4634 fprintf(stderr, "Missing input data.\n");
4635 }
4636 else
4637 {
4638 double *result = NULL;
4639 arraylen_t index = 0;
4640
4641 for (; index < nElements; index++)
4642 {
4643 result = &(pOutData[index]);
4644 *result = DRMS_MISSING_DOUBLE;
4645
4646 if (!drms_ismissing_double(pInData[index]))
4647 {
4648 percentDone = index * 100/nElements;
4649
4650 if (first)
4651 {
4652 fprintf(stdout, "%03d%% done", percentDone);
4653 first = 0;
4654 }
4655 else if (percentDone == update)
4656 {
4657 update++;
4658 fprintf(stdout,
4659 "\b\b\b\b\b\b\b\b\b%03d%% done",
4660 percentDone);
4661 fflush(stdout);
4662 }
4663
4664 lop = &(pInData[index]);
4665 *result = *lop;
4666 }
4667 }
4668
4669 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
4670 fflush(stdout);
4671 }
4672
4673 return error;
4674 }
4675
4676 /* Gets as far as it can, filling in with MISSINGS if necessary. Returns 1
4677 * if any error happens. */
4678 static int PerformOperation(ArithOp_t op, DRMS_Type_t dtype,
4679 const void *pInData, const void *pWithData,
4680 arraylen_t nElements, void *pOutData, double mean)
4681 {
4682 int error = 0;
4683
4684 if (!pInData)
4685 {
4686 error = 1;
4687 fprintf(stderr, "Missing input data.\n");
4688 }
4689 else if (IsBinaryOp(op) && !pWithData)
4690 {
4691 error = 1;
4692 fprintf(stderr, "Missing input data.\n");
4693 }
4694 else
4695 {
4696 if (IsBinaryOp(op))
4697 {
4698 switch (op)
4699 {
4700 case kArithOpMul:
4701 switch (dtype)
4702 {
4703 case DRMS_TYPE_CHAR:
4704 return MultChar(pInData, pWithData, nElements, pOutData);
4705 case DRMS_TYPE_SHORT:
4706 return MultShort(pInData, pWithData, nElements, pOutData);
4707 case DRMS_TYPE_INT:
4708 return MultInt(pInData, pWithData, nElements, pOutData);
4709 case DRMS_TYPE_LONGLONG:
4710 return MultLongLong(pInData, pWithData, nElements, pOutData);
4711 case DRMS_TYPE_FLOAT:
4712 return MultFloat(pInData, pWithData, nElements, pOutData);
4713 case DRMS_TYPE_DOUBLE:
4714 return MultDouble(pInData, pWithData, nElements, pOutData);
4715 }
4716 break;
4717 case kArithOpDiv:
4718 switch (dtype)
4719 {
4720 case DRMS_TYPE_CHAR:
4721 return DivChar(pInData, pWithData, nElements, pOutData);
4722 case DRMS_TYPE_SHORT:
4723 return DivShort(pInData, pWithData, nElements, pOutData);
4724 case DRMS_TYPE_INT:
4725 return DivInt(pInData, pWithData, nElements, pOutData);
4726 case DRMS_TYPE_LONGLONG:
4727 return DivLongLong(pInData, pWithData, nElements, pOutData);
4728 case DRMS_TYPE_FLOAT:
4729 return DivFloat(pInData, pWithData, nElements, pOutData);
4730 case DRMS_TYPE_DOUBLE:
4731 return DivDouble(pInData, pWithData, nElements, pOutData);
4732 }
4733 break;
4734 case kArithOpAdd:
4735 switch (dtype)
4736 {
4737 case DRMS_TYPE_CHAR:
4738 return AddChar(pInData, pWithData, nElements, pOutData);
4739 case DRMS_TYPE_SHORT:
4740 return AddShort(pInData, pWithData, nElements, pOutData);
4741 case DRMS_TYPE_INT:
4742 return AddInt(pInData, pWithData, nElements, pOutData);
4743 case DRMS_TYPE_LONGLONG:
4744 return AddLongLong(pInData, pWithData, nElements, pOutData);
4745 case DRMS_TYPE_FLOAT:
4746 return AddFloat(pInData, pWithData, nElements, pOutData);
4747 case DRMS_TYPE_DOUBLE:
4748 return AddDouble(pInData, pWithData, nElements, pOutData);
4749 }
4750 break;
4751 case kArithOpSub:
4752 switch (dtype)
4753 {
4754 case DRMS_TYPE_CHAR:
4755 return SubChar(pInData, pWithData, nElements, pOutData);
4756 case DRMS_TYPE_SHORT:
4757 return SubShort(pInData, pWithData, nElements, pOutData);
4758 case DRMS_TYPE_INT:
4759 return SubInt(pInData, pWithData, nElements, pOutData);
4760 case DRMS_TYPE_LONGLONG:
4761 return SubLongLong(pInData, pWithData, nElements, pOutData);
4762 case DRMS_TYPE_FLOAT:
4763 return SubFloat(pInData, pWithData, nElements, pOutData);
4764 case DRMS_TYPE_DOUBLE:
4765 return SubDouble(pInData, pWithData, nElements, pOutData);
4766 }
4767 break;
4768 default:
4769 error = 1;
4770 fprintf(stderr, "Expecting a binary operator, got %d instead.\n", (int)op);
4771 }
4772 }
4773 else
4774 {
4775 switch (op)
4776 {
4777 case kArithOpAbs:
4778 switch (dtype)
4779 {
4780 case DRMS_TYPE_CHAR:
4781 return AbsChar(pInData, nElements, pOutData);
4782 case DRMS_TYPE_SHORT:
4783 return AbsShort(pInData, nElements, pOutData);
4784 case DRMS_TYPE_INT:
4785 return AbsInt(pInData, nElements, pOutData);
4786 case DRMS_TYPE_LONGLONG:
4787 return AbsLongLong(pInData, nElements, pOutData);
4788 case DRMS_TYPE_FLOAT:
4789 return AbsFloat(pInData, nElements, pOutData);
4790 case DRMS_TYPE_DOUBLE:
4791 return AbsDouble(pInData, nElements, pOutData);
4792 }
4793 break;
4794 case kArithOpSqrt:
4795 switch (dtype)
4796 {
4797 case DRMS_TYPE_CHAR:
4798 return SqrtChar(pInData, nElements, pOutData);
4799 case DRMS_TYPE_SHORT:
4800 return SqrtShort(pInData, nElements, pOutData);
4801 case DRMS_TYPE_INT:
4802 return SqrtInt(pInData, nElements, pOutData);
4803 case DRMS_TYPE_LONGLONG:
4804 return SqrtLongLong(pInData, nElements, pOutData);
4805 case DRMS_TYPE_FLOAT:
4806 return SqrtFloat(pInData, nElements, pOutData);
4807 case DRMS_TYPE_DOUBLE:
4808 return SqrtDouble(pInData, nElements, pOutData);
4809 }
4810 break;
4811 case kArithOpLog:
4812 switch (dtype)
4813 {
4814 case DRMS_TYPE_CHAR:
4815 return LogChar(pInData, nElements, pOutData);
4816 case DRMS_TYPE_SHORT:
4817 return LogShort(pInData, nElements, pOutData);
4818 case DRMS_TYPE_INT:
4819 return LogInt(pInData, nElements, pOutData);
4820 case DRMS_TYPE_LONGLONG:
4821 return LogLongLong(pInData, nElements, pOutData);
4822 case DRMS_TYPE_FLOAT:
4823 return LogFloat(pInData, nElements, pOutData);
4824 case DRMS_TYPE_DOUBLE:
4825 return LogDouble(pInData, nElements, pOutData);
4826 }
4827 break;
4828 case kArithOpPow:
4829 switch (dtype)
4830 {
4831 case DRMS_TYPE_CHAR:
4832 return PowChar(pInData, nElements, pOutData);
4833 case DRMS_TYPE_SHORT:
4834 return PowShort(pInData, nElements, pOutData);
4835 case DRMS_TYPE_INT:
4836 return PowInt(pInData, nElements, pOutData);
4837 case DRMS_TYPE_LONGLONG:
4838 return PowLongLong(pInData, nElements, pOutData);
4839 case DRMS_TYPE_FLOAT:
4840 return PowFloat(pInData, nElements, pOutData);
4841 case DRMS_TYPE_DOUBLE:
4842 return PowDouble(pInData, nElements, pOutData);
4843 }
4844 break;
4845 case kArithOpSqr:
4846 switch (dtype)
4847 {
4848 case DRMS_TYPE_CHAR:
4849 return SqrChar(pInData, nElements, pOutData);
4850 case DRMS_TYPE_SHORT:
4851 return SqrShort(pInData, nElements, pOutData);
4852 case DRMS_TYPE_INT:
4853 return SqrInt(pInData, nElements, pOutData);
4854 case DRMS_TYPE_LONGLONG:
4855 return SqrLongLong(pInData, nElements, pOutData);
4856 case DRMS_TYPE_FLOAT:
4857 return SqrFloat(pInData, nElements, pOutData);
4858 case DRMS_TYPE_DOUBLE:
4859 return SqrDouble(pInData, nElements, pOutData);
4860 }
4861 break;
4862 case kArithOpRecip:
4863 switch (dtype)
4864 {
4865 case DRMS_TYPE_CHAR:
4866 return RecipChar(pInData, nElements, pOutData);
4867 case DRMS_TYPE_SHORT:
4868 return RecipShort(pInData, nElements, pOutData);
4869 case DRMS_TYPE_INT:
4870 return RecipInt(pInData, nElements, pOutData);
4871 case DRMS_TYPE_LONGLONG:
4872 return RecipLongLong(pInData, nElements, pOutData);
4873 case DRMS_TYPE_FLOAT:
4874 return RecipFloat(pInData, nElements, pOutData);
4875 case DRMS_TYPE_DOUBLE:
4876 return RecipDouble(pInData, nElements, pOutData);
4877 }
4878 break;
4879 case kArithOpSubmean:
4880 switch (dtype)
4881 {
4882 case DRMS_TYPE_CHAR:
4883 return SubmeanChar(pInData, nElements, pOutData, mean);
4884 case DRMS_TYPE_SHORT:
4885 return SubmeanShort(pInData, nElements, pOutData, mean);
4886 case DRMS_TYPE_INT:
4887 return SubmeanInt(pInData, nElements, pOutData, mean);
4888 case DRMS_TYPE_LONGLONG:
4889 return SubmeanLongLong(pInData, nElements, pOutData, mean);
4890 case DRMS_TYPE_FLOAT:
4891 return SubmeanFloat(pInData, nElements, pOutData, mean);
4892 case DRMS_TYPE_DOUBLE:
4893 return SubmeanDouble(pInData, nElements, pOutData, mean);
4894 }
4895 break;
4896 case kArithOpNop:
4897 switch (dtype)
4898 {
4899 case DRMS_TYPE_CHAR:
4900 return NopChar(pInData, nElements, pOutData);
4901 case DRMS_TYPE_SHORT:
4902 return NopShort(pInData, nElements, pOutData);
4903 case DRMS_TYPE_INT:
4904 return NopInt(pInData, nElements, pOutData);
4905 case DRMS_TYPE_LONGLONG:
4906 return NopLongLong(pInData, nElements, pOutData);
4907 case DRMS_TYPE_FLOAT:
4908 return NopFloat(pInData, nElements, pOutData);
4909 case DRMS_TYPE_DOUBLE:
4910 return NopDouble(pInData, nElements, pOutData);
4911 }
4912 break;
4913 default:
4914 error = 1;
4915 fprintf(stderr, "Expecting a unary operator, got %d instead.\n", (int)op);
4916 }
4917 }
4918 }
4919
4920 return error;
4921 }
4922
4923 /* XXX - WARNING: Not modified to work with non-double data!!! But DoUnaryOp was */
4924 int DoBinaryOp(DRMS_Env_t *drmsEnv, ArithOp_t op, DRMS_Type_t dtype,
4925 DRMSContainer_t *inPrimeKeys, DRMSContainer_t *segsToProc,
4926 char *inSeriesQuery,
4927 char *withSeriesName, char *withSeriesQuery,
4928 char *seriesOut, double bzero, double bscale)
4929 {
4930 int error = 0;
4931 int status = 0;
4932 int nWithRecs = 0;
4933 int nInRecs = 0;
4934 double **pOutData = NULL;
4935 char **outSegNames = NULL;
4936
4937 /* Open the inSeries. */
4938 DRMS_RecordSet_t *inRecSet = drms_open_records(drmsEnv, inSeriesQuery, &status);
4939 error = (status != DRMS_SUCCESS);
4940 DRMS_RecordSet_t *withRecSet = NULL;
4941
4942 DRMS_Record_t *inRec = NULL;
4943 DRMS_Record_t *withRec = NULL;
4944
4945 int nSegs = segsToProc->items->num_total;
4946
4947 if (!error)
4948 {
4949 nInRecs = inRecSet->n;
4950 withRecSet = drms_open_records(drmsEnv, withSeriesQuery, &status);
4951 error = (status != DRMS_SUCCESS);
4952 nWithRecs = withRecSet->n;
4953
4954 XASSERT(nWithRecs >= 1);
4955
4956 if (nWithRecs == 0)
4957 {
4958 error = 1;
4959 }
4960 else if (nWithRecs == 1)
4961 {
4962 withRec = withRecSet->records[0];
4963 }
4964 }
4965
4966 int iRec = 0;
4967 for (; !error && iRec < nInRecs; iRec++)
4968 {
4969 inRec = inRecSet->records[iRec];
4970
4971 fprintf(stdout, "Processing record %lld\n", inRec->recnum);
4972
4973 if (nWithRecs != 1)
4974 {
4975 /* We want to choose one record from all withSeries recs. This
4976 * chosen record must match the prime keys of the current inSeries
4977 * record. Since the inSeries and withSeries have the same prime
4978 * keys, because the prime key values select one record from the inSeries,
4979 * they also select one record from the withSeries.
4980 *
4981 * First close the withSeries record that matched
4982 * the previous inSeries record. */
4983 drms_close_records(withRecSet, DRMS_FREE_RECORD);
4984 withRecSet = NULL;
4985
4986 /* Query the withSeries to find the record whose prime keys match
4987 * the current inSeries record's prime key values.
4988 */
4989 char query[kMaxQuery];
4990 char buf[kMaxQuery];
4991 char *pQuery = query;
4992 int maxQuery = kMaxQuery;
4993
4994 snprintf(buf, sizeof(buf), "%s", withSeriesName);
4995 snprintf(pQuery, maxQuery, "%s", buf);
4996 pQuery += strlen(buf);
4997 maxQuery -= strlen(buf);
4998
4999 hiter_rewind(&(inPrimeKeys->iter));
5000 DRMS_Keyword_t **primeKey = NULL;
5001
5002 while (maxQuery > 0 &&
5003 (primeKey = hiter_getnext(&(inPrimeKeys->iter))) != NULL)
5004 {
5005 char *val = CreateStrFromDRMSValue(inRec, (*primeKey)->info->name, &error);
5006 if (!error)
5007 {
5008 if (val != NULL)
5009 {
5010 snprintf(buf, sizeof(buf), "[%s=%s]",
5011 (*primeKey)->info->name,
5012 val);
5013 snprintf(pQuery, maxQuery, "%s", buf);
5014 pQuery += strlen(buf);
5015 maxQuery -= strlen(buf);
5016
5017 if (maxQuery <= 0)
5018 {
5019 error = 1;
5020 break;
5021 }
5022
5023 free(val);
5024 }
5025 else
5026 {
5027 error = 1;
5028 }
5029 }
5030 }
5031
5032 if (!error)
5033 {
5034 withRecSet = drms_open_records(drmsEnv, query, &status);
5035 error = (status != DRMS_SUCCESS);
5036
5037 if (!error && withRecSet != NULL)
5038 {
5039 if (withRecSet -> n != 1)
5040 {
5041 error = 1;
5042 }
5043 else
5044 {
5045 withRec = withRecSet->records[0];
5046 }
5047 }
5048 else
5049 {
5050 error = 1;
5051 }
5052 }
5053 }
5054
5055 if (!error)
5056 {
5057 /* Have a single record from inSeries and a matching single
5058 * record from withSeries. Get matching segments from each record. */
5059 hiter_rewind(&(segsToProc->iter));
5060 DRMS_Segment_t **seg = NULL;
5061 DRMS_Segment_t *inSeg = NULL;
5062 DRMS_Segment_t *withSeg = NULL;
5063 DRMS_Array_t *inSegArray = NULL;
5064 DRMS_Array_t *withSegArray = NULL;
5065
5066 pOutData = (double **)malloc(sizeof(double *) * nSegs);
5067 outSegNames = (char **)malloc(sizeof(char *) * nSegs);
5068
5069 unsigned int iSeg = 0;
5070 while(pOutData != NULL &&
5071 outSegNames != NULL &&
5072 !error &&
5073 (seg = (DRMS_Segment_t **)hiter_getnext(&(segsToProc->iter))) != NULL)
5074 {
5075 fprintf(stdout, " processing segment %s: ", (*seg)->info->name);
5076
5077 inSeg = drms_segment_lookup(inRec, (*seg)->info->name);
5078 withSeg = drms_segment_lookup(withRec, (*seg)->info->name);
5079
5080
5081 XASSERT(inSeg != NULL && withSeg != NULL);
5082 if (inSeg != NULL && withSeg != NULL)
5083 {
5084 inSegArray = drms_segment_read(inSeg, DRMS_TYPE_DOUBLE, &status);
5085 error = (status != DRMS_SUCCESS);
5086 if (!error)
5087 {
5088 withSegArray = drms_segment_read(withSeg, DRMS_TYPE_DOUBLE, &status);
5089 error = (status != DRMS_SUCCESS);
5090 }
5091 }
5092
5093 if (!error)
5094 {
5095 /* Have inSeries seg data and withSeries seg data - do binary op. */
5096 arraylen_t nElementsIn = drms_array_count(inSegArray);
5097 arraylen_t nElementsWith = drms_array_count(withSegArray);
5098 double *pInData = inSegArray->data;
5099 double *pWithData = withSegArray->data;
5100
5101 if (nElementsIn == nElementsWith)
5102 {
5103 pOutData[iSeg] = (double *)malloc(sizeof(double) * nElementsIn);
5104 outSegNames[iSeg] = strdup((*seg)->info->name);
5105
5106 if (pOutData[iSeg] != NULL && outSegNames[iSeg] != NULL)
5107 {
5108 /* Shouldn't return an error - all params checked */
5109 PerformOperation(op,
5110 dtype,
5111 pInData,
5112 pWithData,
5113 nElementsIn,
5114 pOutData[iSeg],
5115 0.0);
5116 iSeg++;
5117 }
5118 else
5119 {
5120 error = 1;
5121 }
5122 }
5123 else
5124 {
5125 error = 1;
5126 }
5127 }
5128
5129 if (inSegArray)
5130 {
5131 drms_free_array(inSegArray);
5132 }
5133
5134 if (withSegArray)
5135 {
5136 drms_free_array(withSegArray);
5137 }
5138
5139 } /* while */
5140 }
5141
5142 if (!error)
5143 {
5144 // CreateRecord(drmsEnv, inRec, outSegNames, pOutData, seriesOut, seriesOutExists);
5145 /* If a record with the same primary key already exists, the new record will be
5146 * a newer version of the original one.
5147 */
5148 DRMS_Record_t *rec = drms_create_record(drmsEnv, seriesOut, DRMS_PERMANENT, &status);
5149 error = (status != DRMS_SUCCESS);
5150 if (rec != NULL && !error)
5151 {
5152 /* Write out outSeries keys - fill them in with values from inSeries. */
5153 HIterator_t hit;
5154 hiter_new(&hit, &(rec->keywords));
5155 DRMS_Keyword_t *outKey = NULL;
5156 DRMS_Keyword_t *inKey = NULL;
5157
5158 while ((outKey = (DRMS_Keyword_t *)hiter_getnext(&hit)) != NULL)
5159 {
5160 inKey = drms_keyword_lookup(inRec, outKey->info->name, 1);
5161 if (inKey != NULL && !drms_keyword_isindex(inKey))
5162 {
5163 status = drms_setkey(rec,
5164 outKey->info->name,
5165 outKey->info->type,
5166 &(inKey->value));
5167
5168 error = (status != DRMS_SUCCESS);
5169 }
5170 }
5171
5172 /* Write segments. */
5173 unsigned int index = 0;
5174 for (; index < nSegs; index++)
5175 {
5176 if (pOutData != NULL && outSegNames != NULL)
5177 {
5178
5179 DRMS_Segment_t *inSeg = drms_segment_lookup(inRec,
5180 outSegNames[index]);
5181 DRMS_Segment_t *seg = drms_segment_lookup(rec, outSegNames[index]);
5182 if (inSeg != NULL && seg != NULL)
5183 {
5184 /* segArray now owns pOutData[index]. */
5185 DRMS_Array_t *segArray = drms_array_create(DRMS_TYPE_DOUBLE,
5186 inSeg->info->naxis,
5187 inSeg->axis,
5188 pOutData[index],
5189 &status);
5190 error = (status != DRMS_SUCCESS);
5191
5192 if (!error)
5193 {
5194 segArray->bzero = bzero;
5195 segArray->bscale = bscale;
5196 segArray->israw = 0;
5197 drms_segment_writewithkeys(seg, segArray, 0);
5198 drms_free_array(segArray);
5199 }
5200 }
5201
5202 }
5203 }
5204
5205 if (!error)
5206 {
5207 drms_close_record(rec, DRMS_INSERT_RECORD);
5208 }
5209 else
5210 {
5211 drms_close_record(rec, DRMS_FREE_RECORD);
5212 }
5213 }
5214 else if (rec != NULL)
5215 {
5216 drms_close_record(rec, DRMS_FREE_RECORD);
5217 }
5218 }
5219
5220 /* Clean up seg names. DO NOT clean up pOutData - this got transferred to segArray
5221 * just prior to writing the segments.
5222 */
5223 unsigned int index = 0;
5224 for (; index < nSegs; index++)
5225 {
5226 if (outSegNames[index] != NULL)
5227 {
5228 char *pName = outSegNames[index];
5229 free(pName);
5230 }
5231 }
5232
5233 if (outSegNames != NULL)
5234 {
5235 free(outSegNames);
5236 }
5237 } /* foreach (record) */
5238
5239 if (inRecSet != NULL)
5240 {
5241 drms_close_records(inRecSet, DRMS_FREE_RECORD);
5242 }
5243
5244 if (withRecSet != NULL)
5245 {
5246 drms_close_records(withRecSet, DRMS_FREE_RECORD);
5247 }
5248
5249 return error;
5250 }
5251
5252 static int DoUnaryOp(DRMS_Env_t *drmsEnv, ArithOp_t op, DRMS_Type_t dtype,
5253 DRMSContainer_t *segsToProc,
5254 char *inSeriesQuery, int *slicelower, int *sliceupper,
5255 char *seriesOut, int *pout, double bzero, double bscale, int nosegs)
5256 {
5257 int error = 0;
5258 int status = 0;
5259 void *pOutData = NULL;
5260 char **outSegNames = NULL;
5261 int nSegs = 0;
5262 DRMS_Type_t actualtype;
5263 double *insegBZERO = NULL;
5264 double *insegBSCALE = NULL;
5265
5266 /* Open the inSeries. */
5267 DRMS_RecordSet_t *inRecSet = drms_open_recordset(drmsEnv, inSeriesQuery, &status);
5268 DRMS_Record_t *inRec = NULL;
5269
5270 DRMS_RecChunking_t cstat = kRecChunking_None;
5271 DRMS_Record_t *targetrec = NULL;
5272
5273 error = (status != DRMS_SUCCESS);
5274
5275 if (!error)
5276 {
5277 if (segsToProc && segsToProc->items)
5278 {
5279 nSegs = segsToProc->items->num_total;
5280 }
5281 else
5282 {
5283 nSegs = 0;
5284 }
5285 }
5286
5287 if (nSegs > 0)
5288 {
5289 insegBZERO = (double *)malloc(sizeof(double) * nSegs);
5290 insegBSCALE = (double *)malloc(sizeof(double) * nSegs);
5291 }
5292
5293 while ((inRec = drms_recordset_fetchnext(drmsEnv, inRecSet, &status, &cstat, NULL)) != NULL)
5294 {
5295 fprintf(stdout, "Processing record %lld\n", inRec->recnum);
5296
5297 /* If not processing segments, then simply copy DRMS keywords. */
5298 if (nosegs)
5299 {
5300 targetrec = drms_create_record(drmsEnv,
5301 seriesOut,
5302 DRMS_PERMANENT,
5303 &status);
5304 error = (status != DRMS_SUCCESS);
5305
5306 if (!error)
5307 {
5308 drms_copykeys(targetrec, inRec, 0, kDRMS_KeyClass_Explicit);
5309
5310 /* write DATE keyword */
5311 drms_keyword_setdate(targetrec);
5312 drms_close_record(targetrec, DRMS_INSERT_RECORD);
5313 }
5314 else
5315 {
5316 drms_close_record(targetrec, DRMS_FREE_RECORD);
5317 }
5318
5319 continue;
5320 }
5321
5322 hiter_rewind(&(segsToProc->iter));
5323 DRMS_Segment_t **seg = NULL;
5324 DRMS_Segment_t *inSeg = NULL;
5325 DRMS_Array_t *inSegArray = NULL;
5326
5327 actualtype = dtype;
5328
5329 pOutData = malloc(sizeof(void *) * nSegs);
5330 outSegNames = (char **)malloc(sizeof(char *) * nSegs);
5331 memset(outSegNames, 0, sizeof(char *) * nSegs);
5332
5333 unsigned int iSeg = 0;
5334 while(pOutData != NULL &&
5335 outSegNames != NULL &&
5336 !error &&
5337 (seg = (DRMS_Segment_t **)hiter_getnext(&(segsToProc->iter))) != NULL)
5338