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