NCEPLIBS-bufr  12.0.1
iupbs3.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Read a data value from Section 3 of a BUFR message.
3 C>
4 C> @author J. Ator @date 2009-03-23
5 
6 C> This function returns a specified value from within Section 3
7 C> of a BUFR message.
8 C>
9 C> @remarks
10 C> The start of the BUFR message (i.e. the string 'BUFR') must be
11 C> aligned on the first 4 bytes of MBAY.
12 C>
13 C> @param[in] MBAY - integer(*): BUFR message
14 C> @param[in] S3MNEM - character*(*): Value to be read from
15 C> Section 3 of MBAY
16 C> - 'NSUB' = Number of data subsets
17 C> - 'IOBS' = Flag indicating whether the message contains observed data:
18 C> - 0 = No
19 C> - 1 = Yes
20 C> - 'ICMP' = Flag indicating whether the message contains compressed data:
21 C> - 0 = No
22 C> - 1 = Yes
23 C>
24 C> @returns iupbs3 - integer: Value corresponding to S3MNEM
25 C> - -1 = S3MNEM was invalid
26 C>
27 C> @author J. Ator @date 2009-03-23
28 
29  RECURSIVE FUNCTION iupbs3(MBAY,S3MNEM) RESULT(IRET)
30 
31  USE modv_im8b
32 
33  dimension mbay(*)
34 
35  CHARACTER*(*) s3mnem
36 
37 C-----------------------------------------------------------------------
38 C-----------------------------------------------------------------------
39 
40 C Check for I8 integers.
41 
42  IF(im8b) THEN
43  im8b=.false.
44 
45  iret = iupbs3(mbay,s3mnem)
46 
47  im8b=.true.
48  RETURN
49  ENDIF
50 
51 C Call subroutine WRDLEN to initialize some important information
52 C about the local machine, just in case subroutine OPENBF hasn't
53 C been called yet.
54 
55  CALL wrdlen
56 
57 C Skip to the beginning of Section 3.
58 
59  CALL getlens(mbay,3,len0,len1,len2,len3,l4,l5)
60  ipt = len0 + len1 + len2
61 
62 C Unpack the requested value.
63 
64  IF(s3mnem.EQ.'NSUB') THEN
65  iret = iupb(mbay,ipt+5,16)
66  ELSE IF( (s3mnem.EQ.'IOBS') .OR. (s3mnem.EQ.'ICMP') ) THEN
67  ival = iupb(mbay,ipt+7,8)
68  IF(s3mnem.EQ.'IOBS') THEN
69  imask = 128
70  ELSE
71  imask = 64
72  ENDIF
73  iret = min(1,iand(ival,imask))
74  ELSE
75  iret = -1
76  ENDIF
77 
78  RETURN
79  END
recursive subroutine getlens(MBAY, LL, LEN0, LEN1, LEN2, LEN3, LEN4, LEN5)
This subroutine reads the lengths of all of the individual sections of a given BUFR message,...
Definition: getlens.f:36
recursive function iupb(MBAY, NBYT, NBIT)
Decode an integer value from an integer array.
Definition: iupb.f:21
recursive function iupbs3(MBAY, S3MNEM)
This function returns a specified value from within Section 3 of a BUFR message.
Definition: iupbs3.f:30
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 ...
subroutine wrdlen
Determine important information about the local machine.
Definition: wrdlen.F:25