NCEPLIBS-bufr  12.0.0
ups.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Unpack a real*8 value from an integer by applying the
3 C> proper scale and reference values.
4 C>
5 C> @author J. Ator @date 2012-03-02
6 
7 C> This function unpacks a real*8 user value from a packed
8 C> BUFR integer by applying the proper scale and reference values.
9 C> Normally the scale and reference values are obtained from index
10 C> node of the internal jump/link table arrays isc(*) and irf(*);
11 C> however, the reference value in irf(*) will be overridden if a
12 C> 2-03 operator is in effect for this node.
13 C>
14 C> This function is the logical inverse of function ipks().
15 C>
16 C> @param[in] IVAL - integer: packed BUFR integer.
17 C> @param[in] NODE - integer: index into internal jump/link tables.
18 C> @returns UPS - real*8: user value.
19 C>
20 C> @author J. Ator @date 2012-03-02
21  REAL*8 FUNCTION ups(IVAL,NODE)
22 
23  USE moda_tables
24  USE moda_nrv203
25 
26  integer*8 ival,imask
27  real*8 ten
28 
29  DATA ten /10./
30 
31 C-----------------------------------------------------------------------
32 
33  ups = ( ival + irf(node) ) * ten**(-isc(node))
34 
35  IF ( nnrv .GT. 0 ) THEN
36 
37 C There are redefined reference values in the jump/link table,
38 C so we need to check if this node is affected by any of them.
39 
40  DO jj = 1, nnrv
41  IF ( node .EQ. inodnrv(jj) ) THEN
42 
43 C This node contains a redefined reference value.
44 C Per the rules of BUFR, negative values may be encoded
45 C as positive integers with the left-most bit set to 1.
46 
47  imask = 2_8**(ibt(node)-1)
48  IF ( iand(ival,imask) .GT. 0 ) THEN
49  nrv(jj) = (-1) * ( ival - imask )
50  ELSE
51  nrv(jj) = ival
52  END IF
53  ups = nrv(jj)
54  RETURN
55  ELSE IF ( ( tag(node)(1:8) .EQ. tagnrv(jj) ) .AND.
56  . ( node .GE. isnrv(jj) ) .AND.
57  . ( node .LE. ienrv(jj) ) ) THEN
58 
59 C The corresponding redefinded reference value needs to
60 C be used when decoding this value.
61 
62  ups = ( ival + nrv(jj) ) * ten**(-isc(node))
63  RETURN
64  END IF
65  END DO
66 
67  END IF
68 
69  RETURN
70  END
This module contains array and variable declarations for use with any 2-03-YYY (change reference valu...
integer, dimension(:), allocatable ienrv
End of entry range in jump/link table, within which the corresponding new reference value in nrv will...
character *8, dimension(:), allocatable tagnrv
Table B mnemonic to which the corresponding new reference value in nrv applies.
integer, dimension(:), allocatable isnrv
Start of entry range in jump/link table, within which the corresponding new reference value in nrv wi...
integer nnrv
Number of entries in the jump/link table which contain new reference values (up to a maximum of MXNRV...
integer *8, dimension(:), allocatable nrv
New reference values corresponding to inodnrv.
integer, dimension(:), allocatable inodnrv
Entries within jump/link table which contain new reference values.
This module contains array and variable declarations used to store the internal jump/link table.
integer, dimension(:), allocatable irf
Reference values corresponding to tag and typ:
integer, dimension(:), allocatable isc
Scale factors corresponding to tag and typ:
integer, dimension(:), allocatable ibt
Bit widths corresponding to tag and typ:
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
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:22