1 REAL*8 FUNCTION UPS
(IVAL
,NODE
)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 C PRGMMR: J. ATOR ORG: NP12 DATE: 2012-03-02
8 C ABSTRACT: THIS FUNCTION UNPACKS A REAL*8 USER VALUE FROM A PACKED
9 C BUFR INTEGER BY APPLYING THE PROPER SCALE AND REFERENCE VALUES.
10 C NORMALLY THE SCALE AND REFERENCE VALUES ARE OBTAINED FROM INDEX
11 C NODE OF THE INTERNAL JUMP/LINK TABLE ARRAYS ISC(*) AND IRF(*);
12 C HOWEVER, THE REFERENCE VALUE IN IRF(*) WILL BE OVERRIDDEN IF A
13 C 2-03 OPERATOR IS IN EFFECT FOR THIS NODE.
15 C PROGRAM HISTORY LOG:
16 C 2012-03-02 J. ATOR -- ORIGINAL AUTHOR; ADAPTED FROM INTERNAL
17 C STATEMENT FUNCTION IN OTHER SUBROUTINES
19 C USAGE: UPS (IVAL,NODE)
20 C INPUT ARGUMENT LIST:
21 C IVAL - INTEGER: PACKED BUFR INTEGER
22 C NODE - INTEGER: INDEX INTO INTERNAL JUMP/LINK TABLES
24 C OUTPUT ARGUMENT LIST:
25 C UPS - REAL*8: USER VALUE
28 C THIS ROUTINE CALLS: None
29 C THIS ROUTINE IS CALLED BY: RDCMPS RDTREE UFBGET UFBTAB
31 C Normally not called by any application
35 C LANGUAGE: FORTRAN 77
36 C MACHINE: PORTABLE TO ALL PLATFORMS
42 COMMON /BTABLES
/ MAXTAB
,NTAB
,TAG
(MAXJL
),TYP
(MAXJL
),KNT
(MAXJL
),
43 . JUMP
(MAXJL
),LINK
(MAXJL
),JMPB
(MAXJL
),
44 . IBT
(MAXJL
),IRF
(MAXJL
),ISC
(MAXJL
),
45 . ITP
(MAXJL
),VALI
(MAXJL
),KNTI
(MAXJL
),
46 . ISEQ
(MAXJL
,2),JSEQ
(MAXJL
)
47 COMMON /NRV203
/ NNRV
,INODNRV
(MXNRV
),NRV
(MXNRV
),TAGNRV
(MXNRV
),
48 . ISNRV
(MXNRV
),IENRV
(MXNRV
),IBTNRV
,IPFNRV
58 C-----------------------------------------------------------------------
60 UPS
= ( IVAL
+ IRF
(NODE
) ) * TEN**
(-ISC
(NODE
))
62 IF ( NNRV
.GT
. 0 ) THEN
64 C There are redefined reference values in the jump/link table,
65 C so we need to check if this node is affected by any of them.
68 IF ( NODE
.EQ
. INODNRV
(JJ
) ) THEN
70 C This node contains a redefined reference value.
71 C Per the rules of BUFR, negative values may be encoded
72 C as positive integers with the left-most bit set to 1.
74 IMASK
= 2**(IBT
(NODE
)-1)
75 IF ( IAND
(IVAL
,IMASK
) .GT
. 0 ) THEN
76 NRV
(JJ
) = (-1) * ( IVAL
- IMASK
)
82 ELSE IF ( ( TAG
(NODE
)(1:8) .EQ
. TAGNRV
(JJ
) ) .AND
.
83 . ( NODE
.GE
. ISNRV
(JJ
) ) .AND
.
84 . ( NODE
.LE
. IENRV
(JJ
) ) ) THEN
86 C The corresponding redefinded reference value needs to
87 C be used when decoding this value.
89 UPS
= ( IVAL
+ NRV
(JJ
) ) * TEN**
(-ISC
(NODE
))