NCEPLIBS-bufr  11.7.0
 All Data Structures Files Functions Variables Pages
pad.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1994-01-06
3 
4 C> THIS SUBROUTINE FIRST PACKS THE VALUE FOR THE NUMBER OF
5 C> BITS BEING "PADDED" (WE'LL GET TO THAT LATER), STARTING WITH BIT
6 C> IBIT+1 AND USING EIGHT BITS IN THE PACKED ARRAY IBAY (WHICH
7 C> REPRESENTS A SUBSET PACKED INTO IBIT BITS). THEN, STARTING WITH
8 C> IBIT+9, IT PACKS ZEROES (I.E., "PADS") TO THE SPECIFIED BIT
9 C> BOUNDARY (IPADB). (NOTE: IT'S THE NUMBER OF BITS PADDED HERE THAT
10 C> WAS PACKED IN BITS IBIT+1 THROUGH IBIT+8 - THIS IS ACTUALLY A
11 C> DELAYED REPLICATION FACTOR). IPADB MUST BE A MULTIPLE OF EIGHT AND
12 C> REPRESENTS THE BIT BOUNDARY ON WHICH THE PACKED SUBSET IN IBAY
13 C> SHOULD END AFTER PADDING. FOR EXAMPLE, IF IPABD IS "8", THEN THE
14 C> NUMBER OF BITS IN IBAY ACTUALLY CONSUMED BY PACKED DATA (INCLUDING
15 C> THE PADDING) WILL BE A MULTIPLE OF EIGHT. IF IPADB IS "16", IT
16 C> WILL BE A MULTIPLE OF SIXTEEN. IN EITHER (OR ANY) CASE, THIS
17 C> ENSURES THAT THE PACKED SUBSET WILL ALWAYS END ON A FULL BYTE
18 C> BOUNDARY.
19 C>
20 C> PROGRAM HISTORY LOG:
21 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
22 C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
23 C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
24 C> ROUTINE "BORT"
25 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
26 C> INTERDEPENDENCIES
27 C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
28 C> DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
29 C> MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
30 C> TERMINATES ABNORMALLY
31 C>
32 C> USAGE: CALL PAD (IBAY, IBIT, IBYT, IPADB)
33 C> INPUT ARGUMENT LIST:
34 C> IBAY - INTEGER: *-WORD PACKED BINARY ARRAY NOT YET PADDED
35 C> IBIT - INTEGER: BIT POINTER WITHIN IBAY TO START PADDING FROM
36 C> IPADB - INTEGER: BIT BOUNDARY TO PAD TO (MUST BE A MULTIPLE OF
37 C> 8)
38 C>
39 C> OUTPUT ARGUMENT LIST:
40 C> IBAY - INTEGER: *-WORD PACKED BINARY ARRAY NOW PADDED
41 C> IBIT - INTEGER: NUMBER OF BITS WITHIN IBAY CONTAINING PACKED
42 C> DATA (INCLUDING PADDING, MUST BE A MULTIPLE OF 8)
43 C> IBYT - INTEGER: NUMBER OF BYTES WITHIN IBAY CONTAINING PACKED
44 C> DATA (INCLUDING PADDING) (I.E., IBIT/8)
45 C>
46 C> REMARKS:
47 C> THIS ROUTINE CALLS: BORT PKB
48 C> THIS ROUTINE IS CALLED BY: MSGUPD
49 C> Normally not called by any application
50 C> programs.
51 C>
52  SUBROUTINE pad(IBAY,IBIT,IBYT,IPADB)
53 
54 
55 
56  CHARACTER*128 bort_str
57  dimension ibay(*)
58 
59 C----------------------------------------------------------------------
60 C----------------------------------------------------------------------
61 
62 C PAD THE SUBSET TO AN IPADB BIT BOUNDARY
63 C ----------------------------------------
64 
65  ipad = ipadb - mod(ibit+8,ipadb)
66 c .... First pack the # of bits being padded (this is a delayed
67 c .... replication factor)
68  CALL pkb(ipad,8,ibay,ibit)
69 c .... Now pad with zeroes to the byte boundary
70  CALL pkb(0,ipad,ibay,ibit)
71  ibyt = ibit/8
72 
73  IF(mod(ibit,ipadb).NE.0) goto 900
74  IF(mod(ibit,8 ).NE.0) goto 901
75 
76 C EXITS
77 C -----
78 
79  RETURN
80 900 WRITE(bort_str,'("BUFRLIB: PAD - THE INPUT BIT BOUNDARY TO PAD '//
81  . 'TO (",I8,") IS NOT A MULTIPLE OF 8")') ipadb
82  CALL bort(bort_str)
83 901 WRITE(bort_str,'("BUFRLIB: PAD - THE NUMBER OF BITS IN A PACKED'//
84  . ' SUBSET AFTER PADDING (",I8,") IS NOT A MULTIPLE OF 8")') ibit
85  CALL bort(bort_str)
86  END
subroutine pad(IBAY, IBIT, IBYT, IPADB)
THIS SUBROUTINE FIRST PACKS THE VALUE FOR THE NUMBER OF BITS BEING "PADDED" (WE'LL GET TO THAT LATE...
Definition: pad.f:52
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:22
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:38