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