NCEPLIBS-bufr 11.7.1
ups.f
Go to the documentation of this file.
1C> @file
2C> @author J @date 2012-03-02
3
4C> THIS FUNCTION UNPACKS A REAL*8 USER VALUE FROM A PACKED
5C> BUFR INTEGER BY APPLYING THE PROPER SCALE AND REFERENCE VALUES.
6C> NORMALLY THE SCALE AND REFERENCE VALUES ARE OBTAINED FROM INDEX
7C> NODE OF THE INTERNAL JUMP/LINK TABLE ARRAYS ISC(*) AND IRF(*);
8C> HOWEVER, THE REFERENCE VALUE IN IRF(*) WILL BE OVERRIDDEN IF A
9C> 2-03 OPERATOR IS IN EFFECT FOR THIS NODE.
10C>
11C> PROGRAM HISTORY LOG:
12C> 2012-03-02 J. ATOR -- ORIGINAL AUTHOR; ADAPTED FROM INTERNAL
13C> STATEMENT FUNCTION IN OTHER SUBROUTINES
14C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
15C> 2022-05-06 J. WOOLLEN -- MAKE IVAL AND IMASK 8BYTE INTEGERS
16C>
17C> USAGE: UPS (IVAL,NODE)
18C> INPUT ARGUMENT LIST:
19C> IVAL - INTEGER: PACKED BUFR INTEGER
20C> NODE - INTEGER: INDEX INTO INTERNAL JUMP/LINK TABLES
21C>
22C> OUTPUT ARGUMENT LIST:
23C> UPS - REAL*8: USER VALUE
24C>
25C> REMARKS:
26C> THIS ROUTINE CALLS: None
27C> THIS ROUTINE IS CALLED BY: RDCMPS RDTREE UFBGET UFBTAB
28C> UFBTAM
29C> Normally not called by any application
30C> programs.
31C>
32 REAL*8 FUNCTION ups(IVAL,NODE)
33
34 USE moda_tables
35 USE moda_nrv203
36
37 integer*8 ival,imask
38 real*8 ten
39
40 DATA ten /10./
41
42C-----------------------------------------------------------------------
43
44 ups = ( ival + irf(node) ) * ten**(-isc(node))
45
46 IF ( nnrv .GT. 0 ) THEN
47
48C There are redefined reference values in the jump/link table,
49C so we need to check if this node is affected by any of them.
50
51 DO jj = 1, nnrv
52 IF ( node .EQ. inodnrv(jj) ) THEN
53
54C This node contains a redefined reference value.
55C Per the rules of BUFR, negative values may be encoded
56C as positive integers with the left-most bit set to 1.
57
58 imask = 2_8**(ibt(node)-1)
59 IF ( iand(ival,imask) .GT. 0 ) THEN
60 nrv(jj) = (-1) * ( ival - imask )
61 ELSE
62 nrv(jj) = ival
63 END IF
64 ups = nrv(jj)
65 RETURN
66 ELSE IF ( ( tag(node)(1:8) .EQ. tagnrv(jj) ) .AND.
67 . ( node .GE. isnrv(jj) ) .AND.
68 . ( node .LE. ienrv(jj) ) ) THEN
69
70C The corresponding redefinded reference value needs to
71C be used when decoding this value.
72
73 ups = ( ival + nrv(jj) ) * ten**(-isc(node))
74 RETURN
75 END IF
76 END DO
77
78 END IF
79
80 RETURN
81 END
This module contains array and variable declarations for use with any 2-03-YYY (change reference valu...
Definition: moda_nrv203.F:15
integer nnrv
Number of entries in the jump/link table which contain new reference values (up to a maximum of MXNRV...
Definition: moda_nrv203.F:56
integer, dimension(:), allocatable ienrv
End of entry range in jump/link table, within which the corresponding new reference value in nrv will...
Definition: moda_nrv203.F:63
integer, dimension(:), allocatable isnrv
Start of entry range in jump/link table, within which the corresponding new reference value in nrv wi...
Definition: moda_nrv203.F:62
integer, dimension(:), allocatable inodnrv
Entries within jump/link table which contain new reference values.
Definition: moda_nrv203.F:60
integer *8, dimension(:), allocatable nrv
New reference values corresponding to inodnrv.
Definition: moda_nrv203.F:61
character *8, dimension(:), allocatable tagnrv
Table B mnemonic to which the corresponding new reference value in nrv applies.
Definition: moda_nrv203.F:59
This module contains array and variable declarations used to store the internal jump/link table.
Definition: moda_tables.F:13
integer, dimension(:), allocatable isc
Scale factors corresponding to tag and typ:
Definition: moda_tables.F:140
integer, dimension(:), allocatable ibt
Bit widths corresponding to tag and typ:
Definition: moda_tables.F:138
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
Definition: moda_tables.F:132
integer, dimension(:), allocatable irf
Reference values corresponding to tag and typ:
Definition: moda_tables.F:139
real *8 function ups(IVAL, NODE)
THIS FUNCTION UNPACKS A REAL*8 USER VALUE FROM A PACKED BUFR INTEGER BY APPLYING THE PROPER SCALE AND...
Definition: ups.f:33