NCEPLIBS-bufr  12.0.0
pkb8.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Encode an 8-byte integer value within an integer array.
3 C>
4 C> @author J. Woollen @date 2022-05-06
5 
6 C> This subroutine encodes an 8-byte integer value within a specified
7 C> number of bits of an integer array, starting at the bit
8 C> immediately after a specified bit within the array.
9 C>
10 C> This subroutine will not work properly if NBITS is less than 0 or
11 C> greater than 64, as determined via an internal call to subroutine
12 C> wrdlen().
13 C>
14 C> This subroutine is the logical inverse of subroutine up8().
15 C>
16 C> @param[in] NVAL - integer*8: Value to be encoded.
17 C> @param[in] NBITS - integer: Number of bits of IBAY within
18 C> which to encode NVAL. Must be between 0 and 64.
19 C> @param[out] IBAY - integer(*): Array containing encoded NVAL.
20 C> @param[in,out] IBIT - integer: Bit pointer within IBAY
21 C> - On input, IBIT points to the bit within
22 C> IBAY after which to begin encoding NVAL.
23 C> - On output, IBIT points to the last bit
24 C> of IBAY which contains the encoded NVAL.
25 C>
26 C> @author J. Woollen @date 2022-05-06
27  subroutine pkb8(nval,nbits,ibay,ibit)
28 
29  common /hrdwrd/ nbytw,nbitw,iord(8)
30 
31  integer(8) :: nval
32  integer(4) :: nbits,ibit,ibay(*)
33 
34  integer(8) :: nval8
35  integer(4) :: nval4
36  integer(4) :: nvals(2)
37 
38  equivalence(nval8,nvals)
39 
40 !----------------------------------------------------------------------
41 !----------------------------------------------------------------------
42 
43  if(nbits<0 ) call bort('bufrlib: pkb8 - nbits < zero !!!!!')
44  if(nbits>64) call bort('bufrlib: pkb8 - nbits > 64 !!!!!')
45 
46  nval8=nval
47  nval4=nvals(2)
48  call pkb(nval4,max(nbits-nbitw,0),ibay,ibit)
49  nval4=nvals(1)
50  call pkb(nval4,min(nbits,nbitw ),ibay,ibit)
51 
52  end subroutine
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
subroutine pkb8(nval, nbits, ibay, ibit)
This subroutine encodes an 8-byte integer value within a specified number of bits of an integer array...
Definition: pkb8.f:28
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