NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
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 
4 C> This function returns a specified value from within Section 3
5 C> of a BUFR message.
6 C>
7 C> @author J. Ator
8 C> @date 2009-03-23
9 C>
10 C> @param[in] MBAY - integer(*): BUFR message
11 C> @param[in] S3MNEM - character*(*): Value to be read from
12 C> Section 3 of MBAY
13 C> - 'NSUB' = Number of data subsets
14 C> - 'IOBS' = Flag indicating whether the
15 C> message contains observed data:
16 C> - 0 = No
17 C> - 1 = Yes
18 C> - 'ICMP' = Flag indicating whether the
19 C> message contains compressed data:
20 C> - 0 = No
21 C> - 1 = Yes
22 C> @returns iupbs3 - integer: Value corresponding to S3MNEM
23 C> - -1 = S3MNEM was invalid
24 C>
25 C> @remarks
26 C> - The start of the BUFR message (i.e. the string 'BUFR') must be
27 C> aligned on the first 4 bytes of MBAY.
28 C>
29 C> <b>Program history log:</b>
30 C> - 2009-03-23 J. Ator -- Original author
31 C>
32  FUNCTION iupbs3(MBAY,S3MNEM)
33 
34  dimension mbay(*)
35 
36  character*(*) s3mnem
37 
38 C-----------------------------------------------------------------------
39 C-----------------------------------------------------------------------
40 
41 C Call subroutine WRDLEN to initialize some important information
42 C about the local machine, just in case subroutine OPENBF hasn't
43 C been called yet.
44 
45  CALL wrdlen
46 
47 C Skip to the beginning of Section 3.
48 
49  CALL getlens(mbay,3,len0,len1,len2,len3,l4,l5)
50  ipt = len0 + len1 + len2
51 
52 C Unpack the requested value.
53 
54  IF(s3mnem.EQ.'NSUB') THEN
55  iupbs3 = iupb(mbay,ipt+5,16)
56  ELSE IF( (s3mnem.EQ.'IOBS') .OR. (s3mnem.EQ.'ICMP') ) THEN
57  ival = iupb(mbay,ipt+7,8)
58  IF(s3mnem.EQ.'IOBS') THEN
59  imask = 128
60  ELSE
61  imask = 64
62  ENDIF
63  iupbs3 = min(1,iand(ival,imask))
64  ELSE
65  iupbs3 = -1
66  ENDIF
67 
68  RETURN
69  END
function iupbs3(MBAY, S3MNEM)
This function returns a specified value from within Section 3 of a BUFR message.
Definition: iupbs3.f:32
function iupb(MBAY, NBYT, NBIT)
THIS FUNCTION UNPACKS AND RETURNS A BINARY INTEGER WORD CONTAINED WITHIN NBIT BITS OF A BUFR MESSAGE ...
Definition: iupb.f:36
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:37
subroutine wrdlen
This subroutine figures out some important information about the local machine on which the BUFRLIB s...
Definition: wrdlen.F:43