NCEPLIBS-bufr  12.0.1
getlens.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Read the section lengths of a BUFR message.
3 C>
4 C> @author J. Ator @date 2005-11-29
5 
6 C> This subroutine reads the lengths of all of the individual
7 C> sections of a given BUFR message, up to a specified point in
8 C> the message.
9 C>
10 C> This subroutine will work on any BUFR message encoded using
11 C> BUFR edition 2, 3, or 4
12 C>
13 C> @param[in] MBAY -- integer(*): BUFR message
14 C> @param[in] LL -- integer: Number of last section for
15 C> which the length is to be read.
16 C> In other words, setting LL = N means to
17 C> read and return the lengths of Sections 0
18 C> through N (i.e. LEN0, LEN1,...,LENN).
19 C> Any section lengths that are not specified
20 C> to be read are returned with a default
21 C> placeholder value of -1.
22 C> @param[out] LEN0 -- integer: Length (in bytes) of Section 0
23 C> @param[out] LEN1 -- integer: Length (in bytes) of Section 1
24 C> @param[out] LEN2 -- integer: Length (in bytes) of Section 2
25 C> @param[out] LEN3 -- integer: Length (in bytes) of Section 3
26 C> @param[out] LEN4 -- integer: Length (in bytes) of Section 4
27 C> @param[out] LEN5 -- integer: Length (in bytes) of Section 5
28 C>
29 C> @remarks
30 C> - The start of the BUFR message (i.e. the string 'BUFR') must be
31 C> aligned on the first 4 bytes of MBAY.
32 C>
33 C> @author J. Ator @date 2005-11-29
34  RECURSIVE SUBROUTINE getlens
35  . (mbay,ll,len0,len1,len2,len3,len4,len5)
36 
37  USE modv_im8b
38 
39  dimension mbay(*)
40 
41 C-----------------------------------------------------------------------
42 C-----------------------------------------------------------------------
43 
44 C Check for I8 integers.
45 
46  IF(im8b) THEN
47  im8b=.false.
48 
49  CALL x84(ll,my_ll,1)
50  CALL getlens(mbay,my_ll,len0,len1,len2,len3,len4,len5)
51  CALL x48(len0,len0,1)
52  CALL x48(len1,len1,1)
53  CALL x48(len2,len2,1)
54  CALL x48(len3,len3,1)
55  CALL x48(len4,len4,1)
56  CALL x48(len5,len5,1)
57 
58  im8b=.true.
59  RETURN
60  ENDIF
61 
62  len0 = -1
63  len1 = -1
64  len2 = -1
65  len3 = -1
66  len4 = -1
67  len5 = -1
68 
69  IF(ll.LT.0) RETURN
70  len0 = iupbs01(mbay,'LEN0')
71 
72  IF(ll.LT.1) RETURN
73  len1 = iupbs01(mbay,'LEN1')
74 
75  IF(ll.LT.2) RETURN
76  iad2 = len0 + len1
77  len2 = iupb(mbay,iad2+1,24) * iupbs01(mbay,'ISC2')
78 
79  IF(ll.LT.3) RETURN
80  iad3 = iad2 + len2
81  len3 = iupb(mbay,iad3+1,24)
82 
83  IF(ll.LT.4) RETURN
84  iad4 = iad3 + len3
85  len4 = iupb(mbay,iad4+1,24)
86 
87  IF(ll.LT.5) RETURN
88  len5 = 4
89 
90  RETURN
91  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 iupbs01(MBAY, S01MNEM)
Read a data value from Section 0 or Section 1 of a BUFR message.
Definition: iupbs01.f:69
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 x48(IIN4, IOUT8, NVAL)
Encode one or more 4-byte integer values as 8-byte integer values.
Definition: x48.F:19
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19