pack_gp.c(3) | Library Functions Manual | pack_gp.c(3) |
pack_gp.c
#include 'grib2_int.h'
#include <stdlib.h>
#define FALSE_ (0)
False. #define TRUE_ (1)
True.
int pack_gp (g2int *kfildo, g2int *ic,
g2int *nxy, g2int *is523, g2int *minpk, g2int
*inc, g2int *missp, g2int *misss, g2int *jmin,
g2int *jmax, g2int *lbit, g2int *nov, g2int
*ndg, g2int *lx, g2int *ibit, g2int *jbit, g2int
*kbit, g2int *novref, g2int *lbitref, g2int *ier)
Determines groups of variable size, but at least of size minpk, the associated
max (jmax( )) and min (jmin( )), the number of bits necessary to hold the
values in each group (lbit( )), the number of values in each group (nov( )),
the number of bits necessary to pack the jmin( ) values (ibit), the number
of bits necessary to pack the lbit( ) values (jbit), and the number of bits
necessary to pack the nov( ) values (kbit).
Author
Date
Definition in file pack_gp.c.
False.
Definition at line 10 of file pack_gp.c.
True.
Definition at line 9 of file pack_gp.c.
Determines groups of variable size, but at least of size minpk, the associated max (jmax( )) and min (jmin( )), the number of bits necessary to hold the values in each group (lbit( )), the number of values in each group (nov( )), the number of bits necessary to pack the jmin( ) values (ibit), the number of bits necessary to pack the lbit( ) values (jbit), and the number of bits necessary to pack the nov( ) values (kbit). The routine is designed to determine the groups such that a small number of bits is necessary to pack the data without excessive computations. If all values in the group are zero, the number of bits to use in packing is defined as zero when there can be no missing values; when there can be missing values, the number of bits must be at least 1 to have the capability to recognize the missing value. However, if all values in a group are missing, the number of bits needed is 0, and the unpacker recognizes this. All variables are g2int. Even though the groups are initially of size minpk or larger, an adjustment between two groups (the lookback procedure) may make a group smaller than minpk. The control on group size is that the sum of the sizes of the two consecutive groups, each of size minpk or larger, is not decreased. When determining the number of bits necessary for packing, the largest value that can be accommodated in, say, mbits, is 2**mbits-1; this largest value (and the next smallest value) is reserved for the missing value indicator (only) when is523 ne 0. If the dimension ndg is not large enough to hold all the groups, the local value of minpk is increased by 50 percent. This is repeated until ndg will suffice. A diagnostic is printed whenever this happens, which should be very rarely. If it happens often, ndg in subroutine pack should be increased and a corresponding increase in subroutine unpack made. Considerable code is provided so that no more checking for missing values within loops is done than necessary; the added efficiency of this is relatively minor, but does no harm. For grib2, the reference value for the length of groups in nov( ) and for the number of bits necessary to pack group values are determined, and subtracted before jbit and kbit are determined.
When 1 or more groups are large compared to the others, the width of all groups must be as large as the largest. A subroutine reduce breaks up large groups into 2 or more to reduce total bits required. If reduce should abort, pack_gp will be executed again without the call to reduce.
PROGRAM HISTORY LOG:
DATA SET USE
Parameters
Returns
INTERNAL VARIABLES
cfeed = contains the character representation of a printer form feed. ifeed = contains the g2int value of a printer form feed. kinc = working copy of inc. may be modified. mina = minimum value in group a. maxa = maximum value in group a. nenda = the place in ic( ) where group a ends. kstart = the place in ic( ) where group a starts. ibita = number of bits needed to hold values in group a. minb = minimum value in group b. maxb = maximum value in group b. nendb = the place in ic( ) where group b ends. ibitb = number of bits needed to hold values in group b. minc = minimum value in group c. maxc = maximum value in group c. ktotal = count of number of values in ic( ) processed. nount = number of values added to group a. lmiss = 0 when is523 = 0. when packing into a specific number of bits, say mbits, the maximum value that can be handled is 2**mbits-1. when is523 = 1, indicating primary missing values, this maximum value is reserved to hold the primary missing value indicator and lmiss = 1. when is523 = 2, the value just below the maximum i.e., 2**mbits-2 is reserved to hold the secondary missing value indicator and lmiss = 2. lminpk = local value of minpk. this will be adjusted upward whenever ndg is not large enough to hold all the groups. mallow = the largest allowable value for packing. mislla = set to 1 when all values in group a are missing. this is used to distinguish between a real minimum when all values are not missing and a minimum that has been set to zero when all values are missing. 0 otherwise. note that this does not distinguish between primary and secondary missings when secondary missings are present. this means that lbit( ) will not be zero with the resulting compression efficiency when secondary missings are present. also note that a check has been made earlier to determine that secondary missings are really there. misllb = set to 1 when all values in group b are missing. this is used to distinguish between a real minimum when all values are not missing and a minimum that has been set to zero when all values are missing. 0 otherwise. misllc = performs the same function for group c that mislla and misllb do for groups b and c, respectively. ibxx2(j) = an array that when this routine is first entered is set to 2**j, j=0,30. ibxx2(30) = 2**30, which is the largest value packable, because 2**31 is larger than the g2int word size. ifirst = set by data statement to 0. changed to 1 on first entry when ibxx2( ) is filled. minak = keeps track of the location in ic( ) where the minimum value in group a is located. maxak = does the same as minak, except for the maximum. minbk = the same as minak for group b. maxbk = the same as maxak for group b. minck = the same as minak for group c. maxck = the same as maxak for group c. adda = keeps track whether or not an attempt to add points to group a was made. if so, then adda keeps from trying to put one back into b. (g2int) ibitbs = keeps current value if ibitb so that loop ending at 166 doesn't have to start at ibitb = 0 every time. misslx(j) = mallow except when a group is all one value (and lbit(j) = 0) and that value is missing. in that case, misslx(j) is missp or misss. this gets inserted into jmin(j) later as the missing indicator; it can't be put in until the end, because jmin( ) is used to calculate the maximum number of bits (ibits) needed to pack jmin( ).
Definition at line 255 of file pack_gp.c.
References FALSE_, reduce(), and TRUE_.
Referenced by compack(), and misspack().
Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.
Version 2.1.0 | NCEPLIBS-g2c |