NCEPLIBS-bufr 11.7.1
gets1loc.f
Go to the documentation of this file.
1C> @file
2C> @author ATOR @date 2005-11-29
3
4C> THIS SUBROUTINE RETURNS THE LOCATION (I.E. STARTING BYTE
5C> AND BIT WIDTH) OF A SPECIFIED VALUE WITHIN SECTION 1 OF A BUFR
6C> MESSAGE ENCODED ACCORDING TO A SPECIFIED BUFR EDITION. IT WILL
7C> WORK ON ANY MESSAGE ENCODED USING BUFR EDITION 2, 3 OR 4. THE
8C> VALUE FOR WHICH THE LOCATION IS TO BE DETERMINED IS SPECIFIED VIA
9C> THE MNEMONIC S1MNEM, AS EXPLAINED IN FURTHER DETAIL BELOW.
10C>
11C> PROGRAM HISTORY LOG:
12C> 2005-11-29 J. ATOR -- ORIGINAL AUTHOR
13C> 2006-04-14 D. KEYSER -- ADDED OPTIONS FOR 'YCEN' AND 'CENT'
14C>
15C> USAGE: GETS1LOC ( S1MNEM, IBEN, ISBYT, IWID, IRET )
16C> INPUT ARGUMENT LIST:
17C> S1MNEM - CHARACTER*(*): MNEMONIC SPECIFYING VALUE WHOSE
18C> LOCATION WITHIN SECTION 1 IS TO BE DETERMINED:
19C> 'LEN1' = LENGTH (IN BYTES) OF SECTION 1
20C> 'BMT' = BUFR MASTER TABLE
21C> 'OGCE' = ORIGINATING CENTER
22C> 'GSES' = ORIGINATING SUBCENTER
23C> (NOTE: THIS VALUE IS PRESENT ONLY IN
24C> BUFR EDITION 3 OR 4 MESSAGES!)
25C> 'USN' = UPDATE SEQUENCE NUMBER
26C> 'ISC2' = FLAG INDICATING ABSENCE/PRESENCE OF
27C> (OPTIONAL) SECTION 2 IN BUFR MESSAGE:
28C> 0 = SECTION 2 ABSENT
29C> 1 = SECTION 2 PRESENT
30C> 'MTYP' = DATA CATEGORY
31C> 'MSBTI' = DATA SUBCATEGORY (INTERNATIONAL)
32C> (NOTE: THIS VALUE IS PRESENT ONLY IN
33C> BUFR EDITION 4 MESSAGES!)
34C> 'MSBT' = DATA SUBCATEGORY (LOCAL)
35C> 'MTV' = VERSION NUMBER OF MASTER TABLE
36C> 'MTVL' = VERSION NUMBER OF LOCAL TABLES
37C> 'YCEN' = YEAR OF CENTURY (1-100)
38C> (NOTE: THIS VALUE IS PRESENT ONLY IN
39C> BUFR EDITION 2 AND 3 MESSAGES!)
40C> 'CENT' = CENTURY (I.E., 20 FOR YEARS 1901-2000,
41C> 21 FOR YEARS 2001-2100)
42C> (NOTE: THIS VALUE *MAY* BE PRESENT IN
43C> BUFR EDITION 2 AND 3 MESSAGES,
44C> BUT IT IS NEVER PRESENT IN ANY
45C> BUFR EDITION 4 MESSAGES!)
46C> 'YEAR' = YEAR (4-DIGIT)
47C> (NOTE: THIS VALUE IS PRESENT ONLY IN
48C> BUFR EDITION 4 MESSAGES!)
49C> 'MNTH' = MONTH
50C> 'DAYS' = DAY
51C> 'HOUR' = HOUR
52C> 'MINU' = MINUTE
53C> 'SECO' = SECOND
54C> (NOTE: THIS VALUE IS PRESENT ONLY IN
55C> BUFR EDITION 4 MESSAGES!)
56C> IBEN - INTEGER: BUFR EDITION NUMBER
57C>
58C>
59C> OUTPUT ARGUMENT LIST:
60C> ISBYT - INTEGER: NUMBER OF STARTING BYTE WITHIN SECTION 1
61C> WHICH CONTAINS VALUE CORRESPONDING TO S1MNEM
62C> (NOTE: ISBYT IS ALWAYS RETURNED AS 18 WHENEVER
63C> S1MNEM = 'CENT' AND IBEN = 2 OR 3; IN SUCH
64C> CASES IT IS THEN UP TO THE CALLING ROUTINE
65C> TO DETERMINE WHETHER THIS LOCATION ACTUALLY
66C> CONTAINS A VALID CENTURY VALUE!)
67C> IWID - INTEGER: WIDTH (IN BITS) OF VALUE CORRESPONDING
68C> TO S1MNEM
69C> IRET - INTEGER: RETURN CODE
70C> 0 = NORMAL RETURN
71C> -1 = THE INPUT S1MNEM MNEMONIC IS INVALID FOR
72C> BUFR EDITION IBEN
73C>
74C> REMARKS:
75C> THIS ROUTINE CALLS: None
76C> THIS ROUTINE IS CALLED BY: CRBMG IUPBS01 PKBS1
77C> Normally not called by any application
78C> programs.
79C>
80 SUBROUTINE gets1loc(S1MNEM,IBEN,ISBYT,IWID,IRET)
81
82
83
84 character*(*) s1mnem
85
86C-----------------------------------------------------------------------
87C-----------------------------------------------------------------------
88
89 iret = 0
90 iwid = 8
91
92 IF(s1mnem.EQ.'LEN1') THEN
93 isbyt = 1
94 iwid = 24
95 ELSE IF(s1mnem.EQ.'BMT') THEN
96 isbyt = 4
97 ELSE IF(s1mnem.EQ.'OGCE') THEN
98 IF(iben.EQ.3) THEN
99 isbyt = 6
100 ELSE
101
102C Note that this location is actually the same for both
103C Edition 2 *and* Edition 4 of BUFR!
104
105 isbyt = 5
106 iwid = 16
107 ENDIF
108 ELSE IF(s1mnem.EQ.'GSES') THEN
109 IF(iben.EQ.3) THEN
110 isbyt = 5
111 ELSE IF(iben.EQ.4) THEN
112 isbyt = 7
113 iwid = 16
114 ELSE
115 iret = -1
116 ENDIF
117 ELSE IF(s1mnem.EQ.'USN') THEN
118 IF(iben.EQ.4) THEN
119 isbyt = 9
120 ELSE
121 isbyt = 7
122 ENDIF
123 ELSE IF(s1mnem.EQ.'ISC2') THEN
124 iwid = 1
125 IF(iben.EQ.4) THEN
126 isbyt = 10
127 ELSE
128 isbyt = 8
129 ENDIF
130 ELSE IF(s1mnem.EQ.'MTYP') THEN
131 IF(iben.EQ.4) THEN
132 isbyt = 11
133 ELSE
134 isbyt = 9
135 ENDIF
136 ELSE IF(s1mnem.EQ.'MSBTI') THEN
137 IF(iben.EQ.4) THEN
138 isbyt = 12
139 ELSE
140 iret = -1
141 ENDIF
142 ELSE IF(s1mnem.EQ.'MSBT') THEN
143 IF(iben.EQ.4) THEN
144 isbyt = 13
145 ELSE
146 isbyt = 10
147 ENDIF
148 ELSE IF(s1mnem.EQ.'MTV') THEN
149 IF(iben.EQ.4) THEN
150 isbyt = 14
151 ELSE
152 isbyt = 11
153 ENDIF
154 ELSE IF(s1mnem.EQ.'MTVL') THEN
155 IF(iben.EQ.4) THEN
156 isbyt = 15
157 ELSE
158 isbyt = 12
159 ENDIF
160 ELSE IF(s1mnem.EQ.'YEAR') THEN
161 IF(iben.EQ.4) THEN
162 isbyt = 16
163 iwid = 16
164 ELSE
165 iret = -1
166 ENDIF
167 ELSE IF(s1mnem.EQ.'YCEN') THEN
168 IF(iben.LT.4) THEN
169 isbyt = 13
170 ELSE
171 iret = -1
172 ENDIF
173 ELSE IF(s1mnem.EQ.'CENT') THEN
174 IF(iben.LT.4) THEN
175 isbyt = 18
176 ELSE
177 iret = -1
178 ENDIF
179 ELSE IF(s1mnem.EQ.'MNTH') THEN
180 IF(iben.EQ.4) THEN
181 isbyt = 18
182 ELSE
183 isbyt = 14
184 ENDIF
185 ELSE IF(s1mnem.EQ.'DAYS') THEN
186 IF(iben.EQ.4) THEN
187 isbyt = 19
188 ELSE
189 isbyt = 15
190 ENDIF
191 ELSE IF(s1mnem.EQ.'HOUR') THEN
192 IF(iben.EQ.4) THEN
193 isbyt = 20
194 ELSE
195 isbyt = 16
196 ENDIF
197 ELSE IF(s1mnem.EQ.'MINU') THEN
198 IF(iben.EQ.4) THEN
199 isbyt = 21
200 ELSE
201 isbyt = 17
202 ENDIF
203 ELSE IF(s1mnem.EQ.'SECO') THEN
204 IF(iben.EQ.4) THEN
205 isbyt = 22
206 ELSE
207 iret = -1
208 ENDIF
209 ELSE
210 iret = -1
211 ENDIF
212
213 RETURN
214 END
subroutine gets1loc(S1MNEM, IBEN, ISBYT, IWID, IRET)
THIS SUBROUTINE RETURNS THE LOCATION (I.E.
Definition: gets1loc.f:81