/
nco_ctl.c
1232 lines (1151 loc) · 76.3 KB
/
nco_ctl.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
/* $Header$ */
/* Purpose: Program flow control functions */
/* Copyright (C) 1995--present Charlie Zender
This file is part of NCO, the netCDF Operators. NCO is free software.
You may redistribute and/or modify NCO under the terms of the
3-Clause BSD License with exceptions described in the LICENSE file */
#include "nco_ctl.h" /* Program flow control functions */
const char * /* O [sng] Compiler and version */
nco_cpl_get(void) /* [fnc] Return compiler and version */
{
/* Purpose: Return string containing compiler and version */
const char fnc_nm[]="nco_cpl_get()";
#if defined(_AIX) && !defined(__GNUC__) && !defined(__xlC__)
#define NCO_XLC_LIKELY
static const char cpl_nm[]="xlc"; /* [sng] Compiler name */
static const char cpl_sng[]="Token _AIX defined in nco_cpl_get(), probably compiled with AIX xlc_r or xlc"; /* [sng] Compiler string */
#endif /* !_AIX */
#if defined(__xlC__)
#define NCO_XLC_LIKELY
static const char cpl_nm[]="xlC"; /* [sng] Compiler name */
static const char cpl_sng[]="Token __xlC__ defined in nco_cpl_get(), probably compiled with AIX xlC_r or xlC"; /* [sng] Compiler string */
#endif /* !__xlC__ */
#if defined(__INTEL_COMPILER)
// https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/macros/additional-predefined-macros.html
/* Some compilers, including icc, also define __GNUC__ by default */
static const char cpl_nm[]="icc";
static const char cpl_sng[]="Token __INTEL_COMPILER defined in nco_cpl_get(), probably compiled with Intel icc"; /* [sng] Compiler string */
static const char itl_vrs[]=TKN2SNG(__INTEL_COMPILER); // [sng] Compiler version
if(nco_dbg_lvl_get() >= nco_dbg_std){
(void)fprintf(stderr,"%s: INFO icc version defined as __INTEL_COMPILER is %s\n",nco_prg_nm_get(),itl_vrs);
(void)fprintf(stderr,"%s: INFO icc version defined as __INTEL_COMPILER_BUILD_DATE is %d\n",nco_prg_nm_get(),__INTEL_COMPILER_BUILD_DATE);
} /* !dbg */
#endif /* !__INTEL_COMPILER */
#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__NVCC__) && !defined(__PATHCC__) && !defined(PGI_CC)
/* Testing for GCC macros early is dangerous because some compilers,
including Intel icc and clang, define GCC macros for compatibility */
#if defined(__GNUG__)
static const char cpl_nm[]="g++"; /* [sng] Compiler name */
static const char cpl_sng[]="Token __GNUG__ defined in nco_cpl_get(). Compiled with GNU g++ (or a compiler that emulates g++)."; /* [sng] Compiler string */
#else /* !__GNUG__ */
static const char cpl_nm[]="gcc"; /* [sng] Compiler name */
static const char cpl_sng[]="Token __GNUC__ defined in nco_cpl_get(). Compiled with GNU gcc (or a compiler that emulates gcc)."; /* [sng] Compiler string */
#endif /* !__GNUG__ */
static const char cpl_vrs[]=TKN2SNG(__VERSION__); // [sng] Compiler version
static const char cpl_vrs_mjr[]=TKN2SNG(__GNUC__); // [sng] Compiler major version
static const char cpl_vrs_mnr[]=TKN2SNG(__GNUC_MINOR__); // [sng] Compiler minor version
static const char cpl_vrs_pch[]=TKN2SNG(__GNUC_PATCHLEVEL__); // [sng] Compiler patch version
/* 20200519: Construct numeric library version */
# define GCC_LIB_VERSION ( __GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__ )
if(nco_dbg_lvl_get() >= nco_dbg_fl){
(void)fprintf(stderr,"%s: INFO GCC major version is %s\n",nco_prg_nm_get(),cpl_vrs_mjr);
(void)fprintf(stderr,"%s: INFO GCC minor version is %s\n",nco_prg_nm_get(),cpl_vrs_mnr);
(void)fprintf(stderr,"%s: INFO GCC patch version is %s\n",nco_prg_nm_get(),cpl_vrs_pch);
} /* !dbg */
if(nco_dbg_lvl_get() >= nco_dbg_std){
(void)fprintf(stderr,"%s: INFO GCC version defined as __VERSION__ is %s\n",nco_prg_nm_get(),cpl_vrs);
(void)fprintf(stderr,"%s: INFO GCC version constructed as integer is %d\n",nco_prg_nm_get(),GCC_LIB_VERSION);
} /* !dbg */
#endif /* !__GNUC__ */
#if defined(__clang__) && !defined(__INTEL_COMPILER)
/* Some compilers, including clang, also define __GNUC__ by default */
static const char cpl_nm[]="clang";
static const char cpl_sng[]="Token __clang__ defined in nco_cpl_get(), compiled with LLVM clang"; /* [sng] Compiler string */
/* 20200513 Obtain clang info with this trick from LWN:
cc -dM -E - < /dev/null | grep clang */
static const char clg_vrs[]=TKN2SNG(__clang_version__); // [sng] Compiler version
static const char clg_vrs_mjr[]=TKN2SNG(__clang_major__); // [sng] Compiler major version
static const char clg_vrs_mnr[]=TKN2SNG(__clang_minor__); // [sng] Compiler minor version
static const char clg_vrs_pch[]=TKN2SNG(__clang_patchlevel__); // [sng] Compiler patch version
if(nco_dbg_lvl_get() >= nco_dbg_fl){
(void)fprintf(stderr,"%s: INFO clang major version is %s\n",nco_prg_nm_get(),clg_vrs_mjr);
(void)fprintf(stderr,"%s: INFO clang minor version is %s\n",nco_prg_nm_get(),clg_vrs_mnr);
(void)fprintf(stderr,"%s: INFO clang patch version is %s\n",nco_prg_nm_get(),clg_vrs_pch);
} /* !dbg */
/* 20200519: Construct numeric library version */
# define CLANG_LIB_VERSION ( __clang_major__ * 100 + __clang_minor__ * 10 + __clang_patchlevel__ )
if(nco_dbg_lvl_get() >= nco_dbg_std){
(void)fprintf(stderr,"%s: INFO clang version defined as __clang_version__ is %s\n",nco_prg_nm_get(),clg_vrs);
(void)fprintf(stderr,"%s: INFO clang version constructed as integer is %d\n",nco_prg_nm_get(),CLANG_LIB_VERSION);
} /* !dbg */
#endif /* !__clang__ */
#ifdef __NVCC__
/* https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html */
static const char cpl_nm[]="nvc";
static const char cpl_sng[]="Token __NVCC__ defined in nco_cpl_get(), probably compiled with Nvidia CUDA nvc"; /* [sng] Compiler string */
static const char nvd_vrs[]=TKN2SNG(__CUDACC_VER_BUILD__); // [sng] Compiler version
static const char nvd_vrs_mjr[]=TKN2SNG(__CUDACC_VER_MAJOR__); // [sng] Compiler major version
static const char nvd_vrs_mnr[]=TKN2SNG(__CUDACC_VER_MINOR__); // [sng] Compiler minor version
if(nco_dbg_lvl_get() >= nco_dbg_fl){
(void)fprintf(stderr,"%s: INFO nvc major version is %s\n",nco_prg_nm_get(),nvd_vrs_mjr);
(void)fprintf(stderr,"%s: INFO nvc minor version is %s\n",nco_prg_nm_get(),nvd_vrs_mnr);
} /* !dbg */
/* 20201210: Construct numeric library version */
# define NVC_LIB_VERSION ( __CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__ * 10 )
if(nco_dbg_lvl_get() >= nco_dbg_std){
(void)fprintf(stderr,"%s: INFO nvc version defined as __CUDACC_VER_BUILD__ is %s\n",nco_prg_nm_get(),nvd_vrs);
(void)fprintf(stderr,"%s: INFO nvc version constructed as integer is %d\n",nco_prg_nm_get(),NVC_LIB_VERSION);
} /* !dbg */
#endif /* !__NVCC__ */
#ifdef __PATHCC__
/* Some compilers, including pathcc, also define __GNUC__ by default */
static const char cpl_nm[]="pathcc";
static const char cpl_sng[]="Token __PATHCC__ defined in nco_cpl_get(), probably compiled with PathScale (Qlogic) pathcc"; /* [sng] Compiler string */
#endif /* !__PATHCC__ */
#ifdef PGI_CC
static const char cpl_nm[]="pgcc";
static const char cpl_sng[]="Token PGI_CC defined in nco_cpl_get(), probably compiled with PGI pgcc"; /* [sng] Compiler string */
#endif /* !PGI_CC */
/* No tokens matched */
#if !defined(NCO_XLC_LIKELY) && !defined(__clang__) && !defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__NVCC__) && !defined(__PATHCC__) && !defined(PGI_CC)
/* Unknown compiler */
static const char cpl_nm[]="unknown"; /* [sng] Compiler name */
static const char cpl_sng[]="Unknown compiler tokens in nco_cpl_get(), compiler is unknown"; /* [sng] Compiler string */
#endif /* !unknown */
if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stderr,"%s: INFO %s reports underlying compiler standardized name is \"%s\"\n%s\n",nco_prg_nm_get(),fnc_nm,cpl_nm,cpl_sng);
return cpl_nm;
} /* end nco_cpl_get() */
const char * /* O [sng] MPI implementation */
nco_mpi_get(void) /* [fnc] Return MPI implementation */
{
/* Purpose: Return string containing MPI implementation information */
const char fnc_nm[]="nco_mpi_get()";
#ifdef _H_MPI
static const char mpi_nm[]="PPE"; /* [sng] MPI name */
static const char mpi_sng[]="Token _H_MPI defined in nco_mpi_get(), MPI environment is probably AIX PPE MPI"; /* [sng] MPI string */
#endif /* !_H_MPI */
#ifdef LAM_MPI
static const char mpi_nm[]="LAM"; /* [sng] MPI name */
static const char mpi_sng[]="Token LAM_MPI defined in nco_mpi_get(), MPI environment is probably LAM-MPI"; /* [sng] MPI string */
#endif /* !LAM_MPI */
#if MPICH_NAME == '1'
static const char mpi_nm[]="MPICH"; /* [sng] MPI name */
static const char mpi_sng[]="Token MPICH_NAME defined to 1 in nco_mpi_get(), MPI environment is probably MPICH version 1"; /* [sng] MPI string */
#endif /* !MPICH_NAME */
#ifdef MPICH2
static const char mpi_nm[]="MPICH2"; /* [sng] MPI name */
static const char mpi_sng[]="Token MPICH2 defined in nco_mpi_get(), MPI environment is probably MPICH2, i.e., MPICH version 2"; /* [sng] MPI string */
#endif /* !MPICH2 */
#ifdef OMPI_MPI_H
static const char mpi_nm[]="OPENMPI"; /* [sng] MPI name */
static const char mpi_sng[]="Token OMPI_MPI_H defined in nco_mpi_get(), MPI environment is probably OpenMPI"; /* [sng] MPI string */
#endif /* !OMPI_MPI_H */
/* In case no token matched */
#if !defined(_H_MPI) && !defined(LAM_MPI) && (MPICH_NAME != '1') && !defined(MPICH2) && !defined(OMPI_MPI_H)
#ifndef MPI_VERSION
/* MPI is not installed */
static const char mpi_nm[]="none"; /* [sng] MPI name */
static const char mpi_sng[]="No MPI tokens found in nco_mpi_get(), MPI environment is not active"; /* [sng] MPI string */
#else /* MPI_VERSION */
/* Unknown MPI implementation */
static const char mpi_nm[]="unknown"; /* [sng] MPI name */
static const char mpi_sng[]="Unknown MPI tokens found in nco_mpi_get(), MPI environment is present and of unknown pedigree"; /* [sng] MPI string */
#endif /* MPI_VERSION */
#endif /* !unknown */
if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stderr,"%s: INFO %s reports MPI implementation name is \"%s\"\n%s\n",nco_prg_nm_get(),fnc_nm,mpi_nm,mpi_sng);
return mpi_nm;
} /* end nco_mpi_get() */
int /* O [rcd] Return code */
nco_ddra /* [fnc] Count operations */
(const char * const var_nm, /* I [sng] Variable name */
const char * const wgt_nm, /* I [sng] Weight name */
const ddra_info_sct * const ddra_info) /* I [sct] DDRA information */
{
/* Purpose: Estimate operation counts required */
/* 20070509 CEWI RUVICFFU: ntg_nbr_rdc_dfl, ntg_nbr_nrm_dfl, flp_nbr_rdc_dfl, flp_nbr_nrm_dfl, rnk_avg */
const char fnc_nm[]="nco_ddra()";
/* Following speed parameter estimates are for clay.ess.uci.edu
clay is the dual opteron used in ppr_ZeM07 */
const float ntg_nbr_brd_fdg_fct=1.8f; /* [frc] Empirical correction to broadcasting */
const float spd_flp_ncwa=153e6f; /* [# s-1] Floating point operation speed */
const float spd_ntg_ncwa=200e6f; /* [# s-1] Integer operation speed */
const float spd_flp_ncbo=353.2e6f; /* [# s-1] Floating point operation speed */
const float spd_ntg_ncbo=1386.54e6f; /* [# s-1] Integer operation speed */
const float spd_rd=63.375e6f; /* [B s-1] Disk read bandwidth */
const float spd_wrt=57.865e6f; /* [B s-1] Disk write bandwidth */
/* 20060602:
hjm estimates faster speeds for ncbo:
spd_flp_ncbo = 353.2e6: Based on unoptimized operations in tacg function
spd_ntg_ncbo = 1386.54e6: Based on counting unoptimized operations in tacg function
hjm estimates slower speeds for ncwa:
spd_flp_ncwa = 153e6: Based on direct PAPI measures
spd_ntg_ncwa = 200e6: Based on direct measure, using large data set, calculating backwards */
float spd_flp=float_CEWI; /* [# s-1] Floating point operation speed */
float spd_ntg=float_CEWI; /* [# s-1] Integer operation speed */
int rcd=NC_NOERR; /* [rcd] Return code */
/* Timer information */
static clock_t tm_obs_old; /* [us] Microseconds initially */
static float tm_obs_ttl=0.0; /* [s] Total seconds elapsed */
clock_t tm_obs_crr; /* [us] Microseconds currently */
float tm_obs_dff; /* [s] Seconds elapsed */
/* Cumulative file costs */
static long long lmn_nbr_ttl=0LL; /* I/O [nbr] Cumulative variable size */
static long long ntg_nbr_ttl=0LL; /* I/O [nbr] Cumulative integer operations */
static long long flp_nbr_ttl=0LL; /* I/O [nbr] Cumulative floating point operations */
/* Cumulative times */
static float tm_ntg_ttl=0.0f; /* I/O [s] Cumulative integer time */
static float tm_flp_ttl=0.0f; /* I/O [s] Cumulative floating point time */
static float tm_rd_ttl=0.0f; /* I/O [s] Cumulative read time */
static float tm_wrt_ttl=0.0f; /* I/O [s] Cumulative write time */
static float tm_io_ttl=0.0f; /* [s] I/O time */
static float tm_ttl=0.0f; /* I/O [s] Cumulative time */
/* Current variable costs */
float tm_ntg; /* [s] Integer time */
float tm_flp; /* [s] Floating point time */
float tm_rd; /* [s] Read time */
float tm_wrt; /* [s] Write time */
float tm_io=float_CEWI; /* [s] I/O time */
float tm_crr=float_CEWI; /* [s] Time for this variable */
long long ntg_nbr=long_long_CEWI; /* [nbr] Integer operations */
long long flp_nbr=long_long_CEWI; /* [nbr] Floating point operations */
long long rd_nbr_byt=long_long_CEWI; /* [B] Bytes read */
long long wrt_nbr_byt=long_long_CEWI; /* [B] Bytes written */
/* Summary statistics */
float tm_frc_flp_ttl=float_CEWI; /* [frc] Floating point time fraction */
float tm_frc_io_ttl=float_CEWI; /* [frc] I/O time fraction */
float tm_frc_ntg_ttl=float_CEWI; /* [frc] Integer time fraction */
float tm_frc_rd_ttl=float_CEWI; /* [frc] Read time fraction */
float tm_frc_wrt_ttl=float_CEWI; /* [frc] Write time fraction */
/* Default algorithm costs if invoked */
long long ntg_nbr_byt_swp_dfl; /* [nbr] Integer operations for byte-swap */
long long ntg_nbr_brd_dfl; /* [nbr] Integer operations for broadcasting */
long long ntg_nbr_clc_dfl; /* [nbr] Integer operations for collection */
/* long long ntg_nbr_rdc_dfl; */ /* [nbr] Integer operations for reduction */
/* long long ntg_nbr_nrm_dfl; */ /* [nbr] Integer operations for normalization */
long long flp_nbr_bnr_dfl; /* [nbr] Floating point operations for binary arithmetic */
/* long long flp_nbr_rdc_dfl; */ /* [nbr] Floating point operations for reduction */
/* long long flp_nbr_nrm_dfl; */ /* [nbr] Floating point operations for normalization */
/* Initialize all algorithm counts for this variable to zero then increment */
long long ntg_nbr_byt_swp=0LL; /* [nbr] Integer operations for byte-swap */
long long ntg_nbr_brd=0LL; /* [nbr] Integer operations for broadcasting */
long long ntg_nbr_clc=0LL; /* [nbr] Integer operations for collection */
long long ntg_nbr_rdc=0LL; /* [nbr] Integer operations for reduction */
long long ntg_nbr_nrm=0LL; /* [nbr] Integer operations for normalization */
long long flp_nbr_bnr=0LL; /* [nbr] Floating point operations for binary arithmetic */
long long flp_nbr_rdc=0LL; /* [nbr] Floating point operations for reduction */
long long flp_nbr_nrm=0LL; /* [nbr] Floating point operations for normalization */
/* Copies of DDRA information */
int nco_op_typ; /* [enm] Operation type */
/* int rnk_avg; */ /* [nbr] Rank of averaging space */
int rnk_var; /* [nbr] Variable rank (in input file) */
int rnk_wgt; /* [nbr] Rank of weight */
int var_idx=int_CEWI; /* [enm] Index */
int wrd_sz; /* [B] Bytes per element */
long long lmn_nbr=int_CEWI; /* [nbr] Variable size */
long long lmn_nbr_avg; /* [nbr] Averaging block size */
long long lmn_nbr_wgt; /* [nbr] Weight size */
nco_bool MRV_flg; /* [flg] Avergaging dimensions are MRV dimensions */
nco_bool wgt_brd_flg; /* [flg] Broadcast weight for this variable */
/* Locals */
long long lmn_nbr_out=long_long_CEWI; /* [nbr] Output elements */
/* Where possible, work in terms of "default" counts per algorithm
Algorithms (e.g., reduction, byte-swapping) are generally subroutines
Record hand-counted counts in only one place
This makes it easier and less error-prone to propagate optimizations
Also, easier to think in terms of procedures than raw counts
Algorithms for subtraction:
"byte_swap+byte_swap+binary_arithmetic+byte_swap"
Algorithms for non-weighted, non-MRV averaging:
"byte_swap(input)+collection+reduction+normalization+byte_swap(output)"
Algorithms for non-weighted, MRV averaging:
"byte_swap(input)+reduction+normalization+byte_swap(output)"
Algorithms for weighted, non-MRV averaging:
"byte_swap(input)+byte_swap(weight)+broadcast(weight)+
collection(numerator)+collection(denominator)+
binary_arithmetic(weight*value)+
reduction(numerator)+reduction(denominator)+
normalization(numerator)+normalization(denominator)+byte_swap(output)"
Units:
[nbr] = Operation counts for lmn_nbr elements
[nbr nbr-1] = Operation counts per element */
switch(ddra_info->tmr_flg){
case nco_tmr_srt: /* [enm] Initialize timer (first timer call) */
tm_obs_crr=clock();
tm_obs_old=tm_obs_crr;
return rcd; /* [rcd] Return code */
break;
case nco_tmr_mtd: /* [enm] Metadata timer (second timer call) */
case nco_tmr_end: /* [enm] Close timer (last timer call) */
goto update_timers;
break;
case nco_tmr_rgl: /* [enm] Regular timer call (main loop timer call) */
break;
default: nco_dfl_case_tmr_typ_err(); break;
} /* end switch */
/* Decode input */
MRV_flg=ddra_info->MRV_flg; /* [flg] Avergaging dimensions are MRV dimensions */
lmn_nbr=ddra_info->lmn_nbr; /* [nbr] Variable size */
lmn_nbr_avg=ddra_info->lmn_nbr_avg; /* [nbr] Averaging block size */
lmn_nbr_wgt=ddra_info->lmn_nbr_wgt; /* [nbr] Weight size */
nco_op_typ=ddra_info->nco_op_typ; /* [enm] Operation type */
/* rnk_avg=ddra_info->rnk_avg; */ /* [nbr] Rank of averaging space */
rnk_var=ddra_info->rnk_var; /* [nbr] Variable rank (in input file) */
rnk_wgt=ddra_info->rnk_wgt; /* [nbr] Rank of weight */
var_idx=ddra_info->var_idx; /* [enm] Index */
wgt_brd_flg=ddra_info->wgt_brd_flg; /* [flg] Broadcast weight for this variable */
wrd_sz=ddra_info->wrd_sz; /* [B] Bytes per element */
/* Derived variables */
switch(nco_op_typ){
/* Types used in ncbo(), ncflint() */
case nco_op_add: /* [enm] Add file_1 to file_2 */
case nco_op_dvd: /* [enm] Divide file_1 by file_2 */
case nco_op_mlt: /* [enm] Multiply file_1 by file_2 */
case nco_op_sbt: /* [enm] Subtract file_2 from file_1 */
spd_flp=spd_flp_ncbo; /* [# s-1] Floating point operation speed */
spd_ntg=spd_ntg_ncbo; /* [# s-1] Integer operation speed */
lmn_nbr_out=lmn_nbr; /* [nbr] Output elements */
break;
/* Types used in ncra(), ncrcat(), ncwa(): */
case nco_op_avg: /* [enm] Average */
case nco_op_min: /* [enm] Minimum value */
case nco_op_max: /* [enm] Maximum value */
case nco_op_ttl: /* [enm] Linear sum */
case nco_op_sqravg: /* [enm] Square of mean */
case nco_op_avgsqr: /* [enm] Mean of sum of squares */
case nco_op_sqrt: /* [enm] Square root of mean */
case nco_op_rms: /* [enm] Root-mean-square (normalized by N) */
case nco_op_rmssdn: /* [enm] Root-mean square normalized by N-1 */
spd_flp=spd_flp_ncwa; /* [# s-1] Floating point operation speed */
spd_ntg=spd_ntg_ncwa; /* [# s-1] Integer operation speed */
lmn_nbr_out=lmn_nbr/lmn_nbr_avg; /* [nbr] Output elements */
break;
case nco_op_nil: /* [enm] Nil or undefined operation type */
break;
default:
(void)fprintf(stdout,"%s: ERROR Illegal nco_op_typ in %s\n",nco_prg_nm_get(),fnc_nm);
nco_exit(EXIT_FAILURE);
break;
} /* end switch */
flp_nbr_bnr_dfl=lmn_nbr; /* [nbr] Floating point operations for binary arithmetic */
/* flp_nbr_nrm_dfl=lmn_nbr_out; */ /* [nbr] Floating point operations for normalization */
/* flp_nbr_rdc_dfl=lmn_nbr; */ /* [nbr] Floating point operations for reduction */
/* Integer operations for broadcasting weight */
ntg_nbr_brd_dfl=(long long int)(ntg_nbr_brd_fdg_fct*lmn_nbr*(6*rnk_var+8*rnk_wgt+2)); /* [nbr] N(6R+8R_w+2) */
/* Byte-swap integer operations per element */
ntg_nbr_byt_swp_dfl=wrd_sz+2; /* [nbr nbr-1] W+2 */
/* Integer operations for collection */
ntg_nbr_clc_dfl=lmn_nbr*(14*rnk_var+4); /* [nbr] N(14R+4) */
/* Integer operations for normalization */
/* ntg_nbr_nrm_dfl=4*lmn_nbr_out; */ /* [nbr] 4N/N_A = 4N_O */
/* Integer operations for reduction */
/* ntg_nbr_rdc_dfl=lmn_nbr*6+lmn_nbr_out; */ /* [nbr] N(6+N/N_A) */
switch(nco_op_typ){
/* Types used in ncbo(), ncflint() */
case nco_op_add: /* [enm] Add file_1 to file_2 */
case nco_op_dvd: /* [enm] Divide file_1 by file_2 */
case nco_op_mlt: /* [enm] Multiply file_1 by file_2 */
case nco_op_sbt: /* [enm] Subtract file_2 from file_1 */
/* Subtraction computation assumes variables are same size
fxm: Account for broadcasting */
/* One floating point (add/subtract/multiply/divide) per element */
flp_nbr_bnr=flp_nbr_bnr_dfl;
/* Byte-swap elements from two input files and one output file */
ntg_nbr_byt_swp=3*lmn_nbr*ntg_nbr_byt_swp_dfl; /* 3N(W+2) */
rd_nbr_byt=2*lmn_nbr*wrd_sz; /* [B] Bytes read */
wrt_nbr_byt=lmn_nbr_out*wrd_sz; /* [B] Bytes written */
break;
/* Types used in ncra(), ncrcat(), ncwa(): */
case nco_op_avg: /* [enm] Average */
case nco_op_min: /* [enm] Minimum value */
case nco_op_max: /* [enm] Maximum value */
case nco_op_ttl: /* [enm] Linear sum */
case nco_op_sqravg: /* [enm] Square of mean */
case nco_op_avgsqr: /* [enm] Mean of sum of squares */
case nco_op_sqrt: /* [enm] Square root of mean */
case nco_op_rms: /* [enm] Root-mean-square (normalized by N) */
case nco_op_rmssdn: /* [enm] Root-mean square normalized by N-1 */
rd_nbr_byt=lmn_nbr*wrd_sz; /* [B] Bytes read */
wrt_nbr_byt=lmn_nbr_out*wrd_sz; /* [B] Bytes written */
/* One floating point add per input element to sum numerator */
flp_nbr_rdc=lmn_nbr;
/* One floating point divide per output element to normalize numerator by denominatro (tally) */
flp_nbr_nrm=lmn_nbr_out;
/* Byte-swap elements from one input file and one (rank-reduced) output file */
ntg_nbr_byt_swp=(lmn_nbr+lmn_nbr_out)*ntg_nbr_byt_swp_dfl;
if(!MRV_flg){
/* Collection required for numerator */
ntg_nbr_clc+=ntg_nbr_clc_dfl;
} /* !MRV_flg */
if(wgt_nm){
if(var_idx == 0){
/* Set cost = 0 after first variable since only read weight once */
rd_nbr_byt+=lmn_nbr_wgt*wrd_sz; /* [B] Bytes read */
/* Byte-swap cost for first weight input is usually negligible */
ntg_nbr_byt_swp+=lmn_nbr_wgt*ntg_nbr_byt_swp_dfl;
} /* var_idx != 0 */
/* One floating point multiply per input element for weight*value in numerator,
and one floating point add per input element to sum weight in denominator */
flp_nbr_rdc+=2*lmn_nbr;
/* One floating point divide per output element to normalize denominator by tally */
flp_nbr_nrm+=lmn_nbr_out;
if(wgt_brd_flg){
/* fxm: Charge for broadcasting weight at least once */
/* Broadcasting cost for weight */
ntg_nbr_brd=ntg_nbr_brd_dfl;
} /* !wgt_brd_flg */
if(!MRV_flg){
/* Collection required for denominator */
ntg_nbr_clc+=ntg_nbr_clc_dfl;
} /* !MRV_flg */
} /* !wgt_nm */
break;
case nco_op_nil: /* [enm] Nil or undefined operation type */
break;
default:
(void)fprintf(stdout,"%s: ERROR Illegal nco_op_typ in %s\n",nco_prg_nm_get(),fnc_nm);
nco_exit(EXIT_FAILURE);
break;
} /* end switch */
flp_nbr= /* [nbr] Floating point operations */
flp_nbr_bnr+ /* [nbr] Floating point operations for binary arithmetic */
flp_nbr_rdc+ /* [nbr] Floating point operations for reduction */
flp_nbr_nrm; /* [nbr] Floating point operations for normalization */
ntg_nbr= /* [nbr] Integer operations */
ntg_nbr_byt_swp+ /* [nbr] Integer operations for byte-swap */
ntg_nbr_brd+ /* [nbr] Integer operations for broadcasting */
ntg_nbr_clc+ /* [nbr] Integer operations for collection */
ntg_nbr_rdc+ /* [nbr] Integer operations for reduction */
ntg_nbr_nrm; /* [nbr] Integer operations for normalization */
tm_ntg=ntg_nbr/spd_ntg; /* [s] Integer time */
tm_flp=flp_nbr/spd_flp; /* [s] Floating point time */
tm_rd=rd_nbr_byt/spd_rd; /* [s] Read time */
tm_wrt=wrt_nbr_byt/spd_wrt; /* [s] Write time */
tm_io=tm_rd+tm_wrt; /* [s] I/O time */
tm_crr=tm_ntg+tm_flp+tm_rd+tm_wrt; /* [s] Time for this variable */
/* Increment running totals */
lmn_nbr_ttl+=lmn_nbr; /* [nbr] Cumulative variable size */
flp_nbr_ttl+=flp_nbr; /* [nbr] Cumulative floating point operations */
ntg_nbr_ttl+=ntg_nbr; /* [nbr] Cumulative integer operations */
tm_ntg_ttl+=tm_ntg; /* [s] Cumulative integer time */
tm_flp_ttl+=tm_flp; /* [s] Cumulative floating point time */
tm_rd_ttl+=tm_rd; /* [s] Cumulative read time */
tm_wrt_ttl+=tm_wrt; /* [s] Cumulative write time */
tm_io_ttl+=tm_io; /* [s] Cumulative I/O time */
tm_ttl+=tm_crr; /* [s] Cumulative time */
tm_frc_flp_ttl=tm_flp_ttl/tm_ttl; /* [frc] Floating point time fraction */
tm_frc_io_ttl=tm_io_ttl/tm_ttl; /* [frc] I/O time fraction */
tm_frc_ntg_ttl=tm_ntg_ttl/tm_ttl; /* [frc] Integer time fraction */
tm_frc_rd_ttl=tm_rd_ttl/tm_ttl; /* [frc] Read time fraction */
tm_frc_wrt_ttl=tm_wrt_ttl/tm_ttl; /* [frc] Write time fraction */
if(var_idx == 0){
/* Table headings */
(void)fprintf(stderr,"%3s %8s %8s %8s %8s %5s %5s %8s %8s %8s %4s %4s %4s %4s %4s %7s %7s\n",
"idx"," var_nm "," lmn "," flp "," ntg ","tm_io"," tm "," lmn_ttl"," flp_ttl"," ntg_ttl"," flp"," ntg"," rd"," wrt"," io"," tm_ttl"," tm_obs");
(void)fprintf(stderr,"%3s %8s %8s %8s %8s %5s %5s %8s %8s %8s %4s %4s %4s %4s %4s %7s %7s\n",
" "," "," # "," # "," # "," s "," s "," # "," # "," # "," % "," % "," % "," % "," % "," s "," s ");
} /* var_idx != 0 */
/* Update timers */
update_timers:
/* NB: POSIX requires CLOCKS_PER_SEC equals 1000000 so resolution = 1 microsecond */
tm_obs_crr=clock();
tm_obs_dff=(float)(tm_obs_crr-tm_obs_old)/CLOCKS_PER_SEC;
tm_obs_old=tm_obs_crr;
tm_obs_ttl+=tm_obs_dff;
switch(ddra_info->tmr_flg){
case nco_tmr_mtd: /* [enm] Metadata timer (second timer call) */
if(ddra_info->flg_ddra || nco_dbg_lvl_get() >= nco_dbg_fl) (void)fprintf(stderr,"%s: TIMER Metadata setup and file layout before main loop took %7.2f s\n",nco_prg_nm_get(),tm_obs_ttl);
break;
case nco_tmr_rgl: /* [enm] Regular timer call (main loop timer call) */
(void)fprintf(stderr,
"%3d %8s %8.2e %8.2e %8.2e %5.2f %5.2f %8.2e %8.2e %8.2e %4.1f %4.1f %4.1f %4.1f %4.1f %7.2f %7.2f\n",
var_idx,var_nm,(float)lmn_nbr,(float)flp_nbr,(float)ntg_nbr,tm_io,tm_crr,(float)lmn_nbr_ttl,(float)flp_nbr_ttl,(float)ntg_nbr_ttl,100.0*tm_frc_flp_ttl,100.0*tm_frc_ntg_ttl,100.0*tm_frc_rd_ttl,100.0*tm_frc_wrt_ttl,100.0*tm_frc_io_ttl,tm_ttl,tm_obs_ttl);
break;
case nco_tmr_end: /* [enm] Close timer (last timer call) */
if(ddra_info->flg_ddra || nco_dbg_lvl_get() >= nco_dbg_fl) (void)fprintf(stderr,"%s: TIMER Elapsed clock() time for command is %7.2f s\n",nco_prg_nm_get(),tm_obs_ttl);
break;
default: nco_dfl_case_tmr_typ_err(); break;
} /* end switch */
return rcd; /* [rcd] Return code */
} /* nco_ddra() */
void
nco_dfl_case_tmr_typ_err(void) /* [fnc] Print error and exit for illegal switch(tmr_typ) case */
{
/* Purpose: Convenience routine for printing error and exiting when
switch(tmr_typ) statement receives an illegal default case
Placing this in its own routine saves many lines
of code since this function is used in many many switch() statements. */
const char fnc_nm[]="nco_dfl_case_tmr_typ_err()";
(void)fprintf(stdout,"%s: ERROR switch(tmr_typ) statement fell through to default case, which is unsafe. This catch-all error handler ensures all switch(tmr_typ) statements are fully enumerated. Exiting...\n",fnc_nm);
nco_err_exit(0,fnc_nm);
} /* !nco_dfl_case_tmr_typ_err() */
void
nco_exit /* [fnc] Wrapper for exit() */
(int rcd) /* I [enm] Return code */
{
/* Purpose: Wrapper for exit()
https://stackoverflow.com/questions/397075/what-is-the-difference-between-exit-and-abort
"abort() exits your program without calling functions registered using atexit() first, and without calling objects' destructors first. exit() does both before exiting your program. It does not call destructors for automatic objects though."
In other words, abort() allows debuggers to access memory at time of error while exit() does not
When True, NCO_ABORT_ON_ERROR causes NCO to abort() not exit(rcd)
abort() returns no code to the system, so shell $? is ill-defined */
const char fnc_nm[]="nco_exit()";
#ifdef NCO_ABORT_ON_ERROR
const char exit_nm[]="abort()";
#else /* !NCO_ABORT_ON_ERROR */
const char exit_nm[]="exit(EXIT_FAILURE)";
#endif /* !NCO_ABORT_ON_ERROR */
if(rcd == EXIT_SUCCESS){
exit(rcd);
}else{
if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stdout,"%s: ERROR Exiting through %s which will now call %s\n",nco_prg_nm_get(),fnc_nm,exit_nm);
#ifdef NCO_ABORT_ON_ERROR
/* abort() allows crashes to be backtraced, more useful to developers */
abort();
#else /* !NCO_ABORT_ON_ERROR */
/* exit() does not create core files that annoy users */
exit(rcd);
#endif /* !NCO_ABORT_ON_ERROR */
} /* !rcd */
} /* !nco_exit() */
void
nco_exit_gracefully(void) /* [fnc] Clean up timers, file descriptors, memory, then exit */
{
/* Purpose: Clean up timers, file descriptors, memory, then exit */
(void)fclose(stderr);
(void)fclose(stdin);
(void)fclose(stdout);
/* This should be penultimate command in program
After program name is free'd, calls to nco_prg_nm_get() will fail */
(void)nco_free(nco_prg_nm_get());
nco_exit(EXIT_SUCCESS);
} /* end nco_exit_gracefully() */
void
nco_exit_lbr_rcd(void) /* [fnc] Exit with netCDF library version as return code */
{
/* Purpose: Exit with status equaling a numeric code determined by netCDF library version
Exit status must be 0-255
Modern netCDF versions range from 300-493
Hence program returns netCDF version minus an offset of 300 so version 4.4.0 exit()s with $?=140
Usage: ncks --lbr_rcd
Verify exit status with "echo $?" */
char lbr_sng[NC_MAX_NAME+1];
int rcd=360;
#if defined(ENABLE_NETCDF4) && defined(HAVE_NETCDF4_H)
strcpy(lbr_sng,nc_inq_libvers());
rcd=400;
/* Detect buggy netCDF version 4.1 so that workarounds may be implemented
Other versions used to enable version-specific regression tests in NCO_rgr.pm */
if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '1'){rcd=410;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '3' && lbr_sng[3] == '.' && lbr_sng[4] == '0'){rcd=430;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '3' && lbr_sng[3] == '.' && lbr_sng[4] == '1'){rcd=431;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '3' && lbr_sng[3] == '.' && lbr_sng[4] == '2'){rcd=432;}
/* NB: Same return values for 4.3.3 and 4.3.3.1. Few people installed 4.3.3, most installed 4.3.3.1. */
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '3' && lbr_sng[3] == '.' && lbr_sng[4] == '3'){rcd=433;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '4' && lbr_sng[3] == '.' && lbr_sng[4] == '0'){rcd=440;}
/* NB: Same return values for 4.4.1 and 4.4.1.1, which simply fixes an ncgen bug in 4.4.1 */
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '4' && lbr_sng[3] == '.' && lbr_sng[4] == '1'){rcd=441;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '5' && lbr_sng[3] == '.' && lbr_sng[4] == '0'){rcd=450;}
/* NB: 4.5.1 was never released, though some development branches employ this version number */
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '5' && lbr_sng[3] == '.' && lbr_sng[4] == '1'){rcd=451;}
/* NB: Same return values for 4.6.0 and 4.6.0.1, which appeared quickly after 4.6.0 */
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '6' && lbr_sng[3] == '.' && lbr_sng[4] == '0'){rcd=460;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '6' && lbr_sng[3] == '.' && lbr_sng[4] == '1'){rcd=461;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '6' && lbr_sng[3] == '.' && lbr_sng[4] == '2'){rcd=462;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '6' && lbr_sng[3] == '.' && lbr_sng[4] == '3'){rcd=463;}
/* NB: 4.6.4 was never released, though some development branches employ this version number */
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '6' && lbr_sng[3] == '.' && lbr_sng[4] == '4'){rcd=464;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '7' && lbr_sng[3] == '.' && lbr_sng[4] == '0'){rcd=470;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '7' && lbr_sng[3] == '.' && lbr_sng[4] == '1'){rcd=471;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '7' && lbr_sng[3] == '.' && lbr_sng[4] == '2'){rcd=472;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '7' && lbr_sng[3] == '.' && lbr_sng[4] == '3'){rcd=473;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '7' && lbr_sng[3] == '.' && lbr_sng[4] == '4'){rcd=474;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '8' && lbr_sng[3] == '.' && lbr_sng[4] == '0'){rcd=480;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '8' && lbr_sng[3] == '.' && lbr_sng[4] == '1'){rcd=481;}
/* NB: 4.8.2 was never released, though some development branches employ this version number */
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '8' && lbr_sng[3] == '.' && lbr_sng[4] == '2'){rcd=482;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '9' && lbr_sng[3] == '.' && lbr_sng[4] == '0'){rcd=490;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '9' && lbr_sng[3] == '.' && lbr_sng[4] == '1'){rcd=491;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '9' && lbr_sng[3] == '.' && lbr_sng[4] == '2'){rcd=492;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '9' && lbr_sng[3] == '.' && lbr_sng[4] == '3'){rcd=493;}
else if(lbr_sng[0] == '4' && lbr_sng[1] == '.' && lbr_sng[2] == '9' && lbr_sng[3] == '.' && lbr_sng[4] == '4'){rcd=494;}
#endif /* HAVE_NETCDF4_H */
/* Use exit() not nco_exit(), because behavior of latter depends on NCO_ABORT_ON_ERROR
When True, NCO_ABORT_ON_ERROR causes NCO to abort() not exit(rcd)
abort() returns no code to the system, so shell $? is ill-defined
exit() with custom rcd solely for use by Perl regression tester nco_bm.pl/NCO_rgr.pm */
rcd-=300;
exit(rcd);
} /* !nco_exit_lbr_rcd() */
nco_bool /* [flg] Program is multi-file operator */
nco_is_mfo /* [fnc] Query whether program is multi-file operator */
(const int nco_prg_id) /* [enm] Program ID */
{
/* Purpose: Is this a multi-file operator (MFO)?
MFOs take arbitrarily large numbers of input files
ncbo and ncflint are not MFOs because they take a fixed number (two) of input files
MFOs attempt to read input filenames from stdin when input filenames are not positional arguments */
switch(nco_prg_id){
case ncfe:
case ncecat:
case ncra:
case ncrcat:
case ncge:
return True;
break;
case ncap:
case ncatted:
case ncbo:
case ncflint:
case ncks:
case ncpdq:
case ncrename:
case ncwa:
return False;
break;
default: nco_dfl_case_prg_id_err(); break;
} /* end switch */
return False;
} /* end nco_is_mfo() */
nco_bool /* [flg] Program does arithmetic */
nco_is_rth_opr /* [fnc] Query whether program does arithmetic */
(const int nco_prg_id) /* [enm] Program ID */
{
/* Purpose: Is operator arithmetic?
For purposes of this function, an arithmetic operator is one which changes values
Concatenators (ncrcat, ncecat) are not arithmetic because they just glue data
Permutor (ncpdq) is not arithmetic because it just re-arranges values
Packer (ncpdq) is not arithmetic because it re-represents values
Attributors (ncrename, ncatted) are not arithmetic because they change metadata, not data
nco_is_rth_opr() flag help control packing behavior
Clearly, arithmetic operators must operate on unpacked values
Hence, one use of nco_is_rth_opr() is to tell arithmetic operators to
automatically unpack variables when reading them
Non-arithmetic operators do not need to unpack variables */
switch(nco_prg_id){
case ncap:
case ncbo:
case ncfe:
case ncflint:
case ncra:
case ncwa:
case ncge:
return True;
break;
case ncatted:
case ncecat:
case ncks:
case ncpdq:
case ncrcat:
case ncrename:
return False;
break;
default: nco_dfl_case_prg_id_err(); break;
} /* end switch */
return False;
} /* end nco_is_rth_opr() */
nco_bool /* [flg] Program does arithmetic and preserves rank */
nco_is_sz_rnk_prv_rth_opr /* [fnc] Is program size and rank-preserving arithmetic operator? */
(const int nco_prg_id, /* I [enm] Program ID */
const int nco_pck_plc) /* I [enm] Packing policy */
{
/* Purpose: Is program size and rank-preserving arithmetic operator?
For purposes of this function, arithmetic operators change values
Concatenators (ncrcat, ncecat) are not arithmetic because they just glue data
Permuter (ncpdq) _is not_ arithmetic because it only re-arranges values
Packer (ncpdq) _is_ arithmetic because it uses floating point arithmetic to re-represent values
nco_pck_plc flag is required as input and used only to distinguish between ncpdq packing and permuting
Attributors (ncrename, ncatted) are not arithmetic because they change metadata, not data
Averager ncwa is clearly not size or rank-preserving
Averager ncra preserves numeric rank though not record-dimension size and so is so is not size and rank-preserving
One use of nco_is_sz_rnk_prv_rth_opr() is to tell which operators should not process multidimensional coordinate values
For example, we want ncwa to act on coordinates that are reduced
However, we do not want ncfe, ncbo, or ncflint, for example, to load and process single or multi-dimensional coordinate variables
Nor do we want ncpdq to pack variables like gaussian weights, or area since that causes a significant loss of arithmetic precision when those are used as weights in re-inflated files
Such variables to these operators are best treated as "fixed" variables to be copied directly from the input to the output file */
switch(nco_prg_id){
case ncap:
case ncbo:
case ncfe:
case ncge:
case ncflint:
return True;
break;
case ncatted:
case ncecat:
case ncks:
case ncrcat:
case ncra: /* Process (not fix) time-varying fields like date, datesec */
case ncrename:
case ncwa:
return False;
break;
case ncpdq:
if(nco_pck_plc != nco_pck_plc_nil) return True; else return False;
break;
default: nco_dfl_case_prg_id_err(); break;
} /* end switch */
return False;
} /* end nco_is_sz_rnk_prv_rth_opr() */
void
nco_cnf_prn(void) /* [fnc] Print NCO configuration and help text */
{
/* Purpose: Print NCO configuration and help text */
const char bld_ngn[]=TKN2SNG(NCO_BUILDENGINE); // [sng] Build-engine
(void)fprintf(stdout,"Homepage: http://nco.sf.net\n");
(void)fprintf(stdout,"Code: http://github.com/nco/nco\n");
(void)fprintf(stdout,"Build-engine: %s\n",bld_ngn);
(void)fprintf(stdout,"User Guide: http://nco.sf.net/nco.html\n");
/* fxm: TKN2YESNO breaks when TKN is undefined
Full macro language like M4 might be useful here, though probably too much trouble */
#define TKN2YESNO(x) ((x+0) ? ("No"):("Yes"))
/* NB: Keep configuration option tokens consistent among configure.ac, bld/Makefile, and nco_ctl.c
Alphabetize list by first word in English text description of token */
(void)fprintf(stdout,"Configuration Option:\tActive?\tMeaning or Reference:\nCheck _FillValue\t%s\thttp://nco.sf.net/nco.html#mss_val\nCommunity Codec Repo\t%s\thttp://github.com/ccr/ccr\nDAP support\t\t%s\thttp://nco.sf.net/nco.html#dap\nDebugging: Custom\t%s\tPedantic, bounds checking (slowest execution)\nDebugging: Symbols\t%s\tProduce symbols for debuggers (e.g., dbx, gdb)\nGNU Scientific Library\t%s\thttp://nco.sf.net/nco.html#gsl\nHDF4 support\t\t%s\thttp://nco.sf.net/nco.html#hdf4\nInternationalization\t%s\thttp://nco.sf.net/nco.html#i18n (pre-alpha)\nLogging\t\t\t%s\thttp://nco.sf.net/nco.html#dbg\nnetCDF3 64-bit offset\t%s\thttp://nco.sf.net/nco.html#lfs\nnetCDF3 64-bit data\t%s\thttp://nco.sf.net/nco.html#cdf5\nnetCDF4/HDF5 support\t%s\thttp://nco.sf.net/nco.html#nco4\nOpenMP SMP threading\t%s\thttp://nco.sf.net/nco.html#omp\nRegular Expressions\t%s\thttp://nco.sf.net/nco.html#rx\nUDUnits2 conversions\t%s\thttp://nco.sf.net/nco.html#udunits\n%s",
(!strcmp("_FillValue",nco_mss_val_sng_get())) ? "Yes" : "No",
#if defined(ENABLE_CCR) && (ENABLE_CCR)
"Yes",
#else /* !ENABLE_CCR */
"No",
#endif /* !ENABLE_CCR */
#if defined(ENABLE_DAP) && (ENABLE_DAP)
"Yes",
#else /* !ENABLE_DAP */
"No",
#endif /* !ENABLE_DAP */
#if defined(ENABLE_DEBUG_CUSTOM) && (ENABLE_DEBUG_CUSTOM)
"Yes",
#else /* !ENABLE_DEBUG_CUSTOM */
"No",
#endif /* !ENABLE_DEBUG_CUSTOM */
#if defined(ENABLE_DEBUG_SYMBOLS) && (ENABLE_DEBUG_SYMBOLS)
"Yes",
#else /* !ENABLE_DEBUG_SYMBOLS */
"No",
#endif /* !ENABLE_DEBUG_SYMBOLS */
#if defined(ENABLE_GSL) && (ENABLE_GSL)
"Yes",
#else /* !ENABLE_GSL */
"No",
#endif /* !ENABLE_GSL */
/* 20131018: This switch is not active yet. Requires netCDF library support */
#if NC_LIB_VERSION >= 433
# if NC_HAS_HDF4
"Yes",
# else /* !NC_HAS_HDF4 */
"No",
# endif /* !NC_HAS_HDF4 */
#else /* !NC_LIB_VERSION */
"Unknown",
#endif /* !NC_LIB_VERSION */
#if defined(I18N) && (I18N)
"Yes",
#else /* !I18N */
"No",
#endif /* !I18N */
#if defined(ENABLE_LOGGING) && (ENABLE_LOGGING)
"Yes",
#else /* !ENABLE_LOGGING */
"No",
#endif /* !ENABLE_LOGGING */
#if defined(NC_64BIT_OFFSET) && (NC_64BIT_OFFSET)
"Yes",
#else /* !NC_64BIT_OFFSET */
"No",
#endif /* !NC_64BIT_OFFSET */
#if defined(NC_LIB_VERSION) && (NC_LIB_VERSION >= 440)
# if defined(NC_HAS_CDF5) && (NC_HAS_CDF5 != 0)
/* 20180916: Simple version test is insufficient since --enable-cdf5 required for netCDF 4.5.x-4.6.1 */
"Yes",
# else /* !NC_HAS_CDF5 */
"No",
# endif /* !NC_HAS_CDF5 */
#else /* !NC_64BIT_DATA */
"No",
#endif /* !NC_64BIT_DATA */
#if defined(ENABLE_NETCDF4) && (ENABLE_NETCDF4)
# if defined(HAVE_NETCDF4_H) && (HAVE_NETCDF4_H)
"Yes",
# else /* !HAVE_NETCDF4_H */
"No",
# endif /* !HAVE_NETCDF4_H */
#else /* !ENABLE_NETCDF4 */
"No",
#endif /* !ENABLE_NETCDF4 */
#if defined(_OPENMP) && (_OPENMP)
"Yes",
#else /* !_OPENMP */
"No",
#endif /* !_OPENMP */
#if defined(NCO_HAVE_REGEX_FUNCTIONALITY) && (NCO_HAVE_REGEX_FUNCTIONALITY)
"Yes",
#else /* !NCO_HAVE_REGEX_FUNCTIONALITY */
"No",
#endif /* !NCO_HAVE_REGEX_FUNCTIONALITY */
#if defined(ENABLE_UDUNITS) && (ENABLE_UDUNITS)
# if defined(HAVE_UDUNITS2_H) && (HAVE_UDUNITS2_H)
"Yes",
# else /* !HAVE_UDUNITS2_H */
"No",
# endif /* !HAVE_UDUNITS2_H */
#else /* !ENABLE_UDUNITS */
"No",
#endif /* !ENABLE_UDUNITS */
"\n"); /* End of print statement marker */
} /* end nco_cnf_prn() */
char * /* O [sng] nm_in stripped of any path (i.e., program name stub) */
nco_prg_prs /* [fnc] Strip program name to stub and set program ID */
(const char * const nm_in, /* I [sng] Name of program, i.e., argv[0] (may include path prefix) */
int * const prg_lcl) /* O [enm] Enumerated number corresponding to nm_in */
{
/* Purpose: Set program name and enum */
char *nm_out;
char *nm_out_tmp;
char *nm_out_orig;
/* Get program name (use strrchr() first in case nm_in contains a path) */
nm_out_orig=nm_out_tmp=(char *)strdup(nm_in);
#if defined(_MSC_VER) || defined(WINOS)
int len;
if(strrchr(nm_out_tmp,'\\')) nm_out_tmp=strrchr(nm_out_tmp,'\\')+1;
char *sfx=strstr(nm_out_tmp,".exe");
if(sfx && !strcmp(sfx,".exe")){
len=strlen(nm_out_tmp); /* cut any '.exe' from name */
nm_out_tmp[len-4]='\0';
} /* endif */
#else /* !_MSC_VER */
if(strrchr(nm_out_tmp,'/')) nm_out_tmp=strrchr(nm_out_tmp,'/')+1;
#endif /* !_MSC_VER */
/* Skip possible libtool prefix */
if(!strncmp(nm_out_tmp,"lt-",3)){nm_out_tmp+=3;}
/* Classify calling program */
/* ncap and acceptable synonyms (symbolic links): */
if(!strcmp(nm_out_tmp,"ncap")){*prg_lcl=ncap;}
else if(!strcmp(nm_out_tmp,"ncap2")){*prg_lcl=ncap;}
/* ncatted and acceptable synonyms (symbolic links): */
else if(!strcmp(nm_out_tmp,"ncatted")){*prg_lcl=ncatted;}
/* ncbo and acceptable synonyms (symbolic links): */
else if(!strcmp(nm_out_tmp,"mpncbo")){*prg_lcl=ncbo;}
else if(!strcmp(nm_out_tmp,"mpncdiff")){*prg_lcl=ncbo;}
else if(!strcmp(nm_out_tmp,"ncadd")){*prg_lcl=ncbo;}
else if(!strcmp(nm_out_tmp,"ncbo")){*prg_lcl=ncbo;}
else if(!strcmp(nm_out_tmp,"ncdiff")){*prg_lcl=ncbo;}
else if(!strcmp(nm_out_tmp,"ncdivide")){*prg_lcl=ncbo;}
else if(!strcmp(nm_out_tmp,"ncmult")){*prg_lcl=ncbo;}
else if(!strcmp(nm_out_tmp,"ncmultiply")){*prg_lcl=ncbo;}
else if(!strcmp(nm_out_tmp,"ncsub")){*prg_lcl=ncbo;}
else if(!strcmp(nm_out_tmp,"ncsubtract")){*prg_lcl=ncbo;}
/* ncecat and acceptable synonyms (symbolic links): */
else if(!strcmp(nm_out_tmp,"ncecat")){*prg_lcl=ncecat;}
else if(!strcmp(nm_out_tmp,"mpncecat")){*prg_lcl=ncecat;}
/* ncfe and acceptable synonyms (symbolic links): */
else if(!strcmp(nm_out_tmp,"ncea")){*prg_lcl=ncfe;}
else if(!strcmp(nm_out_tmp,"mpncea")){*prg_lcl=ncfe;}
else if(!strcmp(nm_out_tmp,"nces")){*prg_lcl=ncfe;}
else if(!strcmp(nm_out_tmp,"mpnces")){*prg_lcl=ncfe;}
else if(!strcmp(nm_out_tmp,"ncfe")){*prg_lcl=ncfe;}
else if(!strcmp(nm_out_tmp,"mpncfe")){*prg_lcl=ncfe;}
/* ncge and acceptable synonyms (symbolic links): */
else if(!strcmp(nm_out_tmp,"ncge")){*prg_lcl=ncge;}
else if(!strcmp(nm_out_tmp,"mpncge")){*prg_lcl=ncge;}
/* ncflint and acceptable synonyms (symbolic links): */
else if(!strcmp(nm_out_tmp,"ncflint")){*prg_lcl=ncflint;}
else if(!strcmp(nm_out_tmp,"mpncflint")){*prg_lcl=ncflint;}
/* ncks and acceptable synonyms (symbolic links): */
else if(!strcmp(nm_out_tmp,"ncks")){*prg_lcl=ncks;}
/* ncpdq and acceptable synonyms (symbolic links): */
else if(!strcmp(nm_out_tmp,"ncpdq")){*prg_lcl=ncpdq;}
else if(!strcmp(nm_out_tmp,"mpncpdq")){*prg_lcl=ncpdq;}
else if(!strcmp(nm_out_tmp,"ncpack")){*prg_lcl=ncpdq;}
else if(!strcmp(nm_out_tmp,"ncunpack")){*prg_lcl=ncpdq;}
/* ncra and acceptable synonyms (symbolic links): */
else if(!strcmp(nm_out_tmp,"ncrs")){*prg_lcl=ncra;}
else if(!strcmp(nm_out_tmp,"mpncrs")){*prg_lcl=ncra;}
else if(!strcmp(nm_out_tmp,"ncra")){*prg_lcl=ncra;}
else if(!strcmp(nm_out_tmp,"mpncra")){*prg_lcl=ncra;}
/* ncrcat and acceptable synonyms (symbolic links): */
else if(!strcmp(nm_out_tmp,"ncrcat")){*prg_lcl=ncrcat;}
else if(!strcmp(nm_out_tmp,"mpncrcat")){*prg_lcl=ncrcat;}
/* ncrename and acceptable synonyms (symbolic links): */
else if(!strcmp(nm_out_tmp,"ncrename")){*prg_lcl=ncrename;}
/* ncwa and acceptable synonyms (symbolic links): */
else if(!strcmp(nm_out_tmp,"ncws")){*prg_lcl=ncwa;}
else if(!strcmp(nm_out_tmp,"mpncws")){*prg_lcl=ncwa;}
else if(!strcmp(nm_out_tmp,"ncwa")){*prg_lcl=ncwa;}
else if(!strcmp(nm_out_tmp,"mpncwa")){*prg_lcl=ncwa;}
else if(!strcmp(nm_out_tmp,"vrl-tst")){*prg_lcl=ncks;}
else{
(void)fprintf(stdout,"%s: ERROR executable name %s not registered in nco_prg_prs()\n",nm_out_tmp,nm_out_tmp);
nco_exit(EXIT_FAILURE);
} /* end else */
/* Duplicate stub for returning */
nm_out=(char *)strdup(nm_out_tmp);
/* Free copy of argv[0] */
nm_out_orig=(char *)nco_free(nm_out_orig);
return nm_out;
} /* end nco_prg_prs() */
void
nco_usg_prn(void)
{
/* Purpose: Print correct command-line usage (currently to stdout) */
char *opt_sng=NULL_CEWI;
int prg_lcl;
prg_lcl=nco_prg_id_get();
switch(prg_lcl){
case ncap:
opt_sng=(char *)strdup("[-3] [-4] [-5] [-6] [-7] [-A] [--bfr byt] [-C] [-c] [--cmp sng] [--cnk_byt byt] [--cnk_csh byt] [--cnk_dmn nm,lmn] [--cnk_map map] [--cnk_min byt] [--cnk_plc plc] [--cnk_scl lmn] [-D dbg_lvl] [-F] [-f] [--fl_fmt fmt] [--glb ...] [-H] [-h] [--hdf] [--hdr_pad nbr] [--hpss] [-L lvl] [-l path] [--no_tmp_fl] [-O] [-o out.nc] [-p path] [-R] [-r] [--ram_all] [-s algebra] [-S fl.nco] [-t thr_nbr] [--uio] [-v] [in.nc] [out.nc]\n");
break;
case ncatted:
opt_sng=(char *)strdup("[-a ...] [--bfr byt] [-D dbg_lvl] [--glb ...] [-H] [-h] [--hdr_pad nbr] [--hpss] [-l path] [-O] [-o out.nc] [-p path] [-R] [-r] [-t] [--uio] in.nc [[out.nc]]\n");
break;
case ncbo:
opt_sng=(char *)strdup("[-3] [-4] [-5] [-6] [-7] [-A] [--bfr byt] [-C] [-c] [--cmp sng] [--cnk_byt byt] [--cnk_csh byt] [--cnk_dmn nm,lmn] [--cnk_map map] [--cnk_min byt] [--cnk_plc plc] [--cnk_scl sz] [-D dbg_lvl] [-d ...] [-F] [--fl_fmt fmt] [-G grp:lvl] [-g ...] [--glb ...] [-H] [-h] [--hdf] [--hdr_pad nbr] [--hpss] [-L lvl] [-l path] [--msa] [-n ...] [--no_cll_msr] [--no_frm_trm] [--no_tmp_fl] [-O] [-o out.nc] [-p path] [--qnt ...] [--qnt_alg alg_nm] [-R] [-r] [--ram_all] [-t thr_nbr] [--uio] [--unn] [-v ...] [-X box] [-x] [-y op_typ] in1.nc in2.nc [out.nc]\n");
break;
case ncflint:
opt_sng=(char *)strdup("[-3] [-4] [-5] [-6] [-7] [-A] [--bfr byt] [-C] [-c] [--cmp sng] [--cnk_byt byt] [--cnk_csh byt] [--cnk_dmn nm,lmn] [--cnk_map map] [--cnk_min byt] [--cnk_plc plc] [--cnk_scl sz] [-D dbg_lvl] [-d ...] [-F] [--fix_rec_crd] [--fl_fmt fmt] [--glb ...] [-H] [-h] [--hdf] [--hdr_pad nbr] [--hpss] [-i var,val] [-L lvl] [-l path] [--msa] [--no_cll_msr] [--no_frm_trm] [--no_tmp_fl] [-O] [-o out.nc] [-p path] [--qnt ...] [--qnt_alg alg_nm] [-R] [-r] [--ram_all] [-t thr_nbr] [--uio] [-v ...] [-X box] [-x] [-w wgt_1[,wgt_2]] in1.nc in2.nc [out.nc]\n");
break;
case ncks:
opt_sng=(char *)strdup("[-3] [-4] [-5] [-6] [-7] [-A] [-a] [--area_wgt] [-b fl_bnr] [--bfr byt] [-C] [-c] [--cal] [--cdl] [--chk_bnd] [--chk_chr] [--chk_map] [--chk_mss] [--chk_nan] [--chk_xtn] [--cmp sng] [--cnk_byt byt] [--cnk_csh byt] [--cnk_dmn nm,lmn] [--cnk_map map] [--cnk_min byt] [--cnk_plc plc] [--cnk_scl sz] [-D dbg_lvl] [-d ...] [--dt_fmt fmt] [-F] [--fix_rec_dmn dim] [--fl_fmt fmt] [--fmt_val fmt] [-G grp:lvl] [-g ...] [--glb ...] [--grp_xtr_var_xcl] [-H] [-h] [--hdn] [--hdr_pad nbr] [--hpss] [--hrz hrz.nc] [--jsn] [--jsn_fmt lvl] [-L lvl] [-l path] [-M] [-m] [--map map.nc] [--md5_dgs] [--md5_wrt] [--mk_rec_dmn dim] [--msa] [--no_blank] [--no_cll_msr] [--no_frm_trm] [--no_tmp_fl] [-O] [-o out.nc] [-P] [-p path] [-Q] [-q] [--qnt ...] [--qnt_alg alg_nm] [-R] [-r] [--rad] [--rgr] [--ram_all] [--rnr=wgt] [-s format] [--sparse] [-t thr_nbr] [-u] [--uio] [--unn] [-V] [-v ...] [--vrt_in vrt.nc] [--vrt_out vrt.nc] [-X box] [-x] [--xml] [--xml_no_loc] [--xml_spr_chr sng] [--xml_spr_nmr sng] [--xtn_var ...] in.nc [[out.nc]]\n");
break;
case ncpdq:
opt_sng=(char *)strdup("[-3] [-4] [-5] [-6] [-7] [-A] [-a ...] [--bfr byt] [-C] [-c] [--cmp sng] [--cnk_byt byt] [--cnk_csh byt] [--cnk_dmn nm,lmn] [--cnk_map map] [--cnk_min byt] [--cnk_plc plc] [--cnk_scl sz] [-D dbg_lvl] [-d ...] [-F] [--fl_fmt fmt] [-G grp:lvl] [-g ...] [--glb ...] [-H] [-h] [--hdf] [--hdr_pad nbr] [--hpss] [-L lvl] [-l path] [-M pck_map] [--mrd] [--msa] [--no_cll_msr] [--no_frm_trm] [--no_tmp_fl] [-O] [-o out.nc] [-P pck_plc] [-p path] [--qnt ...] [--qnt_alg alg_nm] [-R] [-r] [--ram_all] [-t thr_nbr] [--uio] [--unn] [-U] [-v ...] [-X box] [-x] in.nc [out.nc]\n");
break;
case ncra:
opt_sng=(char *)strdup("[-3] [-4] [-5] [-6] [-7] [-A] [--bfr byt] [-C] [-c] [--cb ...] [--cmp sng] [--cnk_byt byt] [--cnk_csh byt] [--cnk_dmn nm,lmn] [--cnk_map map] [--cnk_min byt] [--cnk_plc plc] [--cnk_scl sz] [-D dbg_lvl] [-d ...] [--dbl|flt] [-F] [--fl_fmt fmt] [-G grp:lvl] [-g ...] [--glb ...] [-H] [-h] [--hdf] [--hdr_pad nbr] [--hpss] [-L lvl] [-l path] [--mro] [--msa] [-N] [-n ...] [--no_cll_msr] [--no_cll_mth] [--no_frm_trm] [--no_tmp_fl] [-O] [-o out.nc] [-p path] [--prm_ints] [--prw] [--qnt ...] [--qnt_alg alg_nm] [-R] [-r] [--ram_all] [--rec_apn] [-t thr_nbr] [--uio] [--unn] [-w wgt] [-v ...] [-X box] [-x] [-y op_typ] in1.nc in2.nc [...] [out.nc]\n");
break;
case ncfe:
opt_sng=(char *)strdup("[-3] [-4] [-5] [-6] [-7] [-A] [--bfr byt] [-C] [-c] [--cb ...] [--cmp sng] [--cnk_byt byt] [--cnk_csh byt] [--cnk_dmn nm,lmn] [--cnk_map map] [--cnk_min byt] [--cnk_plc plc] [--cnk_scl sz] [-D dbg_lvl] [-d ...] [--dbl|flt] [-F] [--fl_fmt fmt] [-G grp:lvl] [-g ...] [--glb ...] [-H] [-h] [--hdf] [--hdr_pad nbr] [--hpss] [-L lvl] [-l path] [--msa] [-n ...] [--no_cll_msr] [--no_frm_trm] [--no_tmp_fl] [--nsm_fl] [--nsm_grp] [--nsm_sfx] [-O] [-o out.nc] [-p path] [--qnt ...] [--qnt_alg alg_nm] [-R] [-r] [--ram_all] [-t thr_nbr] [--uio] [--unn] [-v ...] [-w wgt] [-X box] [-x] [-y op_typ] in1.nc in2.nc [...] [out.nc]\n");
break;
case ncge:
opt_sng=(char *)strdup("[-3] [-4] [-5] [-6] [-7] [-A] [--bfr byt] [-C] [-c] [--cb ...] [--cmp sng] [--cnk_byt byt] [--cnk_csh byt] [--cnk_dmn nm,lmn] [--cnk_map map] [--cnk_min byt] [--cnk_plc plc] [--cnk_scl sz] [-D dbg_lvl] [-d ...] [--dbl|flt] [-F] [--fl_fmt fmt] [-G grp:lvl] [-g ...] [--glb ...] [-H] [-h] [--hdf] [--hdr_pad nbr] [--hpss] [-L lvl] [-l path] [--msa] [-n ...] [--no_cll_msr] [--no_frm_trm] [--no_tmp_fl] [--nsm_fl] [--nsm_grp] [--nsm_sfx] [-O] [-o out.nc] [-p path] [--qnt ...] [--qnt_alg alg_nm] [-R] [-r] [--ram_all] [-t thr_nbr] [--uio] [--unn] [-v ...] [-w wgt] [-X box] [-x] [-y op_typ] in1.nc in2.nc [...] [out.nc]\n");
break;
case ncrcat:
opt_sng=(char *)strdup("[-3] [-4] [-5] [-6] [-7] [-A] [--bfr byt] [-C] [-c] [--cb ...] [--cmp sng] [--cnk_byt byt] [--cnk_csh byt] [--cnk_dmn nm,lmn] [--cnk_map map] [--cnk_min byt] [--cnk_plc plc] [--cnk_scl sz] [-D dbg_lvl] [-d ...] [-F] [--fl_fmt fmt] [-G grp:lvl] [-g ...] [--glb ...] [-H] [-h] [--hdr_pad nbr] [--hpss] [-L lvl] [-l path] [--md5_dgs] [--msa] [-n ...] [--no_cll_msr] [--no_frm_trm] [--no_tmp_fl] [-O] [-o out.nc] [-p path] [--qnt ...] [--qnt_alg alg_nm] [-R] [-r] [--ram_all] [--rec_apn] [-t thr_nbr] [--uio] [--unn] [-v ...] [-X box] [-x] in1.nc in2.nc [...] [out.nc]\n");
break;
case ncecat:
opt_sng=(char *)strdup("[-3] [-4] [-5] [-6] [-7] [-A] [--bfr byt] [-C] [-c] [--cmp sng] [--cnk_byt byt] [--cnk_dmn nm,lmn] [--cnk_map map] [--cnk_min byt] [--cnk_plc plc] [--cnk_scl sz] [-D dbg_lvl] [-d ...] [-F] [--fl_fmt fmt] [-G grp:lvl] [-g ...] [--gag] [--glb ...] [-H] [-h] [--hdr_pad nbr] [--hpss] [-L lvl] [-l path] [-M] [--md5_dgs] [--mrd] [--msa] [-n ...] [--no_cll_msr] [--no_frm_trm] [--no_tmp_fl] [-O] [-o out.nc] [-p path] [--qnt ...] [--qnt_alg alg_nm] [-R] [-r] [--ram_all] [-t thr_nbr] [--uio] [-u ulm_nm] [--unn] [-v ...] [-X box] [-x] in1.nc in2.nc [...] [out.nc]\n");