3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 C PRGMMR: WOOLLEN ORG: NP20 DATE: 2000-09-19
8 C ABSTRACT: THIS SUBROUTINE UNCOMPRESSES AND UNPACKS THE NEXT SUBSET
9 C FROM THE INTERNAL COMPRESSED MESSAGE BUFFER (ARRAY MBAY IN COMMON
10 C BLOCK /BITBUF/) AND STORES THE UNPACKED SUBSET WITHIN THE INTERNAL
11 C ARRAY VAL(*,LUN) IN COMMON BLOCK /USRINT/.
13 C PROGRAM HISTORY LOG:
14 C 2000-09-19 J. WOOLLEN -- ORIGINAL AUTHOR
15 C 2002-05-14 J. WOOLLEN -- IMPROVED GENERALITY, PREVIOUSLY RDCMPS
16 C WOULD NOT RECOGNIZE COMPRESSED DELAYED
17 C REPLICATION AS A LEGITIMATE DATA STRUCTURE
18 C 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
19 C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
21 C 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
22 C INCREASED FROM 15000 TO 16000 (WAS IN
23 C VERIFICATION VERSION); UNIFIED/PORTABLE FOR
24 C WRF; ADDED HISTORY DOCUMENTATION
25 C 2004-08-18 J. ATOR -- INITIALIZE CVAL TO EMPTY BEFORE CALLING UPC;
26 C CORRECT LOGIC FOR WHEN A CHARACTER VALUE IS
27 C THE SAME FOR ALL SUBSETS IN A MESSAGE;
28 C MAXIMUM MESSAGE LENGTH INCREASED FROM
29 C 20,000 TO 50,000 BYTES
30 C 2009-03-23 J. ATOR -- PREVENT OVERFLOW OF CVAL AND CREF FOR
31 C STRINGS LONGER THAN 8 CHARACTERS
32 C 2012-03-02 J. ATOR -- USE FUNCTION UPS
33 C 2012-06-04 J. ATOR -- SET DECODED REAL*8 VALUE TO "MISSING" WHEN
34 C CORRESPONDING CHARACTER FIELD HAS ALL BITS
37 C USAGE: CALL RDCMPS (LUN)
38 C INPUT ARGUMENT LIST:
39 C LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
42 C THIS ROUTINE CALLS: BORT ICBFMS UPB UPC
44 C THIS ROUTINE IS CALLED BY: READSB
45 C Normally not called by any application
49 C LANGUAGE: FORTRAN 77
50 C MACHINE: PORTABLE TO ALL PLATFORMS
56 COMMON /BITBUF
/ MAXBYT
,IBIT
,IBAY
(MXMSGLD4
),MBYT
(NFILES
),
57 . MBAY
(MXMSGLD4
,NFILES
)
58 COMMON /MSGCWD
/ NMSG
(NFILES
),NSUB
(NFILES
),MSUB
(NFILES
),
59 . INODE
(NFILES
),IDATE
(NFILES
)
60 COMMON /BTABLES
/ MAXTAB
,NTAB
,TAG
(MAXJL
),TYP
(MAXJL
),KNT
(MAXJL
),
61 . JUMP
(MAXJL
),LINK
(MAXJL
),JMPB
(MAXJL
),
62 . IBT
(MAXJL
),IRF
(MAXJL
),ISC
(MAXJL
),
63 . ITP
(MAXJL
),VALI
(MAXJL
),KNTI
(MAXJL
),
64 . ISEQ
(MAXJL
,2),JSEQ
(MAXJL
)
65 COMMON /USRINT
/ NVAL
(NFILES
),INV
(MAXSS
,NFILES
),VAL
(MAXSS
,NFILES
)
66 COMMON /RLCCMN
/ NRST
,IRNCH
(MXRST
),IRBIT
(MXRST
),CRTAG
(MXRST
)
68 CHARACTER*128 BORT_STR
69 CHARACTER*10 TAG
,CRTAG
72 EQUIVALENCE
(CVAL
,RVAL
)
75 C-----------------------------------------------------------------------
76 C Statement function to compute BUFR "missing value" for field
77 C of length LBIT bits (all bits "on"):
79 LPS
(LBIT
) = MAX
(2**(LBIT
)-1,1)
80 C-----------------------------------------------------------------------
82 C SETUP THE SUBSET TEMPLATE
83 C -------------------------
87 C UNCOMPRESS A SUBSET INTO THE VAL ARRAY ACCORDING TO TABLE B
88 C -----------------------------------------------------------
92 C Note that we are going to unpack the (NSBS)th subset from within
93 C the current BUFR message.
98 C Loop through each element of the subset.
107 C In each of the following code blocks, the "local reference value"
108 C for the element is determined first, followed by the 6-bit value
109 C which indicates how many bits are used to store the increment
110 C (i.e. offset) from this "local reference value". Then, we jump
111 C ahead to where this increment is stored for this particular subset,
112 C unpack it, and add it to the "local reference value" to determine
113 C the final uncompressed value for this element from this subset.
115 C Note that, if an element has the same final uncompressed value
116 C for each subset in the message, then the encoding rules for BUFR
117 C compression dictate that the "local reference value" will be equal
118 C to this value, the 6-bit increment length indicator will have
119 C a value of zero, and the actual increments themselves will be
120 C omitted from the message.
122 IF(ITYP
.EQ
.1.OR
.ITYP
.EQ
.2) THEN
124 C This is a numeric element.
126 CALL UPB
(LREF
,NBIT
,MBAY
(1,LUN
),IBIT
)
127 CALL UPB
(LINC
, 6,MBAY
(1,LUN
),IBIT
)
128 JBIT
= IBIT
+ LINC*
(NSBS
-1)
129 CALL UPB
(NINC
,LINC
,MBAY
(1,LUN
),JBIT
)
130 IF(NINC
.EQ
.LPS
(LINC
)) THEN
136 CALL USRTPL
(LUN
,N
,IVAL
)
139 IF(IVAL
.LT
.LPS
(NBIT
)) VAL
(N
,LUN
) = UPS
(IVAL
,NODE
)
140 IBIT
= IBIT
+ LINC*MSUB
(LUN
)
141 ELSEIF
(ITYP
.EQ
.3) THEN
143 C This is a character element. If there are more than 8
144 C characters, then only the first 8 will be unpacked by this
145 C routine, and a separate subsequent call to BUFR archive library
146 C subroutine READLC will be required to unpack the remainder of
147 C the string. In this case, pointers will be saved within
148 C COMMON /RLCCMN/ for later use within READLC.
150 C Unpack the local reference value.
156 CALL UPC
(CREF
,NCHR
,MBAY
(1,LUN
),IBIT
)
158 IBIT
= IBIT
+ (LELM
-8)*8
160 IF(NRST
.GT
.MXRST
) GOTO 900
161 CRTAG
(NRST
) = TAG
(NODE
)
164 C Unpack the increment length indicator. For character elements,
165 C this length is in bytes rather than bits.
167 CALL UPB
(LINC
, 6,MBAY
(1,LUN
),IBIT
)
175 JBIT
= IBIT
+ LINC*
(NSBS
-1)*8
182 CALL UPC
(CVAL
,NCHR
,MBAY
(1,LUN
),JBIT
)
184 IF (LELM
.LE
.8 .AND
. ICBFMS
(CVAL
,NCHR
).NE
.0) THEN
189 IBIT
= IBIT
+ 8*LINC*MSUB
(LUN
)
194 900 WRITE(BORT_STR
,'("BUFRLIB: RDCMPS - NUMBER OF LONG CHARACTER ' //
195 . 'STRINGS EXCEEDS THE LIMIT (",I4,")")') MXRST