NCEPLIBS-bufr  12.0.0
gets1loc.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Get the location of a specified value within Section 1
3 C> of a BUFR message
4 C>
5 C> @author J. Ator @date 2005-11-29
6 
7 C> This subroutine returns the location of a specified value within
8 C> Section 1 of a BUFR message.
9 C>
10 C> The location and availability of any particular value within
11 C> Section 1 of a BUFR message can vary depending on the edition
12 C> number used to encode the message. This subroutine will work
13 C> for BUFR edition 2, 3, or 4.
14 C>
15 C> @param[in] S1MNEM -- character*(*): Value whose location within
16 C> Section 1 is to be determined:
17 C> - 'LEN1' = Length (in bytes) of Section 1
18 C> - 'BMT' = BUFR master table
19 C> - 'OGCE' = Originating center
20 C> - 'GSES' = Originating subcenter
21 C> - 'USN' = Update sequence number
22 C> - 'ISC2' = Flag indicating absence/presence of
23 C> (optional) Section 2 in BUFR message:
24 C> - 0 = Section 2 absent
25 C> - 1 = Section 2 present
26 C> - 'MTYP' = Data category
27 C> - 'MSBTI' = Data subcategory (international)
28 C> - 'MSBT' = Data subcategory (local)
29 C> - 'MTV' = Version number of master table
30 C> - 'MTVL' = Version number of local tables
31 C> - 'YCEN' = Year of century (1-100)
32 C> - 'CENT' = Century (e.g., 20 for years 1901-2000,
33 C> 21 for years 2001-2100)
34 C> - 'YEAR' = Year (4-digit)
35 C> - 'MNTH' = Month
36 C> - 'DAYS' = Day
37 C> - 'HOUR' = Hour
38 C> - 'MINU' = Minute
39 C> - 'SECO' = Second
40 C> @param[in] IBEN -- integer: BUFR edition number
41 C> @param[out] ISBYT -- integer: Number of starting byte within Section 1
42 C> which contains value corresponding to S1MNEM
43 C> @param[out] IWID -- integer: Width (in bits) of value corresponding
44 C> to S1MNEM, counting from the first bit of the
45 C> byte pointed to by ISBYT
46 C> @param[out] IRET -- integer: Return code:
47 C> - 0 = normal return
48 C> - -1 = S1MNEM is invalid for BUFR edition IBEN
49 C>
50 C> @remarks
51 C> - S1MNEM = 'GSES' is only valid for IBEN = 3 or 4.
52 C> - S1MNEM = 'YCEN' or 'CENT' is only valid for IBEN = 2 or 3.
53 C> - S1MNEM = 'YEAR', 'SECO', or 'MSBTI' is only valid for IBEN = 4.
54 C>
55 C> @author J. Ator @date 2005-11-29
56  RECURSIVE SUBROUTINE gets1loc(S1MNEM,IBEN,ISBYT,IWID,IRET)
57 
58  USE modv_im8b
59 
60  CHARACTER*(*) s1mnem
61 
62 C-----------------------------------------------------------------------
63 C-----------------------------------------------------------------------
64 
65 C Check for I8 integers.
66 
67  IF(im8b) THEN
68  im8b=.false.
69 
70  CALL x84(iben,my_iben,1)
71  CALL gets1loc(s1mnem,my_iben,isbyt,iwid,iret)
72  CALL x48(isbyt,isbyt,1)
73  CALL x48(iwid,iwid,1)
74  CALL x48(iret,iret,1)
75 
76  im8b=.true.
77  RETURN
78  ENDIF
79 
80  iret = 0
81  iwid = 8
82 
83  IF(s1mnem.EQ.'LEN1') THEN
84  isbyt = 1
85  iwid = 24
86  ELSE IF(s1mnem.EQ.'BMT') THEN
87  isbyt = 4
88  ELSE IF(s1mnem.EQ.'OGCE') THEN
89  IF(iben.EQ.3) THEN
90  isbyt = 6
91  ELSE
92 
93 C Note that this location is actually the same for both
94 C Edition 2 *and* Edition 4 of BUFR!
95 
96  isbyt = 5
97  iwid = 16
98  ENDIF
99  ELSE IF(s1mnem.EQ.'GSES') THEN
100  IF(iben.EQ.3) THEN
101  isbyt = 5
102  ELSE IF(iben.EQ.4) THEN
103  isbyt = 7
104  iwid = 16
105  ELSE
106  iret = -1
107  ENDIF
108  ELSE IF(s1mnem.EQ.'USN') THEN
109  IF(iben.EQ.4) THEN
110  isbyt = 9
111  ELSE
112  isbyt = 7
113  ENDIF
114  ELSE IF(s1mnem.EQ.'ISC2') THEN
115  iwid = 1
116  IF(iben.EQ.4) THEN
117  isbyt = 10
118  ELSE
119  isbyt = 8
120  ENDIF
121  ELSE IF(s1mnem.EQ.'MTYP') THEN
122  IF(iben.EQ.4) THEN
123  isbyt = 11
124  ELSE
125  isbyt = 9
126  ENDIF
127  ELSE IF(s1mnem.EQ.'MSBTI') THEN
128  IF(iben.EQ.4) THEN
129  isbyt = 12
130  ELSE
131  iret = -1
132  ENDIF
133  ELSE IF(s1mnem.EQ.'MSBT') THEN
134  IF(iben.EQ.4) THEN
135  isbyt = 13
136  ELSE
137  isbyt = 10
138  ENDIF
139  ELSE IF(s1mnem.EQ.'MTV') THEN
140  IF(iben.EQ.4) THEN
141  isbyt = 14
142  ELSE
143  isbyt = 11
144  ENDIF
145  ELSE IF(s1mnem.EQ.'MTVL') THEN
146  IF(iben.EQ.4) THEN
147  isbyt = 15
148  ELSE
149  isbyt = 12
150  ENDIF
151  ELSE IF(s1mnem.EQ.'YEAR') THEN
152  IF(iben.EQ.4) THEN
153  isbyt = 16
154  iwid = 16
155  ELSE
156  iret = -1
157  ENDIF
158  ELSE IF(s1mnem.EQ.'YCEN') THEN
159  IF(iben.LT.4) THEN
160  isbyt = 13
161  ELSE
162  iret = -1
163  ENDIF
164  ELSE IF(s1mnem.EQ.'CENT') THEN
165  IF(iben.LT.4) THEN
166  isbyt = 18
167  ELSE
168  iret = -1
169  ENDIF
170  ELSE IF(s1mnem.EQ.'MNTH') THEN
171  IF(iben.EQ.4) THEN
172  isbyt = 18
173  ELSE
174  isbyt = 14
175  ENDIF
176  ELSE IF(s1mnem.EQ.'DAYS') THEN
177  IF(iben.EQ.4) THEN
178  isbyt = 19
179  ELSE
180  isbyt = 15
181  ENDIF
182  ELSE IF(s1mnem.EQ.'HOUR') THEN
183  IF(iben.EQ.4) THEN
184  isbyt = 20
185  ELSE
186  isbyt = 16
187  ENDIF
188  ELSE IF(s1mnem.EQ.'MINU') THEN
189  IF(iben.EQ.4) THEN
190  isbyt = 21
191  ELSE
192  isbyt = 17
193  ENDIF
194  ELSE IF(s1mnem.EQ.'SECO') THEN
195  IF(iben.EQ.4) THEN
196  isbyt = 22
197  ELSE
198  iret = -1
199  ENDIF
200  ELSE
201  iret = -1
202  ENDIF
203 
204  RETURN
205  END
recursive subroutine gets1loc(S1MNEM, IBEN, ISBYT, IWID, IRET)
This subroutine returns the location of a specified value within Section 1 of a BUFR message.
Definition: gets1loc.f:57
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