NCEPLIBS-bufr 11.7.1
ipks.f
Go to the documentation of this file.
1C> @file
2C> @author J @date 2012-03-02
3
4C> THIS FUNCTION PACKS A REAL*8 USER VALUE INTO A BUFR
5C> 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 WRTREE
14C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
15C> 2022-05-06 J. WOOLLEN -- MAKE IMASK AND IPKS 8BYTE INTEGERS
16C>
17C> USAGE: IPKS (VAL,NODE)
18C> INPUT ARGUMENT LIST:
19C> VAL - REAL*8: USER VALUE
20C> NODE - INTEGER: INDEX INTO INTERNAL JUMP/LINK TABLES
21C>
22C> OUTPUT ARGUMENT LIST:
23C> IPKS - INTEGER*8: PACKED BUFR VALUE
24C>
25C> REMARKS:
26C> THIS ROUTINE CALLS: None
27C> THIS ROUTINE IS CALLED BY: WRTREE
28C> Normally not called by any application
29C> programs.
30C>
31 FUNCTION ipks(VAL,NODE)
32
33 USE moda_tables
34 USE moda_nrv203
35
36 integer(8) imask, ipks
37 real*8 ten,val
38
39 DATA ten /10./
40
41C-----------------------------------------------------------------------
42
43 ipks = val * ten**isc(node) - irf(node) + .5
44
45 IF ( nnrv .GT. 0 ) THEN
46
47C There are redefined reference values in the jump/link table,
48C so we need to check if this node is affected by any of them.
49
50 DO jj = 1, nnrv
51 IF ( node .EQ. inodnrv(jj) ) THEN
52
53C This node contains a redefined reference value.
54C Per the rules of BUFR, negative values should be encoded
55C as positive integers with the left-most bit set to 1.
56
57 nrv(jj) = nint(val)
58 IF ( nrv(jj) .LT. 0 ) THEN
59 imask = 2_8**(ibt(node)-1)
60 ipks = ior(abs(nrv(jj)),imask)
61 ELSE
62 ipks = nrv(jj)
63 END IF
64 RETURN
65 ELSE IF ( ( tag(node)(1:8) .EQ. tagnrv(jj) ) .AND.
66 . ( node .GE. isnrv(jj) ) .AND.
67 . ( node .LE. ienrv(jj) ) ) THEN
68
69C The corresponding redefinded reference value needs to
70C be used when encoding this value.
71
72 ipks = val * ten**isc(node) - nrv(jj) + .5
73 RETURN
74 END IF
75 END DO
76
77 END IF
78
79 RETURN
80 END
integer(8) function ipks(VAL, NODE)
THIS FUNCTION PACKS A REAL*8 USER VALUE INTO A BUFR INTEGER BY APPLYING THE PROPER SCALE AND REFERENC...
Definition: ipks.f:32
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