NCEPLIBS-bufr  12.0.0
pkftbv.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Determine the numerical data value equivalent to the
3 C> setting of a specified bit within a flag table.
4 C>
5 C> @author J. Ator @date 2005-11-29
6 
7 C> This function computes the numerical value equivalent to the
8 C> setting of bit #(IBIT) within a flag table of NBITS bits.
9 C>
10 C> If the computation fails for any reason, then the function
11 C> returns the current placeholder value for "missing" data.
12 C>
13 C> @param[in] NBITS -- integer: Total number of bits in flag table
14 C> @param[in] IBIT -- integer: Number of bit to be set
15 C>
16 C> @returns pkftbv -- real*8: Value equivalent to the setting of
17 C> bit #(IBIT) within a flag table of NBITS bits
18 C>
19 C> @remarks
20 C> - This function is the logical inverse of subroutine upftbv().
21 C> - According to the WMO standard, bits within a bit field are
22 C> numbered from left to right, so bit #1 is always the high-order
23 C> (i.e. most significant) bit in any bit field.
24 C>
25 C> @author J. Ator @date 2005-11-29
26  RECURSIVE FUNCTION pkftbv(NBITS,IBIT) RESULT(R8VAL)
27 
28  USE modv_bmiss
29  USE modv_im8b
30 
31  real*8 r8val
32 
33 C----------------------------------------------------------------------
34 C----------------------------------------------------------------------
35 
36 C Check for I8 integers.
37 
38  IF(im8b) THEN
39  im8b=.false.
40 
41  CALL x84(nbits,my_nbits,1)
42  CALL x84(ibit,my_ibit,1)
43  r8val=pkftbv(my_nbits,my_ibit)
44 
45  im8b=.true.
46  RETURN
47  ENDIF
48 
49  IF((nbits.LE.0).OR.(ibit.LE.0).OR.(ibit.GT.nbits)) THEN
50  r8val = bmiss
51  ELSE
52  r8val = (2.)**(nbits-ibit)
53  ENDIF
54 
55  RETURN
56  END
This module declares and initializes the BMISS variable.
Definition: modules_vars.F90:9
real *8, public bmiss
Current placeholder value to represent "missing" data when reading from or writing to BUFR files; thi...
This module declares and initializes the IM8B variable.
logical, public im8b
Status indicator to keep track of whether all future calls to BUFRLIB subroutines and functions from ...
recursive real *8 function pkftbv(NBITS, IBIT)
This function computes the numerical value equivalent to the setting of bit #(IBIT) within a flag tab...
Definition: pkftbv.f:27
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19