NCEPLIBS-bufr  12.0.0
padmsg.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Pad a BUFR message with zeroed-out bytes up to the
3 C> next 8-byte boundary.
4 C> @author Ator @date 2005-11-29
5 
6 C> This subroutine pads a BUFR message with zeroed-out bytes
7 C> from the end of the message up to the next 8-byte boundary.
8 C>
9 C> @param[inout] MESG - integer(*):
10 C> - on input, contains BUFR message to be padded
11 C> - on output, contains BUFR message with NPBYT zeroed-out bytes appended
12 C> to the end
13 C> @param[in] LMESG - integer: dimensioned size (in integer words) of MESG;
14 C> used by the subroutine to ensure that it does not overflow the MESG array.
15 C> @param[out] NPBYT - integer: number of zeroed-out bytes appended to MESG.
16 C>
17 C> @author Ator @date 2005-11-29
18  SUBROUTINE padmsg(MESG,LMESG,NPBYT)
19 
20  COMMON /hrdwrd/ nbytw,nbitw,iord(8)
21 
22  dimension mesg(*)
23 
24 C-----------------------------------------------------------------------
25 C-----------------------------------------------------------------------
26 
27 C Make sure that the array is big enough to hold the additional
28 C byte padding that will be appended to the end of the message.
29 
30  nmw = nmwrd(mesg)
31  IF(nmw.GT.lmesg) GOTO 900
32 
33 C Pad from the end of the message up to the next 8-byte boundary.
34 
35  nmb = iupbs01(mesg,'LENM')
36  ibit = nmb*8
37  npbyt = ( nmw * nbytw ) - nmb
38  DO i = 1, npbyt
39  CALL pkb(0,8,mesg,ibit)
40  ENDDO
41 
42  RETURN
43 900 CALL bort('BUFRLIB: PADMSG - CANNOT ADD PADDING TO MESSAGE '//
44  . 'ARRAY; TRY A LARGER DIMENSION FOR THIS ARRAY')
45  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
recursive function iupbs01(MBAY, S01MNEM)
Read a data value from Section 0 or Section 1 of a BUFR message.
Definition: iupbs01.f:69
recursive function nmwrd(MBAY)
Given an integer array containing Section 0 from a BUFR message, this function determines the array s...
Definition: nmwrd.f:24
subroutine padmsg(MESG, LMESG, NPBYT)
This subroutine pads a BUFR message with zeroed-out bytes from the end of the message up to the next ...
Definition: padmsg.f:19
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