NCEPLIBS-bufr  12.1.0
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 
72  equivalence(strz,rl8z)
73 
74  ! Check for I8 integers.
75 
76  if ( im8b ) then
77  im8b = .false.
78 
79  call x84 ( lstr, my_lstr, 1 )
80  iret = icbfms( str, my_lstr )
81 
82  im8b = .true.
83  return
84  end if
85 
86  iret = 0
87 
88  numchr = min(lstr,len(str))
89 
90  ! Beginning with version 10.2.0 of the NCEPLIBS-bufr, all "missing" strings have been explicitly encoded with all bits set
91  ! to 1, and which is the correct encoding per WMO regulations. However, prior to version 10.2.0, the library encoded a
92  ! "missing" string by storing the real*8 value of 10E10 into the string. So for consistency with historical archives,
93  ! the following logic attempts to identify some of these earlier cases, at least for strings between 4 and 8 bytes in length.
94 
95  if ( numchr>=4 .and. numchr<=8 ) then
96  do ii = 1, numchr
97  strz(ii:ii) = str(ii:ii)
98  end do
99  write (zz,'(z16.16)') rl8z
100  ii = 2*(8-numchr)+1
101  if ( zz(ii:16)==zm_be(ii:16) .or. zz(ii:16)==zm_le(ii:16) ) then
102  iret = 1
103  return
104  end if
105  end if
106 
107  ! Otherwise, the logic below will check for "missing" strings of any length which are correctly encoded with all bits set
108  ! to 1, including those encoded by NCEPLIBS-bufr version 10.2.0 or later.
109 
110  do ii=1,numchr
111  strz(1:1) = str(ii:ii)
112  if ( iupm(strz(1:1),8)/=255 ) return
113  enddo
114 
115  iret = 1
116 
117  return
118 end function icbfms
119 
134 real*8 function getbmiss() result(r8val)
135 
136  use modv_vars, only: bmiss
137 
138  implicit none
139 
140  r8val = bmiss
141 
142  return
143 end function getbmiss
144 
170 subroutine setbmiss(xmiss)
171 
172  use modv_vars, only: bmiss
173 
174  implicit none
175 
176  real*8, intent(in) :: xmiss
177 
178  bmiss = xmiss
179 
180  return
181 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:135
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:171
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