24 subroutine pkc(chr,nchr,ibay,ibit)
26 use modv_vars,
only: nbitw, nbytw, iordle, iordbe
30 character*(*),
intent(in) :: chr
33 integer,
intent(in) :: nchr
34 integer,
intent(out) :: ibay(*)
35 integer,
intent(inout) :: ibit
36 integer ival(2), lb, i, nwd, nbt, nbit, int, msk, irev
38 equivalence(cval,ival)
60 int = ishft(ival(1),nbitw-nbit)
62 msk = ishft( -1,nbitw-nbit)
64 ibay(nwd) = irev(ior(iand(irev(ibay(nwd)),not(msk)),int))
65 if(nbt+nbit>nbitw)
then
71 int = ishft(ival(1),2*nbitw-(nbt+nbit))
72 msk = ishft( -1,2*nbitw-(nbt+nbit))
73 ibay(nwd+1) = irev(ior(iand(irev(ibay(nwd+1)),not(msk)),int))
96 subroutine pkb8(nval,nbits,ibay,ibit)
98 use modv_vars,
only: nbitw
102 integer*8,
intent(in) :: nval
103 integer,
intent(in) :: nbits
104 integer,
intent(out) :: ibay(*)
105 integer,
intent(inout) :: ibit
108 integer :: nval4, nvals(2)
110 equivalence(nval8,nvals)
112 if(nbits<0)
call bort(
'bufrlib: pkb8 - nbits < zero !!!!!')
113 if(nbits>64)
call bort(
'bufrlib: pkb8 - nbits > 64 !!!!!')
117 call pkb(nval4,max(nbits-nbitw,0),ibay,ibit)
119 call pkb(nval4,min(nbits,nbitw ),ibay,ibit)
139 subroutine pkb(nval,nbits,ibay,ibit)
141 use modv_vars,
only: nbitw
145 integer,
intent(in) :: nval, nbits
146 integer,
intent(out) :: ibay(*)
147 integer,
intent(inout) :: ibit
148 integer nwd, nbt, ival, int, msk, irev
150 character*156 bort_str
153 write(bort_str,
'("BUFRLIB: PKB - NUMBER OF BITS BEING PACKED '// &
154 ', NBITS (",I4,"), IS > THE INTEGER WORD LENGTH ON THIS MACHINE, NBITW (",I3,")")') nbits,nbitw
159 nbt = mod(ibit,nbitw)
161 if(ishft(ival,-nbits)>0) ival = -1
162 int = ishft(ival,nbitw-nbits)
163 int = ishft(int,-nbt)
164 msk = ishft(-1,nbitw-nbits)
165 msk = ishft(msk,-nbt)
166 ibay(nwd) = irev(ior(iand(irev(ibay(nwd)),not(msk)),int))
167 if(nbt+nbits>nbitw)
then
173 int = ishft(ival,2*nbitw-(nbt+nbits))
174 msk = ishft( -1,2*nbitw-(nbt+nbits))
175 ibay(nwd+1) = irev(ior(iand(irev(ibay(nwd+1)),not(msk)),int))
193 recursive subroutine ipkm(cbay,nbyt,n)
195 use modv_vars,
only: im8b, nbytw
199 integer,
intent(in) :: n, nbyt
200 integer my_n, my_nbyt, int,
irev, i
202 character*(*),
intent(out) :: cbay
203 character*128 bort_str
206 equivalence(cint,int)
214 call x84(nbyt,my_nbyt,1)
215 call ipkm(cbay,my_nbyt,my_n)
222 write(bort_str,
'("BUFRLIB: IPKM - NUMBER OF BYTES BEING PACKED '// &
223 ', NBYT (",I4,"), IS > THE INTEGER WORD LENGTH ON THIS MACHINE, NBYTW (",I3,")")') nbyt,nbytw
227 int =
irev(ishft(n,(nbytw-nbyt)*8))
229 cbay(i:i) = cint(i:i)
251 integer*8 function ipks(val,node)
result(i8ret)
259 integer,
intent(in) :: node
262 real*8,
parameter :: ten = 10.
263 real*8,
intent(in) :: val
265 i8ret = nint(val * ten**
isc(node),8) -
irf(node)
270 if ( node ==
inodnrv(jj) )
then
274 if (
nrv(jj) < 0 )
then
275 imask = 2_8**(
ibt(node)-1)
276 i8ret = ior(abs(
nrv(jj)),imask)
281 else if ( (
tag(node)(1:8) ==
tagnrv(jj) ) .and. ( node >=
isnrv(jj) ) .and. ( node <=
ienrv(jj) ) )
then
283 i8ret = nint(val * ten**
isc(node),8) -
nrv(jj)
subroutine bort(str)
Log an error message, then abort the application program.
subroutine pkc(chr, nchr, ibay, ibit)
Encode a character string within a specified number of bytes of an integer array, starting at the bit...
integer *8 function ipks(val, node)
Pack a real*8 value into an integer by applying the proper scale and reference values.
recursive subroutine ipkm(cbay, nbyt, n)
Encode an integer value within a specified number of bytes of a character string, up to a maximum of ...
subroutine pkb(nval, nbits, ibay, ibit)
Encode an integer value within a specified number of bits of an integer array, starting at the bit im...
subroutine pkb8(nval, nbits, ibay, ibit)
Encode an 8-byte integer value within a specified number of bits of an integer array,...
integer function irev(n)
Return a copy of an integer value with the bytes possibly reversed.
Declare arrays and variables for use with any 2-03-YYY (change reference value) operators present wit...
integer, dimension(:), allocatable ienrv
End of entry range in jump/link table, within which the corresponding new reference value in nrv will...
character *8, dimension(:), allocatable tagnrv
Table B mnemonic to which the corresponding new reference value in nrv applies.
integer, dimension(:), allocatable isnrv
Start of entry range in jump/link table, within which the corresponding new reference value in nrv wi...
integer nnrv
Number of entries in the jump/link table which contain new reference values (up to a maximum of mxnrv...
integer *8, dimension(:), allocatable nrv
New reference values corresponding to inodnrv.
integer, dimension(:), allocatable inodnrv
Entries within jump/link table which contain new reference values.
Declare arrays and variables used to store the internal jump/link table.
integer, dimension(:), allocatable irf
Reference values corresponding to tag and typ:
integer, dimension(:), allocatable isc
Scale factors corresponding to tag and typ:
integer, dimension(:), allocatable ibt
Bit widths corresponding to tag and typ:
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
subroutine x84(iin8, iout4, nval)
Encode one or more 8-byte integer values as 4-byte integer values.