NCEPLIBS-bufr  12.0.0
pad.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Pad a BUFR data subset with zeroed-out bits up to the
3 C> next byte boundary.
4 C>
5 C> @author Woollen @date 1994-01-06
6 
7 C> This subroutine first packs the value for the number of
8 C> bits being "padded" (we'll get to that later), starting with bit
9 C> ibit+1 and using eight bits in the packed array ibay (which
10 C> represents a subset packed into ibit bits). Then, starting with
11 C> ibit+9, it packs zeroes (i.e., "pads") to the specified bit
12 C> boundary (ipadb). (Note: it's the number of bits padded here that
13 C> was packed in bits ibit+1 through ibit+8 - this is actually a
14 C> delayed replication factor). IPADB must be a multiple of eight and
15 C> represents the bit boundary on which the packed subset in ibay
16 C> should end after padding. For example, if ipabd is "8", then the
17 C> number of bits in ibay actually consumed by packed data (including
18 C> the padding) will be a multiple of eight. If ipadb is "16", it
19 C> will be a multiple of sixteen. in either (or any) case, this
20 C> ensures that the packed subset will always end on a full byte
21 C> boundary.
22 C>
23 C> @param[inout] IBAY - integer(*):
24 C> - on input, contains BUFR data subset to be padded
25 C> - on output, contains BUFR data subset padded with zeroed-out bits up to IPADB
26 C> @param[inout] IBIT - integer:
27 C> - on input, contains bit pointer within IBAY after which to begin padding.
28 C> - on output, contains bit pointer within IBAY to last bit that was padded.
29 C> @param[out] IBYT - integer: number of bytes within IBAY containing packed data,
30 C> including padding
31 C> @param[in] IPADB - integer: bit boundary to pad to (must be a multiple of 8).
32 C>
33 C> @author Woollen @date 1994-01-06
34  SUBROUTINE pad(IBAY,IBIT,IBYT,IPADB)
35 
36  CHARACTER*128 BORT_STR
37  dimension ibay(*)
38 
39 C----------------------------------------------------------------------
40 C----------------------------------------------------------------------
41 
42 C PAD THE SUBSET TO AN IPADB BIT BOUNDARY
43 C ----------------------------------------
44 
45  ipad = ipadb - mod(ibit+8,ipadb)
46 c .... First pack the # of bits being padded (this is a delayed
47 c .... replication factor)
48  CALL pkb(ipad,8,ibay,ibit)
49 c .... Now pad with zeroes to the byte boundary
50  CALL pkb(0,ipad,ibay,ibit)
51  ibyt = ibit/8
52 
53  IF(mod(ibit,ipadb).NE.0) GOTO 900
54  IF(mod(ibit,8 ).NE.0) GOTO 901
55 
56 C EXITS
57 C -----
58 
59  RETURN
60 900 WRITE(bort_str,'("BUFRLIB: PAD - THE INPUT BIT BOUNDARY TO PAD '//
61  . 'TO (",I8,") IS NOT A MULTIPLE OF 8")') ipadb
62  CALL bort(bort_str)
63 901 WRITE(bort_str,'("BUFRLIB: PAD - THE NUMBER OF BITS IN A PACKED'//
64  . ' SUBSET AFTER PADDING (",I8,") IS NOT A MULTIPLE OF 8")') ibit
65  CALL bort(bort_str)
66  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
subroutine pad(IBAY, IBIT, IBYT, IPADB)
This subroutine first packs the value for the number of bits being "padded" (we'll get to that later)...
Definition: pad.f:35
subroutine pkb(NVAL, NBITS, IBAY, IBIT)
This subroutine encodes an integer value within a specified number of bits of an integer array,...
Definition: pkb.f:28