NCEPLIBS-bufr 11.7.1
upbb.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
3
4C> THIS SUBROUTINE UNPACKS AND RETURNS A BINARY INTEGER
5C> CONTAINED WITHIN NBITS BITS OF IBAY, STARTING WITH BIT (IBIT+1).
6C> THIS IS SIMILAR TO BUFR ARCHIVE LIBRARY SUBROUTINE UPB, EXCEPT IN
7C> UPBB IBIT IS NOT UPDATED UPON OUTPUT (AND THE ORDER OF ARGUMENTS IS
8C> DIFFERENT).
9C>
10C> PROGRAM HISTORY LOG:
11C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
12C> 1998-10-27 J. WOOLLEN -- MODIFIED TO CORRECT PROBLEMS CAUSED BY IN-
13C> LINING CODE WITH FPP DIRECTIVES
14C> 2003-11-04 J. WOOLLEN -- BIG-ENDIAN/LITTLE-ENDIAN INDEPENDENT (WAS
15C> IN DECODER VERSION)
16C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
17C> INTERDEPENDENCIES
18C> 2003-11-04 D. KEYSER -- ADDED CHECK FOR NBITS EQUAL TO ZERO;
19C> MODIFIED LOGIC TO MAKE IT CONSISTENT WITH
20C> LOGIC IN UPB; UNIFIED/PORTABLE FOR WRF;
21C> ADDED DOCUMENTATION (INCLUDING HISTORY)
22C>
23C> USAGE: CALL UPBB (NVAL, NBITS, IBIT, IBAY)
24C> INPUT ARGUMENT LIST:
25C> NBITS - INTEGER: NUMBER OF BITS OF IBAY WITHIN WHICH TO UNPACK
26C> NVAL
27C> IBIT - INTEGER: BIT POINTER WITHIN IBAY TO START UNPACKING
28C> FROM
29C> IBAY - INTEGER: *-WORD PACKED BINARY ARRAY CONTAINING PACKED
30C> NVAL
31C>
32C> OUTPUT ARGUMENT LIST:
33C> NVAL - INTEGER: UNPACKED INTEGER
34C>
35C> REMARKS:
36C> THIS ROUTINE CALLS: IREV
37C> THIS ROUTINE IS CALLED BY: RCSTPL RDTREE UFBGET UFBTAB
38C> UFBTAM UPB WRITLC
39C> Normally not called by any application
40C> programs.
41C>
42 SUBROUTINE upbb(NVAL,NBITS,IBIT,IBAY)
43
44
45
46 COMMON /hrdwrd/ nbytw,nbitw,iord(8)
47
48 dimension ibay(*)
49
50C----------------------------------------------------------------------
51C----------------------------------------------------------------------
52
53C IF NBITS=0, THEN JUST SET NVAL=0 AND RETURN
54C -------------------------------------------
55
56 IF(nbits.EQ.0)THEN
57 nval=0
58 GOTO 100
59 ENDIF
60
61 nwd = ibit/nbitw + 1
62 nbt = mod(ibit,nbitw)
63 int = ishft(irev(ibay(nwd)),nbt)
64 int = ishft(int,nbits-nbitw)
65 lbt = nbt+nbits
66 IF(lbt.GT.nbitw) THEN
67 jnt = irev(ibay(nwd+1))
68 int = ior(int,ishft(jnt,lbt-2*nbitw))
69 ENDIF
70 nval = int
71
72C EXIT
73C ----
74
75100 RETURN
76 END
function irev(N)
THIS FUNCTION WILL, WHEN THE LOCAL MACHINE IS "LITTLE- ENDIAN" (I.E., USES A RIGHT TO LEFT SCHEME ...
Definition: irev.F:51
subroutine upbb(NVAL, NBITS, IBIT, IBAY)
THIS SUBROUTINE UNPACKS AND RETURNS A BINARY INTEGER CONTAINED WITHIN NBITS BITS OF IBAY,...
Definition: upbb.f:43