NCEPLIBS-bufr 11.7.1
icbfms.f
Go to the documentation of this file.
1C> @file
2C> @brief Test whether a character string is "missing"
3
4C> This function provides a handy way to check whether a
5C> character string returned from a previous call to subroutine
6C> readlc() was encoded as "missing" (all bits set to 1)
7C> within the actual BUFR data subset.
8C>
9C> @author J. Ator
10C> @date 2012-06-07
11C>
12C> @param[in] STR -- character*(*): String
13C> @param[in] LSTR -- integer: Length of string, i.e. number of
14C> characters within STR to be tested
15C> @returns icbfms -- integer:
16C> - 0 = STR is not "missing"
17C> - 1 = STR is "missing"
18C>
19C> @remarks
20C> - The use of an integer return code allows this function
21C> to be called in a logical context from application programs
22C> written in C as well as in Fortran.
23C>
24C> <b>Program history log:</b>
25C> | Date | Programmer | Comments |
26C> | -----|------------|----------|
27C> | 2012-06-07 | J. Ator | Original author |
28C> | 2015-03-10 | J. Woollen | Improved logic for testing legacy cases prior to BUFRLIB V10.2.0 |
29C> | 2016-02-12 | J. Ator | Modified for CRAYFTN compatibility |
30C>
31 INTEGER FUNCTION icbfms ( STR, LSTR )
32
33 character*(*) str
34
35 character*8 strz
36 real*8 rl8z
37
38 character*16 zz
39
40 character*16 zm_be
41 parameter( zm_be = '202020E076483742' )
42C* 10E10 stored as hexadecimal on a big-endian system.
43
44 character*16 zm_le
45 parameter( zm_le = '42374876E8000000' )
46C* 10E10 stored as hexadecimal on a little-endian system.
47
48 equivalence(strz,rl8z)
49
50C-----------------------------------------------------------------------
51
52 icbfms = 0
53
54 numchr = min(lstr,len(str))
55
56C* Beginning with version 10.2.0 of the BUFRLIB, "missing" strings
57C* have always been explicitly encoded with all bits set to 1,
58C* which is the correct encoding per WMO regulations. However,
59C* prior to version 10.2.0, the BUFRLIB stored "missing" strings by
60C* encoding the REAL*8 value of 10E10 into the string, so the
61C* following logic attempts to identify some of these earlier
62C cases, at least for strings between 4 and 8 bytes in length.
63
64 IF ( numchr.GE.4 .AND. numchr.LE.8 ) THEN
65 DO ii = 1, numchr
66 strz(ii:ii) = str(ii:ii)
67 END DO
68 WRITE (zz,'(Z16.16)') rl8z
69 i = 2*(8-numchr)+1
70 n = 16
71 IF ( zz(i:n).EQ.zm_be(i:n) .OR. zz(i:n).EQ.zm_le(i:n) ) THEN
72 icbfms = 1
73 RETURN
74 END IF
75 END IF
76
77C* Otherwise, the logic below will check for "missing" strings of
78C* any length which are correctly encoded with all bits set to 1,
79C* including those encoded by BUFRLIB version 10.2.0 or later.
80
81 DO i=1,numchr
82 IF ( iupm(str(i:i),8).NE.255 ) RETURN
83 ENDDO
84
85 icbfms = 1
86
87 RETURN
88 END
integer function icbfms(STR, LSTR)
This function provides a handy way to check whether a character string returned from a previous call ...
Definition: icbfms.f:32
function iupm(CBAY, NBITS)
THIS FUNCTION UNPACKS AND RETURNS A BINARY INTEGER WORD CONTAINED WITHIN NBITS BITS OF A CHARACTER ST...
Definition: iupm.f:41