forked from scottransom/psrfits_utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
psrfits_subband_cmd.c
1170 lines (1011 loc) · 30.6 KB
/
psrfits_subband_cmd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*****
command line parser -- generated by clig
(http://wsd.iitb.fhg.de/~kir/clighome/)
The command line parser `clig':
(C) 1995-2004 Harald Kirsch ([email protected])
*****/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <float.h>
#include <math.h>
#include "psrfits_subband_cmd.h"
char *Program;
/*@-null*/
static Cmdline cmd = {
/***** -dm: Dispersion measure to use for the subband de-dispersion */
/* dmP = */ 1,
/* dm = */ 0.0,
/* dmC = */ 1,
/***** -nsub: Number of output frequency subbands */
/* nsubP = */ 0,
/* nsub = */ (int)0,
/* nsubC = */ 0,
/***** -dstime: Power-of-2 number of samples to average in time */
/* dstimeP = */ 1,
/* dstime = */ 1,
/* dstimeC = */ 1,
/***** -startfile: Starting file number of sequence */
/* startfileP = */ 1,
/* startfile = */ 1,
/* startfileC = */ 1,
/***** -numfiles: Number of files to process */
/* numfilesP = */ 0,
/* numfiles = */ (int)0,
/* numfilesC = */ 0,
/***** -outbits: Number of output bits desired */
/* outbitsP = */ 0,
/* outbits = */ (int)0,
/* outbitsC = */ 0,
/***** -filetime: Desired length of the resulting files in sec */
/* filetimeP = */ 0,
/* filetime = */ (float)0,
/* filetimeC = */ 0,
/***** -filelen: Desired length of the resulting files in GB */
/* filelenP = */ 0,
/* filelen = */ (float)0,
/* filelenC = */ 0,
/***** -tgtstd: Target stdev. If 0, set in code based on outbits */
/* tgtstdP = */ 1,
/* tgtstd = */ 0.0,
/* tgtstdC = */ 1,
/***** -tgtavg: Target avg for UNSIGNED data. If 0, set in code based on outbits */
/* tgtavgP = */ 1,
/* tgtavg = */ 0.0,
/* tgtavgC = */ 1,
/***** -onlyI: Only output total intensity data */
/* onlyIP = */ 0,
/***** -weights: Filename containing ASCII list of channels and weights to use */
/* wgtsfileP = */ 0,
/* wgtsfile = */ (char*)0,
/* wgtsfileC = */ 0,
/***** -bandpass: Filename containing ASCII list of channels, avgs, stdevs to use */
/* bandpassfileP = */ 0,
/* bandpassfile = */ (char*)0,
/* bandpassfileC = */ 0,
/***** -o: Basename for the output files */
/* outputbasenameP = */ 0,
/* outputbasename = */ (char*)0,
/* outputbasenameC = */ 0,
/***** uninterpreted rest of command line */
/* argc = */ 0,
/* argv = */ (char**)0,
/***** the original command line concatenated */
/* full_cmd_line = */ NULL
};
/*@=null*/
/***** let LCLint run more smoothly */
/*@-predboolothers*/
/*@-boolops*/
/******************************************************************/
/*****
This is a bit tricky. We want to make a difference between overflow
and underflow and we want to allow v==Inf or v==-Inf but not
v>FLT_MAX.
We don't use fabs to avoid linkage with -lm.
*****/
static void
checkFloatConversion(double v, char *option, char *arg)
{
char *err = NULL;
if( (errno==ERANGE && v!=0.0) /* even double overflowed */
|| (v<HUGE_VAL && v>-HUGE_VAL && (v<0.0?-v:v)>(double)FLT_MAX) ) {
err = "large";
} else if( (errno==ERANGE && v==0.0)
|| (v!=0.0 && (v<0.0?-v:v)<(double)FLT_MIN) ) {
err = "small";
}
if( err ) {
fprintf(stderr,
"%s: parameter `%s' of option `%s' to %s to represent\n",
Program, arg, option, err);
exit(EXIT_FAILURE);
}
}
int
getIntOpt(int argc, char **argv, int i, int *value, int force)
{
char *end;
long v;
if( ++i>=argc ) goto nothingFound;
errno = 0;
v = strtol(argv[i], &end, 0);
/***** check for conversion error */
if( end==argv[i] ) goto nothingFound;
/***** check for surplus non-whitespace */
while( isspace((int) *end) ) end+=1;
if( *end ) goto nothingFound;
/***** check if it fits into an int */
if( errno==ERANGE || v>(long)INT_MAX || v<(long)INT_MIN ) {
fprintf(stderr,
"%s: parameter `%s' of option `%s' to large to represent\n",
Program, argv[i], argv[i-1]);
exit(EXIT_FAILURE);
}
*value = (int)v;
return i;
nothingFound:
if( !force ) return i-1;
fprintf(stderr,
"%s: missing or malformed integer value after option `%s'\n",
Program, argv[i-1]);
exit(EXIT_FAILURE);
}
/**********************************************************************/
int
getIntOpts(int argc, char **argv, int i,
int **values,
int cmin, int cmax)
/*****
We want to find at least cmin values and at most cmax values.
cmax==-1 then means infinitely many are allowed.
*****/
{
int alloced, used;
char *end;
long v;
if( i+cmin >= argc ) {
fprintf(stderr,
"%s: option `%s' wants at least %d parameters\n",
Program, argv[i], cmin);
exit(EXIT_FAILURE);
}
/*****
alloc a bit more than cmin values. It does not hurt to have room
for a bit more values than cmax.
*****/
alloced = cmin + 4;
*values = (int*)calloc((size_t)alloced, sizeof(int));
if( ! *values ) {
outMem:
fprintf(stderr,
"%s: out of memory while parsing option `%s'\n",
Program, argv[i]);
exit(EXIT_FAILURE);
}
for(used=0; (cmax==-1 || used<cmax) && used+i+1<argc; used++) {
if( used==alloced ) {
alloced += 8;
*values = (int *) realloc(*values, alloced*sizeof(int));
if( !*values ) goto outMem;
}
errno = 0;
v = strtol(argv[used+i+1], &end, 0);
/***** check for conversion error */
if( end==argv[used+i+1] ) break;
/***** check for surplus non-whitespace */
while( isspace((int) *end) ) end+=1;
if( *end ) break;
/***** check for overflow */
if( errno==ERANGE || v>(long)INT_MAX || v<(long)INT_MIN ) {
fprintf(stderr,
"%s: parameter `%s' of option `%s' to large to represent\n",
Program, argv[i+used+1], argv[i]);
exit(EXIT_FAILURE);
}
(*values)[used] = (int)v;
}
if( used<cmin ) {
fprintf(stderr,
"%s: parameter `%s' of `%s' should be an "
"integer value\n",
Program, argv[i+used+1], argv[i]);
exit(EXIT_FAILURE);
}
return i+used;
}
/**********************************************************************/
int
getLongOpt(int argc, char **argv, int i, long *value, int force)
{
char *end;
if( ++i>=argc ) goto nothingFound;
errno = 0;
*value = strtol(argv[i], &end, 0);
/***** check for conversion error */
if( end==argv[i] ) goto nothingFound;
/***** check for surplus non-whitespace */
while( isspace((int) *end) ) end+=1;
if( *end ) goto nothingFound;
/***** check for overflow */
if( errno==ERANGE ) {
fprintf(stderr,
"%s: parameter `%s' of option `%s' to large to represent\n",
Program, argv[i], argv[i-1]);
exit(EXIT_FAILURE);
}
return i;
nothingFound:
/***** !force means: this parameter may be missing.*/
if( !force ) return i-1;
fprintf(stderr,
"%s: missing or malformed value after option `%s'\n",
Program, argv[i-1]);
exit(EXIT_FAILURE);
}
/**********************************************************************/
int
getLongOpts(int argc, char **argv, int i,
long **values,
int cmin, int cmax)
/*****
We want to find at least cmin values and at most cmax values.
cmax==-1 then means infinitely many are allowed.
*****/
{
int alloced, used;
char *end;
if( i+cmin >= argc ) {
fprintf(stderr,
"%s: option `%s' wants at least %d parameters\n",
Program, argv[i], cmin);
exit(EXIT_FAILURE);
}
/*****
alloc a bit more than cmin values. It does not hurt to have room
for a bit more values than cmax.
*****/
alloced = cmin + 4;
*values = (long int *)calloc((size_t)alloced, sizeof(long));
if( ! *values ) {
outMem:
fprintf(stderr,
"%s: out of memory while parsing option `%s'\n",
Program, argv[i]);
exit(EXIT_FAILURE);
}
for(used=0; (cmax==-1 || used<cmax) && used+i+1<argc; used++) {
if( used==alloced ) {
alloced += 8;
*values = (long int*) realloc(*values, alloced*sizeof(long));
if( !*values ) goto outMem;
}
errno = 0;
(*values)[used] = strtol(argv[used+i+1], &end, 0);
/***** check for conversion error */
if( end==argv[used+i+1] ) break;
/***** check for surplus non-whitespace */
while( isspace((int) *end) ) end+=1;
if( *end ) break;
/***** check for overflow */
if( errno==ERANGE ) {
fprintf(stderr,
"%s: parameter `%s' of option `%s' to large to represent\n",
Program, argv[i+used+1], argv[i]);
exit(EXIT_FAILURE);
}
}
if( used<cmin ) {
fprintf(stderr,
"%s: parameter `%s' of `%s' should be an "
"integer value\n",
Program, argv[i+used+1], argv[i]);
exit(EXIT_FAILURE);
}
return i+used;
}
/**********************************************************************/
int
getFloatOpt(int argc, char **argv, int i, float *value, int force)
{
char *end;
double v;
if( ++i>=argc ) goto nothingFound;
errno = 0;
v = strtod(argv[i], &end);
/***** check for conversion error */
if( end==argv[i] ) goto nothingFound;
/***** check for surplus non-whitespace */
while( isspace((int) *end) ) end+=1;
if( *end ) goto nothingFound;
/***** check for overflow */
checkFloatConversion(v, argv[i-1], argv[i]);
*value = (float)v;
return i;
nothingFound:
if( !force ) return i-1;
fprintf(stderr,
"%s: missing or malformed float value after option `%s'\n",
Program, argv[i-1]);
exit(EXIT_FAILURE);
}
/**********************************************************************/
int
getFloatOpts(int argc, char **argv, int i,
float **values,
int cmin, int cmax)
/*****
We want to find at least cmin values and at most cmax values.
cmax==-1 then means infinitely many are allowed.
*****/
{
int alloced, used;
char *end;
double v;
if( i+cmin >= argc ) {
fprintf(stderr,
"%s: option `%s' wants at least %d parameters\n",
Program, argv[i], cmin);
exit(EXIT_FAILURE);
}
/*****
alloc a bit more than cmin values.
*****/
alloced = cmin + 4;
*values = (float*)calloc((size_t)alloced, sizeof(float));
if( ! *values ) {
outMem:
fprintf(stderr,
"%s: out of memory while parsing option `%s'\n",
Program, argv[i]);
exit(EXIT_FAILURE);
}
for(used=0; (cmax==-1 || used<cmax) && used+i+1<argc; used++) {
if( used==alloced ) {
alloced += 8;
*values = (float *) realloc(*values, alloced*sizeof(float));
if( !*values ) goto outMem;
}
errno = 0;
v = strtod(argv[used+i+1], &end);
/***** check for conversion error */
if( end==argv[used+i+1] ) break;
/***** check for surplus non-whitespace */
while( isspace((int) *end) ) end+=1;
if( *end ) break;
/***** check for overflow */
checkFloatConversion(v, argv[i], argv[i+used+1]);
(*values)[used] = (float)v;
}
if( used<cmin ) {
fprintf(stderr,
"%s: parameter `%s' of `%s' should be a "
"floating-point value\n",
Program, argv[i+used+1], argv[i]);
exit(EXIT_FAILURE);
}
return i+used;
}
/**********************************************************************/
int
getDoubleOpt(int argc, char **argv, int i, double *value, int force)
{
char *end;
if( ++i>=argc ) goto nothingFound;
errno = 0;
*value = strtod(argv[i], &end);
/***** check for conversion error */
if( end==argv[i] ) goto nothingFound;
/***** check for surplus non-whitespace */
while( isspace((int) *end) ) end+=1;
if( *end ) goto nothingFound;
/***** check for overflow */
if( errno==ERANGE ) {
fprintf(stderr,
"%s: parameter `%s' of option `%s' to %s to represent\n",
Program, argv[i], argv[i-1],
(*value==0.0 ? "small" : "large"));
exit(EXIT_FAILURE);
}
return i;
nothingFound:
if( !force ) return i-1;
fprintf(stderr,
"%s: missing or malformed value after option `%s'\n",
Program, argv[i-1]);
exit(EXIT_FAILURE);
}
/**********************************************************************/
int
getDoubleOpts(int argc, char **argv, int i,
double **values,
int cmin, int cmax)
/*****
We want to find at least cmin values and at most cmax values.
cmax==-1 then means infinitely many are allowed.
*****/
{
int alloced, used;
char *end;
if( i+cmin >= argc ) {
fprintf(stderr,
"%s: option `%s' wants at least %d parameters\n",
Program, argv[i], cmin);
exit(EXIT_FAILURE);
}
/*****
alloc a bit more than cmin values.
*****/
alloced = cmin + 4;
*values = (double*)calloc((size_t)alloced, sizeof(double));
if( ! *values ) {
outMem:
fprintf(stderr,
"%s: out of memory while parsing option `%s'\n",
Program, argv[i]);
exit(EXIT_FAILURE);
}
for(used=0; (cmax==-1 || used<cmax) && used+i+1<argc; used++) {
if( used==alloced ) {
alloced += 8;
*values = (double *) realloc(*values, alloced*sizeof(double));
if( !*values ) goto outMem;
}
errno = 0;
(*values)[used] = strtod(argv[used+i+1], &end);
/***** check for conversion error */
if( end==argv[used+i+1] ) break;
/***** check for surplus non-whitespace */
while( isspace((int) *end) ) end+=1;
if( *end ) break;
/***** check for overflow */
if( errno==ERANGE ) {
fprintf(stderr,
"%s: parameter `%s' of option `%s' to %s to represent\n",
Program, argv[i+used+1], argv[i],
((*values)[used]==0.0 ? "small" : "large"));
exit(EXIT_FAILURE);
}
}
if( used<cmin ) {
fprintf(stderr,
"%s: parameter `%s' of `%s' should be a "
"double value\n",
Program, argv[i+used+1], argv[i]);
exit(EXIT_FAILURE);
}
return i+used;
}
/**********************************************************************/
/**
force will be set if we need at least one argument for the option.
*****/
int
getStringOpt(int argc, char **argv, int i, char **value, int force)
{
i += 1;
if( i>=argc ) {
if( force ) {
fprintf(stderr, "%s: missing string after option `%s'\n",
Program, argv[i-1]);
exit(EXIT_FAILURE);
}
return i-1;
}
if( !force && argv[i][0] == '-' ) return i-1;
*value = argv[i];
return i;
}
/**********************************************************************/
int
getStringOpts(int argc, char **argv, int i,
char* **values,
int cmin, int cmax)
/*****
We want to find at least cmin values and at most cmax values.
cmax==-1 then means infinitely many are allowed.
*****/
{
int alloced, used;
if( i+cmin >= argc ) {
fprintf(stderr,
"%s: option `%s' wants at least %d parameters\n",
Program, argv[i], cmin);
exit(EXIT_FAILURE);
}
alloced = cmin + 4;
*values = (char**)calloc((size_t)alloced, sizeof(char*));
if( ! *values ) {
outMem:
fprintf(stderr,
"%s: out of memory during parsing of option `%s'\n",
Program, argv[i]);
exit(EXIT_FAILURE);
}
for(used=0; (cmax==-1 || used<cmax) && used+i+1<argc; used++) {
if( used==alloced ) {
alloced += 8;
*values = (char **)realloc(*values, alloced*sizeof(char*));
if( !*values ) goto outMem;
}
if( used>=cmin && argv[used+i+1][0]=='-' ) break;
(*values)[used] = argv[used+i+1];
}
if( used<cmin ) {
fprintf(stderr,
"%s: less than %d parameters for option `%s', only %d found\n",
Program, cmin, argv[i], used);
exit(EXIT_FAILURE);
}
return i+used;
}
/**********************************************************************/
void
checkIntLower(char *opt, int *values, int count, int max)
{
int i;
for(i=0; i<count; i++) {
if( values[i]<=max ) continue;
fprintf(stderr,
"%s: parameter %d of option `%s' greater than max=%d\n",
Program, i+1, opt, max);
exit(EXIT_FAILURE);
}
}
/**********************************************************************/
void
checkIntHigher(char *opt, int *values, int count, int min)
{
int i;
for(i=0; i<count; i++) {
if( values[i]>=min ) continue;
fprintf(stderr,
"%s: parameter %d of option `%s' smaller than min=%d\n",
Program, i+1, opt, min);
exit(EXIT_FAILURE);
}
}
/**********************************************************************/
void
checkLongLower(char *opt, long *values, int count, long max)
{
int i;
for(i=0; i<count; i++) {
if( values[i]<=max ) continue;
fprintf(stderr,
"%s: parameter %d of option `%s' greater than max=%ld\n",
Program, i+1, opt, max);
exit(EXIT_FAILURE);
}
}
/**********************************************************************/
void
checkLongHigher(char *opt, long *values, int count, long min)
{
int i;
for(i=0; i<count; i++) {
if( values[i]>=min ) continue;
fprintf(stderr,
"%s: parameter %d of option `%s' smaller than min=%ld\n",
Program, i+1, opt, min);
exit(EXIT_FAILURE);
}
}
/**********************************************************************/
void
checkFloatLower(char *opt, float *values, int count, float max)
{
int i;
for(i=0; i<count; i++) {
if( values[i]<=max ) continue;
fprintf(stderr,
"%s: parameter %d of option `%s' greater than max=%f\n",
Program, i+1, opt, max);
exit(EXIT_FAILURE);
}
}
/**********************************************************************/
void
checkFloatHigher(char *opt, float *values, int count, float min)
{
int i;
for(i=0; i<count; i++) {
if( values[i]>=min ) continue;
fprintf(stderr,
"%s: parameter %d of option `%s' smaller than min=%f\n",
Program, i+1, opt, min);
exit(EXIT_FAILURE);
}
}
/**********************************************************************/
void
checkDoubleLower(char *opt, double *values, int count, double max)
{
int i;
for(i=0; i<count; i++) {
if( values[i]<=max ) continue;
fprintf(stderr,
"%s: parameter %d of option `%s' greater than max=%f\n",
Program, i+1, opt, max);
exit(EXIT_FAILURE);
}
}
/**********************************************************************/
void
checkDoubleHigher(char *opt, double *values, int count, double min)
{
int i;
for(i=0; i<count; i++) {
if( values[i]>=min ) continue;
fprintf(stderr,
"%s: parameter %d of option `%s' smaller than min=%f\n",
Program, i+1, opt, min);
exit(EXIT_FAILURE);
}
}
/**********************************************************************/
static char *
catArgv(int argc, char **argv)
{
int i;
size_t l;
char *s, *t;
for(i=0, l=0; i<argc; i++) l += (1+strlen(argv[i]));
s = (char *)malloc(l);
if( !s ) {
fprintf(stderr, "%s: out of memory\n", Program);
exit(EXIT_FAILURE);
}
strcpy(s, argv[0]);
t = s;
for(i=1; i<argc; i++) {
t = t+strlen(t);
*t++ = ' ';
strcpy(t, argv[i]);
}
return s;
}
/**********************************************************************/
void
showOptionValues(void)
{
int i;
printf("Full command line is:\n`%s'\n", cmd.full_cmd_line);
/***** -dm: Dispersion measure to use for the subband de-dispersion */
if( !cmd.dmP ) {
printf("-dm not found.\n");
} else {
printf("-dm found:\n");
if( !cmd.dmC ) {
printf(" no values\n");
} else {
printf(" value = `%.40g'\n", cmd.dm);
}
}
/***** -nsub: Number of output frequency subbands */
if( !cmd.nsubP ) {
printf("-nsub not found.\n");
} else {
printf("-nsub found:\n");
if( !cmd.nsubC ) {
printf(" no values\n");
} else {
printf(" value = `%d'\n", cmd.nsub);
}
}
/***** -dstime: Power-of-2 number of samples to average in time */
if( !cmd.dstimeP ) {
printf("-dstime not found.\n");
} else {
printf("-dstime found:\n");
if( !cmd.dstimeC ) {
printf(" no values\n");
} else {
printf(" value = `%d'\n", cmd.dstime);
}
}
/***** -startfile: Starting file number of sequence */
if( !cmd.startfileP ) {
printf("-startfile not found.\n");
} else {
printf("-startfile found:\n");
if( !cmd.startfileC ) {
printf(" no values\n");
} else {
printf(" value = `%d'\n", cmd.startfile);
}
}
/***** -numfiles: Number of files to process */
if( !cmd.numfilesP ) {
printf("-numfiles not found.\n");
} else {
printf("-numfiles found:\n");
if( !cmd.numfilesC ) {
printf(" no values\n");
} else {
printf(" value = `%d'\n", cmd.numfiles);
}
}
/***** -outbits: Number of output bits desired */
if( !cmd.outbitsP ) {
printf("-outbits not found.\n");
} else {
printf("-outbits found:\n");
if( !cmd.outbitsC ) {
printf(" no values\n");
} else {
printf(" value = `%d'\n", cmd.outbits);
}
}
/***** -filetime: Desired length of the resulting files in sec */
if( !cmd.filetimeP ) {
printf("-filetime not found.\n");
} else {
printf("-filetime found:\n");
if( !cmd.filetimeC ) {
printf(" no values\n");
} else {
printf(" value = `%.40g'\n", cmd.filetime);
}
}
/***** -filelen: Desired length of the resulting files in GB */
if( !cmd.filelenP ) {
printf("-filelen not found.\n");
} else {
printf("-filelen found:\n");
if( !cmd.filelenC ) {
printf(" no values\n");
} else {
printf(" value = `%.40g'\n", cmd.filelen);
}
}
/***** -tgtstd: Target stdev. If 0, set in code based on outbits */
if( !cmd.tgtstdP ) {
printf("-tgtstd not found.\n");
} else {
printf("-tgtstd found:\n");
if( !cmd.tgtstdC ) {
printf(" no values\n");
} else {
printf(" value = `%.40g'\n", cmd.tgtstd);
}
}
/***** -tgtavg: Target avg for UNSIGNED data. If 0, set in code based on outbits */
if( !cmd.tgtavgP ) {
printf("-tgtavg not found.\n");
} else {
printf("-tgtavg found:\n");
if( !cmd.tgtavgC ) {
printf(" no values\n");
} else {
printf(" value = `%.40g'\n", cmd.tgtavg);
}
}
/***** -onlyI: Only output total intensity data */
if( !cmd.onlyIP ) {
printf("-onlyI not found.\n");
} else {
printf("-onlyI found:\n");
}
/***** -weights: Filename containing ASCII list of channels and weights to use */
if( !cmd.wgtsfileP ) {
printf("-weights not found.\n");
} else {
printf("-weights found:\n");
if( !cmd.wgtsfileC ) {
printf(" no values\n");
} else {
printf(" value = `%s'\n", cmd.wgtsfile);
}
}
/***** -bandpass: Filename containing ASCII list of channels, avgs, stdevs to use */
if( !cmd.bandpassfileP ) {
printf("-bandpass not found.\n");
} else {
printf("-bandpass found:\n");
if( !cmd.bandpassfileC ) {
printf(" no values\n");
} else {
printf(" value = `%s'\n", cmd.bandpassfile);
}
}
/***** -o: Basename for the output files */
if( !cmd.outputbasenameP ) {
printf("-o not found.\n");
} else {
printf("-o found:\n");
if( !cmd.outputbasenameC ) {
printf(" no values\n");
} else {
printf(" value = `%s'\n", cmd.outputbasename);
}
}
if( !cmd.argc ) {
printf("no remaining parameters in argv\n");
} else {
printf("argv =");
for(i=0; i<cmd.argc; i++) {
printf(" `%s'", cmd.argv[i]);
}
printf("\n");
}
}
/**********************************************************************/
void
usage(void)
{
fprintf(stderr,"%s"," [-dm dm] [-nsub nsub] [-dstime dstime] [-startfile startfile] [-numfiles numfiles] [-outbits outbits] [-filetime filetime] [-filelen filelen] [-tgtstd tgtstd] [-tgtavg tgtavg] [-onlyI] [-weights wgtsfile] [-bandpass bandpassfile] [-o outputbasename] [--] infile ...\n");
fprintf(stderr,"%s"," \n");
fprintf(stderr,"%s"," Partially de-disperse and subband PSRFITS search-mode data.\n");
fprintf(stderr,"%s"," \n");
fprintf(stderr,"%s"," -dm: Dispersion measure to use for the subband de-dispersion\n");
fprintf(stderr,"%s"," 1 double value between 0.0 and 10000.0\n");
fprintf(stderr,"%s"," default: `0.0'\n");
fprintf(stderr,"%s"," -nsub: Number of output frequency subbands\n");
fprintf(stderr,"%s"," 1 int value between 1 and 4096\n");
fprintf(stderr,"%s"," -dstime: Power-of-2 number of samples to average in time\n");
fprintf(stderr,"%s"," 1 int value between 1 and 128\n");
fprintf(stderr,"%s"," default: `1'\n");
fprintf(stderr,"%s"," -startfile: Starting file number of sequence\n");
fprintf(stderr,"%s"," 1 int value between 1 and 2000\n");
fprintf(stderr,"%s"," default: `1'\n");
fprintf(stderr,"%s"," -numfiles: Number of files to process\n");
fprintf(stderr,"%s"," 1 int value between 1 and 2000\n");
fprintf(stderr,"%s"," -outbits: Number of output bits desired\n");
fprintf(stderr,"%s"," 1 int value between 2 and 8\n");
fprintf(stderr,"%s"," -filetime: Desired length of the resulting files in sec\n");
fprintf(stderr,"%s"," 1 float value between 0.0 and 100000.0\n");
fprintf(stderr,"%s"," -filelen: Desired length of the resulting files in GB\n");
fprintf(stderr,"%s"," 1 float value between 0.0 and 1000.0\n");
fprintf(stderr,"%s"," -tgtstd: Target stdev. If 0, set in code based on outbits\n");
fprintf(stderr,"%s"," 1 float value between 0.0 and 100000.0\n");
fprintf(stderr,"%s"," default: `0.0'\n");
fprintf(stderr,"%s"," -tgtavg: Target avg for UNSIGNED data. If 0, set in code based on outbits\n");
fprintf(stderr,"%s"," 1 float value between 0.0 and 100000.0\n");
fprintf(stderr,"%s"," default: `0.0'\n");
fprintf(stderr,"%s"," -onlyI: Only output total intensity data\n");
fprintf(stderr,"%s"," -weights: Filename containing ASCII list of channels and weights to use\n");
fprintf(stderr,"%s"," 1 char* value\n");
fprintf(stderr,"%s"," -bandpass: Filename containing ASCII list of channels, avgs, stdevs to use\n");
fprintf(stderr,"%s"," 1 char* value\n");
fprintf(stderr,"%s"," -o: Basename for the output files\n");
fprintf(stderr,"%s"," 1 char* value\n");
fprintf(stderr,"%s"," infile: Input file name(s) of the PSRFITs datafiles\n");
fprintf(stderr,"%s"," 1...2000 values\n");
fprintf(stderr,"%s"," version: 17Jun16\n");
fprintf(stderr,"%s"," ");
exit(EXIT_FAILURE);
}