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