1 #include "grib2.h"
2
cmplxpack(g2float * fld,g2int ndpts,g2int idrsnum,g2int * idrstmpl,unsigned char * cpack,g2int * lcpack)3 void cmplxpack(g2float *fld,g2int ndpts, g2int idrsnum,g2int *idrstmpl,
4 unsigned char *cpack, g2int *lcpack)
5 //$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 // . . . .
7 // SUBPROGRAM: cmplxpack
8 // PRGMMR: Gilbert ORG: W/NP11 DATE: 2004-08-27
9 //
10 // ABSTRACT: This subroutine packs up a data field using a complex
11 // packing algorithm as defined in the GRIB2 documentation. It
12 // supports GRIB2 complex packing templates with or without
13 // spatial differences (i.e. DRTs 5.2 and 5.3).
14 // It also fills in GRIB2 Data Representation Template 5.2 or 5.3
15 // with the appropriate values.
16 //
17 // PROGRAM HISTORY LOG:
18 // 2004-08-27 Gilbert
19 //
20 // USAGE: cmplxpack(g2float *fld,g2int ndpts, g2int idrsnum,g2int *idrstmpl,
21 // unsigned char *cpack, g2int *lcpack)
22 // INPUT ARGUMENT LIST:
23 // fld[] - Contains the data values to pack
24 // ndpts - The number of data values in array fld[]
25 // idrsnum - Data Representation Template number 5.N
26 // Must equal 2 or 3.
27 // idrstmpl - Contains the array of values for Data Representation
28 // Template 5.2 or 5.3
29 // [0] = Reference value - ignored on input
30 // [1] = Binary Scale Factor
31 // [2] = Decimal Scale Factor
32 // .
33 // .
34 // [6] = Missing value management
35 // [7] = Primary missing value
36 // [8] = Secondary missing value
37 // .
38 // .
39 // [16] = Order of Spatial Differencing ( 1 or 2 )
40 // .
41 // .
42 //
43 // OUTPUT ARGUMENT LIST:
44 // idrstmpl - Contains the array of values for Data Representation
45 // Template 5.3
46 // [0] = Reference value - set by compack routine.
47 // [1] = Binary Scale Factor - unchanged from input
48 // [2] = Decimal Scale Factor - unchanged from input
49 // .
50 // .
51 // cpack - The packed data field (character*1 array)
52 // lcpack - length of packed field cpack[].
53 //
54 // REMARKS: None
55 //
56 // ATTRIBUTES:
57 // LANGUAGE: C
58 // MACHINE: IBM SP
59 //
60 //$$$
61 {
62
63
64 if ( idrstmpl[6] == 0 ) { // No internal missing values
65 compack(fld,ndpts,idrsnum,idrstmpl,cpack,lcpack);
66 }
67 else if ( idrstmpl[6] == 1 || idrstmpl[6] == 2) {
68 misspack(fld,ndpts,idrsnum,idrstmpl,cpack,lcpack);
69 }
70 else {
71 printf("cmplxpack: Don:t recognize Missing value option.");
72 *lcpack=-1;
73 }
74
75 }
76