NCEPLIBS-bufr  12.2.0
All Data Structures Namespaces Files Functions Variables Macros Pages
missing.F90
Go to the documentation of this file.
1 
5 
24 integer function ibfms ( r8val ) result ( iret )
25 
26  use modv_vars, only: bmiss
27 
28  implicit none
29 
30  real*8, intent(in) :: r8val
31 
32  if ( r8val == bmiss ) then
33  iret = 1
34  else
35  iret = 0
36  endif
37 
38  return
39 end function ibfms
40 
55 recursive integer function icbfms ( str, lstr ) result ( iret )
56 
57  use modv_vars, only: im8b
58 
59  implicit none
60 
61  character*(*), intent(in) :: str
62  character*8 strz
63  character*16 zz
64  character*16, parameter :: zm_be = '202020E076483742' ! 10E10 stored as hexadecimal on a big-endian system
65  character*16, parameter :: zm_le = '42374876E8000000' ! 10E10 stored as hexadecimal on a little-endian system
66 
67  real*8 rl8z
68 
69  integer, intent(in) :: lstr
70  integer my_lstr, numchr, ii, iupm
71  integer*8 il8z
72 
73  equivalence(strz,rl8z)
74 
75  ! Check for I8 integers.
76 
77  if ( im8b ) then
78  im8b = .false.
79 
80  call x84 ( lstr, my_lstr, 1 )
81  iret = icbfms( str, my_lstr )
82 
83  im8b = .true.
84  return
85  end if
86 
87  iret = 0
88 
89  numchr = min(lstr,len(str))
90 
91  ! Beginning with version 10.2.0 of the NCEPLIBS-bufr, all "missing" strings have been explicitly encoded with all bits set
92  ! to 1, and which is the correct encoding per WMO regulations. However, prior to version 10.2.0, the library encoded a
93  ! "missing" string by storing the real*8 value of 10E10 into the string. So for consistency with historical archives,
94  ! the following logic attempts to identify some of these earlier cases, at least for strings between 4 and 8 bytes in length.
95 
96  if ( numchr>=4 .and. numchr<=8 ) then
97  do ii = 1, numchr
98  strz(ii:ii) = str(ii:ii)
99  end do
100  write (zz,'(z16.16)') transfer(rl8z,il8z)
101  ii = 2*(8-numchr)+1
102  if ( zz(ii:16)==zm_be(ii:16) .or. zz(ii:16)==zm_le(ii:16) ) then
103  iret = 1
104  return
105  end if
106  end if
107 
108  ! Otherwise, the logic below will check for "missing" strings of any length which are correctly encoded with all bits set
109  ! to 1, including those encoded by NCEPLIBS-bufr version 10.2.0 or later.
110 
111  do ii=1,numchr
112  strz(1:1) = str(ii:ii)
113  if ( iupm(strz(1:1),8)/=255 ) return
114  enddo
115 
116  iret = 1
117 
118  return
119 end function icbfms
120 
135 real*8 function getbmiss() result(r8val)
136 
137  use modv_vars, only: bmiss
138 
139  implicit none
140 
141  r8val = bmiss
142 
143  return
144 end function getbmiss
145 
171 subroutine setbmiss(xmiss)
172 
173  use modv_vars, only: bmiss
174 
175  implicit none
176 
177  real*8, intent(in) :: xmiss
178 
179  bmiss = xmiss
180 
181  return
182 end subroutine setbmiss
recursive integer function iupm(cbay, nbits)
Decode an integer value from within a specified number of bits of a character string,...
Definition: cidecode.F90:265
real *8 function getbmiss()
Get the current placeholder value which represents "missing" data when reading from or writing to BUF...
Definition: missing.F90:136
recursive integer function icbfms(str, lstr)
Check whether a character string returned from a previous call to subroutine readlc() was encoded as ...
Definition: missing.F90:56
subroutine setbmiss(xmiss)
Specify a customized value to represent "missing" data when reading from or writing to BUFR files.
Definition: missing.F90:172
integer function ibfms(r8val)
Check whether a real*8 data value returned from a previous call to any of the NCEPLIBS-bufr values-re...
Definition: missing.F90:25
subroutine x84(iin8, iout4, nval)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x4884.F90:65